has_serialized 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ pkg/
1
2
  *.swp
2
3
  **/*.swp
3
4
  db
data/Appraisals ADDED
@@ -0,0 +1,7 @@
1
+ appraise "activerecord3.0.x" do
2
+ gem "activerecord", "~> 3.0.0"
3
+ end
4
+
5
+ appraise "activerecord3.x" do
6
+ gem "activerecord", "~> 3.1"
7
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # 1.0.2
2
+
3
+ - Allow attributes to be set during initialization
4
+ - Adds support for multiple activerecord 3 versions
5
+
6
+ # 1.0.0
7
+
8
+ - Drop support for Ruby 1.8.7
9
+ - Clean up gemspec and Gemfile
data/Gemfile.lock CHANGED
@@ -1,34 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- has_serialized (1.0.0)
5
- activerecord (>= 3.0.0)
4
+ has_serialized (1.0.2)
5
+ activerecord (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- activemodel (4.0.0)
11
- activesupport (= 4.0.0)
12
- builder (~> 3.1.0)
13
- activerecord (4.0.0)
14
- activemodel (= 4.0.0)
15
- activerecord-deprecated_finders (~> 1.0.2)
16
- activesupport (= 4.0.0)
17
- arel (~> 4.0.0)
18
- activerecord-deprecated_finders (1.0.3)
19
- activesupport (4.0.0)
10
+ activemodel (3.2.14)
11
+ activesupport (= 3.2.14)
12
+ builder (~> 3.0.0)
13
+ activerecord (3.2.14)
14
+ activemodel (= 3.2.14)
15
+ activesupport (= 3.2.14)
16
+ arel (~> 3.0.2)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.2.14)
20
19
  i18n (~> 0.6, >= 0.6.4)
21
- minitest (~> 4.2)
22
- multi_json (~> 1.3)
23
- thread_safe (~> 0.1)
24
- tzinfo (~> 0.3.37)
25
- arel (4.0.0)
26
- atomic (1.1.12)
27
- builder (3.1.4)
20
+ multi_json (~> 1.0)
21
+ appraisal (0.5.2)
22
+ bundler
23
+ rake
24
+ arel (3.0.2)
25
+ builder (3.0.4)
28
26
  diff-lcs (1.2.4)
29
27
  i18n (0.6.4)
30
- minitest (4.7.5)
31
28
  multi_json (1.7.8)
29
+ rake (10.1.0)
32
30
  rspec (2.14.1)
33
31
  rspec-core (~> 2.14.0)
34
32
  rspec-expectations (~> 2.14.0)
@@ -38,14 +36,13 @@ GEM
38
36
  diff-lcs (>= 1.1.3, < 2.0)
39
37
  rspec-mocks (2.14.2)
40
38
  sqlite3 (1.3.7)
41
- thread_safe (0.1.2)
42
- atomic
43
39
  tzinfo (0.3.37)
44
40
 
45
41
  PLATFORMS
46
42
  ruby
47
43
 
48
44
  DEPENDENCIES
45
+ appraisal
49
46
  has_serialized!
50
47
  rspec
51
48
  sqlite3
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'appraisal'
2
4
 
3
5
  require 'rspec/core'
4
6
  require 'rspec/core/rake_task'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: /Users/dev/src/has_serialized
3
+ specs:
4
+ has_serialized (1.0.2)
5
+ activerecord (~> 3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activemodel (3.0.20)
11
+ activesupport (= 3.0.20)
12
+ builder (~> 2.1.2)
13
+ i18n (~> 0.5.0)
14
+ activerecord (3.0.20)
15
+ activemodel (= 3.0.20)
16
+ activesupport (= 3.0.20)
17
+ arel (~> 2.0.10)
18
+ tzinfo (~> 0.3.23)
19
+ activesupport (3.0.20)
20
+ appraisal (0.5.2)
21
+ bundler
22
+ rake
23
+ arel (2.0.10)
24
+ builder (2.1.2)
25
+ diff-lcs (1.2.4)
26
+ i18n (0.5.0)
27
+ rake (10.1.0)
28
+ rspec (2.14.1)
29
+ rspec-core (~> 2.14.0)
30
+ rspec-expectations (~> 2.14.0)
31
+ rspec-mocks (~> 2.14.0)
32
+ rspec-core (2.14.4)
33
+ rspec-expectations (2.14.0)
34
+ diff-lcs (>= 1.1.3, < 2.0)
35
+ rspec-mocks (2.14.2)
36
+ sqlite3 (1.3.7)
37
+ tzinfo (0.3.37)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ activerecord (~> 3.0.0)
44
+ appraisal
45
+ has_serialized!
46
+ rspec
47
+ sqlite3
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.1"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: /Users/dev/src/has_serialized
3
+ specs:
4
+ has_serialized (1.0.2)
5
+ activerecord (~> 3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activemodel (3.2.14)
11
+ activesupport (= 3.2.14)
12
+ builder (~> 3.0.0)
13
+ activerecord (3.2.14)
14
+ activemodel (= 3.2.14)
15
+ activesupport (= 3.2.14)
16
+ arel (~> 3.0.2)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.2.14)
19
+ i18n (~> 0.6, >= 0.6.4)
20
+ multi_json (~> 1.0)
21
+ appraisal (0.5.2)
22
+ bundler
23
+ rake
24
+ arel (3.0.2)
25
+ builder (3.0.4)
26
+ diff-lcs (1.2.4)
27
+ i18n (0.6.4)
28
+ multi_json (1.7.8)
29
+ rake (10.1.0)
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.4)
35
+ rspec-expectations (2.14.0)
36
+ diff-lcs (>= 1.1.3, < 2.0)
37
+ rspec-mocks (2.14.2)
38
+ sqlite3 (1.3.7)
39
+ tzinfo (0.3.37)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ activerecord (~> 3.1)
46
+ appraisal
47
+ has_serialized!
48
+ rspec
49
+ sqlite3
@@ -28,8 +28,9 @@ Gem::Specification.new do |s|
28
28
  s.rubygems_version = %q{1.6.2}
29
29
  s.summary = %q{Adds dynamic attributes through serialize.}
30
30
 
31
- s.add_runtime_dependency 'activerecord', '>= 3.0.0'
31
+ s.add_runtime_dependency 'activerecord', '~> 3.0'
32
32
  s.add_development_dependency 'sqlite3'
33
33
  s.add_development_dependency 'rspec'
34
+ s.add_development_dependency 'appraisal'
34
35
  end
35
36
 
@@ -14,6 +14,7 @@ module HasSerialized
14
14
  self[serialized] && self[serialized][k]
15
15
  end
16
16
  define_method("#{k}=") do |value|
17
+ self[serialized] ||= {}
17
18
  self[serialized][k] = value
18
19
  end
19
20
  end
@@ -25,7 +26,12 @@ module HasSerialized
25
26
  after_initialize method_name
26
27
 
27
28
  define_method(method_name) do
28
- self[serialized] = accessors if self[serialized].blank?
29
+ accessors.each do |key, default_value|
30
+ self[serialized] ||= {}
31
+ if self[serialized][key].nil?
32
+ self[serialized][key] = default_value
33
+ end
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -1,3 +1,3 @@
1
1
  module HasSerialized
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Page < ActiveRecord::Base
2
- has_serialized :dynamic_attributes, gunslinger: true
2
+ has_serialized :dynamic_attributes, gunslinger: true, lowmen: true, jake: true
3
3
  end
@@ -20,8 +20,10 @@ describe HasSerialized do
20
20
  end
21
21
  end
22
22
 
23
- it 'should be able to initialize with defaults' do
24
- page = Page.new
25
- expect(page.gunslinger).to be_true
23
+ it 'should be able to override certain defaults during instantiation' do
24
+ page = Page.new(gunslinger: 'Roland', jake: false)
25
+ expect(page.gunslinger).to eq('Roland')
26
+ expect(page.lowmen).to be_true
27
+ expect(page.jake).to eq(false)
26
28
  end
27
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_serialized
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,17 +16,17 @@ dependencies:
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 3.0.0
21
+ version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 3.0.0
29
+ version: '3.0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sqlite3
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: appraisal
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: Adds dynamic attributes through serialize. This way, it's in one table,
63
79
  and it's still trivial to track changes to your records.
64
80
  email: ramon@tayag.net
@@ -67,15 +83,19 @@ extensions: []
67
83
  extra_rdoc_files:
68
84
  - README.md
69
85
  files:
70
- - .autotest
71
86
  - .gitignore
72
87
  - .ruby-version
73
- - CHANGELOG
88
+ - Appraisals
89
+ - CHANGELOG.md
74
90
  - Gemfile
75
91
  - Gemfile.lock
76
92
  - MIT-LICENSE
77
93
  - README.md
78
94
  - Rakefile
95
+ - gemfiles/activerecord3.0.x.gemfile
96
+ - gemfiles/activerecord3.0.x.gemfile.lock
97
+ - gemfiles/activerecord3.x.gemfile
98
+ - gemfiles/activerecord3.x.gemfile.lock
79
99
  - has_serialized.gemspec
80
100
  - lib/has_serialized.rb
81
101
  - lib/has_serialized/class_methods.rb
@@ -97,6 +117,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
117
  - - ! '>='
98
118
  - !ruby/object:Gem::Version
99
119
  version: '0'
120
+ segments:
121
+ - 0
122
+ hash: 2106480265213777068
100
123
  required_rubygems_version: !ruby/object:Gem::Requirement
101
124
  none: false
102
125
  requirements:
data/.autotest DELETED
@@ -1,8 +0,0 @@
1
- Autotest.add_hook :initialize do |autotest|
2
- %w{.git .svn .hg .DS_Store ._* vendor tmp log doc db}.each do |exception|
3
- autotest.add_exception(exception)
4
- end
5
- autotest.add_mapping(%r{^lib/.*\.rb$}) do |f, _|
6
- Dir['spec/**/*.rb']
7
- end
8
- end
data/CHANGELOG DELETED
@@ -1,4 +0,0 @@
1
- # 1.0.0
2
-
3
- - Drop support for Ruby 1.8.7
4
- - Clean up gemspec and Gemfile