toystore 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,5 @@ tmp
6
6
  pkg
7
7
  .bundle
8
8
  Gemfile.lock
9
+ bin
10
+ vendor
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml CHANGED
@@ -1,8 +1,11 @@
1
+ gemfile:
2
+ - Gemfile
3
+ - gemfiles/rails_3_1.gemfile
4
+ - gemfiles/rails_3_0.gemfile
1
5
  language: ruby
2
6
  rvm:
3
7
  - 1.8.7
4
8
  - ree
5
- - 1.9.2
6
9
  - 1.9.3
7
10
  notifications:
8
11
  email: false
data/Changelog.md CHANGED
@@ -1,5 +1,11 @@
1
1
  I will do my best to keep this up to date with significant changes here, starting in 0.8.3.
2
2
 
3
+ * 0.10.4
4
+ * Support for ActiveSupport/ActiveModel 3.2.*
5
+
6
+ * 0.10.3
7
+ * More liberal uuid gem dependency version
8
+
3
9
  * 0.10.2
4
10
  * [Allow changing list attribute type](https://github.com/jnunemaker/toystore/commit/a5b1a944622509c32688d2e56088a7d7aa6fc0b3)
5
11
  * [No longer include id in `persisted_attributes`](https://github.com/jnunemaker/toystore/commit/9f713311ebf174e314db700392e27af86ca00662)
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
- gem 'rake', '~> 0.9.0'
5
- gem 'oj', '~> 1.0.0'
6
- gem 'multi_json', '~> 1.3.2'
4
+ gem 'activesupport', '~> 3.2.0'
5
+ gem 'activemodel', '~> 3.2.0'
6
+ gem 'rake', '~> 0.9.0'
7
+ gem 'oj', '~> 1.0.0'
8
+ gem 'multi_json', '~> 1.3.2'
7
9
 
8
10
  group(:guard) do
9
11
  gem 'guard', '~> 1.0.0'
data/Guardfile CHANGED
@@ -1,6 +1,5 @@
1
1
  rspec_options = {
2
2
  :all_after_pass => false,
3
- :all_on_start => false,
4
3
  }
5
4
 
6
5
  guard 'rspec', rspec_options do
data/README.md CHANGED
@@ -228,8 +228,8 @@ As of 0.8.3, I started keeping a [changelog](https://github.com/jnunemaker/toyst
228
228
 
229
229
  ## Compatibility
230
230
 
231
- * Rails 3, Sinatra, etc. No Rails 2 (because it uses Active Model).
232
- * Ruby 1.8.7, 1.9.2, 1.9.3 (specs are run against each before releases)
231
+ * Rails 3.0.*, 3.1.*, 3.2.*, Sinatra, etc. No Rails 2 (because it uses Active Model).
232
+ * Ruby 1.8.7, REE, and 1.9.3
233
233
 
234
234
  ## Mailing List
235
235
 
@@ -0,0 +1,21 @@
1
+ source :rubygems
2
+ gemspec :path => '../'
3
+
4
+ gem 'activesupport', '~> 3.0.0'
5
+ gem 'activemodel', '~> 3.0.0'
6
+ gem 'rake', '~> 0.9.0'
7
+ gem 'oj', '~> 1.0.0'
8
+ gem 'multi_json', '~> 1.3.2'
9
+
10
+ group(:guard) do
11
+ gem 'guard', '~> 1.0.0'
12
+ gem 'guard-rspec', '~> 0.6.0'
13
+ gem 'guard-bundler', '~> 0.1.0'
14
+ end
15
+
16
+ group(:test) do
17
+ gem 'rspec', '~> 2.8.0'
18
+ gem 'timecop', '~> 0.3.0'
19
+ gem 'tzinfo', '~> 0.3.0'
20
+ gem 'rack-test', '~> 0.6.0'
21
+ end
@@ -0,0 +1,21 @@
1
+ source :rubygems
2
+ gemspec :path => '../'
3
+
4
+ gem 'activesupport', '~> 3.1.0'
5
+ gem 'activemodel', '~> 3.1.0'
6
+ gem 'rake', '~> 0.9.0'
7
+ gem 'oj', '~> 1.0.0'
8
+ gem 'multi_json', '~> 1.3.2'
9
+
10
+ group(:guard) do
11
+ gem 'guard', '~> 1.0.0'
12
+ gem 'guard-rspec', '~> 0.6.0'
13
+ gem 'guard-bundler', '~> 0.1.0'
14
+ end
15
+
16
+ group(:test) do
17
+ gem 'rspec', '~> 2.8.0'
18
+ gem 'timecop', '~> 0.3.0'
19
+ gem 'tzinfo', '~> 0.3.0'
20
+ gem 'rack-test', '~> 0.6.0'
21
+ end
@@ -5,7 +5,15 @@ module Toy
5
5
 
6
6
  included do
7
7
  include Identity
8
- attribute_method_suffix('', '=', '?')
8
+
9
+ # blank suffix is no longer needed in 3.2+
10
+ # open to suggestions on how to do this better
11
+ if ActiveSupport::VERSION::MAJOR == 3 && ActiveSupport::VERSION::MINOR < 2
12
+ attribute_method_suffix('')
13
+ end
14
+
15
+ attribute_method_suffix('=')
16
+ attribute_method_suffix('?')
9
17
  end
10
18
 
11
19
  module ClassMethods
@@ -18,7 +26,9 @@ module Toy
18
26
  end
19
27
 
20
28
  def attribute(key, type, options = {})
21
- Attribute.new(self, key, type, options)
29
+ attribute = Attribute.new(self, key, type, options)
30
+ define_attribute_methods [attribute.name]
31
+ attribute
22
32
  end
23
33
 
24
34
  def attribute?(key)
data/lib/toy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Toy
2
- VERSION = "0.10.3"
2
+ VERSION = "0.10.4"
3
3
  end
data/spec/helper.rb CHANGED
@@ -28,6 +28,11 @@ RSpec.configure do |c|
28
28
  c.include(Support::Objects)
29
29
  c.include(IdentityMapMatcher)
30
30
 
31
+ c.filter_run :focused => true
32
+ c.alias_example_to :fit, :focused => true
33
+ c.alias_example_to :xit, :pending => true
34
+ c.run_all_when_everything_filtered = true
35
+
31
36
  c.before(:each) do
32
37
  Toy::IdentityMap.enabled = false
33
38
  Toy.clear
@@ -5,7 +5,6 @@ module Support
5
5
  module ClassMethods
6
6
  def uses_constants(*constants)
7
7
  before { create_constants *constants }
8
- after { remove_constants *constants }
9
8
  end
10
9
  end
11
10
 
@@ -17,8 +16,9 @@ module Support
17
16
  constants.each { |constant| remove_constant constant }
18
17
  end
19
18
 
20
- def create_constant(constant, superclass=nil)
21
- Object.const_set constant, Model(superclass)
19
+ def create_constant(constant)
20
+ remove_constant constant
21
+ Object.const_set constant, ToyStore(constant)
22
22
  end
23
23
 
24
24
  def remove_constant(constant)
@@ -27,11 +27,13 @@ module Support
27
27
  end
28
28
  end
29
29
 
30
- def Model(superclass=nil)
31
- if superclass.nil?
32
- Class.new { include Toy::Store }
33
- else
34
- Class.new(superclass) { include Toy::Store }
30
+ def ToyStore(name = nil)
31
+ Class.new.tap do |object|
32
+ object.class_eval """
33
+ def self.name; '#{name}' end
34
+ def self.to_s; '#{name}' end
35
+ """ if name
36
+ object.send(:include, Toy::Store)
35
37
  end
36
38
  end
37
39
  end
@@ -4,28 +4,30 @@ module Support
4
4
 
5
5
  module ClassMethods
6
6
  def uses_objects(*objects)
7
- before { create_objects(*objects) }
7
+ before { create_objects *objects }
8
8
  end
9
9
  end
10
10
 
11
11
  def create_objects(*objects)
12
- objects.each { |object| create_object(object) }
12
+ objects.each { |object| create_object object }
13
13
  end
14
14
 
15
15
  def remove_objects(*objects)
16
- objects.each { |object| remove_object(object) }
16
+ objects.each { |object| remove_object object }
17
17
  end
18
18
 
19
19
  def create_object(object)
20
- remove_object(object)
21
- Kernel.const_set(object, Object(object))
20
+ remove_object object
21
+ Object.const_set object, ToyObject(object)
22
22
  end
23
23
 
24
24
  def remove_object(object)
25
- Kernel.send(:remove_const, object) if Kernel.const_defined?(object)
25
+ if Object.const_defined?(object)
26
+ Object.send :remove_const, object
27
+ end
26
28
  end
27
29
 
28
- def Object(name=nil)
30
+ def ToyObject(name = nil)
29
31
  Class.new.tap do |object|
30
32
  object.class_eval """
31
33
  def self.name; '#{name}' end
@@ -35,4 +37,4 @@ module Support
35
37
  end
36
38
  end
37
39
  end
38
- end
40
+ end
@@ -119,7 +119,7 @@ describe Toy::Attributes do
119
119
 
120
120
  describe "#attributes" do
121
121
  it "defaults to hash with id" do
122
- attrs = Model().new.attributes
122
+ attrs = ToyStore().new.attributes
123
123
  attrs.keys.should == ['id']
124
124
  end
125
125
 
@@ -42,15 +42,15 @@ describe Toy::Dirty do
42
42
  end
43
43
 
44
44
  it "has attribute was method" do
45
- user = User.new(:name => 'John')
45
+ user = User.new
46
46
  user.name = 'Steve'
47
- user.name_was.should == 'John'
47
+ user.name_was.should be_nil
48
48
  end
49
49
 
50
50
  it "has attribute change method" do
51
- user = User.new(:name => 'John')
51
+ user = User.new
52
52
  user.name = 'Steve'
53
- user.name_change.should == ['John', 'Steve']
53
+ user.name_change.should == [nil, 'Steve']
54
54
  end
55
55
 
56
56
  it "has attribute will change! method" do
@@ -9,12 +9,21 @@ describe Toy::Plugins do
9
9
 
10
10
  describe ".plugin" do
11
11
  before do
12
- class_methods_mod = Module.new { def foo; 'foo' end }
13
- instance_methods_mod = Module.new { def bar; 'bar' end }
12
+ @mod = Module.new {
13
+ extend ActiveSupport::Concern
14
+
15
+ def bar
16
+ 'bar'
17
+ end
18
+ }
19
+
20
+ class_methods_module = Module.new do
21
+ def foo
22
+ 'foo'
23
+ end
24
+ end
14
25
 
15
- @mod = Module.new { extend ActiveSupport::Concern }
16
- @mod.const_set(:ClassMethods, class_methods_mod)
17
- @mod.const_set(:InstanceMethods, instance_methods_mod)
26
+ @mod.const_set :ClassMethods, class_methods_module
18
27
 
19
28
  Toy.plugin(@mod)
20
29
  end
@@ -31,7 +40,7 @@ describe Toy::Plugins do
31
40
  end
32
41
 
33
42
  it "adds plugins to classes declared after plugin was called" do
34
- klass = Class.new { include Toy::Store }
43
+ klass = ToyStore()
35
44
  klass.foo.should == 'foo'
36
45
  klass.new.bar.should == 'bar'
37
46
  end
data/toystore.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_dependency 'adapter', '~> 0.5.1'
21
- s.add_dependency 'activemodel', '~> 3.0', '< 3.2'
22
- s.add_dependency 'activesupport', '~> 3.0', '< 3.2'
21
+ s.add_dependency 'activemodel', '~> 3.0'
22
+ s.add_dependency 'activesupport', '~> 3.0'
23
23
  s.add_dependency 'simple_uuid', '~> 0.2'
24
24
  end
metadata CHANGED
@@ -1,102 +1,98 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: toystore
3
- version: !ruby/object:Gem::Version
4
- version: 0.10.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 63
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 10
9
+ - 4
10
+ version: 0.10.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Geoffrey Dagley
9
14
  - John Nunemaker
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-10-28 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: adapter
17
- requirement: !ruby/object:Gem::Requirement
18
+
19
+ date: 2012-10-29 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ requirement: &id001 !ruby/object:Gem::Requirement
18
24
  none: false
19
- requirements:
25
+ requirements:
20
26
  - - ~>
21
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ hash: 9
29
+ segments:
30
+ - 0
31
+ - 5
32
+ - 1
22
33
  version: 0.5.1
23
- type: :runtime
34
+ version_requirements: *id001
35
+ name: adapter
24
36
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
37
+ type: :runtime
38
+ - !ruby/object:Gem::Dependency
39
+ requirement: &id002 !ruby/object:Gem::Requirement
26
40
  none: false
27
- requirements:
41
+ requirements:
28
42
  - - ~>
29
- - !ruby/object:Gem::Version
30
- version: 0.5.1
31
- - !ruby/object:Gem::Dependency
43
+ - !ruby/object:Gem::Version
44
+ hash: 7
45
+ segments:
46
+ - 3
47
+ - 0
48
+ version: "3.0"
49
+ version_requirements: *id002
32
50
  name: activemodel
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: '3.0'
39
- - - <
40
- - !ruby/object:Gem::Version
41
- version: '3.2'
42
- type: :runtime
43
51
  prerelease: false
44
- version_requirements: !ruby/object:Gem::Requirement
52
+ type: :runtime
53
+ - !ruby/object:Gem::Dependency
54
+ requirement: &id003 !ruby/object:Gem::Requirement
45
55
  none: false
46
- requirements:
56
+ requirements:
47
57
  - - ~>
48
- - !ruby/object:Gem::Version
49
- version: '3.0'
50
- - - <
51
- - !ruby/object:Gem::Version
52
- version: '3.2'
53
- - !ruby/object:Gem::Dependency
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 3
62
+ - 0
63
+ version: "3.0"
64
+ version_requirements: *id003
54
65
  name: activesupport
55
- requirement: !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- version: '3.0'
61
- - - <
62
- - !ruby/object:Gem::Version
63
- version: '3.2'
64
- type: :runtime
65
66
  prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
+ type: :runtime
68
+ - !ruby/object:Gem::Dependency
69
+ requirement: &id004 !ruby/object:Gem::Requirement
67
70
  none: false
68
- requirements:
71
+ requirements:
69
72
  - - ~>
70
- - !ruby/object:Gem::Version
71
- version: '3.0'
72
- - - <
73
- - !ruby/object:Gem::Version
74
- version: '3.2'
75
- - !ruby/object:Gem::Dependency
73
+ - !ruby/object:Gem::Version
74
+ hash: 15
75
+ segments:
76
+ - 0
77
+ - 2
78
+ version: "0.2"
79
+ version_requirements: *id004
76
80
  name: simple_uuid
77
- requirement: !ruby/object:Gem::Requirement
78
- none: false
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: '0.2'
83
- type: :runtime
84
81
  prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ~>
89
- - !ruby/object:Gem::Version
90
- version: '0.2'
82
+ type: :runtime
91
83
  description: An object mapper for anything that can read, write and delete data
92
- email:
84
+ email:
93
85
  - gdagley@gmail.com
94
86
  - nunemaker@gmail.com
95
87
  executables: []
88
+
96
89
  extensions: []
90
+
97
91
  extra_rdoc_files: []
98
- files:
92
+
93
+ files:
99
94
  - .gitignore
95
+ - .rspec
100
96
  - .travis.yml
101
97
  - Changelog.md
102
98
  - Gemfile
@@ -115,6 +111,8 @@ files:
115
111
  - examples/plain_old_object_on_roids.rb
116
112
  - examples/redis.rb
117
113
  - examples/riak.rb
114
+ - gemfiles/rails_3_0.gemfile
115
+ - gemfiles/rails_3_1.gemfile
118
116
  - lib/toy.rb
119
117
  - lib/toy/association_serialization.rb
120
118
  - lib/toy/attribute.rb
@@ -216,31 +214,41 @@ files:
216
214
  - spec/toy_spec.rb
217
215
  - test/lint_test.rb
218
216
  - toystore.gemspec
217
+ has_rdoc: true
219
218
  homepage: http://jnunemaker.github.com/toystore/
220
219
  licenses: []
220
+
221
221
  post_install_message:
222
222
  rdoc_options: []
223
- require_paths:
223
+
224
+ require_paths:
224
225
  - lib
225
- required_ruby_version: !ruby/object:Gem::Requirement
226
+ required_ruby_version: !ruby/object:Gem::Requirement
226
227
  none: false
227
- requirements:
228
- - - ! '>='
229
- - !ruby/object:Gem::Version
230
- version: '0'
231
- required_rubygems_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ hash: 3
232
+ segments:
233
+ - 0
234
+ version: "0"
235
+ required_rubygems_version: !ruby/object:Gem::Requirement
232
236
  none: false
233
- requirements:
234
- - - ! '>='
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ hash: 3
241
+ segments:
242
+ - 0
243
+ version: "0"
237
244
  requirements: []
245
+
238
246
  rubyforge_project:
239
- rubygems_version: 1.8.23
247
+ rubygems_version: 1.6.2
240
248
  signing_key:
241
249
  specification_version: 3
242
250
  summary: An object mapper for anything that can read, write and delete data
243
- test_files:
251
+ test_files:
244
252
  - spec/helper.rb
245
253
  - spec/spec.opts
246
254
  - spec/support/constants.rb