Skip to content

Commit 6d7bfc0

Browse files
committed
Merge branch 'mrjoy'
* mrjoy: (177 commits) Updating authorship. Resolve conflict between generated rakefile and CLI tool. Minor fixups. Updating readme to be RDoc compliant. fixed a few typos Updating docs to point to this fork. Update docs. Yep, I'm tired. Revert "Version bump to 0.0.0" Version bump to 0.0.0 Changing my mind on project name issue... Making project name match Github project name. Bumping version. Wider type column output, play nice with Rake CLI. Fixing behavior with some model sub-classes, adding skip-annotations feature. Making ActiveSupport dependency float, updating gemspec. Updating change log, readme and TODO list. Update generated .rake file with new options. Renaming bin to avoid conflict with ImageMagick. Accept string or symbol for positions. ... Conflicts: Gemfile Gemfile.lock History.txt README.rdoc Rakefile VERSION.yml annotate.gemspec annotate_models.gemspec lib/annotate/annotate_models.rb lib/tasks/annotate_models.rake lib/tasks/annotate_routes.rake spec/annotate/annotate_models_spec.rb spec/spec_helper.rb todo.txt
2 parents c52cefe + b773570 commit 6d7bfc0

24 files changed

+717
-349
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ spec/debug.log
66
pkg/*
77
dist
88
Gemfile.lock
9+
*.gem
10+
/.idea/
11+
.rvmrc

.rvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rvm use ruby-1.9.2-p290@annotate_models

Gemfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ source :rubygems
33
gem "rake"
44

55
group :development do
6-
gem "rspec"
7-
gem "rdoc"
8-
gem "mg"
9-
gem 'activesupport', '>= 2.1.0'
10-
gem "wrong"
6+
gem 'mg'
7+
gem 'rspec'
8+
gem 'wrong'
9+
gem 'rdoc'
1110
end
11+
12+
gem 'activesupport', '>= 3.0.0', :require => nil

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ PLATFORMS
5656
ruby
5757

5858
DEPENDENCIES
59-
activesupport (>= 2.1.0)
59+
activesupport (>= 3.0.0)
6060
mg
6161
rake
6262
rdoc

History.txt

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,53 @@
2020
* Support FactoryGirl
2121
* Support :change migrations (Rails 3.1)
2222
* Allow models with non-standard capitalization
23+
* Widen type column so we can handle longtexts with chopping things off.
24+
* Skip trying to get list of models from commandline when running via Rake (was
25+
preventing the use of multiple rake tasks in one command if one of them was
26+
db:migrate).
27+
* Add ability to skip annotations for a model by adding
28+
'# -*- SkipSchemaAnnotations' anywhere in the file.
29+
* Don't show column limits for integer and boolean types.
30+
* Add sorting for columns and indexes. (Helpful for out-of-order migration
31+
execution, but use --no-sort if you don't want this.)
32+
* Annotate unit tests in subfolders.
33+
* Add generator to install rakefile that automatically annotates on db:migrate.
34+
* Correct Gemfile to clarify which environments need which gems.
35+
* Add an .rvmrc to facilitate clean development.
36+
* Refactor out ActiveRecord monkey-patch to permit extending without
37+
side-effects.
38+
* Use ObjectSpace to locate models to facilitate handling of models with
39+
non-standard capitalization.
40+
Note that this still requires that the inflector be configured to understand
41+
the special case.
42+
* Shore up test cases a bit.
43+
* Merge against many of the older branches on Github whose functionality is
44+
already reflected to reduce confusion about what is and is not implemented
45+
here.
46+
* Accept String or Symbol for :position (et al) options.
47+
* Rename "annotate" bin to "annotate_models" to avoid conflicting with
48+
ImageMagick.
49+
* Add RDoc output formatting as an option.
50+
* Add Markdown output formatting as an option.
51+
* Add option to force annotation regeneration.
52+
* Add new configuration option for controlling where info is placed in
53+
fixtures/factories.
54+
* Fix for models without tables.
55+
* Fix gemspec generation now that Jeweler looks at Gemfile.
56+
* Fix warning: `NOTE: Gem::Specification#default_executable= is deprecated with
57+
no replacement. It will be removed on or after 2011-10-01.`
58+
* Fix handling of files with no trailing newline when putting annotations at
59+
the end of the file.
2360

61+
== 2.4.2 2009-11-21
62+
63+
* Annotates (spec|test)/factories/<model>_factory.rb files
64+
65+
== 2.4.1 2009-11-20
66+
67+
* Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
68+
* Move default annotation position back to top
69+
>>>>>>> mrjoy
2470

2571
== 2.4.0 2009-12-13
2672

@@ -34,7 +80,7 @@
3480
* -i to show database indexes in annotations
3581
* -e to exclude annotating tests or fixtures
3682
* -m to include the migration version number in the annotation
37-
* --model-dir to annotate model files stored a different place than app/models
83+
* --model-dir to annotate model files stored a different place than app/models
3884
* Ignore unknown macros ('acts_as_whatever')
3985

4086
== 2.0 2009-02-03

README.rdoc

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Add a comment summarizing the current schema to the top or bottom of each of you
88
* Object Daddy exemplars
99
* Machinist blueprints
1010
* Fabrication fabricators
11+
* Thoughtbot's factory_girl factories, i.e. the (spec|test)/factories/<model>_factory.rb files
1112

1213
The schema comment looks like this:
1314

@@ -41,16 +42,16 @@ Also, if you pass the -r option, it'll annotate routes.rb with the output of "ra
4142

4243
Into Gemfile from Github:
4344

44-
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
45+
gem 'annotate', :git => 'git://github.com/MrJoy/annotate_models.git'
4546

4647
Into environment gems From rubygems.org:
4748

4849
gem install annotate
4950

5051
Into environment gems from Github checkout:
5152

52-
git clone git://github.com/ctran/annotate_models.git annotate
53-
cd annotate
53+
git clone git://github.com/MrJoy/annotate_models.git annotate_models
54+
cd annotate_models
5455
rake build
5556
gem install pkg/annotate-*.gem
5657

@@ -61,60 +62,61 @@ Into environment gems from Github checkout:
6162
To annotate all your models, tests, fixtures, etc.:
6263

6364
cd /path/to/app
64-
annotate
65+
annotate_models
6566

6667
To annotate your models and tests:
6768

68-
annotate --exclude fixtures
69+
annotate_models --exclude fixtures
6970

7071
To annotate just your models:
7172

72-
annotate --exclude tests,fixtures
73+
annotate_models --exclude tests,fixtures
7374

7475
To annotate routes.rb:
7576

76-
annotate -r
77+
annotate_models -r
7778

78-
To automatically annotate after running 'rake db:migrate':
79-
80-
[*needs more clarity*] unpack the gem into vendor/plugins, or maybe vendor/gems, or maybe just require tasks/migrate.rake.
79+
To remove annotations:
8180

82-
If you install annotate_models as a plugin, it will automatically
83-
adjust your <tt>rake db:migrate</tt> tasks so that they update the
84-
annotations in your model files for you once the migration is
85-
completed. To get the same behavior from a gem, add the following to
86-
your Rakefile:
81+
annotate_models -d
8782

88-
require 'annotate/tasks'
83+
To automatically annotate after running 'rake db:migrate', ensure you've added
84+
annotate_models to your Rails project's Gemfile, and run this:
8985

90-
To customize the behavior of annotate when it is running as a Rake
91-
task, use the following (in your Rakefile or wherever):
86+
rails g annotate_models:install
9287

93-
ENV['position_in_class'] = "before"
94-
ENV['position_in_fixture'] = "before"
95-
ENV['show_indexes'] = "false"
96-
ENV['include_version'] = "false"
97-
ENV['exclude_tests'] = "false"
98-
ENV['exclude_fixtures'] = "false"
99-
ENV['skip_on_db_migrate'] = "false"
88+
This will produce a .rake file that will ensure annotation happens after
89+
migration (but only in development mode), and provide configuration options
90+
you can use to tailor the output.
10091

101-
Warning: ImageMagick installs a tool called `annotate` too (if you're using MacPorts it's in `/opt/local/bin/annotate`. So if you see Usage: annotate imagein.jpg imageout.jpg then put `/usr/bin` ahead on the path and you'll get ours instead.
92+
If you want to always skip annotations on a particular model, add this string
93+
anywhere in the file:
10294

95+
# -*- SkipSchemaAnnotations
10396

10497
== OPTIONS
10598

106-
Usage: annotate [options] [model_file]*
99+
Usage: annotate_models [options] [model_file]*
107100
-d, --delete Remove annotations from all model files
108101
-p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
109102
-r, --routes Annotate routes.rb with the output of 'rake routes'
110103
-v, --version Show the current version of this gem
111104
-m, --show-migration Include the migration version number in the annotation
112-
-i, --show-indexes List the table's database indexes in the annotation
113-
-s, --simple-indexes Concat the column's related indexes in the annotation
105+
-i, --show-indexes List the indexes for the table in the annotation
106+
-s, --simple-indexes Include information about indexes inline with the relevant column
114107
--model-dir dir Annotate model files stored in dir rather than app/models
108+
--ignore-model-subdirs Ignore sub-directories of the models directory.
115109
-R, --require path Additional files to require before loading models
116-
-e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both
110+
-e [tests,fixtures] Skip annotation of fixtures/factories/test files
111+
--exclude
112+
-n --no-sort Sort by column creation order rather than alphabetical order
117113

114+
== SORTING
115+
116+
By default, columns will be sorted alphabetically so that the results of
117+
annotation are consistent regardless of what order migrations are executed in.
118+
119+
If you prefer the old behavior, use --no-sort.
118120

119121
== WARNING
120122

@@ -123,16 +125,16 @@ block in your models if it looks like it was previously added
123125
by annotate models, so you don't want to add additional text
124126
to an automatically created comment block.
125127

126-
* * Back up your model files before using... * *
128+
BACK UP YOUR MODELS BEFORE USING THIS TOOL!
127129

128130
== LINKS
129131

130-
* Factory Girl => http://github.com/thoughtbot/factory_girl (NOT IMPLEMENTED)
131-
* Object Daddy => http://github.com/flogic/object_daddy
132-
* Machinist => http://github.com/notahat/machinist
133-
* Fabrication => http://github.com/paulelliott/fabrication
134-
* SpatialAdapter => http://github.com/pdeffendol/spatial_adapter
135-
* PostgisAdapter => http://github.com/nofxx/postgis_adapter
132+
- Factory Girl: http://github.com/thoughtbot/factory_girl
133+
- Object Daddy: http://github.com/flogic/object_daddy
134+
- Machinist: http://github.com/notahat/machinist
135+
- Fabrication: http://github.com/paulelliott/fabrication
136+
- SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
137+
- PostgisAdapter: http://github.com/nofxx/postgis_adapter
136138

137139
== LICENSE:
138140

@@ -150,21 +152,23 @@ Maintained by: Alex Chaffee and Cuong Tran
150152

151153
Homepage: http://github.com/ctran/annotate_models
152154

153-
Modifications by:
154-
155-
- Alex Chaffee - http://github.com/alexch - [email protected]
156-
- Cuong Tran - http://github.com/ctran - [email protected]
157-
- Jack Danger - http://github.com/JackDanger
158-
- Michael Bumann - http://github.com/bumi
159-
- Henrik Nyh - http://github.com/henrik
160-
- Marcos Piccinini - http://github.com/nofxx
161-
- Neal Clark - http://github.com/nclark
162-
- Jacqui Maher - http://github.com/jacqui
163-
- Nick Plante - http://github.com/zapnap - http://blog.zerosum.org
164-
- Pedro Visintin - http://github.com/peterpunk - http://www.pedrovisintin.com
165-
- Bob Potter - http://github.com/bpot
166-
- Gavin Montague - http://github.com/govan/
167-
- Alexander Semyonov - http://github.com/rotuka/
168-
- Ian Duggan http://github.com/ijcd/
169-
155+
With help from:
156+
157+
- Alex Chaffee - http://github.com/alexch - [email protected]
158+
- Cuong Tran - http://github.com/ctran - [email protected]
159+
- Jack Danger - http://github.com/JackDanger
160+
- Michael Bumann - http://github.com/bumi
161+
- Henrik Nyh - http://github.com/henrik
162+
- Marcos Piccinini - http://github.com/nofxx
163+
- Neal Clark - http://github.com/nclark
164+
- Jacqui Maher - http://github.com/jacqui
165+
- Nick Plante - http://github.com/zapnap - http://blog.zerosum.org
166+
- Pedro Visintin - http://github.com/peterpunk - http://www.pedrovisintin.com
167+
- Bob Potter - http://github.com/bpot
168+
- Gavin Montague - http://github.com/govan/
169+
- Alexander Semyonov - http://github.com/rotuka/
170+
- Nathan Brazil - http://github.com/bitaxis/
171+
- Ian Duggan http://github.com/ijcd/
172+
- Jon Frisby http://github.com/mrjoy/
173+
170174
and many others that I may have missed to add.

Rakefile

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
here = File.dirname __FILE__
22

33
require 'rubygems'
4+
require 'bundler'
5+
begin
6+
Bundler.setup(:default, :development)
7+
rescue Bundler::BundlerError => e
8+
$stderr.puts e.message
9+
$stderr.puts "Run `bundle install` to install missing gems"
10+
exit e.status_code
11+
end
12+
require 'rake/dsl_definition'
413
require 'rake'
14+
515
require "#{here}/lib/annotate"
616

717
# want other tests/tasks run by default? Add them to the list
@@ -25,12 +35,7 @@ begin
2535
rescue LoadError
2636
abort "Please `gem install mg`"
2737
end
28-
MG.new("annotate_models.gemspec")
29-
30-
require 'rspec/core/rake_task'
31-
RSpec::Core::RakeTask.new(:spec) do |spec|
32-
spec.pattern = 'spec/**/*_spec.rb'
33-
end
38+
MG.new("annotate.gemspec")
3439

