annotate 2.6.0.beta2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9cf1dc6bc654533120158f1a4e03caffd4dcb429
4
- data.tar.gz: 12c3f503657c5d96ae02675a47ea5420956918ca
5
- SHA512:
6
- metadata.gz: 69f28f89810d03767192f46583b550a34dac95332fd7d5fe545e57d5405fa5e97664966d2b0700a67eb6a56096a4085db1d1d557773d7947789c017ed7ac3de1
7
- data.tar.gz: d613cad136a5a6941bb33563c777d835a9dfa8b9db7f1c0d9851afbe4976b9763ad279e30515d48fe3304e4241fa9af3c463a94244da13fad6117abf406c20a3
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTZlODkwZTcyMTAzZWQzNmZlNTI2NmVjY2Q5MWE4MmI4YWVhYTJiZQ==
5
+ data.tar.gz: !binary |-
6
+ MjQzMDdhYzNiODVmNzA1ZTY4MzA3YzAzZjBlNjgxNzFjZmM3ZGJhYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NGE3NjhhMGY4Y2RjMGQ5NzUwZDhhZjhiZjYxYTNjMzE4ZTU5NGJhYzBkMWNm
10
+ Njk3ZTBkOTViYzNmYzgwMzBjMzZiZDRhNWY4Njc4NjYyNGRmYmM3MWY4ZDk2
11
+ M2QyZjk5MzMyZTViNzJmZTMwOTE1ZDQzZmFiNmFiNjVkOTQ1ZmI=
12
+ data.tar.gz: !binary |-
13
+ MWQzN2NkYjBkNjkxMWVjNTFkZWY2MWI4NGJlMzVmMTA2NmMyZjdkN2M5NzAw
14
+ ZmRjNGIyNjM3MGM0NGRmZTQ3NjcyYTg2OTcwYjY4YjE4MWZkM2FhM2EzNDFi
15
+ ZWZhNGNjOTJjMTQxMGFkNzlhMjRlMzk0OTBlYzQ3YzUxZmVkOTQ=
@@ -0,0 +1,33 @@
1
+ == Authors
2
+
3
+ - Original code by: Dave Thomas -- Pragmatic Programmers, LLC <http://agilewebdevelopment.com/plugins/annotate_models>
4
+ - Overhauled by: Alex Chaffee <http://alexch.github.com> alex@stinky.com
5
+ - Gemmed by: Cuong Tran <http://github.com/ctran> ctran@pragmaquest.com
6
+ - Maintained by: Alex Chaffee and Cuong Tran
7
+ - Homepage: http://github.com/ctran/annotate_models
8
+
9
+ With help from:
10
+
11
+ - Jack Danger - http://github.com/JackDanger
12
+ - Michael Bumann - http://github.com/bumi
13
+ - Henrik Nyh - http://github.com/henrik
14
+ - Marcos Piccinini - http://github.com/nofxx
15
+ - Neal Clark - http://github.com/nclark
16
+ - Jacqui Maher - http://github.com/jacqui
17
+ - Nick Plante - http://github.com/zapnap - http://blog.zerosum.org
18
+ - Pedro Visintin - http://github.com/peterpunk - http://www.pedrovisintin.com
19
+ - Bob Potter - http://github.com/bpot
20
+ - Gavin Montague - http://github.com/govan
21
+ - Alexander Semyonov - http://github.com/rotuka
22
+ - Nathan Brazil - http://github.com/bitaxis
23
+ - Ian Duggan http://github.com/ijcd
24
+ - Jon Frisby http://github.com/mrjoy
25
+ - Tsutomu Kuroda
26
+ - Kevin Moore
27
+ - Philip Hallstrom
28
+ - Brent Greeff
29
+ - Paul Alexander
30
+ - Dmitry Lihachev
31
+ - qichunren
32
+
33
+ and many others that I may have forgotten to add.
@@ -33,7 +33,7 @@ The schema comment looks like this:
33
33
  . . .
34
34
 
35
35
  It also annotates geometrical columns, geom type and srid, when using
