active_type 0.4.2 → 0.4.3
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +21 -14
- data/README.md +4 -1
- data/gemfiles/Gemfile.3.2.mysql2 +8 -0
- data/gemfiles/Gemfile.3.2.mysql2.lock +48 -0
- data/gemfiles/{Gemfile.3.2 → Gemfile.3.2.sqlite3} +1 -1
- data/gemfiles/{Gemfile.3.2.lock → Gemfile.3.2.sqlite3.lock} +10 -7
- data/gemfiles/{Gemfile.4.0 → Gemfile.4.0.sqlite3} +0 -0
- data/gemfiles/{Gemfile.4.0.lock → Gemfile.4.0.sqlite3.lock} +0 -0
- data/gemfiles/{Gemfile.4.1 → Gemfile.4.1.sqlite3} +0 -0
- data/gemfiles/{Gemfile.4.1.lock → Gemfile.4.1.sqlite3.lock} +0 -0
- data/gemfiles/Gemfile.4.2.1.mysql2 +7 -0
- data/gemfiles/Gemfile.4.2.1.mysql2.lock +52 -0
- data/gemfiles/{Gemfile.4.2.1 → Gemfile.4.2.1.sqlite3} +0 -0
- data/gemfiles/{Gemfile.4.2.1.lock → Gemfile.4.2.1.sqlite3.lock} +0 -0
- data/lib/active_type/type_caster.rb +2 -2
- data/lib/active_type/version.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/database.rb +23 -9
- data/spec/support/database.sample.yml +3 -0
- metadata +16 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 246492245829189c234439a8edd6332010b65cb1
|
|
4
|
+
data.tar.gz: 8f1067dcb972089bbee267c147b17782513795f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30e1c1b46bbb13e3ea56700c001e756d6f7321ab9148f7aec98875114a49549cefe9bb03a888b3ed137632698aa15c933ddfc690abef9b0e67e36fddfd0ba928
|
|
7
|
+
data.tar.gz: 6e507ab9b563b8830a031f090cc05a8e1b5b3c4202ed7ce8029eaf61f4fddc183e21414267f6ae3c6fc46e1f58252273ce9396e710a33b2d8317183567fba5a5
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -6,13 +6,16 @@ rvm:
|
|
|
6
6
|
- "2.1.2"
|
|
7
7
|
- "2.2.0"
|
|
8
8
|
gemfile:
|
|
9
|
-
- gemfiles/Gemfile.3.2
|
|
10
|
-
- gemfiles/Gemfile.
|
|
11
|
-
- gemfiles/Gemfile.4.
|
|
12
|
-
- gemfiles/Gemfile.4.
|
|
9
|
+
- gemfiles/Gemfile.3.2.mysql2
|
|
10
|
+
- gemfiles/Gemfile.3.2.sqlite3
|
|
11
|
+
- gemfiles/Gemfile.4.0.sqlite3
|
|
12
|
+
- gemfiles/Gemfile.4.1.sqlite3
|
|
13
|
+
- gemfiles/Gemfile.4.2.1.mysql2
|
|
13
14
|
- gemfiles/Gemfile.4.2.1.pg
|
|
15
|
+
- gemfiles/Gemfile.4.2.1.sqlite3
|
|
14
16
|
before_script:
|
|
15
17
|
- psql -c 'create database active_type_test;' -U postgres
|
|
18
|
+
- mysql -e 'create database IF NOT EXISTS active_type_test;'
|
|
16
19
|
script: bundle exec rspec spec
|
|
17
20
|
notifications:
|
|
18
21
|
email:
|
|
@@ -23,24 +26,28 @@ branches:
|
|
|
23
26
|
matrix:
|
|
24
27
|
exclude:
|
|
25
28
|
- rvm: "1.8.7"
|
|
26
|
-
gemfile: gemfiles/Gemfile.4.0
|
|
29
|
+
gemfile: gemfiles/Gemfile.4.0.sqlite3
|
|
27
30
|
- rvm: "1.8.7"
|
|
28
|
-
gemfile: gemfiles/Gemfile.4.1
|
|
31
|
+
gemfile: gemfiles/Gemfile.4.1.sqlite3
|
|
29
32
|
- rvm: "1.8.7"
|
|
30
|
-
gemfile: gemfiles/Gemfile.4.2.1
|
|
33
|
+
gemfile: gemfiles/Gemfile.4.2.1.sqlite3
|
|
34
|
+
- rvm: "1.8.7"
|
|
35
|
+
gemfile: gemfiles/Gemfile.4.2.1.mysql2
|
|
31
36
|
- rvm: "1.8.7"
|
|
32
37
|
gemfile: gemfiles/Gemfile.4.2.1.pg
|
|
38
|
+
- rvm: "1.9.3"
|
|
39
|
+
gemfile: gemfiles/Gemfile.4.2.1.mysql2
|
|
33
40
|
- rvm: "1.9.3"
|
|
34
41
|
gemfile: gemfiles/Gemfile.4.2.1.pg
|
|
42
|
+
- rvm: "2.0.0"
|
|
43
|
+
gemfile: gemfiles/Gemfile.4.2.1.mysql2
|
|
35
44
|
- rvm: "2.0.0"
|
|
36
45
|
gemfile: gemfiles/Gemfile.4.2.1.pg
|
|
37
|
-
|
|
38
46
|
- rvm: "2.1.2"
|
|
39
|
-
gemfile: gemfiles/Gemfile.
|
|
40
|
-
- rvm: "2.
|
|
41
|
-
gemfile: gemfiles/Gemfile.
|
|
42
|
-
|
|
47
|
+
gemfile: gemfiles/Gemfile.4.0.sqlite3
|
|
48
|
+
- rvm: "2.2.0"
|
|
49
|
+
gemfile: gemfiles/Gemfile.3.2.sqlite3
|
|
43
50
|
- rvm: "2.2.0"
|
|
44
|
-
gemfile: gemfiles/Gemfile.3.2
|
|
51
|
+
gemfile: gemfiles/Gemfile.3.2.mysql2
|
|
45
52
|
- rvm: "2.2.0"
|
|
46
|
-
gemfile: gemfiles/Gemfile.4.0
|
|
53
|
+
gemfile: gemfiles/Gemfile.4.0.sqlite3
|
data/README.md
CHANGED
|
@@ -193,7 +193,7 @@ end
|
|
|
193
193
|
|
|
194
194
|
- You have to say `nests_many :records`
|
|
195
195
|
- `records` will be validated and saved automatically
|
|
196
|
-
- The generated `.records_attributes =` expects parameters like `ActiveRecord`'s nested attributes, and
|
|
196
|
+
- The generated `.records_attributes =` expects parameters like `ActiveRecord`'s nested attributes, and works together with the `fields_for` helper:
|
|
197
197
|
|
|
198
198
|
- either as a hash (where the keys are meaningless)
|
|
199
199
|
|
|
@@ -335,6 +335,9 @@ Development
|
|
|
335
335
|
- You can run specs against all versions with `rake all:spec`.
|
|
336
336
|
- You can run specs against a single version with `VERSION=4.0 rake`.
|
|
337
337
|
|
|
338
|
+
If you are getting testing failures due to Mysql trying to connect as `root` user, you can put your Mysql credentials into `spec/support/database.yml`.
|
|
339
|
+
See `spec/support/database.sample.yml` for an example.
|
|
340
|
+
|
|
338
341
|
If you would like to contribute:
|
|
339
342
|
|
|
340
343
|
- Fork the repository.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
active_type (0.4.2)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (3.2.22)
|
|
11
|
+
activesupport (= 3.2.22)
|
|
12
|
+
builder (~> 3.0.0)
|
|
13
|
+
activerecord (3.2.22)
|
|
14
|
+
activemodel (= 3.2.22)
|
|
15
|
+
activesupport (= 3.2.22)
|
|
16
|
+
arel (~> 3.0.2)
|
|
17
|
+
tzinfo (~> 0.3.29)
|
|
18
|
+
activesupport (3.2.22)
|
|
19
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
20
|
+
multi_json (~> 1.0)
|
|
21
|
+
arel (3.0.3)
|
|
22
|
+
builder (3.0.4)
|
|
23
|
+
diff-lcs (1.2.5)
|
|
24
|
+
i18n (0.6.11)
|
|
25
|
+
multi_json (1.11.2)
|
|
26
|
+
mysql2 (0.3.11)
|
|
27
|
+
rspec (2.14.1)
|
|
28
|
+
rspec-core (~> 2.14.0)
|
|
29
|
+
rspec-expectations (~> 2.14.0)
|
|
30
|
+
rspec-mocks (~> 2.14.0)
|
|
31
|
+
rspec-core (2.14.8)
|
|
32
|
+
rspec-expectations (2.14.5)
|
|
33
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
34
|
+
rspec-mocks (2.14.6)
|
|
35
|
+
tzinfo (0.3.45)
|
|
36
|
+
|
|
37
|
+
PLATFORMS
|
|
38
|
+
ruby
|
|
39
|
+
|
|
40
|
+
DEPENDENCIES
|
|
41
|
+
active_type!
|
|
42
|
+
activerecord (= 3.2.22)
|
|
43
|
+
i18n (= 0.6.11)
|
|
44
|
+
mysql2 (= 0.3.11)
|
|
45
|
+
rspec (< 2.99)
|
|
46
|
+
|
|
47
|
+
BUNDLED WITH
|
|
48
|
+
1.10.6
|
|
@@ -7,15 +7,15 @@ PATH
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
activemodel (3.2.
|
|
11
|
-
activesupport (= 3.2.
|
|
10
|
+
activemodel (3.2.22)
|
|
11
|
+
activesupport (= 3.2.22)
|
|
12
12
|
builder (~> 3.0.0)
|
|
13
|
-
activerecord (3.2.
|
|
14
|
-
activemodel (= 3.2.
|
|
15
|
-
activesupport (= 3.2.
|
|
13
|
+
activerecord (3.2.22)
|
|
14
|
+
activemodel (= 3.2.22)
|
|
15
|
+
activesupport (= 3.2.22)
|
|
16
16
|
arel (~> 3.0.2)
|
|
17
17
|
tzinfo (~> 0.3.29)
|
|
18
|
-
activesupport (3.2.
|
|
18
|
+
activesupport (3.2.22)
|
|
19
19
|
i18n (~> 0.6, >= 0.6.4)
|
|
20
20
|
multi_json (~> 1.0)
|
|
21
21
|
arel (3.0.3)
|
|
@@ -39,7 +39,10 @@ PLATFORMS
|
|
|
39
39
|
|
|
40
40
|
DEPENDENCIES
|
|
41
41
|
active_type!
|
|
42
|
-
activerecord (
|
|
42
|
+
activerecord (= 3.2.22)
|
|
43
43
|
i18n (= 0.6.11)
|
|
44
44
|
rspec (< 2.99)
|
|
45
45
|
sqlite3
|
|
46
|
+
|
|
47
|
+
BUNDLED WITH
|
|
48
|
+
1.10.6
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
active_type (0.4.2)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (4.2.1)
|
|
11
|
+
activesupport (= 4.2.1)
|
|
12
|
+
builder (~> 3.1)
|
|
13
|
+
activerecord (4.2.1)
|
|
14
|
+
activemodel (= 4.2.1)
|
|
15
|
+
activesupport (= 4.2.1)
|
|
16
|
+
arel (~> 6.0)
|
|
17
|
+
activesupport (4.2.1)
|
|
18
|
+
i18n (~> 0.7)
|
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
|
20
|
+
minitest (~> 5.1)
|
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
22
|
+
tzinfo (~> 1.1)
|
|
23
|
+
arel (6.0.0)
|
|
24
|
+
builder (3.2.2)
|
|
25
|
+
diff-lcs (1.2.5)
|
|
26
|
+
i18n (0.7.0)
|
|
27
|
+
json (1.8.3)
|
|
28
|
+
minitest (5.7.0)
|
|
29
|
+
mysql2 (0.3.20)
|
|
30
|
+
rspec (2.14.1)
|
|
31
|
+
rspec-core (~> 2.14.0)
|
|
32
|
+
rspec-expectations (~> 2.14.0)
|
|
33
|
+
rspec-mocks (~> 2.14.0)
|
|
34
|
+
rspec-core (2.14.8)
|
|
35
|
+
rspec-expectations (2.14.5)
|
|
36
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
37
|
+
rspec-mocks (2.14.6)
|
|
38
|
+
thread_safe (0.3.5)
|
|
39
|
+
tzinfo (1.2.2)
|
|
40
|
+
thread_safe (~> 0.1)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
ruby
|
|
44
|
+
|
|
45
|
+
DEPENDENCIES
|
|
46
|
+
active_type!
|
|
47
|
+
activerecord (~> 4.2.1)
|
|
48
|
+
mysql2 (~> 0.3.17)
|
|
49
|
+
rspec (< 2.99)
|
|
50
|
+
|
|
51
|
+
BUNDLED WITH
|
|
52
|
+
1.10.6
|
|
File without changes
|
|
File without changes
|
|
@@ -68,8 +68,8 @@ module ActiveType
|
|
|
68
68
|
# The specified type (e.g. "string") may not necessary match the
|
|
69
69
|
# native type ("varchar") expected by the connection adapter.
|
|
70
70
|
# PostgreSQL is one of these. Perform a translation if the adapter
|
|
71
|
-
# supports it.
|
|
72
|
-
if !type.nil? && connection.respond_to?(:native_database_types)
|
|
71
|
+
# supports it (but don't turn a mysql boolean into a tinyint).
|
|
72
|
+
if !type.nil? && !(type == :boolean) && connection.respond_to?(:native_database_types)
|
|
73
73
|
native_type = connection.native_database_types[type.to_sym]
|
|
74
74
|
if native_type && native_type[:name]
|
|
75
75
|
type = native_type[:name]
|
data/lib/active_type/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -6,8 +6,8 @@ require 'active_type'
|
|
|
6
6
|
|
|
7
7
|
ActiveRecord::Base.default_timezone = :local
|
|
8
8
|
|
|
9
|
-
Dir["#{File.dirname(__FILE__)}/support
|
|
10
|
-
Dir["#{File.dirname(__FILE__)}/shared_examples
|
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/*.rb"].each {|f| require f}
|
|
10
|
+
Dir["#{File.dirname(__FILE__)}/shared_examples/*.rb"].each {|f| require f}
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
RSpec.configure do |config|
|
data/spec/support/database.rb
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
# pg?
|
|
4
|
+
case ENV['BUNDLE_GEMFILE']
|
|
5
|
+
when /pg/
|
|
6
6
|
if ENV['TRAVIS']
|
|
7
7
|
ActiveRecord::Base.establish_connection(:adapter => 'postgresql', :database => 'active_type_test', :username => 'postgres')
|
|
8
8
|
else
|
|
9
9
|
ActiveRecord::Base.establish_connection(:adapter => 'postgresql', :database => 'active_type_test')
|
|
10
10
|
end
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
# mysql2?
|
|
12
|
+
when /mysql2/
|
|
13
|
+
config = { :adapter => 'mysql2', :encoding => 'utf8', :database => 'active_type_test' }
|
|
14
|
+
custom_config_path = File.join(File.dirname(__FILE__), 'database.yml')
|
|
15
|
+
if File.exists?(custom_config_path)
|
|
16
|
+
custom_config = YAML.load_file(custom_config_path)
|
|
17
|
+
config.merge!(custom_config)
|
|
15
18
|
end
|
|
19
|
+
ActiveRecord::Base.establish_connection(config)
|
|
20
|
+
when /sqlite3/
|
|
21
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
|
22
|
+
else
|
|
23
|
+
raise "Unknown database type in Gemfile suffix: #{ENV['BUNDLE_GEMFILE']}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
connection = ::ActiveRecord::Base.connection
|
|
28
|
+
connection.tables.each do |table|
|
|
29
|
+
connection.drop_table table
|
|
16
30
|
end
|
|
17
31
|
|
|
18
32
|
ActiveRecord::Migration.class_eval do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Kraze
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2015-
|
|
12
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -67,16 +67,20 @@ files:
|
|
|
67
67
|
- README.md
|
|
68
68
|
- Rakefile
|
|
69
69
|
- active_type.gemspec
|
|
70
|
-
- gemfiles/Gemfile.3.2
|
|
71
|
-
- gemfiles/Gemfile.3.2.lock
|
|
72
|
-
- gemfiles/Gemfile.
|
|
73
|
-
- gemfiles/Gemfile.
|
|
74
|
-
- gemfiles/Gemfile.4.
|
|
75
|
-
- gemfiles/Gemfile.4.
|
|
76
|
-
- gemfiles/Gemfile.4.
|
|
77
|
-
- gemfiles/Gemfile.4.
|
|
70
|
+
- gemfiles/Gemfile.3.2.mysql2
|
|
71
|
+
- gemfiles/Gemfile.3.2.mysql2.lock
|
|
72
|
+
- gemfiles/Gemfile.3.2.sqlite3
|
|
73
|
+
- gemfiles/Gemfile.3.2.sqlite3.lock
|
|
74
|
+
- gemfiles/Gemfile.4.0.sqlite3
|
|
75
|
+
- gemfiles/Gemfile.4.0.sqlite3.lock
|
|
76
|
+
- gemfiles/Gemfile.4.1.sqlite3
|
|
77
|
+
- gemfiles/Gemfile.4.1.sqlite3.lock
|
|
78
|
+
- gemfiles/Gemfile.4.2.1.mysql2
|
|
79
|
+
- gemfiles/Gemfile.4.2.1.mysql2.lock
|
|
78
80
|
- gemfiles/Gemfile.4.2.1.pg
|
|
79
81
|
- gemfiles/Gemfile.4.2.1.pg.lock
|
|
82
|
+
- gemfiles/Gemfile.4.2.1.sqlite3
|
|
83
|
+
- gemfiles/Gemfile.4.2.1.sqlite3.lock
|
|
80
84
|
- lib/active_type.rb
|
|
81
85
|
- lib/active_type/extended_record.rb
|
|
82
86
|
- lib/active_type/extended_record/inheritance.rb
|
|
@@ -112,6 +116,7 @@ files:
|
|
|
112
116
|
- spec/shared_examples/mass_assignment.rb
|
|
113
117
|
- spec/spec_helper.rb
|
|
114
118
|
- spec/support/database.rb
|
|
119
|
+
- spec/support/database.sample.yml
|
|
115
120
|
- spec/support/error_on.rb
|
|
116
121
|
- spec/support/i18n.rb
|
|
117
122
|
- spec/support/protected_params.rb
|
|
@@ -161,6 +166,7 @@ test_files:
|
|
|
161
166
|
- spec/shared_examples/mass_assignment.rb
|
|
162
167
|
- spec/spec_helper.rb
|
|
163
168
|
- spec/support/database.rb
|
|
169
|
+
- spec/support/database.sample.yml
|
|
164
170
|
- spec/support/error_on.rb
|
|
165
171
|
- spec/support/i18n.rb
|
|
166
172
|
- spec/support/protected_params.rb
|