Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
af4606aa
Commit
af4606aa
authored
Nov 17, 2015
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #287 from djsegal/develop
Annotate non-model test files: #286
parents
3f85ded7
7ada4e1b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
5 deletions
+22
-5
annotate.gemspec
annotate.gemspec
+3
-3
annotate.rb
lib/annotate.rb
+1
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+16
-2
auto_annotate_models.rake
lib/generators/annotate/templates/auto_annotate_models.rake
+1
-0
annotate_models.rake
lib/tasks/annotate_models.rake
+1
-0
No files found.
annotate.gemspec
View file @
af4606aa
...
@@ -27,13 +27,13 @@ Gem::Specification.new do |s|
...
@@ -27,13 +27,13 @@ Gem::Specification.new do |s|
if
Gem
::
Version
.
new
(
Gem
::
VERSION
)
>=
Gem
::
Version
.
new
(
'1.2.0'
)
then
if
Gem
::
Version
.
new
(
Gem
::
VERSION
)
>=
Gem
::
Version
.
new
(
'1.2.0'
)
then
s
.
add_runtime_dependency
(
%q<rake>
,
[
"~> 10.4"
])
s
.
add_runtime_dependency
(
%q<rake>
,
[
"~> 10.4"
])
s
.
add_runtime_dependency
(
%q<activerecord>
,
[
">= 3.2"
,
"<
= 4.3
"
])
s
.
add_runtime_dependency
(
%q<activerecord>
,
[
">= 3.2"
,
"<
6.0
"
])
else
else
s
.
add_dependency
(
%q<rake>
,
[
"~> 10.4"
])
s
.
add_dependency
(
%q<rake>
,
[
"~> 10.4"
])
s
.
add_dependency
(
%q<activerecord>
,
[
">= 3.2"
,
"<
= 4.3
"
])
s
.
add_dependency
(
%q<activerecord>
,
[
">= 3.2"
,
"<
6.0
"
])
end
end
else
else
s
.
add_dependency
(
%q<rake>
,
[
">= 0.8.7"
])
s
.
add_dependency
(
%q<rake>
,
[
">= 0.8.7"
])
s
.
add_dependency
(
%q<activerecord>
,
[
">= 3.2"
,
"<
= 4.3
"
])
s
.
add_dependency
(
%q<activerecord>
,
[
">= 3.2"
,
"<
6.0
"
])
end
end
end
end
lib/annotate.rb
View file @
af4606aa
...
@@ -27,6 +27,7 @@ module Annotate
...
@@ -27,6 +27,7 @@ module Annotate
:exclude_fixtures
,
:exclude_factories
,
:ignore_model_sub_dir
,
:exclude_fixtures
,
:exclude_factories
,
:ignore_model_sub_dir
,
:format_bare
,
:format_rdoc
,
:format_markdown
,
:sort
,
:force
,
:trace
,
:format_bare
,
:format_rdoc
,
:format_markdown
,
:sort
,
:force
,
:trace
,
:timestamp
,
:exclude_serializers
,
:classified_sort
,
:show_foreign_keys
,
:timestamp
,
:exclude_serializers
,
:classified_sort
,
:show_foreign_keys
,
:exclude_scaffolds
]
]
OTHER_OPTIONS
=
[
OTHER_OPTIONS
=
[
:ignore_columns
,
:skip_on_db_migrate
,
:wrapper_open
,
:wrapper_close
,
:wrapper
:ignore_columns
,
:skip_on_db_migrate
,
:wrapper_open
,
:wrapper_close
,
:wrapper
...
...
lib/annotate/annotate_models.rb
View file @
af4606aa
...
@@ -17,6 +17,12 @@ module AnnotateModels
...
@@ -17,6 +17,12 @@ module AnnotateModels
FIXTURE_TEST_DIR
=
File
.
join
(
"test"
,
"fixtures"
)
FIXTURE_TEST_DIR
=
File
.
join
(
"test"
,
"fixtures"
)
FIXTURE_SPEC_DIR
=
File
.
join
(
"spec"
,
"fixtures"
)
FIXTURE_SPEC_DIR
=
File
.
join
(
"spec"
,
"fixtures"
)
# Other test files
CONTROLLER_TEST_DIR
=
File
.
join
(
"test"
,
"controllers"
)
CONTROLLER_SPEC_DIR
=
File
.
join
(
"spec"
,
"controllers"
)
REQUEST_SPEC_DIR
=
File
.
join
(
"spec"
,
"requests"
)
ROUTING_SPEC_DIR
=
File
.
join
(
"spec"
,
"routing"
)
# Object Daddy http://github.com/flogic/object_daddy/tree/master
# Object Daddy http://github.com/flogic/object_daddy/tree/master
EXEMPLARS_TEST_DIR
=
File
.
join
(
"test"
,
"exemplars"
)
EXEMPLARS_TEST_DIR
=
File
.
join
(
"test"
,
"exemplars"
)
EXEMPLARS_SPEC_DIR
=
File
.
join
(
"spec"
,
"exemplars"
)
EXEMPLARS_SPEC_DIR
=
File
.
join
(
"spec"
,
"exemplars"
)
...
@@ -52,6 +58,13 @@ module AnnotateModels
...
@@ -52,6 +58,13 @@ module AnnotateModels
File
.
join
(
FIXTURE_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%.yml"
),
File
.
join
(
FIXTURE_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%.yml"
),
]
]
SCAFFOLD_PATTERNS
=
[
File
.
join
(
CONTROLLER_TEST_DIR
,
"%PLURALIZED_MODEL_NAME%_controller_test.rb"
),
File
.
join
(
CONTROLLER_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%_controller_spec.rb"
),
File
.
join
(
REQUEST_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%_spec.rb"
),
File
.
join
(
ROUTING_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%_routing_spec.rb"
),
]
FACTORY_PATTERNS
=
[
FACTORY_PATTERNS
=
[
File
.
join
(
EXEMPLARS_TEST_DIR
,
"%MODEL_NAME%_exemplar.rb"
),
File
.
join
(
EXEMPLARS_TEST_DIR
,
"%MODEL_NAME%_exemplar.rb"
),
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"%MODEL_NAME%_exemplar.rb"
),
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"%MODEL_NAME%_exemplar.rb"
),
...
@@ -344,6 +357,7 @@ module AnnotateModels
...
@@ -344,6 +357,7 @@ module AnnotateModels
# :exclude_fixtures<Symbol>:: whether to skip modification of fixture files
# :exclude_fixtures<Symbol>:: whether to skip modification of fixture files
# :exclude_factories<Symbol>:: whether to skip modification of factory files
# :exclude_factories<Symbol>:: whether to skip modification of factory files
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
# :exclude_scaffolds<Symbol>:: whether to skip modification of scaffold files
#
#
def
annotate
(
klass
,
file
,
header
,
options
=
{})
def
annotate
(
klass
,
file
,
header
,
options
=
{})
begin
begin
...
@@ -357,7 +371,7 @@ module AnnotateModels
...
@@ -357,7 +371,7 @@ module AnnotateModels
did_annotate
=
true
did_annotate
=
true
end
end
%w(test fixture factory serializer)
.
each
do
|
key
|
%w(test fixture factory serializer
scaffold
)
.
each
do
|
key
|
exclusion_key
=
"exclude_
#{
key
.
pluralize
}
"
.
to_sym
exclusion_key
=
"exclude_
#{
key
.
pluralize
}
"
.
to_sym
patterns_constant
=
"
#{
key
.
upcase
}
_PATTERNS"
.
to_sym
patterns_constant
=
"
#{
key
.
upcase
}
_PATTERNS"
.
to_sym
position_key
=
"position_in_
#{
key
}
"
.
to_sym
position_key
=
"position_in_
#{
key
}
"
.
to_sym
...
@@ -510,7 +524,7 @@ module AnnotateModels
...
@@ -510,7 +524,7 @@ module AnnotateModels
model_file_name
=
file
model_file_name
=
file
deannotated_klass
=
true
if
(
remove_annotation_of_file
(
model_file_name
))
deannotated_klass
=
true
if
(
remove_annotation_of_file
(
model_file_name
))
(
TEST_PATTERNS
+
FIXTURE_PATTERNS
+
FACTORY_PATTERNS
+
SERIALIZER_PATTERNS
).
(
TEST_PATTERNS
+
SCAFFOLD_PATTERNS
+
FIXTURE_PATTERNS
+
FACTORY_PATTERNS
+
SERIALIZER_PATTERNS
).
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
map
{
|
file
|
resolve_filename
(
file
,
model_name
,
table_name
)
}.
each
do
|
file
|
each
do
|
file
|
if
File
.
exist?
(
file
)
if
File
.
exist?
(
file
)
...
...
lib/generators/annotate/templates/auto_annotate_models.rake
View file @
af4606aa
...
@@ -22,6 +22,7 @@ if Rails.env.development?
...
@@ -22,6 +22,7 @@ if Rails.env.development?
'exclude_fixtures'
=>
"false"
,
'exclude_fixtures'
=>
"false"
,
'exclude_factories'
=>
"false"
,
'exclude_factories'
=>
"false"
,
'exclude_serializers'
=>
"false"
,
'exclude_serializers'
=>
"false"
,
'exclude_scaffolds'
=>
"false"
,
'ignore_model_sub_dir'
=>
"false"
,
'ignore_model_sub_dir'
=>
"false"
,
'skip_on_db_migrate'
=>
"false"
,
'skip_on_db_migrate'
=>
"false"
,
'format_bare'
=>
"true"
,
'format_bare'
=>
"true"
,
...
...
lib/tasks/annotate_models.rake
View file @
af4606aa
...
@@ -27,6 +27,7 @@ task :annotate_models => :environment do
...
@@ -27,6 +27,7 @@ task :annotate_models => :environment do
options
[
:exclude_factories
]
=
Annotate
.
true?
(
ENV
[
'exclude_factories'
])
options
[
:exclude_factories
]
=
Annotate
.
true?
(
ENV
[
'exclude_factories'
])
options
[
:exclude_fixtures
]
=
Annotate
.
true?
(
ENV
[
'exclude_fixtures'
])
options
[
:exclude_fixtures
]
=
Annotate
.
true?
(
ENV
[
'exclude_fixtures'
])
options
[
:exclude_serializers
]
=
Annotate
.
true?
(
ENV
[
'exclude_serializers'
])
options
[
:exclude_serializers
]
=
Annotate
.
true?
(
ENV
[
'exclude_serializers'
])
options
[
:exclude_scaffolds
]
=
Annotate
.
true?
(
ENV
[
'exclude_scaffolds'
])
options
[
:ignore_model_sub_dir
]
=
Annotate
.
true?
(
ENV
[
'ignore_model_sub_dir'
])
options
[
:ignore_model_sub_dir
]
=
Annotate
.
true?
(
ENV
[
'ignore_model_sub_dir'
])
options
[
:format_bare
]
=
Annotate
.
true?
(
ENV
[
'format_bare'
])
options
[
:format_bare
]
=
Annotate
.
true?
(
ENV
[
'format_bare'
])
options
[
:format_rdoc
]
=
Annotate
.
true?
(
ENV
[
'format_rdoc'
])
options
[
:format_rdoc
]
=
Annotate
.
true?
(
ENV
[
'format_rdoc'
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment