gigo-activerecord 1.0.0 → 1.1.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.
data/Appraisals CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ appraise 'activerecord30' do
3
+ gem 'activerecord', '~> 3.0.0'
4
+ end
5
+
2
6
  appraise 'activerecord31' do
3
7
  gem 'activerecord', '~> 3.1.0'
4
8
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: /Users/kencollins/Repositories/customink/gigo-activerecord
3
+ specs:
4
+ gigo-activerecord (1.1.0)
5
+ activerecord (>= 3.0)
6
+ gigo
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (3.0.20)
12
+ activesupport (= 3.0.20)
13
+ builder (~> 2.1.2)
14
+ i18n (~> 0.5.0)
15
+ activerecord (3.0.20)
16
+ activemodel (= 3.0.20)
17
+ activesupport (= 3.0.20)
18
+ arel (~> 2.0.10)
19
+ tzinfo (~> 0.3.23)
20
+ activesupport (3.0.20)
21
+ appraisal (0.5.2)
22
+ bundler
23
+ rake
24
+ arel (2.0.10)
25
+ builder (2.1.2)
26
+ ensure_valid_encoding (0.5.3)
27
+ gigo (2.0.0)
28
+ activesupport (>= 3.0)
29
+ ensure_valid_encoding (~> 0.5.3)
30
+ i18n (0.5.0)
31
+ minitest (5.0.2)
32
+ rake (10.0.4)
33
+ sqlite3 (1.3.7)
34
+ tzinfo (0.3.37)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ activerecord (~> 3.0.0)
41
+ appraisal
42
+ gigo-activerecord!
43
+ minitest (~> 5.0)
44
+ rake
45
+ sqlite3
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /Users/kencollins/Repositories/customink/gigo-activerecord
3
3
  specs:
4
- gigo-activerecord (1.0.0)
5
- activerecord (>= 3.1)
4
+ gigo-activerecord (1.1.0)
5
+ activerecord (>= 3.0)
6
6
  gigo
7
7
 
8
8
  GEM
@@ -29,7 +29,7 @@ GEM
29
29
  activesupport (>= 3.0)
30
30
  ensure_valid_encoding (~> 0.5.3)
31
31
  i18n (0.6.4)
32
- minitest (5.0.1)
32
+ minitest (5.0.2)
33
33
  multi_json (1.7.3)
34
34
  rake (10.0.4)
35
35
  sqlite3 (1.3.7)
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /Users/kencollins/Repositories/customink/gigo-activerecord
3
3
  specs:
4
- gigo-activerecord (1.0.0)
5
- activerecord (>= 3.1)
4
+ gigo-activerecord (1.1.0)
5
+ activerecord (>= 3.0)
6
6
  gigo
7
7
 
8
8
  GEM
@@ -29,7 +29,7 @@ GEM
29
29
  activesupport (>= 3.0)
30
30
  ensure_valid_encoding (~> 0.5.3)
31
31
  i18n (0.6.1)
32
- minitest (5.0.1)
32
+ minitest (5.0.2)
33
33
  multi_json (1.7.3)
34
34
  rake (10.0.4)
35
35
  sqlite3 (1.3.7)
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: git://github.com/rails/rails.git
3
- revision: 3b266bcfeaa2268cabf4afa362ea0982b92e5b4c
3
+ revision: f47b4236e089b07cb683ee9b7ff8b06111a0ec10
4
4
  specs:
5
5
  activemodel (4.1.0.beta)
6
6
  activesupport (= 4.1.0.beta)
@@ -20,8 +20,8 @@ GIT
20
20
  PATH
21
21
  remote: /Users/kencollins/Repositories/customink/gigo-activerecord
22
22
  specs:
23
- gigo-activerecord (1.0.0)
24
- activerecord (>= 3.1)
23
+ gigo-activerecord (1.1.0)
24
+ activerecord (>= 3.0)
25
25
  gigo
26
26
 
27
27
  GEM
@@ -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', '>= 3.1'
20
+ spec.add_runtime_dependency 'activerecord', '>= 3.0'
21
21
  spec.add_development_dependency 'appraisal'
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_development_dependency 'minitest', '~> 5.0'
@@ -1,4 +1,5 @@
1
1
  require 'gigo'
2
2
  require 'active_record'
3
+ require 'active_record/version'
3
4
  require 'gigo/active_record/version'
4
5
  require 'gigo/active_record/base'
@@ -1,46 +1,90 @@
1
1
  module GIGO
2
2
  module ActiveRecord
3
3
  module Base
