property_sets 0.6.0 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/Appraisals CHANGED
@@ -5,7 +5,7 @@ appraise "rails2.3" do
5
5
  end
6
6
 
7
7
  appraise "rails3.2" do
8
- gem "activerecord", "3.2.1"
9
- gem "activesupport", "3.2.1"
10
- gem "actionpack", "3.2.1"
8
+ gem "activerecord", "3.2.2"
9
+ gem "activesupport", "3.2.2"
10
+ gem "actionpack", "3.2.2"
11
11
  end
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  gem 'activerecord-jdbcmysql-adapter', '1.2.2', :platforms => :jruby
4
4
  gem 'mysql', :platforms => :ruby
5
- gem 'ruby-debug'
5
+
6
6
  gemspec
7
7
 
@@ -4,7 +4,6 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "activerecord-jdbcmysql-adapter", "1.2.2", :platforms=>:jruby
6
6
  gem "mysql", :platforms=>:ruby
7
- gem "ruby-debug"
8
7
  gem "activerecord", "2.3.14"
9
8
  gem "activesupport", "2.3.14"
10
9
  gem "actionpack", "2.3.14"
@@ -1,11 +1,10 @@
1
1
  PATH
2
- remote: /Users/ben/src/property_sets
2
+ remote: /Users/primdahl/Git/property_sets
3
3
  specs:
4
- property_sets (0.5.6)
4
+ property_sets (0.6.1)
5
5
  actionpack (>= 2.3.14, < 3.3)
6
6
  activerecord (>= 2.3.14, < 3.3)
7
7
  activesupport (>= 2.3.14, < 3.3)
8
- json
9
8
 
10
9
  GEM
11
10
  remote: http://rubygems.org/
@@ -23,23 +22,13 @@ GEM
23
22
  appraisal (0.4.0)
24
23
  bundler
25
24
  rake
26
- columnize (0.3.6)
27
25
  jdbc-mysql (5.1.13)
28
- json (1.6.1)
29
- linecache (0.46)
30
- rbx-require-relative (> 0.0.4)
31
26
  metaclass (0.0.1)
32
27
  mocha (0.10.3)
33
28
  metaclass (~> 0.0.1)
34
29
  mysql (2.8.1)
35
30
  rack (1.1.3)
36
31
  rake (0.9.2.2)
37
- rbx-require-relative (0.0.5)
38
- ruby-debug (0.10.4)
39
- columnize (>= 0.1)
40
- ruby-debug-base (~> 0.10.4.0)
41
- ruby-debug-base (0.10.4)
42
- linecache (>= 0.3)
43
32
  shoulda (2.11.3)
44
33
 
45
34
  PLATFORMS
@@ -57,5 +46,4 @@ DEPENDENCIES
57
46
  mysql
58
47
  property_sets!
59
48
  rake
60
- ruby-debug
61
49
  shoulda
@@ -4,9 +4,8 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "activerecord-jdbcmysql-adapter", "1.2.2", :platforms=>:jruby
6
6
  gem "mysql", :platforms=>:ruby
7
- gem "ruby-debug"
8
- gem "activerecord", "3.2.1"
9
- gem "activesupport", "3.2.1"
10
- gem "actionpack", "3.2.1"
7
+ gem "activerecord", "3.2.2"
8
+ gem "activesupport", "3.2.2"
9
+ gem "actionpack", "3.2.2"
11
10
 
12
11
  gemspec :path=>"../"
@@ -1,18 +1,17 @@
1
1
  PATH
2
- remote: /Users/ben/src/property_sets
2
+ remote: /Users/primdahl/Git/property_sets
3
3
  specs:
4
- property_sets (0.5.6)
4
+ property_sets (0.6.1)
5
5
  actionpack (>= 2.3.14, < 3.3)
6
6
  activerecord (>= 2.3.14, < 3.3)
7
7
  activesupport (>= 2.3.14, < 3.3)
8
- json
9
8
 
10
9
  GEM
11
10
  remote: http://rubygems.org/
12
11
  specs:
13
- actionpack (3.2.1)
14
- activemodel (= 3.2.1)
15
- activesupport (= 3.2.1)
12
+ actionpack (3.2.2)
13
+ activemodel (= 3.2.2)
14
+ activesupport (= 3.2.2)
16
15
  builder (~> 3.0.0)