36
- `SpatialAdapter` or `PostgisAdapter`:
36
+ `SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
37
37
 
38
38
  # == Schema Info
39
39
  #
@@ -119,15 +119,6 @@ anywhere in the file:
119
119
 
120
120
  # -*- SkipSchemaAnnotations
121
121
 
122
- To generate a configuration file (in the form of a `.rake` file), to set
123
- default options:
124
-
125
- rails g annotate:install
126
-
127
- Edit this file to control things like output format, where annotations are
128
- added (top or bottom of file), and in which artifacts.
129
-
130
-
131
122
  === Configuration in Rails
132
123
 
133
124
  To generate a configuration file (in the form of a `.rake` file), to set
@@ -137,6 +128,7 @@ default options:
137
128
 
138
129
  Edit this file to control things like output format, where annotations are
139
130
  added (top or bottom of file), and in which artifacts.
131
+
140
132
  == Rails Integration
141
133
 
142
134
  By default, once you've generated a configuration file, annotate will be
@@ -148,7 +140,7 @@ change:
148
140
 
149
141
  To:
150
142
 
151
- 'skip_on_db_migrate' => "try",
143
+ 'skip_on_db_migrate' => "true",
152
144
 
153
145
  If you want to run `rake db:migrate` as a one-off without running annotate,
154
146
  you can do so with a simple environment variable, instead of editing the
@@ -217,12 +209,17 @@ Be sure to add this to your `Gemfile` as well:
217
209
 
218
210
  == WARNING
219
211
 
220
- Note that this code will blow away the initial/final comment block in your
221
- models if it looks like it was previously added by this gem, so you don't want
222
- to add additional text to an automatically created comment block.
212
+ <b>Don't add text after an automatically-created comment block.</b> This tool
213
+ will blow away the initial/final comment block in your models if it looks like
214
+ it was previously added by this gem.
223
215
 
224
- BACK UP YOUR MODELS BEFORE USING THIS TOOL!
216
+ Be sure to check the changes that this tool makes! If you are using Git,
217
+ you may simply check your project's status after running `annotate`:
225
218
 
219
+ $ git status
220
+
221
+ If you are not using a VCS (like Git, Subversion or similar), please tread
222
+ extra carefully, and consider using one.
226
223
 
227
224
  == Links
228
225
 
@@ -232,43 +229,19 @@ BACK UP YOUR MODELS BEFORE USING THIS TOOL!
232
229
  - Fabrication: http://github.com/paulelliott/fabrication
233
230
  - SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
234
231
  - PostgisAdapter: http://github.com/nofxx/postgis_adapter
232
+ - PostGISAdapter: https://github.com/dazuma/activerecord-postgis-adapter
235
233
 
236
234
 
237
235
  == License
238
236
 
239
237
  Released under the same license as Ruby. No Support. No Warranty.
240
238
 
239
+ == Code Status
240
+ {<img src="https://travis-ci.org/ctran/annotate_models.png" />}[https://travis-ci.org/ctran/annotate_models]
241
+ {<img src="https://gemnasium.com/ctran/annotate_models.png" />}[https://gemnasium.com/ctran/annotate_models]
242
+
241
243
 
242
244
  == Authors
243
245
 
244
- - Original code by: Dave Thomas -- Pragmatic Programmers, LLC <http://agilewebdevelopment.com/plugins/annotate_models>
245
- - Overhauled by: Alex Chaffee <http://alexch.github.com> alex@stinky.com
246
- - Gemmed by: Cuong Tran <http://github.com/ctran> ctran@pragmaquest.com
247
- - Maintained by: Alex Chaffee and Cuong Tran
248
- - Homepage: http://github.com/ctran/annotate_models
249
-
250
- With help from:
251
-
252
- - Jack Danger - http://github.com/JackDanger
253
- - Michael Bumann - http://github.com/bumi
254
- - Henrik Nyh - http://github.com/henrik
255
- - Marcos Piccinini - http://github.com/nofxx
256
- - Neal Clark - http://github.com/nclark
257
- - Jacqui Maher - http://github.com/jacqui
258
- - Nick Plante - http://github.com/zapnap - http://blog.zerosum.org
259
- - Pedro Visintin - http://github.com/peterpunk - http://www.pedrovisintin.com
260
- - Bob Potter - http://github.com/bpot
261
- - Gavin Montague - http://github.com/govan
262
- - Alexander Semyonov - http://github.com/rotuka
263
- - Nathan Brazil - http://github.com/bitaxis
264
- - Ian Duggan http://github.com/ijcd
265
- - Jon Frisby http://github.com/mrjoy
266
- - Tsutomu Kuroda
267
- - Kevin Moore
268
- - Philip Hallstrom
269
- - Brent Greeff
270
- - Paul Alexander
271
- - Dmitry Lihachev
272
- - qichunren
273
-
274
- and many others that I may have forgotten to add.
246
+ {See AUTHORS.rdoc}[link:AUTHORS.rdoc].
247
+
@@ -4,21 +4,20 @@
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "annotate"
7
- s.version = "2.6.0.beta2"
7
+ s.version = "2.6.0"
8
8
 
9
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
9
  s.authors = ["Cuong Tran", "Alex Chaffee", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"]
11
- s.date = "2013-06-21"
10
+ s.date = "2013-11-29"
12
11
  s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema."
13
12
  s.email = ["alex@stinky.com", "ctran@pragmaquest.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
14
13
  s.executables = ["annotate"]
15
14
  s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "TODO.rdoc"]
16
- s.files = ["CHANGELOG.rdoc", "README.rdoc", "TODO.rdoc", "annotate.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/active_record_patch.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/annotate/tasks.rb", "lib/annotate/version.rb", "lib/generators/annotate/USAGE", "lib/generators/annotate/install_generator.rb", "lib/generators/annotate/templates/auto_annotate_models.rake", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake", "tasks/migrate.rake"]
15
+ s.files = ["AUTHORS.rdoc", "CHANGELOG.rdoc", "README.rdoc", "TODO.rdoc", "annotate.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/active_record_patch.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/annotate/tasks.rb", "lib/annotate/version.rb", "lib/generators/annotate/USAGE", "lib/generators/annotate/install_generator.rb", "lib/generators/annotate/templates/auto_annotate_models.rake", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake", "tasks/migrate.rake"]
17
16
  s.homepage = "http://github.com/ctran/annotate_models"
18
17
  s.licenses = ["Ruby"]
19
18
  s.require_paths = ["lib"]
20
19
  s.rubyforge_project = "annotate"
21
- s.rubygems_version = "2.0.3"
20
+ s.rubygems_version = "2.0.6"
22
21
  s.summary = "Annotates Rails Models, routes, fixtures, and others based on the database schema."
23
22
 
24
23
  if s.respond_to? :specification_version then
@@ -134,6 +134,11 @@ OptionParser.new do |opts|
134
134
  opts.on('--trace', 'If unable to annotate a file, print the full stack trace, not just the exception message.') do |value|
135
135
  ENV['trace'] = 'yes'
136
136
  end
137
+
138
+ opts.on('-I', '--ignore-columns REGEX', "don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`" ) do |regex|
139
+ ENV['ignore_columns'] = regex
140
+ end
141
+
137
142
  end.parse!
