annotate 2.6.1 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWI2ZDRiZDhkOTkwNDNmMDMxYWU2ZTY3NWEyYzMyMzVlYTc2OTFmMA==
4
+ OTk0YjllMjkxZmIzMDQwNDA3ZTNjZGYyOTFjM2E4NDNhYzgyN2RiNQ==
5
5
  data.tar.gz: !binary |-
6
- OWQ0MTY4ZjZmZWFmNDU0Yzc4NDgzNmNkNjM5MmNlN2U3NjQzZWM4OQ==
6
+ NGE3NjA2ODE2ZGExNDZiNGMzOWRiM2I4MDFiZDg2NGFmNmM3NjdhOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDdkYmQ1ZjE0ZTQ4ZWYyNzYxMGQ3YTNlZDMxZDRmZGJiNzlkZTc0ZjgxNGFk
10
- NDAwZjVmOGNmM2Y3OTRiNWE4ZjYwOWU4NGIwNWE4ZmI3MzI2YjZiOWJlZWQz
11
- YTlkZWQ5NjUxOGVjM2VjMmFlMTJlZDVkZGZlMTA1Yzk0NGYwNDA=
9
+ ZDIwZTMxMDBhOTg2MzEzZmY2N2M4ZTY1MTdjMjQ5ZjE2YTYyNjNmNGQ3N2Vi
10
+ NWUxNzM1YzdmZDc4NjRlYTQyYjk0ZmZhMmRlYWUzN2E0NmY5NjhmM2QyOGU5
11
+ NWZhODZkMGJiMjdmMzNjODkwOWIyM2JkMGYwNDQwZDZjNzM1YmU=
12
12
  data.tar.gz: !binary |-