17
16
  erubis (~> 2.7.0)
18
17
  journey (~> 1.0.1)
@@ -20,74 +19,63 @@ GEM
20
19
  rack-cache (~> 1.1)
21
20
  rack-test (~> 0.6.1)
22
21
  sprockets (~> 2.1.2)
23
- activemodel (3.2.1)
24
- activesupport (= 3.2.1)
22
+ activemodel (3.2.2)
23
+ activesupport (= 3.2.2)
25
24
  builder (~> 3.0.0)
26
- activerecord (3.2.1)
27
- activemodel (= 3.2.1)
28
- activesupport (= 3.2.1)
29
- arel (~> 3.0.0)
25
+ activerecord (3.2.2)
26
+ activemodel (= 3.2.2)
27
+ activesupport (= 3.2.2)
28
+ arel (~> 3.0.2)
30
29
  tzinfo (~> 0.3.29)
31
30
  activerecord-jdbc-adapter (1.2.2)
32
31
  activerecord-jdbcmysql-adapter (1.2.2)
33
32
  activerecord-jdbc-adapter (~> 1.2.2)
34
33
  jdbc-mysql (~> 5.1.0)
35
- activesupport (3.2.1)
34
+ activesupport (3.2.2)
36
35
  i18n (~> 0.6)
37
36
  multi_json (~> 1.0)
38
37
  appraisal (0.4.0)
39
38
  bundler
40
39
  rake
41
- arel (3.0.0)
40
+ arel (3.0.2)
42
41
  builder (3.0.0)
43
- columnize (0.3.6)
44
42
  erubis (2.7.0)
45
43
  hike (1.2.1)
46
44
  i18n (0.6.0)
47
45
  jdbc-mysql (5.1.13)
48
- journey (1.0.1)
49
- json (1.6.1)
50
- linecache (0.46)
51
- rbx-require-relative (> 0.0.4)
46
+ journey (1.0.3)
52
47
  metaclass (0.0.1)
53
48
  mocha (0.10.3)
54
49
  metaclass (~> 0.0.1)
55
- multi_json (1.0.4)
50
+ multi_json (1.1.0)
56
51
  mysql (2.8.1)
57
52
  rack (1.4.1)
58
- rack-cache (1.1)
53
+ rack-cache (1.2)
59
54
  rack (>= 0.4)
60
55
  rack-test (0.6.1)
61
56
  rack (>= 1.0)
62
57
  rake (0.9.2.2)
63
- rbx-require-relative (0.0.5)
64
- ruby-debug (0.10.4)
65
- columnize (>= 0.1)
66
- ruby-debug-base (~> 0.10.4.0)
67
- ruby-debug-base (0.10.4)
68
- linecache (>= 0.3)
69
58
  shoulda (2.11.3)
70
59
  sprockets (2.1.2)
71
60
  hike (~> 1.2)
72
61
  rack (~> 1.0)
73
62
  tilt (~> 1.1, != 1.3.0)
74
63
  tilt (1.3.3)
75
- tzinfo (0.3.31)
64
+ tzinfo (0.3.32)
76
65
 
77
66
  PLATFORMS
78
67
  java
79
68
  ruby
80
69
 
81
70
  DEPENDENCIES
82
- actionpack (= 3.2.1)
83
- activerecord (= 3.2.1)
71
+ actionpack (= 3.2.2)
72
+ activerecord (= 3.2.2)
84
73
  activerecord-jdbcmysql-adapter (= 1.2.2)
85
- activesupport (= 3.2.1)
74
+ activesupport (= 3.2.2)
86
75
  appraisal
87
76
  bundler
88
77
  mocha
89
78
  mysql
90
79
  property_sets!
91
80
  rake
92
- ruby-debug
93
81
  shoulda
data/lib/property_sets.rb CHANGED
@@ -3,7 +3,7 @@ require 'property_sets/active_record_extension'
3
3
  require 'property_sets/action_view_extension'
4
4
 
5
5
  module PropertySets
6
- VERSION = "0.6.0"
6
+ VERSION = "0.6.2"
7
7
 
8
8
  def self.ensure_property_set_class(association, owner_class)