138
143
 
139
144
 
@@ -25,7 +25,7 @@ module Annotate
25
25
  :format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
26
26
  ]
27
27
  OTHER_OPTIONS=[
28
- :model_dir,
28
+ :model_dir, :ignore_columns
29
29
  ]
30
30
  PATH_OPTIONS=[
31
31
  :require,
@@ -5,7 +5,7 @@ module AnnotateModels
5
5
  PREFIX = "== Schema Information"
6
6
  PREFIX_MD = "## Schema Information"
7
7
  END_MARK = "== Schema Information End"
8
- PATTERN = /^\n?# (?:#{COMPAT_PREFIX}|#{COMPAT_PREFIX_MD}).*?\n(#.*\n)*\n/
8
+ PATTERN = /^\n?# (?:#{COMPAT_PREFIX}|#{COMPAT_PREFIX_MD}).*?\n(#.*\n)*\n*/
9
9
 
10
10
  # File.join for windows reverse bar compat?
11
11
  # I dont use windows, can`t test
@@ -108,6 +108,9 @@ module AnnotateModels
108
108
  end
109
109
 
110
110
  cols = klass.columns
111
+ if options[:ignore_columns]
112
+ cols.reject! { |col| col.name.match(/#{options[:ignore_columns]}/) }
113
+ end
111
114
  cols = cols.sort_by(&:name) if(options[:sort])
112
115
  cols.each do |col|
113
116
  attrs = []
@@ -118,9 +121,13 @@ module AnnotateModels
118
121
  col_type = (col.type || col.sql_type).to_s
119
122
  if col_type == "decimal"
120
123
  col_type << "(#{col.precision}, #{col.scale})"
121
- else
124
+ elsif col_type != "spatial"
122
125
  if (col.limit)
123
- col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
126
+ if col.limit.is_a? Array
127
+ attrs << "(#{col.limit.join(', ')})"
128
+ else
129
+ col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
130
+ end
124
131
  end
125
132
  end
126
133
 
@@ -128,6 +135,8 @@ module AnnotateModels
128
135
  # and print the type and SRID
129
136
  if col.respond_to?(:geometry_type)
130
137
  attrs << "#{col.geometry_type}, #{col.srid}"
138
+ elsif col.respond_to?(:geometric_type) and col.geometric_type.present?
139
+ attrs << "#{col.geometric_type.to_s.downcase}, #{col.srid}"
131
140
  end
132
141
 
133
142
  # Check if the column has indices and print "indexed" if true
@@ -160,9 +169,9 @@ module AnnotateModels
160
169
  if options[:format_rdoc]
161
170
  info << "#--\n"
162
171
  info << "# #{END_MARK}\n"
163
- info << "#++\n\n"
172
+ info << "#++\n"
164
173
  else
165
- info << "#\n\n"
174
+ info << "#\n"
166
175
  end
167
176
  end
168
177
 
@@ -204,7 +213,7 @@ module AnnotateModels
204
213
  return false if(old_content =~ /# -\*- SkipSchemaAnnotations.*\n/)
205
214
 
206
215
  # Ignore the Schema version line because it changes with each migration
207
- header_pattern = /(^# Table name:.*?\n(#.*[\r]?\n)*[\r]?\n)/
216
+ header_pattern = /(^# Table name:.*?\n(#.*[\r]?\n)*[\r]?)/
208
217
  old_header = old_content.match(header_pattern).to_s
209
218
  new_header = info_block.match(header_pattern).to_s
210
219
 
@@ -212,7 +221,7 @@ module AnnotateModels
212
221
  old_columns = old_header && old_header.scan(column_pattern).sort
213
222
  new_columns = new_header && new_header.scan(column_pattern).sort
214
223
 
215
- encoding = Regexp.new(/(^#\s*encoding:.*\n)|(^# coding:.*\n)|(^# -\*- coding:.*\n)/)
224
+ encoding = Regexp.new(/(^#\s*encoding:.*\n)|(^# coding:.*\n)|(^# -\*- coding:.*\n)|(^# -\*- encoding\s?:.*\n)/)
216
225
  encoding_header = old_content.match(encoding).to_s
217
226
 
218
227
  if old_columns == new_columns && !options[:force]
@@ -238,7 +247,7 @@ module AnnotateModels
238
247
 
239
248
  new_content = options[position].to_s == 'after' ?
240
249
  (encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
241
- (encoding_header + info_block + old_content)
250
+ (encoding_header + info_block + "\n" + old_content)
242
251
 
243
252
  File.open(file_name, "wb") { |f| f.puts new_content }
244
253
  return true
@@ -407,7 +416,7 @@ module AnnotateModels
407
416
  def annotate_model_file(annotated, file, header, options)
408
417
  begin
409
418
  klass = get_model_class(file)
410
- if klass && klass < ActiveRecord::Base && !klass.abstract_class?
419
+ if klass && klass < ActiveRecord::Base && !klass.abstract_class? && klass.table_exists?
411
420
  if annotate(klass, file, header, options)
412
421
  annotated << klass
413
422
  end
@@ -1,5 +1,5 @@
1
1
  module Annotate
2
2
  def self.version
3
- '2.6.0.beta2'
3
+ '2.6.0'
4
4
  end
5
5
  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.6.0.beta2
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cuong Tran
@@ -12,34 +12,34 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-06-21 00:00:00.000000000 Z
15
+ date: 2013-11-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - '>='
21
+ - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.8.7
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - '>='
28
+ - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: 0.8.7
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: activerecord
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - '>='
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: 2.3.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - '>='
42
+ - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: 2.3.0
45
45
  description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others based
@@ -58,6 +58,7 @@ extra_rdoc_files:
58
58
  - CHANGELOG.rdoc
59
59
  - TODO.rdoc
60
60
  files:
61
+ - AUTHORS.rdoc
61
62
  - CHANGELOG.rdoc
62
63
  - README.rdoc
63
64
  - TODO.rdoc
@@ -85,17 +86,17 @@ require_paths:
85
86
  - lib
86
87
  required_ruby_version: !ruby/object:Gem::Requirement
87
88
  requirements:
88
- - - '>='
89
+ - - ! '>='
89
90
  - !ruby/object:Gem::Version
90
91
  version: '0'
91
92
  required_rubygems_version: !ruby/object:Gem::Requirement
92
93
  requirements:
93
- - - '>'
94
+ - - ! '>='
94
95
  - !ruby/object:Gem::Version
95
- version: 1.3.1
96
+ version: '0'
96
97
  requirements: []
97
98
  rubyforge_project: annotate
98
- rubygems_version: 2.0.3
99
+ rubygems_version: 2.0.6
99
100
  signing_key:
100
101
  specification_version: 4
101
102
  summary: Annotates Rails Models, routes, fixtures, and others based on the database