annotate 2.5.0.pre1 → 2.5.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,18 +1,18 @@
1
1
  == 2.5.0
2
2
 
3
- * Fixed that schema kept prepending additional newlines
4
- * Updates to make annotate smarter about when to touch a model
3
+ * Works better with Rails 3
4
+ * Bugfix: schema kept prepending additional newlines
5
+ * Updates to make annotate smarter about when to touch a model
5
6
  * Recognize column+type, and don't change a file unless the column+type combination of the new schema are different than that of the old (i.e., don't regenerate if columns happen to be in a different order. That's just how life is sometimes)
6
7
  * Grab old specification even if it has \r\n as line endings rather than pure \ns
7
8
  * Various warning and specification fixes
8
9
  * Fix "no such file to load -- annotate/annotate_models (MissingSourceFile)" error (require statements in tasks now use full path to lib files)
9
- * warn about macros, to mitigate when we're included during a production run, not just a rakefile run -- possibly at the expense of too much noise
10
+ * warn about macros, to mitigate when we're included during a production run, not just a rakefile run -- possibly at the expense of too much noise
10
11
  * Adding rake as a runtime dependency
11
- * If the schema is already in the model file, it will be replaced into the same location. If it didn't previously exist, it'll be placed according to the "position", as before.
12
+ * If the schema is already in the model file, it will be replaced into the same location. If it didn't previously exist, it'll be placed according to the "position", as before.
12
13
  * Allow task loading from Rakefile for gems (plugin installation already auto-detects).
13
- * Add skip_on_db_migrate option as well for people that don't want it
14
- * Fix options parsing to convert strings to proper booleans. Change annotate to use opt
15
- ions hash instead of ENV.
14
+ * Add skip_on_db_migrate option as well for people that don't want it
15
+ * Fix options parsing to convert strings to proper booleans
16
16
  * Add support for Fabrication fabricators
17
17
  * Leave magic encoding comment intact
18
18
  * Fix issue #14 - RuntimeError: Already memoized