9
9
  const_name = "#{owner_class.name}#{association.to_s.singularize.capitalize}".to_sym
@@ -49,7 +49,6 @@ module PropertySets
49
49
  define_method "#{key}=" do |value|
50
50
  instance = lookup(key)
51
51
  instance.value = PropertySets::Casting.write(property_class.type(key), value)
52
- instance.value
53
52
  end
54
53
 
55
54
  define_method "#{key}_record" do
@@ -57,10 +56,6 @@ module PropertySets
57
56
  end
58
57
  end
59
58
 
60
- define_method :property_serialized? do |key|
61
- property_class.type(key) == :serialized
62
- end
63
-
64
59
  def save(*args)
65
60
  each { |p| p.save(*args) }
66
61
  end
@@ -93,7 +88,6 @@ module PropertySets
93
88
  def lookup(arg)
94
89
  instance = lookup_without_default(arg)
95
90
  instance ||= build_default(arg)
96
- instance.validate_serialization = property_serialized?(arg)
97
91
 
98
92
  if ActiveRecord::VERSION::MAJOR == 3
99
93
  owner = proxy_association.owner
@@ -117,8 +111,6 @@ module PropertySets
117
111
  end
118
112
  association_class.new(:value => default(arg))
119
113
  end
120
- instance.validate_serialization = property_serialized?(arg)
121
- instance
122
114
  end
123
115
  end
124
116
  end
@@ -1,5 +1,3 @@
1
- require 'json'
2
-
3
1
  module PropertySets
4
2
  module Casting
5
3
 
@@ -17,8 +15,6 @@ module PropertySets
17
15
  value.to_i
18
16
  when :boolean
19
17
  ![ "false", "0", "", "off", "n" ].member?(value.to_s.downcase)
20
- when :serialized
21
- JSON.parse(value)
22
18
  end
23
19
  end
24
20
 
@@ -32,8 +28,6 @@ module PropertySets
32
28
  else
33
29
  value.in_time_zone("UTC").to_s
34
30
  end
35
- when :serialized
36
- value.to_json
37
31
  else
38
32
  value.to_s
39
33
  end
@@ -28,8 +28,6 @@ module PropertySets
28
28
  value.to_s
29
29
  end
30
30
 
31
- attr_accessor :validate_serialization
32
-
33
31
  private
34
32
 
35
33
  def validate_format_of_name
@@ -40,12 +38,6 @@ module PropertySets
40
38
  end
41
39
  end
42
40
 
43
- def validate_length_of_serialized_data
44
- if validate_serialization && self.class.columns_hash["value"].limit < self.value.size
45
- errors.add(:value, :invalid)
46
- end
47
- end
48
-
49
41
  def coerce_value
50
42
  self.value = value.to_s unless value.nil?
51
43
  end
@@ -59,7 +51,6 @@ module PropertySets
59
51
  module ClassMethods
60
52
  def self.extended(base)
61
53
  base.validate :validate_format_of_name
62
- base.validate :validate_length_of_serialized_data
63
54
  base.before_create :coerce_value
64
55
  end
65
56
 
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'property_sets'
16
- s.version = '0.6.0'
16
+ s.version = '0.6.2'
17
17
  s.date = '2012-03-22'
18
18
  s.rubyforge_project = 'property_sets'
19
19
 
@@ -50,7 +50,6 @@ Gem::Specification.new do |s|
50
50
  s.add_runtime_dependency("activesupport", ">= 2.3.14", "< 3.3")
51
51
  s.add_runtime_dependency("activerecord", ">= 2.3.14", "< 3.3")
52
52
  s.add_runtime_dependency("actionpack", ">= 2.3.14", "< 3.3")
53
- s.add_runtime_dependency("json")
54
53
 
55
54
  ## List your development dependencies here. Development dependencies are
56
55
  ## those that are only needed during development
data/test/helper.rb CHANGED
@@ -69,6 +69,5 @@ class Account < ActiveRecord::Base
69
69
  property :datetime_prop, :type => :datetime
70
70
  property :float_prop, :type => :float
71
71
  property :int_prop, :type => :integer
72
- property :serialized_prop, :type => :serialized
73
72
  end
74
73
  end
