modalfields 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.5
1
+ 1.4.6
@@ -370,8 +370,9 @@ module ModalFields
370
370
  end
371
371
  existing_fields -= assoc_cols
372
372
 
373
+ has_fields_info = model.respond_to?(:fields_info) && model.fields_info != :omitted
373
374
  fields = Array(fields).reject{|line, name, comment| name.blank?}
374
- if model.respond_to?(:fields_info)
375
+ if has_fields_info
375
376
  field_order = model.fields_info.map(&:name).map(&:to_s) & existing_fields.map(&:name)
376
377
  else
377
378
  field_order = []
@@ -380,7 +381,7 @@ module ModalFields
380
381
  field_order += existing_fields.map(&:name).reject{|name| field_order.include?(name.to_s)}
381
382
  end
382
383
  field_comments = Hash[fields.map{|line, name, comment| [name,comment]}]
383
- field_extras = Hash[ model.fields_info.map{|fi| [fi.name.to_s,fi.attributes]}]
384
+ field_extras = has_fields_info ? Hash[ model.fields_info.map{|fi| [fi.name.to_s,fi.attributes]}] : {}
384
385
  field_order.each do |field_name|
385
386
  field_info = existing_fields.find{|f| f.name.to_s==field_name}
386
387
  field_comment = field_comments[field_name]
@@ -731,7 +732,7 @@ module ModalFields
731
732
  existing_fields = model.columns rescue []
732
733
  assocs = model.reflect_on_all_associations(:belongs_to) +
733
734
  submodels.map{|sc| sc.reflect_on_all_associations(:belongs_to)}.flatten
734
- association_fields = assocs.map{ |r|
735
+ association_fields = assocs.uniq.map{ |r|
735
736
  # up to ActiveRecord 3.1 we had primary_key_name in AssociationReflection; now it's foreign_key
736
737
  cols = [r.respond_to?(:primary_key_name) ? r.primary_key_name : r.foreign_key]
737
738
  if r.options[:polymorphic]
data/lib/tasks/csv.rake CHANGED
@@ -16,7 +16,7 @@ namespace :fields do
16
16
  CSV.open(fn, 'w', *options) do |csv|
17
17
  csv << %w{table column pk assoc foreign sql_type type attributes extra comments}
18
18
  ModalFields.report(
19
- :primary_keys=>true, :foreing_keys=>true,
19
+ :primary_keys=>true, :foreign_keys=>true,
20
20
  :undeclared_fields=>true) do |kind, table, name, data|
21
21
  row_data = [table, name, kind==:primary_key]
22
22
  if kind==:foreign_key
data/modalfields.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "modalfields"
8
- s.version = "1.4.5"
8
+ s.version = "1.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javier Goizueta"]
12
- s.date = "2012-09-26"
12
+ s.date = "2012-10-15"
13
13
  s.description = "ModelFields is a Rails plugin that adds fields declarations to your models."
14
14
  s.email = "jgoizueta@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modalfields
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-26 00:00:00.000000000 Z
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: modalsettings
@@ -232,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  segments:
234
234
  - 0
235
- hash: -744716552947708725
235
+ hash: -4428809271904174224
236
236
  required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  none: false
238
238
  requirements: