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 +2 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -1
- data/Changelog.md +6 -0
- data/Gemfile +5 -3
- data/Guardfile +0 -1
- data/README.md +2 -2
- data/gemfiles/rails_3_0.gemfile +21 -0
- data/gemfiles/rails_3_1.gemfile +21 -0
- data/lib/toy/attributes.rb +12 -2
- data/lib/toy/version.rb +1 -1
- data/spec/helper.rb +5 -0
- data/spec/support/constants.rb +10 -8
- data/spec/support/objects.rb +10 -8
- data/spec/toy/attributes_spec.rb +1 -1
- data/spec/toy/dirty_spec.rb +4 -4
- data/spec/toy/plugins_spec.rb +15 -6
- data/toystore.gemspec +2 -2
- metadata +89 -81
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
CHANGED
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 '
|
5
|
-
gem '
|
6
|
-
gem '
|
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
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
|
232
|
-
* Ruby 1.8.7,
|
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
|
data/lib/toy/attributes.rb
CHANGED
@@ -5,7 +5,15 @@ module Toy
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
include Identity
|
8
|
-
|
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
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
|
data/spec/support/constants.rb
CHANGED
@@ -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
|
21
|
-
|
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
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
data/spec/support/objects.rb
CHANGED
@@ -4,28 +4,30 @@ module Support
|
|
4
4
|
|
5
5
|
module ClassMethods
|
6
6
|
def uses_objects(*objects)
|
7
|
-
before { create_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
|
12
|
+
objects.each { |object| create_object object }
|
13
13
|
end
|
14
14
|
|
15
15
|
def remove_objects(*objects)
|
16
|
-
objects.each { |object| remove_object
|
16
|
+
objects.each { |object| remove_object object }
|
17
17
|
end
|
18
18
|
|
19
19
|
def create_object(object)
|
20
|
-
remove_object
|
21
|
-
|
20
|
+
remove_object object
|
21
|
+
Object.const_set object, ToyObject(object)
|
22
22
|
end
|
23
23
|
|
24
24
|
def remove_object(object)
|
25
|
-
|
25
|
+
if Object.const_defined?(object)
|
26
|
+
Object.send :remove_const, object
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
|
-
def
|
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
|
data/spec/toy/attributes_spec.rb
CHANGED
data/spec/toy/dirty_spec.rb
CHANGED
@@ -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
|
45
|
+
user = User.new
|
46
46
|
user.name = 'Steve'
|
47
|
-
user.name_was.should
|
47
|
+
user.name_was.should be_nil
|
48
48
|
end
|
49
49
|
|
50
50
|
it "has attribute change method" do
|
51
|
-
user = User.new
|
51
|
+
user = User.new
|
52
52
|
user.name = 'Steve'
|
53
|
-
user.name_change.should == [
|
53
|
+
user.name_change.should == [nil, 'Steve']
|
54
54
|
end
|
55
55
|
|
56
56
|
it "has attribute will change! method" do
|
data/spec/toy/plugins_spec.rb
CHANGED
@@ -9,12 +9,21 @@ describe Toy::Plugins do
|
|
9
9
|
|
10
10
|
describe ".plugin" do
|
11
11
|
before do
|
12
|
-
|
13
|
-
|
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
|
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 =
|
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'
|
22
|
-
s.add_dependency 'activesupport', '~> 3.0'
|
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
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
34
|
+
version_requirements: *id001
|
35
|
+
name: adapter
|
24
36
|
prerelease: false
|
25
|
-
|
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
|
-
|
31
|
-
|
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
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
231
|
-
|
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
|
-
|
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.
|
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
|