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
f0d10d63
Commit
f0d10d63
authored
Jan 25, 2016
by
Guillermo Guerrero Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted refactors.
parent
65770b5d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
83 deletions
+74
-83
.rubocop_todo.yml
.rubocop_todo.yml
+7
-12
annotate_models.rb
lib/annotate/annotate_models.rb
+67
-1
file_patterns.rb
lib/annotate/file_patterns.rb
+0
-70
No files found.
.rubocop_todo.yml
View file @
f0d10d63
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-01-2
3 17:15:16
+0100 using RuboCop version 0.36.0.
# on 2016-01-2
5 09:57:25
+0100 using RuboCop version 0.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
...
...
@@ -105,7 +105,7 @@ Metrics/MethodLength:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength
:
Max
:
444
Max
:
507
# Offense count: 7
Metrics/PerceivedComplexity
:
...
...
@@ -207,7 +207,7 @@ Style/ConditionalAssignment:
-
'
bin/annotate'
-
'
lib/annotate/annotate_models.rb'
# Offense count:
8
# Offense count:
7
Style/Documentation
:
Exclude
:
-
'
spec/**/*'
...
...
@@ -215,7 +215,6 @@ Style/Documentation:
-
'
lib/annotate.rb'
-
'
lib/annotate/active_record_patch.rb'
-
'
lib/annotate/annotate_models.rb'
-
'
lib/annotate/file_patterns.rb'
-
'
lib/annotate/version.rb'
-
'
lib/generators/annotate/install_generator.rb'
-
'
lib/tasks/migrate.rake'
...
...
@@ -267,7 +266,6 @@ Style/ExtraSpacing:
Exclude
:
-
'
Guardfile'
-
'
lib/annotate/annotate_models.rb'
-
'
lib/annotate/file_patterns.rb'
-
'
lib/tasks/annotate_routes.rake'
-
'
spec/integration/rails_2.3_with_bundler/script/console'
-
'
spec/integration/rails_3.2.2/script/rails'
...
...
@@ -632,7 +630,7 @@ Style/SpaceInsideStringInterpolation:
Style/SpecialGlobalVars
:
Enabled
:
false
# Offense count:
411
# Offense count:
384
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
...
...
@@ -661,14 +659,13 @@ Style/Tab:
-
'
spec/integration/rails_4.2.0/app/models/sub1/sub2/sub3/event.rb'
-
'
spec/integration/rails_4.2.0/app/models/task.rb'
# Offense count:
6
# Offense count:
5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: final_newline, final_blank_line
Style/TrailingBlankLines
:
Exclude
:
-
'
Guardfile'
-
'
lib/annotate/file_patterns.rb'
-
'
spec/integration/rails_4.1.1/app/models/task_observer.rb'
-
'
spec/integration/rails_4.1.1/config/initializers/cookies_serializer.rb'
-
'
spec/integration/rails_4.2.0/app/models/task_observer.rb'
...
...
@@ -682,22 +679,20 @@ Style/TrailingCommaInArguments:
Exclude
:
-
'
spec/annotate/annotate_models_spec.rb'
# Offense count:
12
# Offense count:
8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
# SupportedStyles: comma, consistent_comma, no_comma
Style/TrailingCommaInLiteral
:
Exclude
:
-
'
lib/annotate/file_patterns.rb'
-
'
spec/annotate/annotate_models_spec.rb'
-
'
spec/integration/rails_4.1.1/lib/tasks/auto_annotate_models.rake'
-
'
spec/integration/rails_4.2.0/lib/tasks/auto_annotate_models.rake'
# Offense count:
3
# Offense count:
2
# Cop supports --auto-correct.
Style/TrailingWhitespace
:
Exclude
:
-
'
lib/annotate/annotate_models.rb'
-
'
spec/annotate/annotate_models_spec.rb'
-
'
spec/integration/rails_2.3_with_bundler/db/schema.rb'
...
...
lib/annotate/annotate_models.rb
View file @
f0d10d63
require
'bigdecimal'
require
'annotate/file_patterns'
module
AnnotateModels
TRUE_RE
=
/^(true|t|yes|y|1)$/i
...
...
@@ -78,6 +77,73 @@ module AnnotateModels
attr_writer
:root_dir
def
test_files
(
root_directory
)
[
File
.
join
(
root_directory
,
UNIT_TEST_DIR
,
"%MODEL_NAME%_test.rb"
),
File
.
join
(
root_directory
,
MODEL_TEST_DIR
,
"%MODEL_NAME%_test.rb"
),
File
.
join
(
root_directory
,
SPEC_MODEL_DIR
,
"%MODEL_NAME%_spec.rb"
)
]
end
def
fixture_files
(
root_directory
)
[
File
.
join
(
root_directory
,
FIXTURE_TEST_DIR
,
"%TABLE_NAME%.yml"
),
File
.
join
(
root_directory
,
FIXTURE_SPEC_DIR
,
"%TABLE_NAME%.yml"
),
File
.
join
(
root_directory
,
FIXTURE_TEST_DIR
,
"%PLURALIZED_MODEL_NAME%.yml"
),
File
.
join
(
root_directory
,
FIXTURE_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%.yml"
)
]
end
def
scaffold_files
(
root_directory
)
[
File
.
join
(
root_directory
,
CONTROLLER_TEST_DIR
,
"%PLURALIZED_MODEL_NAME%_controller_test.rb"
),
File
.
join
(
root_directory
,
CONTROLLER_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%_controller_spec.rb"
),
File
.
join
(
root_directory
,
REQUEST_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%_spec.rb"
),
File
.
join
(
root_directory
,
ROUTING_SPEC_DIR
,
"%PLURALIZED_MODEL_NAME%_routing_spec.rb"
)
]
end
def
factory_files
(
root_directory
)
[
File
.
join
(
root_directory
,
EXEMPLARS_TEST_DIR
,
"%MODEL_NAME%_exemplar.rb"
),
File
.
join
(
root_directory
,
EXEMPLARS_SPEC_DIR
,
"%MODEL_NAME%_exemplar.rb"
),
File
.
join
(
root_directory
,
BLUEPRINTS_TEST_DIR
,
"%MODEL_NAME%_blueprint.rb"
),
File
.
join
(
root_directory
,
BLUEPRINTS_SPEC_DIR
,
"%MODEL_NAME%_blueprint.rb"
),
File
.
join
(
root_directory
,
FACTORY_GIRL_TEST_DIR
,
"%MODEL_NAME%_factory.rb"
),
# (old style)
File
.
join
(
root_directory
,
FACTORY_GIRL_SPEC_DIR
,
"%MODEL_NAME%_factory.rb"
),
# (old style)
File
.
join
(
root_directory
,
FACTORY_GIRL_TEST_DIR
,
"%TABLE_NAME%.rb"
),
# (new style)
File
.
join
(
root_directory
,
FACTORY_GIRL_SPEC_DIR
,
"%TABLE_NAME%.rb"
),
# (new style)
File
.
join
(
root_directory
,
FABRICATORS_TEST_DIR
,
"%MODEL_NAME%_fabricator.rb"
),
File
.
join
(
root_directory
,
FABRICATORS_SPEC_DIR
,
"%MODEL_NAME%_fabricator.rb"
)
]
end
def
serialize_files
(
root_directory
)
[
File
.
join
(
root_directory
,
SERIALIZERS_DIR
,
"%MODEL_NAME%_serializer.rb"
),
File
.
join
(
root_directory
,
SERIALIZERS_TEST_DIR
,
"%MODEL_NAME%_serializer_spec.rb"
),
File
.
join
(
root_directory
,
SERIALIZERS_SPEC_DIR
,
"%MODEL_NAME%_serializer_spec.rb"
)
]
end
def
files_by_pattern
(
root_directory
,
pattern_type
)
case
pattern_type
when
'test'
then
test_files
(
root_directory
)
when
'fixture'
then
fixture_files
(
root_directory
)
when
'scaffold'
then
scaffold_files
(
root_directory
)
when
'factory'
then
factory_files
(
root_directory
)
when
'serializer'
then
serialize_files
(
root_directory
)
when
'controller'
[
File
.
join
(
root_directory
,
CONTROLLER_DIR
,
"%PLURALIZED_MODEL_NAME%_controller.rb"
)]
when
'admin'
[
File
.
join
(
root_directory
,
ACTIVEADMIN_DIR
,
"%MODEL_NAME%.rb"
)]
when
'helper'
[
File
.
join
(
root_directory
,
HELPER_DIR
,
"%PLURALIZED_MODEL_NAME%_helper.rb"
)]
else
[]
end
end
def
get_patterns
(
pattern_types
=
[])
current_patterns
=
[]
root_dir
.
each
do
|
root_directory
|
...
...
lib/annotate/file_patterns.rb
deleted
100644 → 0
View file @
65770b5d
module
FilePatterns
class
<<
self
def
test_files
(
root_directory
)
[
File
.
join
(
root_directory
,
UNIT_TEST_DIR
,
'%MODEL_NAME%_test.rb'
),
File
.
join
(
root_directory
,
MODEL_TEST_DIR
,
'%MODEL_NAME%_test.rb'
),
File
.
join
(
root_directory
,
SPEC_MODEL_DIR
,
'%MODEL_NAME%_spec.rb'
),
]
end
def
fixture_files
(
root_directory
)
[
File
.
join
(
root_directory
,
FIXTURE_TEST_DIR
,
'%TABLE_NAME%.yml'
),
File
.
join
(
root_directory
,
FIXTURE_SPEC_DIR
,
'%TABLE_NAME%.yml'
),
File
.
join
(
root_directory
,
FIXTURE_TEST_DIR
,
'%PLURALIZED_MODEL_NAME%.yml'
),
File
.
join
(
root_directory
,
FIXTURE_SPEC_DIR
,
'%PLURALIZED_MODEL_NAME%.yml'
),
]
end
def
scaffold_files
(
root_directory
)
[
File
.
join
(
root_directory
,
CONTROLLER_TEST_DIR
,
'%PLURALIZED_MODEL_NAME%_controller_test.rb'
),
File
.
join
(
root_directory
,
CONTROLLER_SPEC_DIR
,
'%PLURALIZED_MODEL_NAME%_controller_spec.rb'
),
File
.
join
(
root_directory
,
REQUEST_SPEC_DIR
,
'%PLURALIZED_MODEL_NAME%_spec.rb'
),
File
.
join
(
root_directory
,
ROUTING_SPEC_DIR
,
'%PLURALIZED_MODEL_NAME%_routing_spec.rb'
),
]
end
def
factory_files
(
root_directory
)
[
File
.
join
(
root_directory
,
EXEMPLARS_TEST_DIR
,
'%MODEL_NAME%_exemplar.rb'
),
File
.
join
(
root_directory
,
EXEMPLARS_SPEC_DIR
,
'%MODEL_NAME%_exemplar.rb'
),
File
.
join
(
root_directory
,
BLUEPRINTS_TEST_DIR
,
'%MODEL_NAME%_blueprint.rb'
),
File
.
join
(
root_directory
,
BLUEPRINTS_SPEC_DIR
,
'%MODEL_NAME%_blueprint.rb'
),
File
.
join
(
root_directory
,
FACTORY_GIRL_TEST_DIR
,
'%MODEL_NAME%_factory.rb'
),
# (old style)
File
.
join
(
root_directory
,
FACTORY_GIRL_SPEC_DIR
,
'%MODEL_NAME%_factory.rb'
),
# (old style)
File
.
join
(
root_directory
,
FACTORY_GIRL_TEST_DIR
,
'%TABLE_NAME%.rb'
),
# (new style)
File
.
join
(
root_directory
,
FACTORY_GIRL_SPEC_DIR
,
'%TABLE_NAME%.rb'
),
# (new style)
File
.
join
(
root_directory
,
FABRICATORS_TEST_DIR
,
'%MODEL_NAME%_fabricator.rb'
),
File
.
join
(
root_directory
,
FABRICATORS_SPEC_DIR
,
'%MODEL_NAME%_fabricator.rb'
),
]
end
def
serialize_files
(
root_directory
)
[
File
.
join
(
root_directory
,
SERIALIZERS_DIR
,
'%MODEL_NAME%_serializer.rb'
),
File
.
join
(
root_directory
,
SERIALIZERS_TEST_DIR
,
'%MODEL_NAME%_serializer_spec.rb'
),
File
.
join
(
root_directory
,
SERIALIZERS_SPEC_DIR
,
'%MODEL_NAME%_serializer_spec.rb'
)
]
end
def
files_by_pattern
(
root_directory
,
pattern_type
)
case
pattern_type
when
'test'
then
test_files
(
root_directory
)
when
'fixture'
then
fixture_files
(
root_directory
)
when
'scaffold'
then
scaffold_files
(
root_directory
)
when
'factory'
then
factory_files
(
root_directory
)
when
'serializer'
then
serialize_files
(
root_directory
)
when
'controller'
[
File
.
join
(
root_directory
,
CONTROLLER_DIR
,
'%PLURALIZED_MODEL_NAME%_controller.rb'
)]
when
'admin'
[
File
.
join
(
root_directory
,
ACTIVEADMIN_DIR
,
'%MODEL_NAME%.rb'
)]
when
'helper'
[
File
.
join
(
root_directory
,
HELPER_DIR
,
'%PLURALIZED_MODEL_NAME%_helper.rb'
)]
else
[]
end
end
end
end
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