@@ -57,6 +57,10 @@
57
57
  no replacement. It will be removed on or after 2011-10-01.`
58
58
  * Fix handling of files with no trailing newline when putting annotations at
59
59
  the end of the file.
60
+ * Now works on tables with no primary key.
61
+ * Add --format=markdown option
62
+ * "Table name" annotation (if table name is different from model name)
63
+ * "Human name" annotation (enabling translation to non-English locales)
60
64
 
61
65
  == 2.4.2 2009-11-21
62
66
 
data/README.rdoc CHANGED
@@ -41,9 +41,13 @@ Also, if you pass the -r option, it'll annotate routes.rb with the output of "ra
41
41
 
42
42
  == INSTALL
43
43
 
44
+ Into Gemfile from rubygems.org:
45
+
46
+ gem 'annotate', ">=2.5.0.pre1"
47
+
44
48
  Into Gemfile from Github:
45
49
 
46
- gem 'annotate', :git => 'git://github.com/MrJoy/annotate_models.git'
50
+ gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
47
51
 
48
52
  Into environment gems From rubygems.org:
49
53
 
@@ -51,10 +55,10 @@ Into environment gems From rubygems.org:
51
55
 
52
56
  Into environment gems from Github checkout:
53
57
 
54
- git clone git://github.com/MrJoy/annotate_models.git annotate_models
55
- cd annotate_models
56
- rake build
57
- gem install pkg/annotate-*.gem
58
+ git clone git://github.com/ctran/annotate_models.git annotate_models
59
+ cd annotate_models
60
+ rake build
61
+ gem install pkg/annotate-*.gem
58
62
 
59
63
  == USAGE
60
64
 
@@ -63,23 +67,23 @@ Into environment gems from Github checkout:
63
67
  To annotate all your models, tests, fixtures, etc.:
64
68
 
65
69
  cd /path/to/app
66
- annotate_models
70
+ annotate
67
71
 
68
72
  To annotate your models and tests:
69
73
 
70
- annotate_models --exclude fixtures
74
+ annotate --exclude fixtures
71
75
 
72
76
  To annotate just your models:
73
77
 
74
- annotate_models --exclude tests,fixtures
78
+ annotate --exclude tests,fixtures
75
79
 
76
80
  To annotate routes.rb:
77
81
 
78
- annotate_models -r
82
+ annotate -r
79
83
 
80
84
  To remove annotations:
81
85
 
82
- annotate_models -d
86
+ annotate -d
83
87
 
84
88
  To automatically annotate after running 'rake db:migrate', ensure you've added
85
89
  annotate_models to your Rails project's Gemfile, and run this:
@@ -103,21 +107,24 @@ anywhere in the file:
103
107
  -r, --routes Annotate routes.rb with the output of 'rake routes'
104
108
  -v, --version Show the current version of this gem
105
109
  -m, --show-migration Include the migration version number in the annotation
106
- -i, --show-indexes List the indexes for the table in the annotation
107
- -s, --simple-indexes Include information about indexes inline with the relevant column
110
+ -i, --show-indexes List the table's database indexes in the annotation
111
+ -s, --simple-indexes Concat the column's related indexes in the annotation
108
112
  --model-dir dir Annotate model files stored in dir rather than app/models
109
- --ignore-model-subdirs Ignore sub-directories of the models directory.
113
+ --ignore-model-subdirects Ignore subdirectories of the models directory
114
+ --sort Sort columns alphabetically, rather than in creation order
110
115
  -R, --require path Additional files to require before loading models
111
- -e [tests,fixtures] Skip annotation of fixtures/factories/test files
112
- --exclude
113
- -n --no-sort Sort by column creation order rather than alphabetical order
116
+ -e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both
117
+ -f [bare|rdoc|markdown], Render Schema Infomation as plain/RDoc/Markdown
118
+ --format
119
+ --force Force new annotations even if there are no changes.
120
+
114
121
 
115
122
  == SORTING
116
123
 
117
- By default, columns will be sorted alphabetically so that the results of
118
- annotation are consistent regardless of what order migrations are executed in.
124
+ By default, columns will be sorted in database order (i.e. the order in which migrations were run).
119
125
 
120
- If you prefer the old behavior, use --no-sort.
126
+ If you prefer to sort alphabetically so that the results of
127
+ annotation are consistent regardless of what order migrations are executed in, use --sort.
121
128
 
122
129
  == WARNING
123
130
 
@@ -165,5 +172,12 @@ With help from:
165
172
  - Nathan Brazil - http://github.com/bitaxis
166
173
  - Ian Duggan http://github.com/ijcd
167
174
  - Jon Frisby http://github.com/mrjoy
175
+ - Tsutomu Kuroda
176
+ - Kevin Moore
177
+ - Philip Hallstrom
178
+ - Brent Greeff
179
+ - Paul Alexander
180
+ - Dmitry Lihachev
181
+ - qichunren
168
182
 
169
183
  and many others that I may have missed to add.
data/bin/annotate CHANGED
@@ -61,9 +61,9 @@ OptionParser.new do |opts|
61
61
  ENV['ignore_model_sub_dir'] = "yes"
62
62
  end
63
63
 
64
- opts.on('-n', '--no-sort',
65
- "Sort columns in creation order rather than alphabetically") do |dir|
66
- ENV['no_sort'] = "yes"
64
+ opts.on('--sort',
65
+ "Sort columns alphabetically, rather than in creation order") do |dir|
66
+ ENV['sort'] = "yes"
67
67
  end
68
68
 
69
69
  opts.on('-R', '--require path',
@@ -73,7 +73,7 @@ OptionParser.new do |opts|
73
73
  else
74
74
  ENV['require'] = path
75
75
  end
76
- end
76
+ end\
77
77
 
78
78
  opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions|
79
79
  exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
@@ -39,7 +39,7 @@ module AnnotateModels
39
39
  def model_dir
40
40
  @model_dir || "app/models"
41
41
  end
42
-
42
+
43
43
  def model_dir=(dir)
44
44
  @model_dir = dir
45
45
  end
@@ -77,12 +77,12 @@ module AnnotateModels
77
77
  end
78
78
 
79
79
  cols = klass.columns
80
- cols = cols.sort_by(&:name) unless(options[:no_sort])
80
+ cols = cols.sort_by(&:name) if(options[:sort])
81
81
  cols.each do |col|
82
82
  attrs = []
83
83
  attrs << "default(#{quote(col.default)})" unless col.default.nil?
84
84
  attrs << "not null" unless col.null
85
- attrs << "primary key" if col.name.to_sym == klass.primary_key.to_sym
85
+ attrs << "primary key" if klass.primary_key && col.name.to_sym == klass.primary_key.to_sym
86
86
 
87
87
  col_type = (col.type || col.sql_type).to_s
88
88
  if col_type == "decimal"
@@ -92,7 +92,7 @@ module AnnotateModels
92
92
  col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
93
93
  end
94
94
  end
95
-
95
+
96
96
  # Check out if we got a geometric column
97
97
  # and print the type and SRID
98
98
  if col.respond_to?(:geometry_type)
@@ -207,13 +207,11 @@ module AnnotateModels
207
207
  end
208
208
  end
209
209
  end
210
-
210
+
211
211
  def remove_annotation_of_file(file_name)
212
212
  if File.exist?(file_name)
213
213
  content = File.read(file_name)
214
-
215
214
  content.sub!(PATTERN, '')
216
-
217
215
  File.open(file_name, "wb") { |f| f.puts content }
218
216
  end
219
217
  end
@@ -304,7 +302,7 @@ module AnnotateModels
304
302
  end
305
303
  models
306
304
  end
307
-
305
+
308
306
  # Retrieve the classes belonging to the model names we're asked to process
309
307
  # Check for namespaced models in subdirectories as well as models
310
308
  # in subdirectories without namespacing.
@@ -319,7 +317,10 @@ module AnnotateModels
319
317
  # Retrieve loaded model class by path to the file where it's supposed to be defined.
320
318
  def get_loaded_model(model_path)
321
319
  ObjectSpace.each_object.
322
- select { |c| c.is_a?(Class) && c.ancestors.include?(ActiveRecord::Base) }.
320
+ select { |c|
321
+ Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
322
+ c.ancestors.include?(ActiveRecord::Base)
323
+ }.
323
324
  detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
324
325
  end
325
326
 
@@ -340,9 +341,9 @@ module AnnotateModels
340
341
  version = ActiveRecord::Migrator.current_version rescue 0
341
342
  if version > 0
342
343
  header << "\n# Schema version: #{version}"
343
- end
344
+ end
344
345
  end
345
-
346
+
346
347
  if options[:model_dir]
347
348
  self.model_dir = options[:model_dir]
348
349
  end
@@ -359,6 +360,8 @@ module AnnotateModels
359
360
  rescue Exception => e
360
361
  # todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
361
362
  puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
363
+ # todo: save this backtrace somewhere nice
364
+ # puts "\t" + e.backtrace.join("\n\t")
362
365
  end
363
366
  end
364
367
  if annotated.empty?
@@ -367,7 +370,7 @@ module AnnotateModels
367
370
  puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
368
371
  end
369
372
  end
370
-
373
+
371
374
  def remove_annotations(options={})
372
375
  if options[:model_dir]
373
376
  puts "removing"
@@ -1,5 +1,5 @@
1
1
  module Annotate
2
2
  def self.version
3
- "2.5.0.pre1"
3
+ "2.5.0.pre2"
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@ task :annotate_models => :environment do
26
26
  options[:ignore_model_sub_dir] = ENV['ignore_model_sub_dir'] =~ true_re
27
27
  options[:format_rdoc] = ENV['format_rdoc'] =~ true_re
28
28
  options[:format_markdown] = ENV['format_markdown'] =~ true_re
29
- options[:no_sort] = ENV['no_sort'] =~ true_re
29
+ options[:sort] = ENV['sort'] =~ true_re
30
30
  options[:force] = ENV['force'] =~ true_re
31
31
  AnnotateModels.do_annotations(options)
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0.pre1
4
+ version: 2.5.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-06-08 00:00:00.000000000 Z
15
+ date: 2012-07-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  segments:
76
76
  - 0
77
- hash: -2416321078825126796
77
+ hash: 3749853893858180843
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  none: false
80
80
  requirements:
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: 1.3.1
84
84
  requirements: []
85
85
  rubyforge_project: annotate
86
- rubygems_version: 1.8.21
86
+ rubygems_version: 1.8.24
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: Annotates Rails Models, routes, fixtures, and others based on the database