3540
task :default => :spec
3641

@@ -39,18 +44,10 @@ RSpec::Core::RakeTask.new(:spec) do |t|
3944
t.pattern = ['spec/*_spec.rb', 'spec/**/*_spec.rb']
4045
end
4146

42-
# FIXME not working yet
43-
RSpec::Core::RakeTask.new(:rcov) do |t|
44-
t.pattern = 'spec/**/*_spec.rb'
45-
t.rcov = true
47+
require 'rdoc/task'
48+
RDoc::Task.new do |rdoc|
49+
rdoc.rdoc_dir = 'rdoc'
50+
rdoc.title = "annotated_models #{Annotate.version}"
51+
rdoc.rdoc_files.include('README*')
52+
rdoc.rdoc_files.include('lib/**/*.rb')
4653
end
47-
48-
# FIXME warns "already initialized constant Task"
49-
# FIXME throws "uninitialized constant RDoc::VISIBILITIES"
50-
# require 'rdoc/task'
51-
# RDoc::Task.new do |rdoc|
52-
# rdoc.main = "README.rdoc"
53-
# rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
54-
# # require 'lib/annotate'
55-
# # rdoc.title = "annotate #{Annotate.version}"
56-
# end

VERSION.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
:major: 2
33
:minor: 5
44
:patch: 0

annotate_models.gemspec

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)