annotated_models 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ annotated_models (3.0.0)
5
+ activesupport
6
+ annotated_models
7
+ i18n
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ activesupport (3.0.4)
13
+ diff-lcs (1.1.2)
14
+ fakefs (0.3.1)
15
+ git (1.2.5)
16
+ i18n (0.5.0)
17
+ jeweler (1.5.2)
18
+ bundler (~> 1.0.0)
19
+ git (>= 1.2.5)
20
+ rake
21
+ rake (0.8.7)
22
+ rcov (0.9.9)
23
+ rspec (2.5.0)
24
+ rspec-core (~> 2.5.0)
25
+ rspec-expectations (~> 2.5.0)
26
+ rspec-mocks (~> 2.5.0)
27
+ rspec-core (2.5.1)
28
+ rspec-expectations (2.5.0)
29
+ diff-lcs (~> 1.1.2)
30
+ rspec-mocks (2.5.0)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ activesupport
37
+ annotated_models!
38
+ bundler
39
+ fakefs
40
+ i18n
41
+ jeweler
42
+ rcov
43
+ rspec
data/History.txt ADDED
@@ -0,0 +1,51 @@
1
+ == 2.4.2 2009-11-21
2
+
3
+ * Annotates (spec|test)/factories/<model>_factory.rb files
4
+
5
+ == 2.4.1 2009-11-20
6
+
7
+ * Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
8
+ * Move default annotation position back to top
9
+
10
+ == 2.4.0 2009-12-13
11
+
12
+ * Incorporated lots of patches from the Github community, including support for Blueprints fixtures
13
+ * Several bug fixes
14
+
15
+ == 2.1 2009-10-18
16
+
17
+ * New options
18
+ * -R to require additional files before loading the models
19
+ * -i to show database indexes in annotations
20
+ * -e to exclude annotating tests or fixtures
21
+ * -m to include the migration version number in the annotation
22
+ * --model-dir to annotate model files stored a different place than app/models
23
+ * Ignore unknown macros ('acts_as_whatever')
24
+
25
+ == 2.0 2009-02-03
26
+
27
+ * Add annotate_models plugin fork additions
28
+ * Annotates Rspec and Test Unit models
29
+ * Annotates Object Daddy exemplars
30
+ * Annotates geometrical columns
31
+ * Add AnnotateRoutes rake task
32
+ * Up gem structure to newgem defaults
33
+
34
+ == 1.0.4 2008-09-04
35
+
36
+ * Only update modified models since last run, thanks to sant0sk1
37
+
38
+ == 1.0.3 2008-05-02
39
+
40
+ * Add misc changes from Dustin Sallings and Henrik N
41
+ * Remove trailing whitespace
42
+ * More intuitive info messages
43
+ * Update README file with update-to-date example
44
+
45
+ == 1.0.2 2008-03-22
46
+
47
+ * Add contributions from Michael Bumann (http://github.com/bumi)
48
+ * added an option "position" to choose to put the annotation,
49
+ * spec/fixtures now also get annotated
50
+ * added a task to remove the annotations
51
+ * these options can be specified from command line as -d and -p [before|after]
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Dmitry Lihachev
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,145 @@
1
+ == Annotate (aka AnnotatedModels)
2
+
3
+ Add a comment summarizing the current schema to the top or bottom of each of your...
4
+
5
+ * ActiveRecord models
6
+ * Fixture files
7
+ * Tests and Specs
8
+ * Object Daddy exemplars
9
+ * Machinist blueprints
10
+ * Thoughtbot's factory_girl factories, i.e. the (spec|test)/factories/<model>_factory.rb files
11
+
12
+ The schema comment looks like this:
13
+
14
+ # == Schema Info
15
+ #
16
+ # Table name: line_items
17
+ #
18
+ # id :integer(11) not null, primary key
19
+ # quantity :integer(11) not null
20
+ # product_id :integer(11) not null
21
+ # unit_price :float
22
+ # order_id :integer(11)
23
+ #
24
+
25
+ class LineItem < ActiveRecord::Base
26
+ belongs_to :product
27
+ . . .
28
+
29
+ It also annotates geometrical columns, geom type and srid, when using SpatialAdapter or PostgisAdapter:
30
+
31
+ # == Schema Info
32
+ #
33
+ # Table name: trips
34
+ #
35
+ # local :geometry point, 4326
36
+ # path :geometry line_string, 4326
37
+
38
+ Also, if you pass the -r option, it'll annotate routes.rb with the output of "rake routes".
39
+
40
+ == INSTALL
41
+
42
+ From rubyforge:
43
+
44
+ sudo gem install annotate
45
+
46
+ From github:
47
+
48
+ git clone git://github.com/ctran/annotate_models.git annotate
49
+ cd annotate
50
+ gem build annotate.gemspec
51
+ sudo gem install annotate-<version>.gem
52
+
53
+ == USAGE
54
+
55
+ To annotate all your models, tests, fixtures, etc.:
56
+
57
+ cd /path/to/app
58
+ annotate
59
+
60
+ To annotate your models and tests:
61
+
62
+ annotate --exclude fixtures
63
+
64
+ To annotate just your models:
65
+
66
+ annotate --exclude tests,fixtures
67
+
68
+ To annotate routes.rb:
69
+
70
+ annotate -r
71
+
72
+ To automatically annotate after running 'rake db:migrate':
73
+
74
+ [needs more clarity] unpack the gem into vendor/plugins, or maybe vendor/gems, or maybe just require tasks/migrate.rake.
75
+
76
+ If you install annotate_models as a plugin, it will automatically
77
+ adjust your <tt>rake db:migrate</tt> tasks so that they update the
78
+ annotations in your model files for you once the migration is
79
+ completed.
80
+
81
+ 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.
82
+
83
+
84
+ == OPTIONS
85
+
86
+ Usage: annotate [options] [model_file]*
87
+ -d, --delete Remove annotations from all model files
88
+ -p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
89
+ -r, --routes Annotate routes.rb with the output of 'rake routes'
90
+ -v, --version Show the current version of this gem
91
+ -m, --show-migration Include the migration version number in the annotation
92
+ -i, --show-indexes List the table's database indexes in the annotation
93
+ -s, --simple-indexes Concat the column's related indexes in the annotation
94
+ --model-dir dir Annotate model files stored in dir rather than app/models
95
+ -R, --require path Additional files to require before loading models
96
+ -e [tests,fixtures,factories] Do not annotate fixtures, test files, and/or factories
97
+ --exclude
98
+
99
+
100
+ == WARNING
101
+
102
+ Note that this code will blow away the initial/final comment
103
+ block in your models if it looks like it was previously added
104
+ by annotate models, so you don't want to add additional text
105
+ to an automatically created comment block.
106
+
107
+ * * Back up your model files before using... * *
108
+
109
+ == LINKS
110
+
111
+ * Factory Girl => http://github.com/thoughtbot/factory_girl
112
+ * Object Daddy => http://github.com/flogic/object_daddy
113
+ * SpatialAdapter => http://github.com/pdeffendol/spatial_adapter
114
+ * PostgisAdapter => http://github.com/nofxx/postgis_adapter
115
+
116
+ == LICENSE:
117
+
118
+ Released under the same license as Ruby. No Support. No Warranty.
119
+
120
+ == AUTHOR:
121
+
122
+ Original code by: Dave Thomas -- Pragmatic Programmers, LLC
123
+ Overhauled by: Alex Chaffee
124
+ Gemmed by: Cuong Tran
125
+ Maintained by: Alex Chaffee and Cuong Tran
126
+ Homepage: http://github.com/ctran/annotate_models
127
+
128
+ Modifications by:
129
+
130
+ - Alex Chaffee - http://github.com/alexch - alex@pivotallabs.com
131
+ - Cuong Tran - http://github.com/ctran - ctran@pragmaquest.com
132
+ - Jack Danger - http://github.com/JackDanger
133
+ - Michael Bumann - http://github.com/bumi
134
+ - Henrik Nyh - http://github.com/henrik
135
+ - Marcos Piccinini - http://github.com/nofxx
136
+ - Neal Clark - http://github.com/nclark
137
+ - Jacqui Maher - http://github.com/jacqui
138
+ - Nick Plante - http://github.com/zapnap - http://blog.zerosum.org
139
+ - Pedro Visintin - http://github.com/peterpunk - http://www.pedrovisintin.com
140
+ - Bob Potter - http://github.com/bpot
141
+ - Gavin Montague - http://github.com/govan/
142
+ - Alexander Semyonov - http://github.com/rotuka/
143
+ - Nathan Brazil - http://github.com/bitaxis/
144
+
145
+ and many others that I may have missed to add.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "annotated_models"
16
+ gem.homepage = "http://github.com/lda/annotated_models"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Annotate ActiveRecord models as a gem}
19
+ gem.description = %Q{Add a comment summarizing the current schema to the top or bottom of each of your models}
20
+ gem.email = "lda@openteam.ru"
21
+ gem.authors = ["Dave Thomas", "Alex Chaffee", "Cuong Tran", "Alex Chaffee", "Dmitry Lihachev"]
22
+
23
+ gem.add_development_dependency(%q<bundler>, [">= 0"])
24
+ gem.add_development_dependency(%q<jeweler>, [">= 0"])
25
+ gem.add_development_dependency(%q<rcov>, [">= 0"])
26
+ gem.add_development_dependency(%q<fakefs>, [">= 0"])
27
+ gem.add_development_dependency(%q<rspec>, [">= 0"])
28
+
29
+ gem.add_runtime_dependency(%q<activesupport>, [">= 0"])
30
+ gem.add_runtime_dependency(%q<i18n>, [">= 0"])
31
+ end
32
+ Jeweler::RubygemsDotOrgTasks.new
33
+
34
+ require 'rspec/core'
35
+ require 'rspec/core/rake_task'
36
+ RSpec::Core::RakeTask.new(:spec) do |spec|
37
+ spec.pattern = FileList['spec/**/*_spec.rb']
38
+ end
39
+
40
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
41
+ spec.pattern = 'spec/**/*_spec.rb'
42
+ spec.rcov = true
43
+ end
44
+
45
+ task :default => :spec
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "annotated_models #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 3
3
+ :minor: 0
4
+ :patch: 0
5
+ :build:
@@ -0,0 +1,120 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{annotated_models}
8
+ s.version = "3.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dave Thomas", "Alex Chaffee", "Cuong Tran", "Alex Chaffee", "Dmitry Lihachev"]
12
+ s.date = %q{2011-02-22}
13
+ s.default_executable = %q{annotate}
14
+ s.description = %q{Add a comment summarizing the current schema to the top or bottom of each of your models}
15
+ s.email = %q{lda@openteam.ru}
16
+ s.executables = ["annotate"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "History.txt",
27
+ "LICENSE.txt",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "VERSION.yml",
31
+ "annotated_models.gemspec",
32
+ "bin/annotate",
33
+ "lib/annotated_models.rb",
34
+ "lib/tasks/annotate_models.rake",
35
+ "lib/tasks/migrate.rake",
36
+ "spec/annotate_models_spec.rb",
37
+ "spec/spec_helper.rb",
38
+ "todo.txt"
39
+ ]
40
+ s.homepage = %q{http://github.com/lda/annotated_models}
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.7}
44
+ s.summary = %q{Annotate ActiveRecord models as a gem}
45
+ s.test_files = [
46
+ "spec/annotate_models_spec.rb",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<annotated_models>, [">= 0"])
56
+ s.add_development_dependency(%q<rspec>, [">= 0"])
57
+ s.add_development_dependency(%q<bundler>, [">= 0"])
58
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
59
+ s.add_development_dependency(%q<rcov>, [">= 0"])
60
+ s.add_development_dependency(%q<fakefs>, [">= 0"])
61
+ s.add_development_dependency(%q<activesupport>, [">= 0"])
62
+ s.add_development_dependency(%q<i18n>, [">= 0"])
63
+ s.add_development_dependency(%q<bundler>, [">= 0"])
64
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
65
+ s.add_development_dependency(%q<rcov>, [">= 0"])
66
+ s.add_development_dependency(%q<fakefs>, [">= 0"])
67
+ s.add_development_dependency(%q<rspec>, [">= 0"])
68
+ s.add_development_dependency(%q<bundler>, [">= 0"])
69
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
70
+ s.add_development_dependency(%q<rcov>, [">= 0"])
71
+ s.add_development_dependency(%q<fakefs>, [">= 0"])
72
+ s.add_development_dependency(%q<rspec>, [">= 0"])
73
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
74
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
75
+ else
76
+ s.add_dependency(%q<annotated_models>, [">= 0"])
77
+ s.add_dependency(%q<rspec>, [">= 0"])
78
+ s.add_dependency(%q<bundler>, [">= 0"])
79
+ s.add_dependency(%q<jeweler>, [">= 0"])
80
+ s.add_dependency(%q<rcov>, [">= 0"])
81
+ s.add_dependency(%q<fakefs>, [">= 0"])
82
+ s.add_dependency(%q<activesupport>, [">= 0"])
83
+ s.add_dependency(%q<i18n>, [">= 0"])
84
+ s.add_dependency(%q<bundler>, [">= 0"])
85
+ s.add_dependency(%q<jeweler>, [">= 0"])
86
+ s.add_dependency(%q<rcov>, [">= 0"])
87
+ s.add_dependency(%q<fakefs>, [">= 0"])
88
+ s.add_dependency(%q<rspec>, [">= 0"])
89
+ s.add_dependency(%q<bundler>, [">= 0"])
90
+ s.add_dependency(%q<jeweler>, [">= 0"])
91
+ s.add_dependency(%q<rcov>, [">= 0"])
92
+ s.add_dependency(%q<fakefs>, [">= 0"])
93
+ s.add_dependency(%q<rspec>, [">= 0"])
94
+ s.add_dependency(%q<activesupport>, [">= 0"])
95
+ s.add_dependency(%q<i18n>, [">= 0"])
96
+ end
97
+ else
98
+ s.add_dependency(%q<annotated_models>, [">= 0"])
99
+ s.add_dependency(%q<rspec>, [">= 0"])
100
+ s.add_dependency(%q<bundler>, [">= 0"])
101
+ s.add_dependency(%q<jeweler>, [">= 0"])
102
+ s.add_dependency(%q<rcov>, [">= 0"])
103
+ s.add_dependency(%q<fakefs>, [">= 0"])
104
+ s.add_dependency(%q<activesupport>, [">= 0"])
105
+ s.add_dependency(%q<i18n>, [">= 0"])
106
+ s.add_dependency(%q<bundler>, [">= 0"])
107
+ s.add_dependency(%q<jeweler>, [">= 0"])
108
+ s.add_dependency(%q<rcov>, [">= 0"])
109
+ s.add_dependency(%q<fakefs>, [">= 0"])
110
+ s.add_dependency(%q<rspec>, [">= 0"])
111
+ s.add_dependency(%q<bundler>, [">= 0"])
112
+ s.add_dependency(%q<jeweler>, [">= 0"])
113
+ s.add_dependency(%q<rcov>, [">= 0"])
114
+ s.add_dependency(%q<fakefs>, [">= 0"])
115
+ s.add_dependency(%q<rspec>, [">= 0"])
116
+ s.add_dependency(%q<activesupport>, [">= 0"])
117
+ s.add_dependency(%q<i18n>, [">= 0"])
118
+ end
119
+ end
120
+
data/bin/annotate ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'annotate'
5
+
6
+ task = :annotate_models
7
+
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: annotate [options] [model_file]*"
10
+
11
+ opts.on('-d', '--delete',
12
+ "Remove annotations from all model files") do
13
+ task = :remove_annotation
14
+ end
15
+
16
+ opts.on('-p', '--position [before|after]', ['before', 'after'],
17
+ "Place the annotations at the top (before) or the bottom (after) of the model file") do |p|
18
+ ENV['position'] = p
19
+ end
20
+
21
+ opts.on('-r', '--routes',
22
+ "Annotate routes.rb with the output of 'rake routes'") do
23
+ task = :annotate_routes
24
+ end
25
+
26
+ opts.on('-v', '--version',
27
+ "Show the current version of this gem") do
28
+ puts "annotate v#{Annotate.version}"; exit
29
+ end
30
+
31
+ opts.on('-m', '--show-migration',
32
+ "Include the migration version number in the annotation") do
33
+ ENV['include_version'] = "yes"
34
+ end
35
+
36
+ opts.on('-i', '--show-indexes',
37
+ "List the table's database indexes in the annotation") do
38
+ ENV['show_indexes'] = "yes"
39
+ end
40
+
41
+ opts.on('-s', '--simple-indexes',
42
+ "Concat the column's related indexes in the annotation") do
43
+ ENV['simple_indexes'] = "yes"
44
+ end
45
+
46
+ opts.on('--model-dir dir',
47
+ "Annotate model files stored in dir rather than app/models") do |dir|
48
+ ENV['model_dir'] = dir
49
+ end
50
+
51
+ opts.on('-R', '--require path',
52
+ "Additional files to require before loading models") do |path|
53
+ if ENV['require']
54
+ ENV['require'] = ENV['require'] + ",#{path}"
55
+ else
56
+ ENV['require'] = path
57
+ end
58
+ end
59
+
60
+ opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions|
61
+ exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
62
+ end
63
+
64
+ opts.on('-f', '--format [bare|rdoc]', ['bare', 'rdoc'], 'rdoc: render Schema Infomation as RDoc') do |fmt|
65
+ ENV['format_#{fmt}'] = 'yes'
66
+ end
67
+
68
+ end.parse!
69
+
70
+ if Annotate.load_tasks
71
+ Rake::Task[task].invoke
72
+ else
73
+ STDERR.puts "Can't find Rakefile. Are we in a Rails folder?"
74
+ end