gigo-activerecord 1.5.0 → 2.0.0
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 +5 -5
- data/Appraisals +9 -9
- data/README.md +4 -5
- data/Rakefile +2 -1
- data/gemfiles/activerecord50.gemfile +8 -0
- data/gemfiles/activerecord50.gemfile.lock +54 -0
- data/gemfiles/activerecord51.gemfile +8 -0
- data/gemfiles/activerecord51.gemfile.lock +54 -0
- data/gemfiles/activerecord52.gemfile +8 -0
- data/gemfiles/activerecord52.gemfile.lock +54 -0
- data/gigo-activerecord.gemspec +1 -1
- data/lib/gigo/active_record/base.rb +51 -81
- data/lib/gigo/active_record/version.rb +1 -1
- data/test/cases/all_test.rb +5 -15
- data/test/sqlite3_monkey_patch.rb +29 -0
- data/test/test_helper.rb +2 -6
- metadata +11 -17
- data/gemfiles/activerecord32.gemfile +0 -7
- data/gemfiles/activerecord32.gemfile.lock +0 -49
- data/gemfiles/activerecord40.gemfile +0 -7
- data/gemfiles/activerecord40.gemfile.lock +0 -54
- data/gemfiles/activerecord41.gemfile +0 -7
- data/gemfiles/activerecord41.gemfile.lock +0 -53
- data/gemfiles/activerecord42.gemfile +0 -7
- data/gemfiles/activerecord42.gemfile.lock +0 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3eafc54a48e75b749aa622b82dc90ca91dcd393aefd6278ec6cfa194d627fb8b
|
|
4
|
+
data.tar.gz: fba7450a03c3b57bda71af5b697b038d8b2e94de232205989d411a663c87fb63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e89d1e55975fce1f8505fd38b7e10cee5f55a1f3fa98df819cade7ddc5a8c8cf9955a427377cbabd5023d101d8fde5eddd86956a4a800251b0dc2e2185f8be0c
|
|
7
|
+
data.tar.gz: fc28f06e1c753dfb7b78edf86cca2c396ad118d3d9d13191711628c4237f0f6266d8a92672191bb62d6f2acb6721926522f841293a8f44e2fd2b0c6ded10349f
|
data/Appraisals
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
appraise '
|
|
3
|
-
gem 'activerecord', '~>
|
|
2
|
+
appraise 'activerecord50' do
|
|
3
|
+
gem 'activerecord', '~> 5.0.0'
|
|
4
|
+
gem 'sqlite3', '~> 1.3.6'
|
|
4
5
|
end
|
|
5
6
|
|
|
6
|
-
appraise '
|
|
7
|
-
gem 'activerecord', '
|
|
7
|
+
appraise 'activerecord51' do
|
|
8
|
+
gem 'activerecord', '~> 5.1.0'
|
|
9
|
+
gem 'sqlite3', '~> 1.3.6'
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
appraise '
|
|
11
|
-
gem 'activerecord', '~>
|
|
12
|
+
appraise 'activerecord52' do
|
|
13
|
+
gem 'activerecord', '~> 5.2.0'
|
|
14
|
+
gem 'sqlite3', '~> 1.3.6'
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
appraise 'activerecord42' do
|
|
15
|
-
gem 'activerecord', '~> 4.2.0'
|
|
16
|
-
end
|
data/README.md
CHANGED
|
@@ -59,15 +59,14 @@ Sometimes your serialized attributes need GIGO before loading the YAML.
|
|
|
59
59
|
|
|
60
60
|
```ruby
|
|
61
61
|
class Order < ActiveRecord::Base
|
|
62
|
-
serialize :notes, Hash
|
|
63
|
-
gigo_serialized_attribute :notes
|
|
62
|
+
serialize :notes, gigo_coder_for(Hash)
|
|
64
63
|
end
|
|
65
64
|
```
|
|
66
65
|
|
|
67
66
|
|
|
68
67
|
## Contributing
|
|
69
68
|
|
|
70
|
-
GIGO is fully tested with ActiveRecord
|
|
69
|
+
GIGO is fully tested with ActiveRecord 5 and upward. If you detect a problem, open up a github issue or fork the repo and help out. After you fork or clone the repository, the following commands will get you up and running on the test suite.
|
|
71
70
|
|
|
72
71
|
```shell
|
|
73
72
|
$ bundle install
|
|
@@ -75,8 +74,8 @@ $ bundle exec appraisal install
|
|
|
75
74
|
$ bundle exec appraisal rake test
|
|
76
75
|
```
|
|
77
76
|
|
|
78
|
-
We use the [appraisal](https://github.com/thoughtbot/appraisal) gem from Thoughtbot to help us generate the individual Gemfiles for each ActiveSupport version and to run the tests locally against each generated Gemfile. The `rake appraisal test` command actually runs our test suite against all Rails versions in our `Appraisal` file. If you want to run the tests for a specific Rails version, use `rake -T` for a list. For example, the following command will run the tests for Rails
|
|
77
|
+
We use the [appraisal](https://github.com/thoughtbot/appraisal) gem from Thoughtbot to help us generate the individual Gemfiles for each ActiveSupport version and to run the tests locally against each generated Gemfile. The `rake appraisal test` command actually runs our test suite against all Rails versions in our `Appraisal` file. If you want to run the tests for a specific Rails version, use `rake -T` for a list. For example, the following command will run the tests for Rails 5 only.
|
|
79
78
|
|
|
80
79
|
```shell
|
|
81
|
-
$ bundle exec appraisal
|
|
80
|
+
$ bundle exec appraisal activerecord50 rake test
|
|
82
81
|
```
|
data/Rakefile
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
gigo-activerecord (2.0.0)
|
|
5
|
+
activerecord (>= 5.0)
|
|
6
|
+
gigo
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activemodel (5.0.7.2)
|
|
12
|
+
activesupport (= 5.0.7.2)
|
|
13
|
+
activerecord (5.0.7.2)
|
|
14
|
+
activemodel (= 5.0.7.2)
|
|
15
|
+
activesupport (= 5.0.7.2)
|
|
16
|
+
arel (~> 7.0)
|
|
17
|
+
activesupport (5.0.7.2)
|
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
19
|
+
i18n (>= 0.7, < 2)
|
|
20
|
+
minitest (~> 5.1)
|
|
21
|
+
tzinfo (~> 1.1)
|
|
22
|
+
appraisal (2.2.0)
|
|
23
|
+
bundler
|
|
24
|
+
rake
|
|
25
|
+
thor (>= 0.14.0)
|
|
26
|
+
arel (7.1.4)
|
|
27
|
+
concurrent-ruby (1.1.5)
|
|
28
|
+
ensure_valid_encoding (0.5.3)
|
|
29
|
+
gigo (2.2.0)
|
|
30
|
+
activesupport (>= 2.3)
|
|
31
|
+
ensure_valid_encoding (~> 0.5.3)
|
|
32
|
+
i18n (1.6.0)
|
|
33
|
+
concurrent-ruby (~> 1.0)
|
|
34
|
+
minitest (5.11.3)
|
|
35
|
+
rake (12.3.2)
|
|
36
|
+
sqlite3 (1.3.13)
|
|
37
|
+
thor (0.20.3)
|
|
38
|
+
thread_safe (0.3.6)
|
|
39
|
+
tzinfo (1.2.5)
|
|
40
|
+
thread_safe (~> 0.1)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
ruby
|
|
44
|
+
|
|
45
|
+
DEPENDENCIES
|
|
46
|
+
activerecord (~> 5.0.0)
|
|
47
|
+
appraisal
|
|
48
|
+
gigo-activerecord!
|
|
49
|
+
minitest
|
|
50
|
+
rake
|
|
51
|
+
sqlite3 (~> 1.3.6)
|
|
52
|
+
|
|
53
|
+
BUNDLED WITH
|
|
54
|
+
1.17.3
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
gigo-activerecord (2.0.0)
|
|
5
|
+
activerecord (>= 5.0)
|
|
6
|
+
gigo
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activemodel (5.1.7)
|
|
12
|
+
activesupport (= 5.1.7)
|
|
13
|
+
activerecord (5.1.7)
|
|
14
|
+
activemodel (= 5.1.7)
|
|
15
|
+
activesupport (= 5.1.7)
|
|
16
|
+
arel (~> 8.0)
|
|
17
|
+
activesupport (5.1.7)
|
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
19
|
+
i18n (>= 0.7, < 2)
|
|
20
|
+
minitest (~> 5.1)
|
|
21
|
+
tzinfo (~> 1.1)
|
|
22
|
+
appraisal (2.2.0)
|
|
23
|
+
bundler
|
|
24
|
+
rake
|
|
25
|
+
thor (>= 0.14.0)
|
|
26
|
+
arel (8.0.0)
|
|
27
|
+
concurrent-ruby (1.1.5)
|
|
28
|
+
ensure_valid_encoding (0.5.3)
|
|
29
|
+
gigo (2.2.0)
|
|
30
|
+
activesupport (>= 2.3)
|
|
31
|
+
ensure_valid_encoding (~> 0.5.3)
|
|
32
|
+
i18n (1.6.0)
|
|
33
|
+
concurrent-ruby (~> 1.0)
|
|
34
|
+
minitest (5.11.3)
|
|
35
|
+
rake (12.3.2)
|
|
36
|
+
sqlite3 (1.3.13)
|
|
37
|
+
thor (0.20.3)
|
|
38
|
+
thread_safe (0.3.6)
|
|
39
|
+
tzinfo (1.2.5)
|
|
40
|
+
thread_safe (~> 0.1)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
ruby
|
|
44
|
+
|
|
45
|
+
DEPENDENCIES
|
|
46
|
+
activerecord (~> 5.1.0)
|
|
47
|
+
appraisal
|
|
48
|
+
gigo-activerecord!
|
|
49
|
+
minitest
|
|
50
|
+
rake
|
|
51
|
+
sqlite3 (~> 1.3.6)
|
|
52
|
+
|
|
53
|
+
BUNDLED WITH
|
|
54
|
+
1.17.3
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
gigo-activerecord (2.0.0)
|
|
5
|
+
activerecord (>= 5.0)
|
|
6
|
+
gigo
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activemodel (5.2.3)
|
|
12
|
+
activesupport (= 5.2.3)
|
|
13
|
+
activerecord (5.2.3)
|
|
14
|
+
activemodel (= 5.2.3)
|
|
15
|
+
activesupport (= 5.2.3)
|
|
16
|
+
arel (>= 9.0)
|
|
17
|
+
activesupport (5.2.3)
|
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
19
|
+
i18n (>= 0.7, < 2)
|
|
20
|
+
minitest (~> 5.1)
|
|
21
|
+
tzinfo (~> 1.1)
|
|
22
|
+
appraisal (2.2.0)
|
|
23
|
+
bundler
|
|
24
|
+
rake
|
|
25
|
+
thor (>= 0.14.0)
|
|
26
|
+
arel (9.0.0)
|
|
27
|
+
concurrent-ruby (1.1.5)
|
|
28
|
+
ensure_valid_encoding (0.5.3)
|
|
29
|
+
gigo (2.2.0)
|
|
30
|
+
activesupport (>= 2.3)
|
|
31
|
+
ensure_valid_encoding (~> 0.5.3)
|
|
32
|
+
i18n (1.6.0)
|
|
33
|
+
concurrent-ruby (~> 1.0)
|
|
34
|
+
minitest (5.11.3)
|
|
35
|
+
rake (12.3.2)
|
|
36
|
+
sqlite3 (1.3.13)
|
|
37
|
+
thor (0.20.3)
|
|
38
|
+
thread_safe (0.3.6)
|
|
39
|
+
tzinfo (1.2.5)
|
|
40
|
+
thread_safe (~> 0.1)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
ruby
|
|
44
|
+
|
|
45
|
+
DEPENDENCIES
|
|
46
|
+
activerecord (~> 5.2.0)
|
|
47
|
+
appraisal
|
|
48
|
+
gigo-activerecord!
|
|
49
|
+
minitest
|
|
50
|
+
rake
|
|
51
|
+
sqlite3 (~> 1.3.6)
|
|
52
|
+
|
|
53
|
+
BUNDLED WITH
|
|
54
|
+
1.17.3
|
data/gigo-activerecord.gemspec
CHANGED
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
spec.require_paths = ["lib"]
|
|
19
19
|
spec.add_runtime_dependency 'gigo'
|
|
20
|
-
spec.add_runtime_dependency 'activerecord', '>=
|
|
20
|
+
spec.add_runtime_dependency 'activerecord', '>= 5.0'
|
|
21
21
|
spec.add_development_dependency 'appraisal'
|
|
22
22
|
spec.add_development_dependency 'rake'
|
|
23
23
|
spec.add_development_dependency 'minitest'
|
|
@@ -1,107 +1,77 @@
|
|
|
1
1
|
module GIGO
|
|
2
2
|
module ActiveRecord
|
|
3
3
|
module Base
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
m = const_set(:GIGOColumns, Module.new)
|
|
13
|
-
include m
|
|
14
|
-
m
|
|
15
|
-
end
|
|
4
|
+
def gigo_column(*attrs)
|
|
5
|
+
mod = begin
|
|
6
|
+
if const_defined?(:GIGOColumns)
|
|
7
|
+
const_get(:GIGOColumns)
|
|
8
|
+
else
|
|
9
|
+
m = const_set(:GIGOColumns, Module.new)
|
|
10
|
+
include m
|
|
11
|
+
m
|
|
16
12
|
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
end
|
|
14
|
+
attrs.each do |attr|
|
|
15
|
+
mod.module_eval <<-CODE, __FILE__, __LINE__
|
|
16
|
+
def #{attr}
|
|
17
|
+
begin
|
|
18
|
+
GIGO.load(super)
|
|
19
|
+
rescue NoMethodError, ActiveModel::MissingAttributeError
|
|
20
|
+
nil
|
|
25
21
|
end
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
end
|
|
23
|
+
CODE
|
|
28
24
|
end
|
|
25
|
+
end
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
def gigo_columns(*excepts)
|
|
28
|
+
cols = columns.select{ |c| c.type == :string || c.type == :text }.map{ |c| c.name.to_s } - excepts.map(&:to_s)
|
|
29
|
+
gigo_column(*cols)
|
|
30
|
+
end
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
private :gigoize_attributes
|
|
32
|
+
def after_initialize_gigoize_attributes
|
|
33
|
+
after_initialize :gigoize_attributes
|
|
34
|
+
define_method :gigoize_attributes do
|
|
35
|
+
self.class.const_get(:GIGOColumns).instance_methods.each { |name| self.send(name) }
|
|
41
36
|
end
|
|
42
|
-
|
|
37
|
+
private :gigoize_attributes
|
|
43
38
|
end
|
|
44
39
|
|
|
45
|
-
|
|
40
|
+
def gigo_coder_for(klass)
|
|
41
|
+
GigoCoder.new(klass)
|
|
42
|
+
end
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
class GigoCoder
|
|
45
|
+
attr_reader :klass
|
|
48
46
|
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
def initialize(klass)
|
|
48
|
+
@klass = klass
|
|
49
|
+
@default_internal = Encoding.default_internal
|
|
52
50
|
end
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
begin
|
|
61
|
-
existing_encoding = Encoding.default_internal
|
|
62
|
-
Encoding.default_internal = GIGO.encoding
|
|
63
|
-
s = GIGO.load(string)
|
|
64
|
-
YAML::load(s) rescue s
|
|
65
|
-
ensure
|
|
66
|
-
Encoding.default_internal = existing_encoding
|
|
67
|
-
end
|
|
52
|
+
def load(yaml)
|
|
53
|
+
return klass.new if yaml.nil?
|
|
54
|
+
Encoding.default_internal = GIGO.encoding
|
|
55
|
+
value = YAML.load(GIGO.load(yaml))
|
|
56
|
+
unless value.is_a?(klass)
|
|
57
|
+
raise SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{hash.class}."
|
|
68
58
|
end
|
|
69
|
-
|
|
59
|
+
value
|
|
60
|
+
ensure
|
|
61
|
+
Encoding.default_internal = @default_internal
|
|
70
62
|
end
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
include Shared
|
|
77
|
-
|
|
78
|
-
def gigo_serialized_attribute(*attrs)
|
|
79
|
-
attrs.each do |attr|
|
|
80
|
-
yaml_column = self.serialized_attributes[attr.to_s]
|
|
81
|
-
next unless yaml_column
|
|
82
|
-
yaml_column.class_eval do
|
|
83
|
-
def load_with_gigo(yaml)
|
|
84
|
-
existing_encoding = Encoding.default_internal
|
|
85
|
-
Encoding.default_internal = GIGO.encoding
|
|
86
|
-
yaml = GIGO.load(yaml)
|
|
87
|
-
load_without_gigo(yaml)
|
|
88
|
-
ensure
|
|
89
|
-
Encoding.default_internal = existing_encoding
|
|
90
|
-
end
|
|
91
|
-
alias_method_chain :load, :gigo
|
|
92
|
-
end
|
|
64
|
+
def dump(value)
|
|
65
|
+
return klass.new.to_yaml if value.nil?
|
|
66
|
+
unless value.is_a?(klass)
|
|
67
|
+
raise SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}."
|
|
93
68
|
end
|
|
69
|
+
value.to_yaml
|
|
94
70
|
end
|
|
95
|
-
|
|
96
71
|
end
|
|
97
|
-
|
|
98
72
|
end
|
|
99
73
|
end
|
|
100
74
|
end
|
|
101
75
|
|
|
102
|
-
|
|
103
|
-
ActiveRecord::Base.extend GIGO::ActiveRecord::Base::ThreeOhOnly
|
|
104
|
-
else
|
|
105
|
-
ActiveRecord::Base.extend GIGO::ActiveRecord::Base::ThreeOneAndUp
|
|
106
|
-
end
|
|
76
|
+
ActiveRecord::Base.extend GIGO::ActiveRecord::Base
|
|
107
77
|
|
data/test/cases/all_test.rb
CHANGED
|
@@ -5,7 +5,7 @@ module GIGO
|
|
|
5
5
|
module ActiveRecord
|
|
6
6
|
class AllTest < TestCase
|
|
7
7
|
|
|
8
|
-
describe '
|
|
8
|
+
describe 'gigo_coder_for' do
|
|
9
9
|
|
|
10
10
|
before { user_data_utf8 ; user_data_cp1252 ; user_data_binary ; user_data_iso8859 }
|
|
11
11
|
|
|
@@ -45,24 +45,14 @@ module GIGO
|
|
|
45
45
|
|
|
46
46
|
it 'allows serialized attribute to still work with nil/defaults' do
|
|
47
47
|
user = UserGIGO.new
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
user.reload.notes.must_be_nil
|
|
52
|
-
else
|
|
53
|
-
user.notes.must_equal Hash.new
|
|
54
|
-
user.save
|
|
55
|
-
user.reload.notes.must_equal Hash.new
|
|
56
|
-
end
|
|
48
|
+
user.notes.must_equal Hash.new
|
|
49
|
+
user.save
|
|
50
|
+
user.reload.notes.must_equal Hash.new
|
|
57
51
|
end
|
|
58
52
|
|
|
59
53
|
it 'allows serialized attribute to still work as normal' do
|
|
60
54
|
user = UserGIGO.new
|
|
61
|
-
|
|
62
|
-
user.notes = {:foo => 'bar'}
|
|
63
|
-
else
|
|
64
|
-
user.notes[:foo] = 'bar'
|
|
65
|
-
end
|
|
55
|
+
user.notes[:foo] = 'bar'
|
|
66
56
|
user.save
|
|
67
57
|
user.reload.notes[:foo].must_equal 'bar'
|
|
68
58
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This monkey patch is necessary because adapters with version 5.x and up are smart enough to encode strings
|
|
3
|
+
that come in with Encoding::ASCII-8BIT to Encoding::UTF-8 but others aren't.
|
|
4
|
+
So to mimic the worst case, for example using a bad oracle adapter, we monkey patch the
|
|
5
|
+
SQLite3Adapter to just return the string instead of trying to encode it using utf8.
|
|
6
|
+
=end
|
|
7
|
+
require 'active_record/connection_adapters/sqlite3_adapter'
|
|
8
|
+
|
|
9
|
+
module ActiveRecord
|
|
10
|
+
module ConnectionAdapters
|
|
11
|
+
class SQLite3Adapter < AbstractAdapter
|
|
12
|
+
private
|
|
13
|
+
def _type_cast(value)
|
|
14
|
+
case value
|
|
15
|
+
when BigDecimal
|
|
16
|
+
value.to_f
|
|
17
|
+
when String
|
|
18
|
+
if value.encoding == Encoding::ASCII_8BIT
|
|
19
|
+
value
|
|
20
|
+
else
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'bundler' ; Bundler.require :development, :test
|
|
|
3
3
|
require 'gigo-activerecord'
|
|
4
4
|
require 'minitest/autorun'
|
|
5
5
|
require 'logger'
|
|
6
|
+
require 'sqlite3_monkey_patch'
|
|
6
7
|
|
|
7
8
|
ActiveRecord::Base.logger = Logger.new('/dev/null')
|
|
8
9
|
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
|
|
@@ -50,10 +51,6 @@ module GIGO
|
|
|
50
51
|
|
|
51
52
|
private
|
|
52
53
|
|
|
53
|
-
def activerecord_30?
|
|
54
|
-
::ActiveRecord::VERSION::STRING < '3.1'
|
|
55
|
-
end
|
|
56
|
-
|
|
57
54
|
def setup_schema
|
|
58
55
|
::ActiveRecord::Base.class_eval do
|
|
59
56
|
connection.instance_eval do
|
|
@@ -94,8 +91,7 @@ module GIGO
|
|
|
94
91
|
|
|
95
92
|
class UserGIGO < ::ActiveRecord::Base
|
|
96
93
|
self.table_name = :users
|
|
97
|
-
serialize :notes, Hash
|
|
98
|
-
gigo_serialized_attribute :notes
|
|
94
|
+
serialize :notes, gigo_coder_for(Hash)
|
|
99
95
|
gigo_column :subject
|
|
100
96
|
end
|
|
101
97
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gigo-activerecord
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ken Collins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gigo
|
|
@@ -29,9 +29,6 @@ dependencies:
|
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.0'
|
|
34
|
-
- - "<"
|
|
35
32
|
- !ruby/object:Gem::Version
|
|
36
33
|
version: '5.0'
|
|
37
34
|
type: :runtime
|
|
@@ -39,9 +36,6 @@ dependencies:
|
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
38
|
- - ">="
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
version: '3.0'
|
|
44
|
-
- - "<"
|
|
45
39
|
- !ruby/object:Gem::Version
|
|
46
40
|
version: '5.0'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
@@ -113,20 +107,19 @@ files:
|
|
|
113
107
|
- LICENSE.txt
|
|
114
108
|
- README.md
|
|
115
109
|
- Rakefile
|
|
116
|
-
- gemfiles/
|
|
117
|
-
- gemfiles/
|
|
118
|
-
- gemfiles/
|
|
119
|
-
- gemfiles/
|
|
120
|
-
- gemfiles/
|
|
121
|
-
- gemfiles/
|
|
122
|
-
- gemfiles/activerecord42.gemfile
|
|
123
|
-
- gemfiles/activerecord42.gemfile.lock
|
|
110
|
+
- gemfiles/activerecord50.gemfile
|
|
111
|
+
- gemfiles/activerecord50.gemfile.lock
|
|
112
|
+
- gemfiles/activerecord51.gemfile
|
|
113
|
+
- gemfiles/activerecord51.gemfile.lock
|
|
114
|
+
- gemfiles/activerecord52.gemfile
|
|
115
|
+
- gemfiles/activerecord52.gemfile.lock
|
|
124
116
|
- gigo-activerecord.gemspec
|
|
125
117
|
- lib/gigo-activerecord.rb
|
|
126
118
|
- lib/gigo/active_record.rb
|
|
127
119
|
- lib/gigo/active_record/base.rb
|
|
128
120
|
- lib/gigo/active_record/version.rb
|
|
129
121
|
- test/cases/all_test.rb
|
|
122
|
+
- test/sqlite3_monkey_patch.rb
|
|
130
123
|
- test/test_helper.rb
|
|
131
124
|
homepage: http://github.com/customink/gigo-activerecord
|
|
132
125
|
licenses:
|
|
@@ -148,10 +141,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
148
141
|
version: '0'
|
|
149
142
|
requirements: []
|
|
150
143
|
rubyforge_project:
|
|
151
|
-
rubygems_version: 2.
|
|
144
|
+
rubygems_version: 2.7.3
|
|
152
145
|
signing_key:
|
|
153
146
|
specification_version: 4
|
|
154
147
|
summary: GIGO for ActiveRecord
|
|
155
148
|
test_files:
|
|
156
149
|
- test/cases/all_test.rb
|
|
150
|
+
- test/sqlite3_monkey_patch.rb
|
|
157
151
|
- test/test_helper.rb
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../
|
|
3
|
-
specs:
|
|
4
|
-
gigo-activerecord (1.3.0)
|
|
5
|
-
activerecord (>= 3.0, < 5.0)
|
|
6
|
-
gigo
|
|
7
|
-
|
|
8
|
-
GEM
|
|
9
|
-
remote: https://rubygems.org/
|
|
10
|
-
specs:
|
|
11
|
-
activemodel (3.2.21)
|
|
12
|
-
activesupport (= 3.2.21)
|
|
13
|
-
builder (~> 3.0.0)
|
|
14
|
-
activerecord (3.2.21)
|
|
15
|
-
activemodel (= 3.2.21)
|
|
16
|
-
activesupport (= 3.2.21)
|
|
17
|
-
arel (~> 3.0.2)
|
|
18
|
-
tzinfo (~> 0.3.29)
|
|
19
|
-
activesupport (3.2.21)
|
|
20
|
-
i18n (~> 0.6, >= 0.6.4)
|
|
21
|
-
multi_json (~> 1.0)
|
|
22
|
-
appraisal (1.0.2)
|
|
23
|
-
bundler
|
|
24
|
-
rake
|
|
25
|
-
thor (>= 0.14.0)
|
|
26
|
-
arel (3.0.3)
|
|
27
|
-
builder (3.0.4)
|
|
28
|
-
ensure_valid_encoding (0.5.3)
|
|
29
|
-
gigo (2.0.0)
|
|
30
|
-
activesupport (>= 3.0)
|
|
31
|
-
ensure_valid_encoding (~> 0.5.3)
|
|
32
|
-
i18n (0.7.0)
|
|
33
|
-
minitest (5.5.1)
|
|
34
|
-
multi_json (1.10.1)
|
|
35
|
-
rake (10.4.2)
|
|
36
|
-
sqlite3 (1.3.10)
|
|
37
|
-
thor (0.19.1)
|
|
38
|
-
tzinfo (0.3.43)
|
|
39
|
-
|
|
40
|
-
PLATFORMS
|
|
41
|
-
ruby
|
|
42
|
-
|
|
43
|
-
DEPENDENCIES
|
|
44
|
-
activerecord (~> 3.2.0)
|
|
45
|
-
appraisal
|
|
46
|
-
gigo-activerecord!
|
|
47
|
-
minitest
|
|
48
|
-
rake
|
|
49
|
-
sqlite3
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../
|
|
3
|
-
specs:
|
|
4
|
-
gigo-activerecord (1.3.0)
|
|
5
|
-
activerecord (>= 3.0, < 5.0)
|
|
6
|
-
gigo
|
|
7
|
-
|
|
8
|
-
GEM
|
|
9
|
-
remote: https://rubygems.org/
|
|
10
|
-
specs:
|
|
11
|
-
activemodel (4.0.0)
|
|
12
|
-
activesupport (= 4.0.0)
|
|
13
|
-
builder (~> 3.1.0)
|
|
14
|
-
activerecord (4.0.0)
|
|
15
|
-
activemodel (= 4.0.0)
|
|
16
|
-
activerecord-deprecated_finders (~> 1.0.2)
|
|
17
|
-
activesupport (= 4.0.0)
|
|
18
|
-
arel (~> 4.0.0)
|
|
19
|
-
activerecord-deprecated_finders (1.0.3)
|
|
20
|
-
activesupport (4.0.0)
|
|
21
|
-
i18n (~> 0.6, >= 0.6.4)
|
|
22
|
-
minitest (~> 4.2)
|
|
23
|
-
multi_json (~> 1.3)
|
|
24
|
-
thread_safe (~> 0.1)
|
|
25
|
-
tzinfo (~> 0.3.37)
|
|
26
|
-
appraisal (1.0.2)
|
|
27
|
-
bundler
|
|
28
|
-
rake
|
|
29
|
-
thor (>= 0.14.0)
|
|
30
|
-
arel (4.0.2)
|
|
31
|
-
builder (3.1.4)
|
|
32
|
-
ensure_valid_encoding (0.5.3)
|
|
33
|
-
gigo (2.0.0)
|
|
34
|
-
activesupport (>= 3.0)
|
|
35
|
-
ensure_valid_encoding (~> 0.5.3)
|
|
36
|
-
i18n (0.7.0)
|
|
37
|
-
minitest (4.7.5)
|
|
38
|
-
multi_json (1.10.1)
|
|
39
|
-
rake (10.4.2)
|
|
40
|
-
sqlite3 (1.3.10)
|
|
41
|
-
thor (0.19.1)
|
|
42
|
-
thread_safe (0.3.4)
|
|
43
|
-
tzinfo (0.3.43)
|
|
44
|
-
|
|
45
|
-
PLATFORMS
|
|
46
|
-
ruby
|
|
47
|
-
|
|
48
|
-
DEPENDENCIES
|
|
49
|
-
activerecord (= 4.0.0)
|
|
50
|
-
appraisal
|
|
51
|
-
gigo-activerecord!
|
|
52
|
-
minitest
|
|
53
|
-
rake
|
|
54
|
-
sqlite3
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../
|
|
3
|
-
specs:
|
|
4
|
-
gigo-activerecord (1.3.0)
|
|
5
|
-
activerecord (>= 3.0, < 5.0)
|
|
6
|
-
gigo
|
|
7
|
-
|
|
8
|
-
GEM
|
|
9
|
-
remote: https://rubygems.org/
|
|
10
|
-
specs:
|
|
11
|
-
activemodel (4.1.8)
|
|
12
|
-
activesupport (= 4.1.8)
|
|
13
|
-
builder (~> 3.1)
|
|
14
|
-
activerecord (4.1.8)
|
|
15
|
-
activemodel (= 4.1.8)
|
|
16
|
-
activesupport (= 4.1.8)
|
|
17
|
-
arel (~> 5.0.0)
|
|
18
|
-
activesupport (4.1.8)
|
|
19
|
-
i18n (~> 0.6, >= 0.6.9)
|
|
20
|
-
json (~> 1.7, >= 1.7.7)
|
|
21
|
-
minitest (~> 5.1)
|
|
22
|
-
thread_safe (~> 0.1)
|
|
23
|
-
tzinfo (~> 1.1)
|
|
24
|
-
appraisal (1.0.2)
|
|
25
|
-
bundler
|
|
26
|
-
rake
|
|
27
|
-
thor (>= 0.14.0)
|
|
28
|
-
arel (5.0.1.20140414130214)
|
|
29
|
-
builder (3.2.2)
|
|
30
|
-
ensure_valid_encoding (0.5.3)
|
|
31
|
-
gigo (2.0.0)
|
|
32
|
-
activesupport (>= 3.0)
|
|
33
|
-
ensure_valid_encoding (~> 0.5.3)
|
|
34
|
-
i18n (0.7.0)
|
|
35
|
-
json (1.8.2)
|
|
36
|
-
minitest (5.5.1)
|
|
37
|
-
rake (10.4.2)
|
|
38
|
-
sqlite3 (1.3.10)
|
|
39
|
-
thor (0.19.1)
|
|
40
|
-
thread_safe (0.3.4)
|
|
41
|
-
tzinfo (1.2.2)
|
|
42
|
-
thread_safe (~> 0.1)
|
|
43
|
-
|
|
44
|
-
PLATFORMS
|
|
45
|
-
ruby
|
|
46
|
-
|
|
47
|
-
DEPENDENCIES
|
|
48
|
-
activerecord (~> 4.1.0)
|
|
49
|
-
appraisal
|
|
50
|
-
gigo-activerecord!
|
|
51
|
-
minitest
|
|
52
|
-
rake
|
|
53
|
-
sqlite3
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../
|
|
3
|
-
specs:
|
|
4
|
-
gigo-activerecord (1.3.0)
|
|
5
|
-
activerecord (>= 3.0, < 5.0)
|
|
6
|
-
gigo
|
|
7
|
-
|
|
8
|
-
GEM
|
|
9
|
-
remote: https://rubygems.org/
|
|
10
|
-
specs:
|
|
11
|
-
activemodel (4.2.0)
|
|
12
|
-
activesupport (= 4.2.0)
|
|
13
|
-
builder (~> 3.1)
|
|
14
|
-
activerecord (4.2.0)
|
|
15
|
-
activemodel (= 4.2.0)
|
|
16
|
-
activesupport (= 4.2.0)
|
|
17
|
-
arel (~> 6.0)
|
|
18
|
-
activesupport (4.2.0)
|
|
19
|
-
i18n (~> 0.7)
|
|
20
|
-
json (~> 1.7, >= 1.7.7)
|
|
21
|
-
minitest (~> 5.1)
|
|
22
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
|
23
|
-
tzinfo (~> 1.1)
|
|
24
|
-
appraisal (1.0.2)
|
|
25
|
-
bundler
|
|
26
|
-
rake
|
|
27
|
-
thor (>= 0.14.0)
|
|
28
|
-
arel (6.0.0)
|
|
29
|
-
builder (3.2.2)
|
|
30
|
-
ensure_valid_encoding (0.5.3)
|
|
31
|
-
gigo (2.0.0)
|
|
32
|
-
activesupport (>= 3.0)
|
|
33
|
-
ensure_valid_encoding (~> 0.5.3)
|
|
34
|
-
i18n (0.7.0)
|
|
35
|
-
json (1.8.2)
|
|
36
|
-
minitest (5.5.1)
|
|
37
|
-
rake (10.4.2)
|
|
38
|
-
sqlite3 (1.3.10)
|
|
39
|
-
thor (0.19.1)
|
|
40
|
-
thread_safe (0.3.4)
|
|
41
|
-
tzinfo (1.2.2)
|
|
42
|
-
thread_safe (~> 0.1)
|
|
43
|
-
|
|
44
|
-
PLATFORMS
|
|
45
|
-
ruby
|
|
46
|
-
|
|
47
|
-
DEPENDENCIES
|
|
48
|
-
activerecord (~> 4.2.0)
|
|
49
|
-
appraisal
|
|
50
|
-
gigo-activerecord!
|
|
51
|
-
minitest
|
|
52
|
-
rake
|
|
53
|
-
sqlite3
|