4
-
5
- def gigo_serialized_attribute(*attrs)
6
- attrs.each do |attr|
7
- yaml_column = self.serialized_attributes[attr.to_s]
8
- next unless yaml_column
9
- yaml_column.class_eval do
10
- def load_with_gigo(yaml)
4
+
5
+ module Shared
6
+
7
+ def gigo_column(*attrs)
8
+ mod = begin
9
+ if defined?(GIGOColumns)
10
+ const_get(:GIGOColumns)
11
+ else
12
+ m = const_set(:GIGOColumns, Module.new)
13
+ include m
14
+ m
15
+ end
16
+ end
17
+ attrs.each do |attr|
18
+ mod.module_eval <<-CODE, __FILE__, __LINE__
19
+ def #{attr}
20
+ GIGO.load(super)
21
+ end
22
+ CODE
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ module ThreeOhOnly
29
+
30
+ include Shared
31
+
32
+ def gigo_serialized_attribute(*attrs)
33
+ # ActiveRecord 3.0 has no proper hooks. So we fix all YAML object laoding for this class.
34
+ include InstanceMethods
35
+ end
36
+
37
+ module InstanceMethods
38
+
39
+ private
40
+
41
+ def object_from_yaml(string)
42
+ return string unless string.is_a?(String) && string =~ /^---/
43
+ begin
11
44
  existing_encoding = Encoding.default_internal
12
45
  Encoding.default_internal = GIGO.encoding
13
- yaml = GIGO.load(yaml)
14
- load_without_gigo(yaml)
46
+ s = GIGO.load(string)
47
+ YAML::load(s) rescue s
15
48
  ensure
16
49
  Encoding.default_internal = existing_encoding
17
50
  end
18
- alias_method_chain :load, :gigo
19
51
  end
52
+
20
53
  end
54
+
21
55
  end
22
56
 
23
- def gigo_column(*attrs)
24
- mod = begin
25
- if defined?(GIGOColumns)
26
- const_get(:GIGOColumns)
27
- else
28
- m = const_set(:GIGOColumns, Module.new)
29
- include m
30
- m
31
- end
32
- end
33
- attrs.each do |attr|
34
- mod.module_eval <<-CODE, __FILE__, __LINE__
35
- def #{attr}
36
- GIGO.load(super)
57
+ module ThreeOneAndUp
58
+
59
+ include Shared
60
+
61
+ def gigo_serialized_attribute(*attrs)
62
+ attrs.each do |attr|
63
+ yaml_column = self.serialized_attributes[attr.to_s]
64
+ next unless yaml_column
65
+ yaml_column.class_eval do
66
+ def load_with_gigo(yaml)
67
+ existing_encoding = Encoding.default_internal
68
+ Encoding.default_internal = GIGO.encoding
69
+ yaml = GIGO.load(yaml)
70
+ load_without_gigo(yaml)
71
+ ensure
72
+ Encoding.default_internal = existing_encoding
73
+ end
74
+ alias_method_chain :load, :gigo
37
75
  end
38
- CODE
76
+ end
39
77
  end
78
+
40
79
  end
41
80
 
42
81
  end
43
82
  end
44
83
  end
45
84
 
46
- ActiveRecord::Base.extend GIGO::ActiveRecord::Base
85
+ if ActiveRecord::VERSION::STRING < '3.1'
86
+ ActiveRecord::Base.extend GIGO::ActiveRecord::Base::ThreeOhOnly
87
+ else
88
+ ActiveRecord::Base.extend GIGO::ActiveRecord::Base::ThreeOneAndUp
89
+ end
90
+
@@ -1,5 +1,5 @@
1
1
  module GIGO
2
2
  module ActiveRecord
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gigo-activerecord
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ken Collins
@@ -34,13 +34,13 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '3.1'
37
+ version: '3.0'
38
38
  none: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: '3.1'
43
+ version: '3.0'
44
44
  none: false
45
45
  prerelease: false
46
46
  - !ruby/object:Gem::Dependency
@@ -120,6 +120,8 @@ files:
120
120
  - LICENSE.txt
121
121
  - README.md
122
122
  - Rakefile
123
+ - gemfiles/activerecord30.gemfile
124
+ - gemfiles/activerecord30.gemfile.lock
123
125
  - gemfiles/activerecord31.gemfile
124
126
  - gemfiles/activerecord31.gemfile.lock
125
127
  - gemfiles/activerecord32.gemfile
@@ -146,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
148
  - !ruby/object:Gem::Version
147
149
  segments:
148
150
  - 0
149
- hash: -546867824294194641
151
+ hash: -2101830360572712562
150
152
  version: '0'
151
153
  none: false
152
154
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -155,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
157
  - !ruby/object:Gem::Version
156
158
  segments:
157
159
  - 0
158
- hash: -546867824294194641
160
+ hash: -2101830360572712562
159
161
  version: '0'
160
162
  none: false
161
163
  requirements: []