13
- ZTZkMDkzODI2MTQ1MjY3ZjgzNjFjMjUxNTcwMzVjM2JhYmQzYzJmZGFiYjE4
14
- NjcwNDg1MDk5ZTMwMmI5YzJmNjk0ZThmYzM1ZWEyNjQ4NzdlMDM1MTJiMDRm
15
- MjQ2ZDY0NjJkMzUxNWZkNGQ0M2FmMjY1MjM5N2EyOTc1ZmY1OGE=
13
+ ZDZjM2M2YjczZmEzMDM1NDVjNWIyMmJhM2UzOTZiZTlkM2I0OGVmZmRmNWQ3
14
+ ZGNjNzdkYWJmZWFhNzMzMWU2MDZhNGZmM2RiZjJkN2YyMzUwNmI5ZDU0ODhj
15
+ ZjVkNzhmZTJhYjk1MTRjYjg4N2JmODIyMTc0MzA2NDBmZGI1ZjI=
@@ -1,3 +1,8 @@
1
+ == 2.6.2
2
+ * Retain the current annotate block unless --force is specified
3
+ * Always load models, since they may not be autoloaded by Rails
4
+ * The pg array type is now detected (see #158)
5
+
1
6
  == 2.6.0.beta2
2
7
 
3
8
  * support for composite_primary_keys (garysweaver)
@@ -1,20 +1,18 @@
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 -*-
1
+ # -*- encoding: utf-8 -*-
4
2
  # stub: annotate 2.6.1 ruby lib
5
3
 
6
4
  Gem::Specification.new do |s|
7
5
  s.name = "annotate"
8
- s.version = "2.6.1"
6
+ s.version = "2.6.2"
9
7
 
10
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
9
  s.authors = ["Cuong Tran", "Alex Chaffee", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"]
12
- s.date = "2013-12-21"
10
+ s.date = "2014-02-26"
13
11
  s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema."
14
- s.email = ["alex@stinky.com", "ctran@pragmaquest.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
12
+ s.email = ["alex@stinky.com", "cuong.tran@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
15
13
  s.executables = ["annotate"]
16
14
  s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "TODO.rdoc"]
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", "tasks/migrate.rake"]
15
+ 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"]
18
16
  s.homepage = "http://github.com/ctran/annotate_models"
19
17
  s.licenses = ["Ruby"]
20
18
  s.require_paths = ["lib"]
@@ -119,8 +119,8 @@ OptionParser.new do |opts|
119
119
  end
120
120
  end
121
121
 
122
- opts.on('-e', '--exclude [DIRS]', ['tests','fixtures','factories'], "Do not annotate fixtures, test files, and/or factories") do |exclusions|
123
- exclusions ||= %w(tests fixtures factories)
122
+ opts.on('-e', '--exclude [tests,fixtures,factories]', Array, "Do not annotate fixtures, test files, and/or factories") do |exclusions|
123
+ exclusions ||= %w(tests fixtures factories)
124
124
  exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
125
125
  end
126
126
 
@@ -31,8 +31,8 @@ module AnnotateModels
31
31
  FABRICATORS_SPEC_DIR = File.join("spec", "fabricators")
32
32
 
33
33
  TEST_PATTERNS = [
34
- [UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"],
35
- [SPEC_MODEL_DIR, "%MODEL_NAME%_spec.rb"],
34
+ File.join(UNIT_TEST_DIR, "%MODEL_NAME%_test.rb"),
35
+ File.join(SPEC_MODEL_DIR, "%MODEL_NAME%_spec.rb"),
36
36
  ]
37
37
 
38
38
  FIXTURE_PATTERNS = [
@@ -131,6 +131,11 @@ module AnnotateModels
131
131
  end
132
132
  end
133
133
 
134
+ # Check out if we got an array column
135
+ if col.respond_to?(:array) && col.array
136
+ attrs << "is an Array"
137
+ end
138
+
134
139
  # Check out if we got a geometric column
135
140
  # and print the type and SRID
136
141
  if col.respond_to?(:geometry_type)
@@ -227,27 +232,23 @@ module AnnotateModels
227
232
  if old_columns == new_columns && !options[:force]
228
233
  return false
229
234
  else
235
+ # Replace inline the old schema info with the new schema info
236
+ new_content = old_content.sub(PATTERN, info_block + "\n")
230
237
 
231
- # todo: figure out if we need to extract any logic from this merge chunk
232
- # <<<<<<< HEAD
233
- # # Replace the old schema info with the new schema info
234
- # new_content = old_content.sub(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n*/, info_block)
235
- # # But, if there *was* no old schema info, we simply need to insert it
236
- # if new_content == old_content
237
- # old_content.sub!(encoding, '')
238
- # new_content = options[:position] == 'after' ?
239
- # (encoding_header + (old_content =~ /\n$/ ? old_content : old_content + "\n") + info_block) :
240
- # (encoding_header + info_block + old_content)
241
- # end
242
- # =======
243
-
244
- # Strip the old schema info, and insert new schema info.
245
- old_content.sub!(encoding, '')
246
- old_content.sub!(PATTERN, '')
247
-
248
- new_content = options[position].to_s == 'after' ?
249
- (encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
250
- (encoding_header + info_block + "\n" + old_content)
238
+ if new_content.end_with? (info_block + "\n")
239
+ new_content = old_content.sub(PATTERN, "\n" + info_block)
240
+ end
241
+
242
+ # if there *was* no old schema info (no substitution happened) or :force was passed,
243
+ # we simply need to insert it in correct position
244
+ if new_content == old_content || options[:force]
245
+ old_content.sub!(encoding, '')
246
+ old_content.sub!(PATTERN, '')
247
+
248
+ new_content = options[position].to_s == 'after' ?
249
+ (encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
250
+ (encoding_header + info_block + "\n" + old_content)
251
+ end
251
252
 
252
253
  File.open(file_name, "wb") { |f| f.puts new_content }
253
254
  return true
@@ -301,8 +302,7 @@ module AnnotateModels
301
302
 
302
303
  unless options[:exclude_tests]
303
304
  did_annotate = TEST_PATTERNS.
304
- map { |pat| [pat[0], resolve_filename(pat[1], model_name, table_name)] }.
305
- map { |pat| find_test_file(*pat) }.
305
+ map { |file| resolve_filename(file, model_name, table_name) }.
306
306
  map { |file| annotate_one_file(file, info, :position_in_test, options_with_position(options, :position_in_test)) }.
307
307
  detect { |result| result } || did_annotate
308
308
  end
@@ -370,7 +370,7 @@ module AnnotateModels
370
370
  # in subdirectories without namespacing.
371
371
  def get_model_class(file)
372
372
  # this is for non-rails projects, which don't get Rails auto-require magic
373
- require File.expand_path("#{model_dir}/#{file}") unless Module.const_defined?(:Rails)
373
+ require File.expand_path("#{model_dir}/#{file}")
374
374
  model_path = file.gsub(/\.rb$/, '')
375
375
  get_loaded_model(model_path) || get_loaded_model(model_path.split('/').last)
376
376
  end
@@ -441,16 +441,7 @@ module AnnotateModels
441
441
  model_file_name = File.join(model_dir, file)
442
442
  deannotated_klass = true if(remove_annotation_of_file(model_file_name))
443
443
 
444
- TEST_PATTERNS.
445
- map { |pat| [pat[0], resolve_filename(pat[1], model_name, table_name)]}.
446
- map { |pat| find_test_file(*pat) }.each do |file|
447
- if(File.exist?(file))
448
- remove_annotation_of_file(file)
449
- deannotated_klass = true
450
- end
451
- end
452
-
453
- (FIXTURE_PATTERNS + FACTORY_PATTERNS).
444
+ (TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS).
454
445
  map { |file| resolve_filename(file, model_name, table_name) }.
455
446
  each do |file|
456
447
  if File.exist?(file)
@@ -468,10 +459,6 @@ module AnnotateModels
468
459
  puts "Removed annotations from: #{deannotated.join(', ')}"
469
460
  end
470
461
 
471
- def find_test_file(dir, file_name)
472
- Dir.glob(File.join(dir, "**", file_name)).first || File.join(dir, file_name)
473
- end
474
-
475
462
  def resolve_filename(filename_template, model_name, table_name)
476
463
  return filename_template.
477
464
  gsub('%MODEL_NAME%', model_name).
@@ -1,5 +1,5 @@
1
1
  module Annotate
2
2
  def self.version
3
- '2.6.1'
3
+ '2.6.2'
4
4
  end
5
5
  end
File without changes
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.1
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cuong Tran
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-12-21 00:00:00.000000000 Z
15
+ date: 2014-02-26 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -50,7 +50,7 @@ description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others b
50
50
  on the database schema.
51
51
  email:
52
52
  - alex@stinky.com
53
- - ctran@pragmaquest.com
53
+ - cuong.tran@gmail.com
54
54
  - x@nofxx.com
55
55
  - turadg@aleahmad.net
56
56
  - jon@cloudability.com
@@ -80,7 +80,7 @@ files:
80
80
  - lib/generators/annotate/templates/auto_annotate_models.rake
81
81
  - lib/tasks/annotate_models.rake
82
82
  - lib/tasks/annotate_routes.rake
83
- - tasks/migrate.rake
83
+ - lib/tasks/migrate.rake
84
84
  homepage: http://github.com/ctran/annotate_models
85
85
  licenses:
86
86
  - Ruby