annotate 2.6.3 → 2.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjA3ODY1MmI2NTJiOGRjYzlhYmVmYzY5OTk1OTI2ZDBmNWI4OWVkOA==
4
+ OWJjZmE2N2E0NDFhOGU5MmFjZGJlZjZmNTg4YjI4MWZmYjhlZDUxNw==
5
5
  data.tar.gz: !binary |-
6
- NTkwZTZmN2NkOTlmYzYwYThkODRhNzU0ZjczYzI4MzcyOTYxNzUwYw==
6
+ ZDViMWZlYjVlZWMxN2IzMjM2NWFlYmJmYTc2NGEyY2FlYmIyOWYxNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTRkNmFkYzVhZWM1NWZjOGE0Y2YwZDk4NzAzZWE0OWE2NGJhNzgyZWJhOWQ1
10
- MWYyZTgyNzMxMjJmYWExZDM5NjJkZmIxYTVlOWIzNzYzNzFjMmY1ZDhjMWVk
11
- YWEzYzQ3M2Q3MWI0ZTAyNDczMzhmYWFiMDc5MWY2NTY3NWY4ZjQ=
9
+ NDBlMTlmZTczYjk0YjUxYzg1ZTljOWE3YmE1MjYxOGNhZjhmOGNlZWZhMDlh
10
+ N2EzNDRjMjcwZWRiYzk4ZmFlM2U5OGQ1ZDJlNTQ2YmM0ZTQwZDg5NzdmMDMx
11
+ NTU4NjM2OWY1ZmI3OTk3MTc2MTVkMTE4ZDNiMTJkZTk5NzA5M2I=
12
12
  data.tar.gz: !binary |-