data/test/test_casting.rb CHANGED
@@ -8,10 +8,6 @@ class TestCasting < ActiveSupport::TestCase
8
8
  assert_equal nil, PropertySets::Casting.read(:string, nil)
9
9
  assert_equal nil, PropertySets::Casting.read(:hello, nil)
10
10
  end
11
-
12
- should "deserialize properly" do
13
- assert_equal [1,2,3], PropertySets::Casting.read(:serialized, "[1, 2, 3]")
14
- end
15
11
  end
16
12
 
17
13
  context "Casting#write" do
@@ -28,10 +24,6 @@ class TestCasting < ActiveSupport::TestCase
28
24
  should "convert integers to strings" do
29
25
  assert_equal "123", PropertySets::Casting.write(:integer, 123)
30
26
  end
31
-
32
- should "serialize data marked as :serialize to json" do
33
- assert_equal "[123]", PropertySets::Casting.write(:serialized, [123])
34
- end
35
27
  end
36
28
 
37
29
  end
@@ -302,22 +302,6 @@ class TestPropertySets < ActiveSupport::TestCase
302
302
  assert_equal string_rep, @account.typed_data.lookup("datetime_prop").value
303
303
  end
304
304
  end
305
-
306
- context "serialized data" do
307
- should "store data in json" do
308
- value = {:a => 1, :b => 2}
309
- @account.typed_data.serialized_prop = value
310
- @account.save!
311
- @account.reload
312
- assert_equal({'a' => 1, 'b' => 2}, @account.typed_data.serialized_prop)
313
- end
314
-
315
- should "not overflow the column" do
316
- @account.typed_data.serialized_prop = (1..100_000).to_a
317
- assert !@account.typed_data.lookup(:serialized_prop).valid?
318
- assert !@account.save
319
- end
320
- end
321
305
  end
322
306
  end
323
307
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: property_sets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl
@@ -87,7 +87,7 @@ dependencies:
87
87
  type: :runtime
88
88
  version_requirements: *id003
89
89
  - !ruby/object:Gem::Dependency
90
- name: json
90
+ name: rake
91
91
  prerelease: false
92
92
  requirement: &id004 !ruby/object:Gem::Requirement
93
93
  none: false
@@ -98,10 +98,10 @@ dependencies:
98
98
  segments:
99
99
  - 0
100
100
  version: "0"
101
- type: :runtime
101
+ type: :development
102
102
  version_requirements: *id004
103
103
  - !ruby/object:Gem::Dependency
104
- name: rake
104
+ name: bundler
105
105
  prerelease: false
106
106
  requirement: &id005 !ruby/object:Gem::Requirement
107
107
  none: false
@@ -115,7 +115,7 @@ dependencies:
115
115
  type: :development
116
116
  version_requirements: *id005
117
117
  - !ruby/object:Gem::Dependency
118
- name: bundler
118
+ name: shoulda
119
119
  prerelease: false
120
120
  requirement: &id006 !ruby/object:Gem::Requirement
121
121
  none: false
@@ -129,7 +129,7 @@ dependencies:
129
129
  type: :development
130
130
  version_requirements: *id006
131
131
  - !ruby/object:Gem::Dependency
132
- name: shoulda
132
+ name: mocha
133
133
  prerelease: false
134
134
  requirement: &id007 !ruby/object:Gem::Requirement
135
135
  none: false
@@ -143,7 +143,7 @@ dependencies:
143
143
  type: :development
144
144
  version_requirements: *id007
145
145
  - !ruby/object:Gem::Dependency
146
- name: mocha
146
+ name: appraisal
147
147
  prerelease: false
148
148
  requirement: &id008 !ruby/object:Gem::Requirement
149
149
  none: false
@@ -156,20 +156,6 @@ dependencies:
156
156
  version: "0"
157
157
  type: :development
158
158
  version_requirements: *id008
159
- - !ruby/object:Gem::Dependency
160
- name: appraisal
161
- prerelease: false
162
- requirement: &id009 !ruby/object:Gem::Requirement
163
- none: false
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- hash: 3
168
- segments:
169
- - 0
170
- version: "0"
171
- type: :development
172
- version_requirements: *id009
173
159
  description: This gem is an ActiveRecord extension which provides a convenient interface for managing per row properties.
174
160
  email: primdahl@me.com
175
161
  executables: []