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
dcd4ba6d
Commit
dcd4ba6d
authored
Nov 20, 2009
by
Nathan Brazil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for factory_girl and move default annotation position to top. Also…
Add support for factory_girl and move default annotation position to top. Also updated documentation files.
parent
9c68c8c9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
12 deletions
+36
-12
History.txt
History.txt
+5
-0
README.rdoc
README.rdoc
+7
-4
VERSION.yml
VERSION.yml
+1
-1
annotate.gemspec
annotate.gemspec
+6
-4
annotate
bin/annotate
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+15
-1
annotate_models.rake
lib/tasks/annotate_models.rake
+1
-0
todo.txt
todo.txt
+0
-1
No files found.
History.txt
View file @
dcd4ba6d
== 2.4.1 2009-11-20
* Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
* Move default annotation position back to top
== 2.1 2009-10-18
== 2.1 2009-10-18
* New options
* New options
...
...
README.rdoc
View file @
dcd4ba6d
...
@@ -7,6 +7,7 @@ Add a comment summarizing the current schema to the top or bottom of each of you
...
@@ -7,6 +7,7 @@ Add a comment summarizing the current schema to the top or bottom of each of you
* Tests and Specs
* Tests and Specs
* Object Daddy exemplars
* Object Daddy exemplars
* Machinist blueprints
* Machinist blueprints
* Thoughtbot's factory_girl factories (test/factories/<model>_factory.rb files)
The schema comment looks like this:
The schema comment looks like this:
...
@@ -46,8 +47,8 @@ From github:
...
@@ -46,8 +47,8 @@ From github:
git clone git://github.com/ctran/annotate_models.git annotate
git clone git://github.com/ctran/annotate_models.git annotate
cd annotate
cd annotate
rake gem
gem build annotate.gemspec
sudo gem install
pkg/annotate-*
.gem
sudo gem install
annotate-<version>
.gem
== USAGE
== USAGE
...
@@ -89,7 +90,8 @@ completed.
...
@@ -89,7 +90,8 @@ completed.
-s, --simple-indexes Concat the column's related indexes in the annotation
-s, --simple-indexes Concat the column's related indexes in the annotation
--model-dir dir Annotate model files stored in dir rather than app/models
--model-dir dir Annotate model files stored in dir rather than app/models
-R, --require path Additional files to require before loading models
-R, --require path Additional files to require before loading models
-e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both
-e [tests,fixtures,factories] Do not annotate fixtures, test files, and/or factories
--exclude
== WARNING
== WARNING
...
@@ -103,7 +105,7 @@ to an automatically created comment block.
...
@@ -103,7 +105,7 @@ to an automatically created comment block.
== LINKS
== LINKS
* Factory Girl => http://github.com/thoughtbot/factory_girl
(NOT IMPLEMENTED)
* Factory Girl => http://github.com/thoughtbot/factory_girl
* Object Daddy => http://github.com/flogic/object_daddy
* Object Daddy => http://github.com/flogic/object_daddy
* SpatialAdapter => http://github.com/pdeffendol/spatial_adapter
* SpatialAdapter => http://github.com/pdeffendol/spatial_adapter
* PostgisAdapter => http://github.com/nofxx/postgis_adapter
* PostgisAdapter => http://github.com/nofxx/postgis_adapter
...
@@ -134,5 +136,6 @@ Modifications by:
...
@@ -134,5 +136,6 @@ Modifications by:
- Bob Potter - http://github.com/bpot
- Bob Potter - http://github.com/bpot
- Gavin Montague - http://github.com/govan/
- Gavin Montague - http://github.com/govan/
- Alexander Semyonov - http://github.com/rotuka/
- Alexander Semyonov - http://github.com/rotuka/
- Nathan Brazil - http://github.com/bitaxis/
and many others that I may have missed to add.
and many others that I may have missed to add.
VERSION.yml
View file @
dcd4ba6d
---
---
:major
:
2
:major
:
2
:minor
:
4
:minor
:
4
:patch
:
0
:patch
:
1
annotate.gemspec
View file @
dcd4ba6d
# Generated by jeweler
# Generated by jeweler
# DO NOT EDIT THIS FILE
# DO NOT EDIT THIS FILE
DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run
`rake gemspec`
# Instead, edit Jeweler::Tasks in Rakefile, and run
the gemspec command
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-
Gem
::
Specification
.
new
do
|
s
|
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
%q{annotate}
s
.
name
=
%q{annotate}
s
.
version
=
"2.4.
0
"
s
.
version
=
"2.4.
1
"
s
.
required_rubygems_version
=
Gem
::
Requirement
.
new
(
">= 0"
)
if
s
.
respond_to?
:required_rubygems_version
=
s
.
required_rubygems_version
=
Gem
::
Requirement
.
new
(
">= 0"
)
if
s
.
respond_to?
:required_rubygems_version
=
s
.
authors
=
[
"Cuong Tran"
,
"Alex Chaffee"
,
"Marcos Piccinini"
]
s
.
authors
=
[
"Cuong Tran"
,
"Alex Chaffee"
,
"Marcos Piccinini"
]
s
.
date
=
%q{2009-1
0-23
}
s
.
date
=
%q{2009-1
1-16
}
s
.
default_executable
=
%q{annotate}
s
.
default_executable
=
%q{annotate}
s
.
description
=
%q{Annotates Rails Models, routes, fixtures, and others based on the database schema.}
s
.
description
=
%q{Annotates Rails Models, routes, fixtures, and others based on the database schema.}
s
.
email
=
[
"alex@stinky.com"
,
"ctran@pragmaquest.com"
,
"x@nofxx.com"
]
s
.
email
=
[
"alex@stinky.com"
,
"ctran@pragmaquest.com"
,
"x@nofxx.com"
]
...
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
...
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
s
.
homepage
=
%q{http://github.com/ctran/annotate}
s
.
homepage
=
%q{http://github.com/ctran/annotate}
s
.
rdoc_options
=
[
"--charset=UTF-8"
]
s
.
rdoc_options
=
[
"--charset=UTF-8"
]
s
.
require_paths
=
[
"lib"
]
s
.
require_paths
=
[
"lib"
]
s
.
rubyforge_project
=
%q{annotate}
s
.
rubygems_version
=
%q{1.3.5}
s
.
rubygems_version
=
%q{1.3.5}
s
.
summary
=
%q{Annotates Rails Models, routes, fixtures, and others based on the database schema.}
s
.
summary
=
%q{Annotates Rails Models, routes, fixtures, and others based on the database schema.}
s
.
test_files
=
[
s
.
test_files
=
[
...
@@ -56,3 +57,4 @@ Gem::Specification.new do |s|
...
@@ -56,3 +57,4 @@ Gem::Specification.new do |s|
else
else
end
end
end
end
bin/annotate
View file @
dcd4ba6d
...
@@ -57,7 +57,7 @@ OptionParser.new do |opts|
...
@@ -57,7 +57,7 @@ OptionParser.new do |opts|
end
end
end
end
opts
.
on
(
'-e'
,
'--exclude [tests,fixtures
]'
,
Array
,
"Do not annotate fixtures, test files, or both
"
)
do
|
exclusions
|
opts
.
on
(
'-e'
,
'--exclude [tests,fixtures
,factories]'
,
Array
,
"Do not annotate fixtures, test files, and/or factories
"
)
do
|
exclusions
|
exclusions
.
each
{
|
exclusion
|
ENV
[
"exclude_
#{
exclusion
}
"
]
=
"yes"
}
exclusions
.
each
{
|
exclusion
|
ENV
[
"exclude_
#{
exclusion
}
"
]
=
"yes"
}
end
end
...
...
lib/annotate/annotate_models.rb
View file @
dcd4ba6d
...
@@ -14,6 +14,8 @@ module AnnotateModels
...
@@ -14,6 +14,8 @@ module AnnotateModels
EXEMPLARS_SPEC_DIR
=
File
.
join
(
"spec"
,
"exemplars"
)
EXEMPLARS_SPEC_DIR
=
File
.
join
(
"spec"
,
"exemplars"
)
# Machinist http://github.com/notahat/machinist
# Machinist http://github.com/notahat/machinist
BLUEPRINTS_DIR
=
File
.
join
(
"test"
,
"blueprints"
)
BLUEPRINTS_DIR
=
File
.
join
(
"test"
,
"blueprints"
)
# Factory Girl http://github.com/thoughtbot/factory_girl
FACTORIES_DIR
=
File
.
join
(
"test"
,
"factories"
)
def
model_dir
def
model_dir
@model_dir
||
"app/models"
@model_dir
||
"app/models"
...
@@ -130,7 +132,7 @@ module AnnotateModels
...
@@ -130,7 +132,7 @@ module AnnotateModels
old_content
.
sub!
(
/^#
#{
COMPAT_PREFIX
}
.*?\n(#.*\n)*\n/
,
''
)
old_content
.
sub!
(
/^#
#{
COMPAT_PREFIX
}
.*?\n(#.*\n)*\n/
,
''
)
# Write it back
# Write it back
new_content
=
options
[
:position
]
==
'before'
?
(
info_block
+
old_content
)
:
(
old_content
+
"
\n
"
+
info_block
)
new_content
=
((
options
[
:position
]
||
:before
).
to_sym
==
:before
)
?
(
info_block
+
old_content
)
:
(
old_content
+
"
\n
"
+
info_block
)
File
.
open
(
file_name
,
"wb"
)
{
|
f
|
f
.
puts
new_content
}
File
.
open
(
file_name
,
"wb"
)
{
|
f
|
f
.
puts
new_content
}
true
true
...
@@ -190,6 +192,14 @@ module AnnotateModels
...
@@ -190,6 +192,14 @@ module AnnotateModels
end
end
end
end
end
end
unless
ENV
[
'exclude_factories'
]
[
File
.
join
(
FACTORIES_DIR
,
"
#{
model_name
}
_factory.rb"
),
# test/factories
].
each
do
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_factory
))
end
end
annotated
annotated
end
end
...
@@ -309,6 +319,10 @@ module AnnotateModels
...
@@ -309,6 +319,10 @@ module AnnotateModels
remove_annotation_of_file
(
file
)
if
File
.
exist?
(
file
)
remove_annotation_of_file
(
file
)
if
File
.
exist?
(
file
)
end
end
[
File
.
join
(
FACTORIES_DIR
,
"
#{
klass
.
name
.
underscore
}
_factory.rb"
)].
each
do
|
file
|
remove_annotation_of_file
(
file
)
if
File
.
exist?
(
file
)
end
end
end
rescue
Exception
=>
e
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
...
...
lib/tasks/annotate_models.rake
View file @
dcd4ba6d
...
@@ -3,6 +3,7 @@ task :annotate_models => :environment do
...
@@ -3,6 +3,7 @@ task :annotate_models => :environment do
require
'annotate/annotate_models'
require
'annotate/annotate_models'
options
=
{}
options
=
{}
options
[
:position_in_class
]
=
ENV
[
'position_in_class'
]
||
ENV
[
'position'
]
||
:before
options
[
:position_in_class
]
=
ENV
[
'position_in_class'
]
||
ENV
[
'position'
]
||
:before
options
[
:position_in_factory
]
=
ENV
[
'position_in_factory'
]
||
ENV
[
'position'
]
||
:before
options
[
:position_in_fixture
]
=
ENV
[
'position_in_fixture'
]
||
ENV
[
'position'
]
||
:before
options
[
:position_in_fixture
]
=
ENV
[
'position_in_fixture'
]
||
ENV
[
'position'
]
||
:before
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
options
[
:show_indexes
]
=
ENV
[
'show_indexes'
]
options
[
:simple_indexes
]
=
ENV
[
'simple_indexes'
]
options
[
:simple_indexes
]
=
ENV
[
'simple_indexes'
]
...
...
todo.txt
View file @
dcd4ba6d
TODO
TODO
-----
-----
change default position back to "top" for all
add "top" and "bottom" as synonyms for "before" and "after"
add "top" and "bottom" as synonyms for "before" and "after"
change 'exclude' to 'only' (double negatives are not unconfusing)
change 'exclude' to 'only' (double negatives are not unconfusing)
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