13
- MDg5YTI3ZDY4MWMzYzRhYTg5MzE4YjNkM2E3Mjc4OGQxZTRiNTIxY2E2NTAy
14
- MWNiM2U4ZGRlODMwODljNjA3YTc1MWE4ODEyMDhlNzYyMzZmOWU5MjI4ZDQ4
15
- YzMyZWFiYTA1ZmU4MTNhYjg5MmJhMmU4NTIwZmZiMzE4YmM4MzQ=
13
+ YzIzY2ZmNDA1YWEzYTVlZDY0ZDg4MDg3YThhYjBiYTQ1MjQ4ZTQwYzY2Mjc1
14
+ YmRjNjMxMTUwMDQ2OTIzZmFmNWI1ODM2Mzk5MjYwYmY2OWIzZTk0YmM5ODll
15
+ MDlmNTEwYjk2M2E1ZGZjOTUzZDE2ODJhYTQ1N2JlYzBjZTU4M2I=
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,14 @@
1
+ == 2.6.4
2
+ * Skip "models/concerns", #194
3
+ * Fix #173 where annotate says "Nothing to annotate" in rails 4.2
4
+ * Display an error message if not run from the root of the project, #186
5
+ * Support rails 4.0 new default test directory, #182
6
+ * Add an option to show timestamp in routes "-timestamp", #136
7
+ * Skip plain ruby objects if they have the same class name as an ActiveRecord object, #121
8
+
9
+ == 2.6.3
10
+ * Fix bug of annotate position in routes (#158)
11
+
1
12
  == 2.6.2
2
13
  * Retain the current annotate block unless --force is specified
3
14
  * Always load models, since they may not be autoloaded by Rails
data/README.rdoc CHANGED
@@ -1,7 +1,8 @@
1
1
  == Annotate (aka AnnotateModels)
2
2
 
3
- IMPORTANT: If you're upgrading from a previous version, including 2.5.0,
4
- re-run the generator task!
3
+ {<img src="https://badge.fury.io/rb/annotate.svg" alt="Gem Version" />}[http://badge.fury.io/rb/annotate]
4
+ {<img src="https://travis-ci.org/ctran/annotate_models.png" />}[https://travis-ci.org/ctran/annotate_models]
5
+ {<img src="https://gemnasium.com/ctran/annotate_models.png" />}[https://gemnasium.com/ctran/annotate_models]
5
6
 
6
7
  Add a comment summarizing the current schema to the top or bottom of each of
7
8
  your...
@@ -54,7 +55,7 @@ Into Gemfile from rubygems.org:
54
55
 
55
56
  Into Gemfile from Github:
56
57
 
57
- gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
58
+ gem 'annotate', github: 'ctran/annotate_models'
58
59
 
59
60
  Into environment gems from rubygems.org:
60
61
 
@@ -179,6 +180,7 @@ you can do so with a simple environment variable, instead of editing the
179
180
  --format
180
181
  --force Force new annotations even if there are no changes.
181
182
  --trace If unable to annotate a file, print the full stack trace, not just the exception message.
183
+ --timestamp Include an updated time in routes.rb
182
184
 
183
185
 
184
186
  == Sorting
@@ -236,11 +238,6 @@ extra carefully, and consider using one.
236
238
 
237
239
  Released under the same license as Ruby. No Support. No Warranty.
238
240
 
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
-
243
-
244
241
  == Authors
245
242
 
246
243
  {See AUTHORS.rdoc}[link:AUTHORS.rdoc].
data/annotate.gemspec CHANGED
@@ -1,25 +1,25 @@
1
- # This file is auto-generated!
2
- # DO NOT EDIT THIS FILE DIRECTLY!
3
- # Instead, edit the Rakefile and run 'rake gems:gemspec'.# -*- encoding: utf-8 -*-
4
- # stub: annotate 2.6.3 ruby lib
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'annotate/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "annotate"
8
- s.version = "2.6.3"
8
+ s.version = Annotate.version
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.require_paths = ["lib"]
12
- s.authors = ["Alex Chaffee", "Cuong Tran", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"]
13
- s.date = "2014-04-05"
11
+ s.authors = ["Cuong Tran", "Alex Chaffee", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"]
12
+ s.date = "2014-06-16"
14
13
  s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema."
15
- s.email = ["alex@stinky.com", "cuong@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
14
+ s.email = ["alex@stinky.com", "cuong.tran@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
16
15
  s.executables = ["annotate"]
17
16
  s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "TODO.rdoc"]
18
- s.files = [".travis.yml", "AUTHORS.rdoc", "CHANGELOG.rdoc", "LICENSE.txt", "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", "lib/tasks/migrate.rake"]
17
+ s.files = ["AUTHORS.rdoc", "CHANGELOG.rdoc", "LICENSE.txt", "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", "lib/tasks/migrate.rake"]
19
18
  s.homepage = "http://github.com/ctran/annotate_models"
20
19
  s.licenses = ["Ruby"]
20
+ s.require_paths = ["lib"]
21
21
  s.rubyforge_project = "annotate"
22
- s.rubygems_version = "2.2.2"
22
+ s.rubygems_version = "2.1.11"
23
23
  s.summary = "Annotates Rails Models, routes, fixtures, and others based on the database schema."
24
24
 
25
25
  if s.respond_to? :specification_version then
data/bin/annotate CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ unless File.exists?('./Rakefile') || File.exists?('./Gemfile')
4
+ abort "Please run annotate from the root of the project."
5
+ end
6
+
2
7
  require 'rubygems'
3
8
  begin
4
9
  require 'bundler'
@@ -132,6 +137,10 @@ OptionParser.new do |opts|
132
137
  ENV['force'] = 'yes'
133
138
  end
134
139
 
140
+ opts.on('--timestamp', 'Include timestamp in (routes) annotation') do
141
+ ENV['timestamp'] = 'true'
142
+ end
143
+
135
144
  opts.on('--trace', 'If unable to annotate a file, print the full stack trace, not just the exception message.') do |value|
136
145
  ENV['trace'] = 'yes'
137
146
  end
@@ -142,7 +151,6 @@ OptionParser.new do |opts|
142
151
 
143
152
  end.parse!
144
153
 
145
-
146
- options=Annotate.setup_options({ :is_rake => !ENV['is_rake'].blank? })
154
+ options = Annotate.setup_options({ :is_rake => ENV['is_rake'] && !ENV['is_rake'].empty? })
147
155
  Annotate.eager_load(options)
148
156
  target[:klass].send(target[:task], options)
data/lib/annotate.rb CHANGED
@@ -22,7 +22,7 @@ module Annotate
22
22
  FLAG_OPTIONS=[
23
23
  :show_indexes, :simple_indexes, :include_version, :exclude_tests,
24
24
  :exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
25
- :format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
25
+ :format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace, :timestamp
26
26
  ]
27
27
  OTHER_OPTIONS=[
28
28
  :model_dir, :ignore_columns
@@ -10,6 +10,7 @@ module AnnotateModels
10
10
  # File.join for windows reverse bar compat?
11
11
  # I dont use windows, can`t test
12
12
  UNIT_TEST_DIR = File.join("test", "unit")
13
+ MODEL_TEST_DIR = File.join("test", "models") # since rails 4.0
13
14
  SPEC_MODEL_DIR = File.join("spec", "models")
14
15
  FIXTURE_TEST_DIR = File.join("test", "fixtures")
15
16
  FIXTURE_SPEC_DIR = File.join("spec", "fixtures")
@@ -32,6 +33,7 @@ module AnnotateModels
32
33
 
33
34
  TEST_PATTERNS = [
34
35
  File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"),
36
+ File.join(MODEL_TEST_DIR, "%MODEL_NAME%_test.rb"),
35
37
  File.join(SPEC_MODEL_DIR, "%MODEL_NAME%_spec.rb"),
36
38
  ]
37
39
 
@@ -121,7 +123,7 @@ module AnnotateModels
121
123
  col_type = (col.type || col.sql_type).to_s
122
124
  if col_type == "decimal"
123
125
  col_type << "(#{col.precision}, #{col.scale})"
124
- elsif col_type != "spatial"
126
+ elsif col_type != "spatial"
125
127
  if (col.limit)
126
128
  if col.limit.is_a? Array
127
129
  attrs << "(#{col.limit.join(', ')})"
@@ -140,7 +142,7 @@ module AnnotateModels
140
142
  # and print the type and SRID
141
143
  if col.respond_to?(:geometry_type)
142
144
  attrs << "#{col.geometry_type}, #{col.srid}"
143
- elsif col.respond_to?(:geometric_type) and col.geometric_type.present?
145
+ elsif col.respond_to?(:geometric_type) and col.geometric_type.present?
144
146
  attrs << "#{col.geometric_type.to_s.downcase}, #{col.srid}"
145
147
  end
146
148
 
@@ -222,7 +224,7 @@ module AnnotateModels
222
224
  old_header = old_content.match(header_pattern).to_s
223
225
  new_header = info_block.match(header_pattern).to_s
224
226
 
225
- column_pattern = /^#[\t ]+\w+[\t ]+.+$/
227
+ column_pattern = /^#[\t ]+[\w\*`]+[\t ]+.+$/
226
228
  old_columns = old_header && old_header.scan(column_pattern).sort
227
229
  new_columns = new_header && new_header.scan(column_pattern).sort
228
230
 
@@ -235,10 +237,10 @@ module AnnotateModels
235
237
  # Replace inline the old schema info with the new schema info
236
238
  new_content = old_content.sub(PATTERN, info_block + "\n")
237
239
 
238
- if new_content.end_with? (info_block + "\n")
240
+ if new_content.end_with?(info_block + "\n")
239
241
  new_content = old_content.sub(PATTERN, "\n" + info_block)
240
242
  end
241
-
243
+
242
244
  # if there *was* no old schema info (no substitution happened) or :force was passed,
243
245
  # we simply need to insert it in correct position
244
246
  if new_content == old_content || options[:force]
@@ -352,7 +354,7 @@ module AnnotateModels
352
354
  models = if options[:ignore_model_sub_dir]
353
355
  Dir["*.rb"]
354
356
  else
355
- Dir["**/*.rb"]
357
+ Dir["**/*.rb"].reject{ |f| f["concerns/"] }
356
358
  end
357
359
  end
358
360
  rescue SystemCallError
@@ -369,21 +371,36 @@ module AnnotateModels
369
371
  # Check for namespaced models in subdirectories as well as models
370
372
  # in subdirectories without namespacing.
371
373
  def get_model_class(file)
372
- # this is for non-rails projects, which don't get Rails auto-require magic
373
- require File.expand_path("#{model_dir}/#{file}")
374
374
  model_path = file.gsub(/\.rb$/, '')
375
- get_loaded_model(model_path) || get_loaded_model(model_path.split('/').last)
375
+ begin
376
+ get_loaded_model(model_path) or raise LoadError.new("cannot load a model from #{file}")
377
+ rescue LoadError
378
+ # this is for non-rails projects, which don't get Rails auto-require magic
379
+ if Kernel.require(File.expand_path("#{model_dir}/#{model_path}"))
380
+ retry
381
+ elsif model_path.match(/\//)
382
+ model_path = model_path.split('/')[1..-1].join('/').to_s
383
+ retry
384
+ else
385
+ raise
386
+ end
387
+ end
376
388
  end
377
389
 
378
390
  # Retrieve loaded model class by path to the file where it's supposed to be defined.
379
391
  def get_loaded_model(model_path)
380
- ObjectSpace.each_object(::Class).
381
- select do |c|
382
- Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
383
- c.ancestors.respond_to?(:include?) and # to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
384
- c.ancestors.include?(ActiveRecord::Base)
385
- end.
386
- detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
392
+ begin
393
+ ActiveSupport::Inflector.constantize(ActiveSupport::Inflector.camelize(model_path))
394
+ rescue
395
+ # Revert to the old way but it is not really robust
396
+ ObjectSpace.each_object(::Class).
397
+ select do |c|
398
+ Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
399
+ c.ancestors.respond_to?(:include?) and # to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
400
+ c.ancestors.include?(ActiveRecord::Base)
401
+ end.
402
+ detect { |c| ActiveSupport::Inflector.underscore(c.to_s) == model_path }
403
+ end
387
404
  end
388
405
 
389
406
  # We're passed a name of things that might be
@@ -428,7 +445,6 @@ module AnnotateModels
428
445
  end
429
446
 
430
447
  def remove_annotations(options={})
431
-
432
448
  self.model_dir = options[:model_dir] if options[:model_dir]
433
449
  deannotated = []
434
450
  deannotated_klass = false
@@ -33,7 +33,7 @@ module AnnotateRoutes
33
33
  routes_map.shift if(routes_map.first =~ /^\(in \//)
34
34
 
35
35
  header = [
36
- "#{PREFIX} (Updated #{Time.now.strftime("%Y-%m-%d %H:%M")})",
36
+ "#{PREFIX}" + (options[:timestamp] ? " (Updated #{Time.now.strftime("%Y-%m-%d %H:%M")})" : ""),
37
37
  "#"
38
38
  ] + routes_map.map { |line| "# #{line}".rstrip }
39
39
 
@@ -1,5 +1,5 @@
1
1
  module Annotate
2
2
  def self.version
3
- '2.6.3'
3
+ '2.6.5'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # NOTE: only doing this in development as some production environments (Heroku)
2
2
  # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3
3
  # NOTE: to have a dev-mode tool do its thing in production.
4
- if(Rails.env.development?)
4
+ if Rails.env.development?
5
5
  task :set_annotation_options do
6
6
  # You can override any of these by setting an environment variable of the
7
7
  # same name.
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 2.6.5
5
5
  platform: ruby
6
6
  authors:
7
- - Alex Chaffee
8
7
  - Cuong Tran
8
+ - Alex Chaffee
9
9
  - Marcos Piccinini
10
10
  - Turadg Aleahmad
11
11
  - Jon Frisby
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-04-05 00:00:00.000000000 Z
15
+ date: 2014-06-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -20,14 +20,16 @@ dependencies:
20
20
  requirements:
21
21
  - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
- version: 0.8.7
23
+ version: !binary |-
24
+ MC44Ljc=
24
25
  type: :runtime
25
26
  prerelease: false
26
27
  version_requirements: !ruby/object:Gem::Requirement
27
28
  requirements:
28
29
  - - ! '>='
29
30
  - !ruby/object:Gem::Version
30
- version: 0.8.7
31
+ version: !binary |-
32
+ MC44Ljc=
31
33
  - !ruby/object:Gem::Dependency
32
34
  name: activerecord
33
35
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +48,7 @@ description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others b
46
48
  on the database schema.
47
49
  email:
48
50
  - alex@stinky.com
49
- - cuong@gmail.com
51
+ - cuong.tran@gmail.com
50
52
  - x@nofxx.com
51
53
  - turadg@aleahmad.net
52
54
  - jon@cloudability.com
@@ -58,7 +60,6 @@ extra_rdoc_files:
58
60
  - CHANGELOG.rdoc
59
61
  - TODO.rdoc
60
62
  files:
61
- - .travis.yml
62
63
  - AUTHORS.rdoc
63
64
  - CHANGELOG.rdoc
64
65
  - LICENSE.txt
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  version: '0'
99
100
  requirements: []
100
101
  rubyforge_project: annotate
101
- rubygems_version: 2.2.2
102
+ rubygems_version: 2.3.0
102
103
  signing_key:
103
104
  specification_version: 4
104
105
  summary: Annotates Rails Models, routes, fixtures, and others based on the database
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
-
5
- before_install:
6
- - rvm @global do gem install bundler