modalfields 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/modalfields/modalfields.rb +6 -3
- data/modalfields.gemspec +98 -0
- data/test/helper.rb +12 -8
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -263,7 +263,10 @@ module ModalFields
|
|
263
263
|
def diff(model)
|
264
264
|
# model.columns will fail if the table does not exist
|
265
265
|
existing_fields = model.columns rescue []
|
266
|
-
|
266
|
+
# up to ActiveRecord 3.1 we had primary_key_name in AssociationReflection; not itis foreign_key
|
267
|
+
association_fields = model.reflect_on_all_associations(:belongs_to).map{ |r|
|
268
|
+
r.respond_to?(:primary_key_name) ? r.primary_key_name : r.foreign_key
|
269
|
+
}.flatten.map(&:to_s)
|
267
270
|
pk_fields = Array(model.primary_key).map(&:to_s)
|
268
271
|
case show_primary_keys
|
269
272
|
when true
|
@@ -300,11 +303,11 @@ module ModalFields
|
|
300
303
|
attr_keys = attrs.keys
|
301
304
|
decl_attrs = attr_keys.map{|a|
|
302
305
|
v = field_declaration.attributes[a]
|
303
|
-
v==attrs[a] ? nil : v
|
306
|
+
v==attrs[a] ? nil : (v==false ? nil : v)
|
304
307
|
}
|
305
308
|
col_attrs = attr_keys.map{|a|
|
306
309
|
v = column.attributes[a]
|
307
|
-
v==attrs[a] ? nil : v
|
310
|
+
v==attrs[a] ? nil : (v==false ? nil : v)
|
308
311
|
}
|
309
312
|
if decl_attrs == col_attrs
|
310
313
|
identical=true
|
data/modalfields.gemspec
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "modalfields"
|
8
|
+
s.version = "1.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Javier Goizueta"]
|
12
|
+
s.date = "2012-04-24"
|
13
|
+
s.description = "ModelFields is a Rails plugin that adds fields declarations to your models."
|
14
|
+
s.email = "jgoizueta@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc",
|
18
|
+
"TODO"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"TODO",
|
28
|
+
"VERSION",
|
29
|
+
"lib/modalfields.rb",
|
30
|
+
"lib/modalfields/modalfields.rb",
|
31
|
+
"lib/modalfields/standardfields.rb",
|
32
|
+
"lib/modalfields/tasks.rb",
|
33
|
+
"lib/tasks/check.rake",
|
34
|
+
"lib/tasks/migrate.rake",
|
35
|
+
"lib/tasks/update.rake",
|
36
|
+
"modalfields.gemspec",
|
37
|
+
"test/create_database.rb",
|
38
|
+
"test/database.yml",
|
39
|
+
"test/helper.rb",
|
40
|
+
"test/model_cases/bare/after/author.rb",
|
41
|
+
"test/model_cases/bare/after/book.rb",
|
42
|
+
"test/model_cases/bare/before/author.rb",
|
43
|
+
"test/model_cases/bare/before/book.rb",
|
44
|
+
"test/model_cases/clean/after/author.rb",
|
45
|
+
"test/model_cases/clean/after/book.rb",
|
46
|
+
"test/model_cases/clean/before/author.rb",
|
47
|
+
"test/model_cases/clean/before/book.rb",
|
48
|
+
"test/model_cases/dirty/after/author.rb",
|
49
|
+
"test/model_cases/dirty/after/book.rb",
|
50
|
+
"test/model_cases/dirty/before/author.rb",
|
51
|
+
"test/model_cases/dirty/before/book.rb",
|
52
|
+
"test/schema.rb",
|
53
|
+
"test/test_diff.rb",
|
54
|
+
"test/test_update.rb"
|
55
|
+
]
|
56
|
+
s.homepage = "http://github.com/jgoizueta/modalfields"
|
57
|
+
s.licenses = ["MIT"]
|
58
|
+
s.require_paths = ["lib"]
|
59
|
+
s.rubygems_version = "1.8.21"
|
60
|
+
s.summary = "Model annotator with Ruby (Hobo-like) syntax and hooks."
|
61
|
+
|
62
|
+
if s.respond_to? :specification_version then
|
63
|
+
s.specification_version = 3
|
64
|
+
|
65
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
66
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
67
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
|
68
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_development_dependency(%q<bundler>, ["~> 1"])
|
71
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
72
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<pg>, [">= 0"])
|
74
|
+
s.add_runtime_dependency(%q<rails>, [">= 2.3.0"])
|
75
|
+
else
|
76
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
77
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
78
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
79
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
80
|
+
s.add_dependency(%q<bundler>, ["~> 1"])
|
81
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
82
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
83
|
+
s.add_dependency(%q<pg>, [">= 0"])
|
84
|
+
s.add_dependency(%q<rails>, [">= 2.3.0"])
|
85
|
+
end
|
86
|
+
else
|
87
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
88
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
89
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
90
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
91
|
+
s.add_dependency(%q<bundler>, ["~> 1"])
|
92
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
93
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
94
|
+
s.add_dependency(%q<pg>, [">= 0"])
|
95
|
+
s.add_dependency(%q<rails>, [">= 2.3.0"])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
data/test/helper.rb
CHANGED
@@ -24,21 +24,24 @@ end
|
|
24
24
|
|
25
25
|
ENV['RAILS_ENV'] = 'test'
|
26
26
|
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) # + '/../../../..'
|
27
|
-
|
27
|
+
|
28
28
|
# require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
|
29
29
|
|
30
30
|
module Rails
|
31
31
|
def self.root
|
32
32
|
ENV['RAILS_ROOT']
|
33
33
|
end
|
34
|
+
def version
|
35
|
+
ActiveRecord::VERSION::STRING
|
36
|
+
end
|
34
37
|
end
|
35
|
-
|
38
|
+
|
36
39
|
def load_schema
|
37
40
|
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')).with_indifferent_access
|
38
41
|
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
39
|
-
|
42
|
+
|
40
43
|
db_adapter = ENV['DB']
|
41
|
-
|
44
|
+
|
42
45
|
# no db passed, try one of these fine config-free DBs before bombing.
|
43
46
|
db_adapter ||=
|
44
47
|
begin
|
@@ -47,15 +50,16 @@ def load_schema
|
|
47
50
|
'sqlite3'
|
48
51
|
rescue MissingSourceFile
|
49
52
|
end
|
50
|
-
|
53
|
+
|
51
54
|
if db_adapter.nil?
|
52
55
|
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite3."
|
53
56
|
end
|
54
|
-
|
57
|
+
|
55
58
|
require File.dirname(__FILE__) + '/create_database'
|
56
59
|
create_database config[db_adapter]
|
57
|
-
|
60
|
+
|
58
61
|
ActiveRecord::Base.establish_connection(config[db_adapter])
|
59
62
|
load(File.dirname(__FILE__) + "/schema.rb")
|
60
|
-
require File.dirname(__FILE__) + '/../
|
63
|
+
require File.dirname(__FILE__) + '/../lib/modalfields'
|
64
|
+
ModalFields.enable
|
61
65
|
end
|
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.1.
|
4
|
+
version: 1.1.2
|
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-04-
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/tasks/check.rake
|
180
180
|
- lib/tasks/migrate.rake
|
181
181
|
- lib/tasks/update.rake
|
182
|
+
- modalfields.gemspec
|
182
183
|
- test/create_database.rb
|
183
184
|
- test/database.yml
|
184
185
|
- test/helper.rb
|
@@ -212,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
213
|
version: '0'
|
213
214
|
segments:
|
214
215
|
- 0
|
215
|
-
hash:
|
216
|
+
hash: 913054434622430133
|
216
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
218
|
none: false
|
218
219
|
requirements:
|