gigo-activerecord 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Appraisals CHANGED
@@ -12,5 +12,5 @@ appraise 'activerecord32' do
12
12
  end
13
13
 
14
14
  appraise 'activerecord40' do
15
- gem 'activerecord', :github => 'rails/rails'
15
+ gem 'activerecord', '~> 4.0.0'
16
16
  end
data/README.md CHANGED
@@ -45,6 +45,14 @@ end
45
45
  @note.subject # => "€20 – “WOOHOO”"
46
46
  ```
47
47
 
48
+ If you want to exten all `:string` and `:text` columns, use the `gigo_columns` method. All string/text columns will be GIGO'ized. Any arguments passed to `gigi_columns` will be exculded.
49
+
50
+ ```ruby
51
+ class LegacyTable < ActiveRecord::Base
52
+ gigo_columns
53
+ end
54
+ ```
55
+
48
56
  #### Serialized Attributes
49
57
 
50
58
  Sometimes your serialized attributes need GIGO before loading the YAML.
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /Users/kencollins/Repositories/customink/gigo-activerecord
3
3
  specs:
4
- gigo-activerecord (1.2.0)
5
- activerecord (>= 3.0)
4
+ gigo-activerecord (1.2.1)
5
+ activerecord (>= 3.0, < 5.0)
6
6
  gigo
7
7
 
8
8
  GEM
@@ -28,10 +28,10 @@ GEM
28
28
  activesupport (>= 3.0)
29
29
  ensure_valid_encoding (~> 0.5.3)
30
30
  i18n (0.5.0)
31
- minitest (5.0.4)
32
- rake (10.0.4)
33
- sqlite3 (1.3.7)
34
- tzinfo (0.3.37)
31
+ minitest (4.7.5)
32
+ rake (10.1.0)
33
+ sqlite3 (1.3.8)
34
+ tzinfo (0.3.38)
35
35
 
36
36
  PLATFORMS
37
37
  ruby
@@ -40,6 +40,6 @@ DEPENDENCIES
40
40
  activerecord (~> 3.0.0)
41
41
  appraisal
42
42
  gigo-activerecord!
43
- minitest (~> 5.0)
43
+ minitest (~> 4.2)
44
44
  rake
45
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.2.0)
5
- activerecord (>= 3.0)
4
+ gigo-activerecord (1.2.1)
5
+ activerecord (>= 3.0, < 5.0)
6
6
  gigo
7
7
 
8
8
  GEM
@@ -28,12 +28,12 @@ GEM
28
28
  gigo (2.0.0)
29
29
  activesupport (>= 3.0)
30
30
  ensure_valid_encoding (~> 0.5.3)
31
- i18n (0.6.4)
32
- minitest (5.0.4)
33
- multi_json (1.7.6)
34
- rake (10.0.4)
35
- sqlite3 (1.3.7)
36
- tzinfo (0.3.37)
31
+ i18n (0.6.5)
32
+ minitest (4.7.5)
33
+ multi_json (1.8.2)
34
+ rake (10.1.0)
35
+ sqlite3 (1.3.8)
36
+ tzinfo (0.3.38)
37
37
 
38
38
  PLATFORMS
39
39
  ruby
@@ -42,6 +42,6 @@ DEPENDENCIES
42
42
  activerecord (~> 3.1.0)
43
43
  appraisal
44
44
  gigo-activerecord!
45
- minitest (~> 5.0)
45
+ minitest (~> 4.2)
46
46
  rake
47
47
  sqlite3
@@ -1,39 +1,39 @@
1
1
  PATH
2
2
  remote: /Users/kencollins/Repositories/customink/gigo-activerecord
3
3
  specs:
4
- gigo-activerecord (1.2.0)
5
- activerecord (>= 3.0)
4
+ gigo-activerecord (1.2.1)
5
+ activerecord (>= 3.0, < 5.0)
6
6
  gigo
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (3.2.13)
12
- activesupport (= 3.2.13)
11
+ activemodel (3.2.15)
12
+ activesupport (= 3.2.15)
13
13
  builder (~> 3.0.0)
14
- activerecord (3.2.13)
15
- activemodel (= 3.2.13)
16
- activesupport (= 3.2.13)
14
+ activerecord (3.2.15)
15
+ activemodel (= 3.2.15)
16
+ activesupport (= 3.2.15)
17
17
  arel (~> 3.0.2)
18
18
  tzinfo (~> 0.3.29)
19
- activesupport (3.2.13)
20
- i18n (= 0.6.1)
19
+ activesupport (3.2.15)
20
+ i18n (~> 0.6, >= 0.6.4)
21
21
  multi_json (~> 1.0)
22
22
  appraisal (0.5.2)
23
23
  bundler
24
24
  rake
25
- arel (3.0.2)
25
+ arel (3.0.3)
26
26
  builder (3.0.4)
27
27
  ensure_valid_encoding (0.5.3)
28
28
  gigo (2.0.0)
29
29
  activesupport (>= 3.0)
30
30
  ensure_valid_encoding (~> 0.5.3)
31
- i18n (0.6.1)
32
- minitest (5.0.4)
33
- multi_json (1.7.6)
34
- rake (10.0.4)
35
- sqlite3 (1.3.7)
36
- tzinfo (0.3.37)
31
+ i18n (0.6.5)
32
+ minitest (4.7.5)
33
+ multi_json (1.8.2)
34
+ rake (10.1.0)
35
+ sqlite3 (1.3.8)
36
+ tzinfo (0.3.38)
37
37
 
38
38
  PLATFORMS
39
39
  ruby
@@ -42,6 +42,6 @@ DEPENDENCIES
42
42
  activerecord (~> 3.2.0)
43
43
  appraisal
44
44
  gigo-activerecord!
45
- minitest (~> 5.0)
45
+ minitest (~> 4.2)
46
46
  rake
47
47
  sqlite3
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", :github=>"rails/rails"
5
+ gem "activerecord", "~> 4.0.0"
6
6
 
7
7
  gemspec :path=>"../"
@@ -1,59 +1,54 @@
1
- GIT
2
- remote: git://github.com/rails/rails.git
3
- revision: ebf2113a0565d2e38802f29291b3971b2c7f7922
4
- specs:
5
- activemodel (4.1.0.beta)
6
- activesupport (= 4.1.0.beta)
7
- builder (~> 3.1.0)
8
- activerecord (4.1.0.beta)
9
- activemodel (= 4.1.0.beta)
10
- activerecord-deprecated_finders (~> 1.0.2)
11
- activesupport (= 4.1.0.beta)
12
- arel (~> 4.0.0)
13
- activesupport (4.1.0.beta)
14
- i18n (~> 0.6, >= 0.6.4)
15
- json (~> 1.7)
16
- minitest (~> 5.0)
17
- thread_safe (~> 0.1)
18
- tzinfo (~> 0.3.37)
19
-
20
1
  PATH
21
2
  remote: /Users/kencollins/Repositories/customink/gigo-activerecord
22
3
  specs:
23
- gigo-activerecord (1.2.0)
24
- activerecord (>= 3.0)
4
+ gigo-activerecord (1.2.1)
5
+ activerecord (>= 3.0, < 5.0)
25
6
  gigo
26
7
 
27
8
  GEM
28
9
  remote: https://rubygems.org/
29
10
  specs:
30
- activerecord-deprecated_finders (1.0.2)
11
+ activemodel (4.0.1)
12
+ activesupport (= 4.0.1)
13
+ builder (~> 3.1.0)
14
+ activerecord (4.0.1)
15
+ activemodel (= 4.0.1)
16
+ activerecord-deprecated_finders (~> 1.0.2)
17
+ activesupport (= 4.0.1)
18
+ arel (~> 4.0.0)
19
+ activerecord-deprecated_finders (1.0.3)
20
+ activesupport (4.0.1)
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)
31
26
  appraisal (0.5.2)
32
27
  bundler
33
28
  rake
34
- arel (4.0.0)
35
- atomic (1.1.9)
29
+ arel (4.0.1)
30
+ atomic (1.1.14)
36
31
  builder (3.1.4)
37
32
  ensure_valid_encoding (0.5.3)
38
33
  gigo (2.0.0)
39
34
  activesupport (>= 3.0)
40
35
  ensure_valid_encoding (~> 0.5.3)
41
- i18n (0.6.4)
42
- json (1.8.0)
43
- minitest (5.0.4)
44
- rake (10.0.4)
45
- sqlite3 (1.3.7)
46
- thread_safe (0.1.0)
36
+ i18n (0.6.5)
37
+ minitest (4.7.5)
38
+ multi_json (1.8.2)
39
+ rake (10.1.0)
40
+ sqlite3 (1.3.8)
41
+ thread_safe (0.1.3)
47
42
  atomic
48
- tzinfo (0.3.37)
43
+ tzinfo (0.3.38)
49
44
 
50
45
  PLATFORMS
51
46
  ruby
52
47
 
53
48
  DEPENDENCIES
54
- activerecord!
49
+ activerecord (~> 4.0.0)
55
50
  appraisal
56
51
  gigo-activerecord!
57
- minitest (~> 5.0)
52
+ minitest (~> 4.2)
58
53
  rake
59
54
  sqlite3
@@ -17,9 +17,9 @@ 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.0'
20
+ spec.add_runtime_dependency 'activerecord', '>= 3.0', '< 5.0'
21
21
  spec.add_development_dependency 'appraisal'
22
22
  spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'minitest', '~> 5.0'
23
+ spec.add_development_dependency 'minitest', '~> 4.2'
24
24
  spec.add_development_dependency 'sqlite3'
25
25
  end
@@ -6,7 +6,7 @@ module GIGO
6
6
 
7
7
  def gigo_column(*attrs)
8
8
  mod = begin
9
- if defined?(GIGOColumns)
9
+ if const_defined?(:GIGOColumns)
10
10
  const_get(:GIGOColumns)
11
11
  else
12
12
  m = const_set(:GIGOColumns, Module.new)
@@ -27,6 +27,11 @@ module GIGO
27
27
  end
28
28
  end
29
29
 
30
+ def gigo_columns(*excepts)
31
+ cols = columns.select{ |c| c.type == :string || c.type == :text }.map{ |c| c.name.to_s } - excepts.map(&:to_s)
32
+ gigo_column(*cols)
33
+ end
34
+
30
35
  end
31
36
 
32
37
  module ThreeOhOnly
@@ -1,5 +1,5 @@
1
1
  module GIGO
2
2
  module ActiveRecord
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -25,6 +25,10 @@ module GIGO
25
25
  let(:seralized_data_iso8859_raw) { with_db_encoding(iso8859) { UserRaw.find(user_data_iso8859.id).notes } }
26
26
  let(:seralized_data_iso8859_gigo) { with_db_encoding(iso8859) { UserGIGO.find(user_data_iso8859.id).notes[:data] } }
27
27
 
28
+ it 'allows dual calls' do
29
+ UserWithDualGIGO
30
+ end
31
+
28
32
  it 'can setup different DB data in other encodings so other test assumptions work' do
29
33
  seralized_data_utf8_raw.encoding.must_equal utf8
30
34
  seralized_data_cp1252_raw.encoding.must_equal cp1252
@@ -87,6 +91,23 @@ module GIGO
87
91
 
88
92
  end
89
93
 
94
+ describe 'gigo_columns' do
95
+
96
+ it 'converts all columns' do
97
+ LegacyAll.gigo_columns
98
+ assert LegacyAll::GIGOColumns.method_defined?(:subject)
99
+ assert LegacyAll::GIGOColumns.method_defined?(:body)
100
+ assert LegacyAll::GIGOColumns.method_defined?(:data)
101
+ end
102
+
103
+ it 'converts all but specified columns' do
104
+ LegacySome.gigo_columns :data
105
+ assert LegacySome::GIGOColumns.method_defined?(:subject)
106
+ assert LegacySome::GIGOColumns.method_defined?(:body)
107
+ refute LegacySome::GIGOColumns.method_defined?(:data)
108
+ end
109
+
110
+ end
90
111
 
91
112
  end
92
113
  end
data/test/test_helper.rb CHANGED
@@ -62,6 +62,11 @@ module GIGO
62
62
  t.text :notes
63
63
  t.timestamps
64
64
  end
65
+ create_table :legacies, :force => true do |t|
66
+ t.string :subject
67
+ t.text :body
68
+ t.text :data
69
+ end
65
70
  end
66
71
  end
67
72
  end
@@ -102,6 +107,19 @@ module GIGO
102
107
  end
103
108
  end
104
109
 
110
+ class UserWithDualGIGO < ::ActiveRecord::Base
111
+ gigo_column :subject
112
+ gigo_column :subject
113
+ end
114
+
115
+ class LegacyAll < ::ActiveRecord::Base
116
+ self.table_name = :legacies
117
+ end
118
+
119
+ class LegacySome < ::ActiveRecord::Base
120
+ self.table_name = :legacies
121
+ end
122
+
105
123
  end
106
124
  end
107
125
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: gigo-activerecord
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ken Collins
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-10 00:00:00.000000000 Z
12
+ date: 2013-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gigo
@@ -35,12 +35,18 @@ dependencies:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '3.0'
38
+ - - <
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
38
41
  none: false
39
42
  version_requirements: !ruby/object:Gem::Requirement
40
43
  requirements:
41
44
  - - ! '>='
42
45
  - !ruby/object:Gem::Version
43
46
  version: '3.0'
47
+ - - <
48
+ - !ruby/object:Gem::Version
49
+ version: '5.0'
44
50
  none: false
45
51
  prerelease: false
46
52
  - !ruby/object:Gem::Dependency
@@ -82,13 +88,13 @@ dependencies:
82
88
  requirements:
83
89
  - - ~>
84
90
  - !ruby/object:Gem::Version
85
- version: '5.0'
91
+ version: '4.2'
86
92
  none: false
87
93
  version_requirements: !ruby/object:Gem::Requirement
88
94
  requirements:
89
95
  - - ~>
90
96
  - !ruby/object:Gem::Version
91
- version: '5.0'
97
+ version: '4.2'
92
98
  none: false
93
99
  prerelease: false
94
100
  - !ruby/object:Gem::Dependency
@@ -148,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
154
  - !ruby/object:Gem::Version
149
155
  segments:
150
156
  - 0
151
- hash: -1606933277418764219
157
+ hash: -3544303589874900389
152
158
  version: '0'
153
159
  none: false
154
160
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -157,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
163
  - !ruby/object:Gem::Version
158
164
  segments:
159
165
  - 0
160
- hash: -1606933277418764219
166
+ hash: -3544303589874900389
161
167
  version: '0'
162
168
  none: false
163
169
  requirements: []