IPGlider-annotate 2.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,27 @@
1
+ == 1.0.2 2008-03-22
2
+
3
+ * Add contributions from Michael Bumann (http://github.com/bumi)
4
+ * added an option "position" to choose to put the annotation,
5
+ * spec/fixtures now also get annotated
6
+ * added a task to remove the annotations
7
+ * these options can be specified from command line as -d and -p [before|after]
8
+
9
+ == 1.0.3 2008-05-02
10
+
11
+ * Add misc changes from Dustin Sallings and Henrik N
12
+ * Remove trailing whitespace
13
+ * More intuitive info messages
14
+ * Update README file with update-to-date example
15
+
16
+ == 2.0.0 2008-12-25
17
+
18
+ * Add annotate_models plugin fork additions
19
+ * Annotates Rspec and Test Unit models
20
+ * Annotates Object Daddy exemplars
21
+ * Annotates geometrical columns
22
+ * Add AnnotateRoutes rake task
23
+ * Up gem structure to newgem defaults
24
+
25
+
26
+
27
+
data/License.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2008 Dave Thomas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,66 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ annotate.gemspec
7
+ bin/annotate
8
+ lib/annotate.rb
9
+ lib/annotate/annotate_models.rb
10
+ lib/annotate/annotate_routes.rb
11
+ lib/tasks/annotate_models.rake
12
+ lib/tasks/annotate_routes.rake
13
+ script/console
14
+ script/destroy
15
+ script/generate
16
+ setup.rb
17
+ spec/annotate/annotate_models_spec.rb
18
+ spec/annotate/annotate_routes_spec.rb
19
+ spec/annotate_spec.rb
20
+ spec/spec.opts
21
+ spec/spec_helper.rb
22
+ tasks/rspec.rake
23
+ History.txt
24
+ License.txt
25
+ Manifest.txt
26
+ README.rdoc
27
+ Rakefile
28
+ annotate.gemspec
29
+ bin/annotate
30
+ lib/annotate.rb
31
+ lib/annotate/annotate_models.rb
32
+ lib/annotate/annotate_routes.rb
33
+ lib/tasks/annotate_models.rake
34
+ lib/tasks/annotate_routes.rake
35
+ script/console
36
+ script/destroy
37
+ script/generate
38
+ setup.rb
39
+ spec/annotate/annotate_models_spec.rb
40
+ spec/annotate/annotate_routes_spec.rb
41
+ spec/annotate_spec.rb
42
+ spec/spec.opts
43
+ spec/spec_helper.rb
44
+ tasks/rspec.rake
45
+ History.txt
46
+ License.txt
47
+ Manifest.txt
48
+ README.rdoc
49
+ Rakefile
50
+ annotate.gemspec
51
+ bin/annotate
52
+ lib/annotate.rb
53
+ lib/annotate/annotate_models.rb
54
+ lib/annotate/annotate_routes.rb
55
+ lib/tasks/annotate_models.rake
56
+ lib/tasks/annotate_routes.rake
57
+ script/console
58
+ script/destroy
59
+ script/generate
60
+ setup.rb
61
+ spec/annotate/annotate_models_spec.rb
62
+ spec/annotate/annotate_routes_spec.rb
63
+ spec/annotate_spec.rb
64
+ spec/spec.opts
65
+ spec/spec_helper.rb
66
+ tasks/rspec.rake
data/README.rdoc ADDED
@@ -0,0 +1,125 @@
1
+ _
2
+ /_| _/__/_
3
+ ( |/)/)()/(//(-
4
+ ________________
5
+
6
+
7
+ Add a comment summarizing the current schema to the bottom of each
8
+ ActiveRecord model, test file and fixture.
9
+ If you are using Object Daddy, it`ll annotate your example files too.
10
+
11
+ # == Schema Info
12
+ # Schema version: 20081001061831
13
+ #
14
+ # Table name: line_item
15
+ #
16
+ # id :integer(11) not null, primary key
17
+ # quantity :integer(11) not null
18
+ # product_id :integer(11) not null
19
+ # unit_price :float
20
+ # order_id :integer(11)
21
+ #
22
+
23
+ class LineItem < ActiveRecord::Base
24
+ belongs_to :product
25
+ . . .
26
+
27
+ Annotates geometrical columns, geom type and srid, when using SpatialAdapter or PostgisAdapter:
28
+
29
+ # == Schema Info
30
+ # Schema version: 20081213204851
31
+ #
32
+ # Table name: trips
33
+ #
34
+ # local :geometry point, 4326
35
+ # path :geometry line_string, 4326
36
+
37
+
38
+ == INSTALL
39
+
40
+ sudo gem install nofxx-annotate
41
+
42
+
43
+ == HOW TO USE:
44
+
45
+ To annotate all your models:
46
+
47
+ cd /path/to/app
48
+ annotate
49
+
50
+ To annotate routes.rb:
51
+
52
+ annotate -r
53
+
54
+
55
+ More:
56
+
57
+ annotate -h
58
+
59
+
60
+ To migrate & annotate (TODO):
61
+
62
+
63
+ Options:
64
+
65
+ Annotate on the head of the file:
66
+
67
+ annotate -p [before|after]
68
+
69
+
70
+ == WARNING
71
+
72
+ Note that this code will blow away the initial/final comment
73
+ block in your models if it looks like it was previously added
74
+ by annotate models, so you don't want to add additional text
75
+ to an automatically created comment block.
76
+
77
+ * * Back up your model files before using... * *
78
+
79
+ == LINKS
80
+
81
+ * Factory Girl => http://github.com/thoughtbot/factory_girl (NOT IMPLEMENTED)
82
+ * Object Daddy => http://github.com/flogic/object_daddy
83
+
84
+ * SpatialAdapter => http://github.com/pdeffendol/spatial_adapter
85
+ * PostgisAdapter => http://github.com/nofxx/postgis_adapter
86
+
87
+
88
+ == TODO
89
+
90
+ * Spec
91
+
92
+
93
+ == LICENSE:
94
+
95
+ Original code by:
96
+
97
+ Dave Thomas -- Pragmatic Programmers, LLC
98
+
99
+ Refactored, improved and maintained by:
100
+
101
+ Marcos Piccinini ( http://github.com/nofxx/annotate )
102
+
103
+ AnnotateModels mods by:
104
+
105
+ Alexander Semyonov ( http://github.com/rotuka/annotate_models )
106
+
107
+ AnnotateRoutes originally by:
108
+
109
+ Gavin Montague ( http://github.com/govan/annotate-routes )
110
+
111
+
112
+ == Forked from:
113
+
114
+ http://github.com/ctran/annotate_models
115
+
116
+
117
+ == Modifications
118
+ - alex@pivotallabs.com
119
+ - Cuong Tran - http://github.com/ctran
120
+ - Jack Danger - http://github.com/JackDanger
121
+ - Michael Bumann - http://github.com/bumi
122
+ - Henrik Nyh - http://github.com/henrik
123
+
124
+
125
+ Released under the same license as Ruby. No Support. No Warranty.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/annotate'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('annotate', Annotate::VERSION) do |p|
7
+ p.developer('Marcos Piccinini', 'x@nofxx.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.rubyforge_name = p.name
10
+ p.url = "http://github.com/nofxx/annotate"
11
+ p.summary = "Annotates Rails Models and Routes"
12
+ p.description = "Annotates Rails Models and Routes"
13
+
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+ Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ # TODO - want other tests/tasks run by default? Add them to the list
28
+ # task :default => [:spec, :features]
data/annotate.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{annotate}
5
+ s.version = "2.2.6"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Marcos Piccinini"]
9
+ s.date = %q{2009-02-14}
10
+ s.default_executable = %q{annotate}
11
+ s.description = %q{Annotates Rails Models and Routes}
12
+ s.email = ["x@nofxx.com"]
13
+ s.executables = ["annotate"]
14
+ s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc"]
15
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "annotate.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake", "script/console", "script/destroy", "script/generate", "setup.rb", "spec/annotate/annotate_models_spec.rb", "spec/annotate/annotate_routes_spec.rb", "spec/annotate_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://github.com/nofxx/annotate}
18
+ s.rdoc_options = ["--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{annotate}
21
+ s.rubygems_version = %q{1.3.1}
22
+ s.summary = %q{Annotates Rails Models and Routes}
23
+
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 2
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ s.add_development_dependency(%q<newgem>, [">= 1.2.2"])
30
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
31
+ else
32
+ s.add_dependency(%q<newgem>, [">= 1.2.2"])
33
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
34
+ end
35
+ else
36
+ s.add_dependency(%q<newgem>, [">= 1.2.2"])
37
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
38
+ end
39
+ end
data/bin/annotate ADDED
@@ -0,0 +1,21 @@
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]"
10
+ opts.on('-d', '--delete') { task = :remove_annotation }
11
+ opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p }
12
+ opts.on('-r', '--routes') { task = :annotate_routes }
13
+ opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit }
14
+ end.parse!
15
+
16
+ begin
17
+ Rake::Task[task].invoke
18
+ #TODO: rescue only rake error
19
+ rescue NameError => e
20
+ puts "Can`t find Rake. Are we in a Rails folder?"
21
+ end
@@ -0,0 +1,225 @@
1
+ module AnnotateModels
2
+ class << self
3
+ # Annotate Models plugin use this header
4
+ COMPAT_PREFIX = "== Schema Info"
5
+ PREFIX = "== Schema Information"
6
+
7
+ MODEL_DIR = "app/models"
8
+ FIXTURE_DIRS = ["test/fixtures","spec/fixtures"]
9
+ # File.join for windows reverse bar compat?
10
+ # I dont use windows, can`t test
11
+ UNIT_TEST_DIR = File.join("test", "unit" )
12
+ SPEC_MODEL_DIR = File.join("spec", "models")
13
+ # Object Daddy http://github.com/flogic/object_daddy/tree/master
14
+ EXEMPLARS_DIR = File.join("spec", "exemplars")
15
+
16
+
17
+ # Simple quoting for the default column value
18
+ def quote(value)
19
+ case value
20
+ when NilClass then "NULL"
21
+ when TrueClass then "TRUE"
22
+ when FalseClass then "FALSE"
23
+ when Float, Fixnum, Bignum then value.to_s
24
+ # BigDecimals need to be output in a non-normalized form and quoted.
25
+ when BigDecimal then value.to_s('F')
26
+ else
27
+ value.inspect
28
+ end
29
+ end
30
+
31
+ # Use the column information in an ActiveRecord class
32
+ # to create a comment block containing a line for
33
+ # each column. The line contains the column name,
34
+ # the type (and length), and any optional attributes
35
+ def get_schema_info(klass, header)
36
+ info = "# #{header}\n#\n"
37
+ info << "# Table name: #{klass.table_name}\n#\n"
38
+
39
+ max_size = klass.column_names.collect{|name| name.size}.max + 1
40
+ klass.columns.each do |col|
41
+ attrs = []
42
+ attrs << "default(#{quote(col.default)})" unless col.default.nil?
43
+ attrs << "not null" unless col.null
44
+ attrs << "primary key" if col.name == klass.primary_key
45
+
46
+ col_type = col.type.to_s
47
+ if col_type == "decimal"
48
+ col_type << "(#{col.precision}, #{col.scale})"
49
+ else
50
+ col_type << "(#{col.limit})" if col.limit
51
+ end
52
+
53
+ # Check out if we got a geometric column
54
+ # and print the type and SRID
55
+ if col.respond_to?(:geometry_type)
56
+ attrs << "#{col.geometry_type}, #{col.srid}"
57
+ end
58
+
59
+ info << sprintf("# %-#{max_size}.#{max_size}s:%-15.15s %s", col.name, col_type, attrs.join(", ")).rstrip + "\n"
60
+ end
61
+
62
+ info << "#\n\n"
63
+ end
64
+
65
+ # Add a schema block to a file. If the file already contains
66
+ # a schema info block (a comment starting with "== Schema Information"), check if it
67
+ # matches the block that is already there. If so, leave it be. If not, remove the old
68
+ # info block and write a new one.
69
+ # Returns true or false depending on whether the file was modified.
70
+ #
71
+ # === Options (opts)
72
+ # :position<Symbol>:: where to place the annotated section in fixture or model file,
73
+ # "before" or "after". Default is "before".
74
+ # :position_in_class<Symbol>:: where to place the annotated section in model file
75
+ # :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
76
+ #
77
+ def annotate_one_file(file_name, info_block, options={})
78
+ if File.exist?(file_name)
79
+ old_content = File.read(file_name)
80
+
81
+ # Ignore the Schema version line because it changes with each migration
82
+ header = Regexp.new(/(^# Table name:.*?\n(#.*\n)*\n)/)
83
+ old_header = old_content.match(header).to_s
84
+ new_header = info_block.match(header).to_s
85
+
86
+ if old_header == new_header
87
+ false
88
+ else
89
+ # Remove old schema info
90
+ old_content.sub!(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, '')
91
+
92
+ # Write it back
93
+ new_content = options[:position] == "before" ? (info_block + old_content) : (old_content + "\n" + info_block)
94
+
95
+ File.open(file_name, "wb") { |f| f.puts new_content }
96
+ true
97
+ end
98
+ end
99
+ end
100
+
101
+ def remove_annotation_of_file(file_name)
102
+ if File.exist?(file_name)
103
+ content = File.read(file_name)
104
+
105
+ content.sub!(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, '')
106
+
107
+ File.open(file_name, "wb") { |f| f.puts content }
108
+ end
109
+ end
110
+
111
+ # Given the name of an ActiveRecord class, create a schema
112
+ # info block (basically a comment containing information
113
+ # on the columns and their types) and put it at the front
114
+ # of the model and fixture source files.
115
+ # Returns true or false depending on whether the source
116
+ # files were modified.
117
+
118
+ def annotate(klass, file, header,options={})
119
+ info = get_schema_info(klass, header)
120
+ annotated = false
121
+ model_name = klass.name.underscore
122
+ model_file_name = File.join(MODEL_DIR, file)
123
+ if annotate_one_file(model_file_name, info, options.merge(
124
+ :position=>(options[:position_in_class] || options[:position])))
125
+ annotated = true
126
+ end
127
+
128
+ [
129
+ File.join(UNIT_TEST_DIR, "#{model_name}_test.rb"), # test
130
+ File.join(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec
131
+ File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
132
+ ].each { |file| annotate_one_file(file, info) }
133
+
134
+ FIXTURE_DIRS.each do |dir|
135
+ fixture_file_name = File.join(dir,klass.table_name + ".yml")
136
+ annotate_one_file(fixture_file_name, info, options.merge(:position=>(options[:position_in_fixture] || options[:position]))) if File.exist?(fixture_file_name)
137
+ end
138
+ annotated
139
+ end
140
+
141
+ # Return a list of the model files to annotate. If we have
142
+ # command line arguments, they're assumed to be either
143
+ # the underscore or CamelCase versions of model names.
144
+ # Otherwise we take all the model files in the
145
+ # app/models directory.
146
+ def get_model_files
147
+ models = ARGV.dup
148
+ models.shift
149
+ models.reject!{|m| m.starts_with?("position=")}
150
+ if models.empty?
151
+ Dir.chdir(MODEL_DIR) do
152
+ models = Dir["**/*.rb"]
153
+ end
154
+ end
155
+ models
156
+ end
157
+
158
+ # Retrieve the classes belonging to the model names we're asked to process
159
+ # Check for namespaced models in subdirectories as well as models
160
+ # in subdirectories without namespacing.
161
+ def get_model_class(file)
162
+ model = file.gsub(/\.rb$/, '').camelize
163
+ parts = model.split('::')
164
+ begin
165
+ parts.inject(Object) {|klass, part| klass.const_get(part) }
166
+ rescue LoadError
167
+ Object.const_get(parts.last)
168
+ end
169
+ end
170
+
171
+ # We're passed a name of things that might be
172
+ # ActiveRecord models. If we can find the class, and
173
+ # if its a subclass of ActiveRecord::Base,
174
+ # then pas it to the associated block
175
+ def do_annotations(options={})
176
+ header = PREFIX.dup
177
+ version = ActiveRecord::Migrator.current_version rescue 0
178
+ if version > 0
179
+ header << "\n# Schema version: #{version}"
180
+ end
181
+
182
+ annotated = []
183
+ get_model_files.each do |file|
184
+ begin
185
+ klass = get_model_class(file)
186
+ if klass < ActiveRecord::Base && !klass.abstract_class?
187
+ if annotate(klass, file, header,options)
188
+ annotated << klass
189
+ end
190
+ end
191
+ rescue Exception => e
192
+ puts "Unable to annotate #{file}: #{e.message}"
193
+ end
194
+ end
195
+ if annotated.empty?
196
+ puts "Nothing annotated!"
197
+ else
198
+ puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
199
+ end
200
+ end
201
+
202
+ def remove_annotations
203
+ deannotated = []
204
+ get_model_files.each do |file|
205
+ begin
206
+ klass = get_model_class(file)
207
+ if klass < ActiveRecord::Base && !klass.abstract_class?
208
+ deannotated << klass
209
+
210
+ model_file_name = File.join(MODEL_DIR, file)
211
+ remove_annotation_of_file(model_file_name)
212
+
213
+ FIXTURE_DIRS.each do |dir|
214
+ fixture_file_name = File.join(dir,klass.table_name + ".yml")
215
+ remove_annotation_of_file(fixture_file_name) if File.exist?(fixture_file_name)
216
+ end
217
+ end
218
+ rescue Exception => e
219
+ puts "Unable to annotate #{file}: #{e.message}"
220
+ end
221
+ end
222
+ puts "Removed annotation from: #{deannotated.join(', ')}"
223
+ end
224
+ end
225
+ end
@@ -0,0 +1,41 @@
1
+ # == Annotate Routes
2
+ #
3
+ # Based on:
4
+ #
5
+ #
6
+ #
7
+ # Prepends the output of "rake routes" to the top of your routes.rb file.
8
+ # Yes, it's simple but I'm thick and often need a reminder of what my routes mean.
9
+ #
10
+ # Running this task will replace any exising route comment generated by the task.
11
+ # Best to back up your routes file before running:
12
+ #
13
+ # Author:
14
+ # Gavin Montague
15
+ # gavin@leftbrained.co.uk
16
+ #
17
+ # Released under the same license as Ruby. No Support. No Warranty.module AnnotateRoutes
18
+ #
19
+ module AnnotateRoutes
20
+ PREFIX = "#== Route Map"
21
+
22
+ def self.do_annotate
23
+ routes_rb = File.join("config", "routes.rb")
24
+ header = PREFIX + "\n# Generated on #{Time.now.strftime("%d %b %Y %H:%M")}\n#"
25
+ if File.exists? routes_rb
26
+ routes_map = `rake routes`
27
+ routes_map = routes_map.split("\n")
28
+ routes_map.shift # remove the first line of rake routes which is just a file path
29
+ routes_map = routes_map.inject(header){|sum, line| sum<<"\n# "<<line}
30
+ content = File.read(routes_rb)
31
+ content, old = content.split(/^#== Route .*?\n/)
32
+ File.open(routes_rb, "wb") do |f|
33
+ f.puts content.sub!(/\n?\z/, "\n") + routes_map
34
+ end
35
+ puts "Route file annotated."
36
+ else
37
+ puts "Can`t find routes.rb"
38
+ end
39
+ end
40
+
41
+ end
data/lib/annotate.rb ADDED
@@ -0,0 +1,14 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Annotate
5
+ VERSION = '2.2.6'
6
+ end
7
+
8
+ begin
9
+ load 'Rakefile'
10
+ Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
11
+ rescue LoadError => e
12
+ nil
13
+ end
14
+
@@ -0,0 +1,14 @@
1
+ desc "Add schema information (as comments) to model and fixture files"
2
+ task :annotate_models => :environment do
3
+ require 'annotate/annotate_models'
4
+ options={}
5
+ options[:position_in_class] = ENV['position_in_class'] || ENV['position']
6
+ options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
7
+ AnnotateModels.do_annotations(options)
8
+ end
9
+
10
+ desc "Remove schema information from model and fixture files"
11
+ task :remove_annotation => :environment do
12
+ require 'annotate_models'
13
+ AnnotateModels.remove_annotations
14
+ end
@@ -0,0 +1,5 @@
1
+ desc "Prepends the route map to the top of routes.rb"
2
+ task :annotate_routes do
3
+ require 'annotate/annotate_routes'
4
+ AnnotateRoutes.do_annotate
5
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/annotate.rb'}"
9
+ puts "Loading annotate gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)