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
841c3e78
Commit
841c3e78
authored
Aug 21, 2012
by
Jeremy McNevin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change expected Factory Girl factory filenames.
parent
98d00635
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
annotate_models.rb
lib/annotate/annotate_models.rb
+14
-14
No files found.
lib/annotate/annotate_models.rb
View file @
841c3e78
...
@@ -39,7 +39,7 @@ module AnnotateModels
...
@@ -39,7 +39,7 @@ module AnnotateModels
def
model_dir
def
model_dir
@model_dir
||
"app/models"
@model_dir
||
"app/models"
end
end
def
model_dir
=
(
dir
)
def
model_dir
=
(
dir
)
@model_dir
=
dir
@model_dir
=
dir
end
end
...
@@ -92,7 +92,7 @@ module AnnotateModels
...
@@ -92,7 +92,7 @@ module AnnotateModels
col_type
<<
"(
#{
col
.
limit
}
)"
unless
NO_LIMIT_COL_TYPES
.
include?
(
col_type
)
col_type
<<
"(
#{
col
.
limit
}
)"
unless
NO_LIMIT_COL_TYPES
.
include?
(
col_type
)
end
end
end
end
# Check out if we got a geometric column
# Check out if we got a geometric column
# and print the type and SRID
# and print the type and SRID
if
col
.
respond_to?
(
:geometry_type
)
if
col
.
respond_to?
(
:geometry_type
)
...
@@ -180,7 +180,7 @@ module AnnotateModels
...
@@ -180,7 +180,7 @@ module AnnotateModels
if
old_columns
==
new_columns
&&
!
options
[
:force
]
if
old_columns
==
new_columns
&&
!
options
[
:force
]
false
false
else
else
# todo: figure out if we need to extract any logic from this merge chunk
# todo: figure out if we need to extract any logic from this merge chunk
# <<<<<<< HEAD
# <<<<<<< HEAD
# # Replace the old schema info with the new schema info
# # Replace the old schema info with the new schema info
...
@@ -197,7 +197,7 @@ module AnnotateModels
...
@@ -197,7 +197,7 @@ module AnnotateModels
# Strip the old schema info, and insert new schema info.
# Strip the old schema info, and insert new schema info.
old_content
.
sub!
(
encoding
,
''
)
old_content
.
sub!
(
encoding
,
''
)
old_content
.
sub!
(
PATTERN
,
''
)
old_content
.
sub!
(
PATTERN
,
''
)
new_content
=
(
options
[
:position
]
||
'before'
).
to_s
==
'after'
?
new_content
=
(
options
[
:position
]
||
'before'
).
to_s
==
'after'
?
(
encoding_header
+
(
old_content
.
rstrip
+
"
\n\n
"
+
info_block
))
:
(
encoding_header
+
(
old_content
.
rstrip
+
"
\n\n
"
+
info_block
))
:
(
encoding_header
+
info_block
+
old_content
)
(
encoding_header
+
info_block
+
old_content
)
...
@@ -207,7 +207,7 @@ module AnnotateModels
...
@@ -207,7 +207,7 @@ module AnnotateModels
end
end
end
end
end
end
def
remove_annotation_of_file
(
file_name
)
def
remove_annotation_of_file
(
file_name
)
if
File
.
exist?
(
file_name
)
if
File
.
exist?
(
file_name
)
content
=
File
.
read
(
file_name
)
content
=
File
.
read
(
file_name
)
...
@@ -252,8 +252,8 @@ module AnnotateModels
...
@@ -252,8 +252,8 @@ module AnnotateModels
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
BLUEPRINTS_TEST_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
BLUEPRINTS_TEST_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
BLUEPRINTS_SPEC_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
BLUEPRINTS_SPEC_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
FACTORY_GIRL_TEST_DIR
,
"
#{
model_name
}
_factory.rb"
),
# Factory Girl Factories
File
.
join
(
FACTORY_GIRL_TEST_DIR
,
"
#{
klass
.
table_name
}
.rb"
),
# Factory Girl Factories
File
.
join
(
FACTORY_GIRL_SPEC_DIR
,
"
#{
model_name
}
_factory.rb"
),
# Factory Girl Factories
File
.
join
(
FACTORY_GIRL_SPEC_DIR
,
"
#{
klass
.
table_name
}
.rb"
),
# Factory Girl Factories
File
.
join
(
FABRICATORS_TEST_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
File
.
join
(
FABRICATORS_TEST_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
File
.
join
(
FABRICATORS_SPEC_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
File
.
join
(
FABRICATORS_SPEC_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
].
each
do
|
file
|
].
each
do
|
file
|
...
@@ -302,7 +302,7 @@ module AnnotateModels
...
@@ -302,7 +302,7 @@ module AnnotateModels
end
end
models
models
end
end
# Retrieve the classes belonging to the model names we're asked to process
# Retrieve the classes belonging to the model names we're asked to process
# Check for namespaced models in subdirectories as well as models
# Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing.
# in subdirectories without namespacing.
...
@@ -320,7 +320,7 @@ module AnnotateModels
...
@@ -320,7 +320,7 @@ module AnnotateModels
select
do
|
c
|
select
do
|
c
|
Class
===
c
and
# note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
Class
===
c
and
# note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
c
.
ancestors
.
respond_to?
(
:include?
)
and
# to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
c
.
ancestors
.
respond_to?
(
:include?
)
and
# to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
c
.
ancestors
.
include?
(
ActiveRecord
::
Base
)
c
.
ancestors
.
include?
(
ActiveRecord
::
Base
)
end
.
end
.
detect
{
|
c
|
ActiveSupport
::
Inflector
.
underscore
(
c
)
==
model_path
}
detect
{
|
c
|
ActiveSupport
::
Inflector
.
underscore
(
c
)
==
model_path
}
end
end
...
@@ -342,9 +342,9 @@ module AnnotateModels
...
@@ -342,9 +342,9 @@ module AnnotateModels
version
=
ActiveRecord
::
Migrator
.
current_version
rescue
0
version
=
ActiveRecord
::
Migrator
.
current_version
rescue
0
if
version
>
0
if
version
>
0
header
<<
"
\n
# Schema version:
#{
version
}
"
header
<<
"
\n
# Schema version:
#{
version
}
"
end
end
end
end
self
.
model_dir
=
options
[
:model_dir
]
if
options
[
:model_dir
]
self
.
model_dir
=
options
[
:model_dir
]
if
options
[
:model_dir
]
annotated
=
[]
annotated
=
[]
...
@@ -394,8 +394,8 @@ module AnnotateModels
...
@@ -394,8 +394,8 @@ module AnnotateModels
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
BLUEPRINTS_TEST_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
BLUEPRINTS_TEST_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
BLUEPRINTS_SPEC_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
BLUEPRINTS_SPEC_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
File
.
join
(
FACTORY_GIRL_TEST_DIR
,
"
#{
model_name
}
_factory.rb"
),
# Factory Girl Factories
File
.
join
(
FACTORY_GIRL_TEST_DIR
,
"
#{
klass
.
table_name
}
.rb"
),
# Factory Girl Factories
File
.
join
(
FACTORY_GIRL_SPEC_DIR
,
"
#{
model_name
}
_factory.rb"
),
# Factory Girl Factories
File
.
join
(
FACTORY_GIRL_SPEC_DIR
,
"
#{
klass
.
table_name
}
.rb"
),
# Factory Girl Factories
File
.
join
(
FABRICATORS_TEST_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
File
.
join
(
FABRICATORS_TEST_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
File
.
join
(
FABRICATORS_SPEC_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
File
.
join
(
FABRICATORS_SPEC_DIR
,
"
#{
model_name
}
_fabricator.rb"
),
# Fabrication Fabricators
].
each
do
|
file
|
].
each
do
|
file
|
...
@@ -405,7 +405,7 @@ module AnnotateModels
...
@@ -405,7 +405,7 @@ module AnnotateModels
end
end
rescue
Exception
=>
e
rescue
Exception
=>
e
puts
"Unable to deannotate
#{
file
}
:
#{
e
.
message
}
"
puts
"Unable to deannotate
#{
file
}
:
#{
e
.
message
}
"
puts
"
\t
"
+
e
.
backtrace
.
join
(
"
\n\t
"
)
if
options
[
:trace
]
puts
"
\t
"
+
e
.
backtrace
.
join
(
"
\n\t
"
)
if
options
[
:trace
]
end
end
end
end
puts
"Removed annotation from:
#{
deannotated
.
join
(
', '
)
}
"
puts
"Removed annotation from:
#{
deannotated
.
join
(
', '
)
}
"
...
...
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