kartograph 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/kartograph.gemspec +1 -1
- data/lib/kartograph/artist.rb +6 -7
- data/lib/kartograph/dsl.rb +4 -3
- data/lib/kartograph/property.rb +5 -2
- data/lib/kartograph/property_collection.rb +9 -2
- data/lib/kartograph/version.rb +1 -1
- data/spec/integration/allocations_spec.rb +100 -0
- data/spec/integration/testdata/sample.json +23332 -0
- data/spec/lib/kartograph/artist_spec.rb +15 -17
- metadata +22 -18
@@ -6,12 +6,10 @@ describe Kartograph::Artist do
|
|
6
6
|
|
7
7
|
describe '#initialize' do
|
8
8
|
it 'initializes with an object and a map' do
|
9
|
-
object = double('object', name: 'hello')
|
10
9
|
properties << Kartograph::Property.new(:name)
|
11
10
|
|
12
|
-
artist = Kartograph::Artist.new(
|
11
|
+
artist = Kartograph::Artist.new(map)
|
13
12
|
|
14
|
-
expect(artist.object).to be(object)
|
15
13
|
expect(artist.map).to be(map)
|
16
14
|
end
|
17
15
|
end
|
@@ -21,8 +19,8 @@ describe Kartograph::Artist do
|
|
21
19
|
object = double('object', hello: 'world')
|
22
20
|
properties << Kartograph::Property.new(:hello)
|
23
21
|
|
24
|
-
artist = Kartograph::Artist.new(
|
25
|
-
masterpiece = artist.draw
|
22
|
+
artist = Kartograph::Artist.new(map)
|
23
|
+
masterpiece = artist.draw(object)
|
26
24
|
|
27
25
|
expect(masterpiece).to include('hello' => 'world')
|
28
26
|
end
|
@@ -31,9 +29,9 @@ describe Kartograph::Artist do
|
|
31
29
|
class TestArtistNoMethod; end
|
32
30
|
object = TestArtistNoMethod.new
|
33
31
|
properties << Kartograph::Property.new(:bunk)
|
34
|
-
artist = Kartograph::Artist.new(
|
32
|
+
artist = Kartograph::Artist.new(map)
|
35
33
|
|
36
|
-
expect { artist.draw }.to raise_error(ArgumentError).with_message("#{object} does not respond to bunk, so we can't map it")
|
34
|
+
expect { artist.draw(object) }.to raise_error(ArgumentError).with_message("#{object} does not respond to bunk, so we can't map it")
|
37
35
|
end
|
38
36
|
|
39
37
|
context 'for a property with a key set on it' do
|
@@ -41,8 +39,8 @@ describe Kartograph::Artist do
|
|
41
39
|
object = double('object', hello: 'world')
|
42
40
|
properties << Kartograph::Property.new(:hello, key: :hola)
|
43
41
|
|
44
|
-
artist = Kartograph::Artist.new(
|
45
|
-
masterpiece = artist.draw
|
42
|
+
artist = Kartograph::Artist.new(map)
|
43
|
+
masterpiece = artist.draw(object)
|
46
44
|
|
47
45
|
expect(masterpiece).to include('hola' => 'world')
|
48
46
|
end
|
@@ -54,8 +52,8 @@ describe Kartograph::Artist do
|
|
54
52
|
properties << Kartograph::Property.new(:hello, scopes: [:create, :read])
|
55
53
|
properties << Kartograph::Property.new(:foo, scopes: [:create])
|
56
54
|
|
57
|
-
artist = Kartograph::Artist.new(
|
58
|
-
masterpiece = artist.draw(:read)
|
55
|
+
artist = Kartograph::Artist.new(map)
|
56
|
+
masterpiece = artist.draw(object, :read)
|
59
57
|
|
60
58
|
expect(masterpiece).to eq('hello' => 'world')
|
61
59
|
end
|
@@ -72,8 +70,8 @@ describe Kartograph::Artist do
|
|
72
70
|
|
73
71
|
properties << root_property
|
74
72
|
|
75
|
-
artist = Kartograph::Artist.new(
|
76
|
-
masterpiece = artist.draw(:read)
|
73
|
+
artist = Kartograph::Artist.new(map)
|
74
|
+
masterpiece = artist.draw(object, :read)
|
77
75
|
|
78
76
|
expect(masterpiece).to eq('child' => { 'foo' => child.foo })
|
79
77
|
end
|
@@ -89,8 +87,8 @@ describe Kartograph::Artist do
|
|
89
87
|
map.cache_key { |obj, scope| obj.cache_key }
|
90
88
|
map.property :foo
|
91
89
|
|
92
|
-
artist = Kartograph::Artist.new(
|
93
|
-
masterpiece = artist.draw
|
90
|
+
artist = Kartograph::Artist.new(map)
|
91
|
+
masterpiece = artist.draw(object)
|
94
92
|
|
95
93
|
expect(masterpiece).to eq(cacher.fetch)
|
96
94
|
|
@@ -105,8 +103,8 @@ describe Kartograph::Artist do
|
|
105
103
|
|
106
104
|
map.property :foo, scopes: [:read]
|
107
105
|
|
108
|
-
artist = Kartograph::Artist.new(
|
109
|
-
masterpiece = artist.draw(:read)
|
106
|
+
artist = Kartograph::Artist.new(map)
|
107
|
+
masterpiece = artist.draw(object, :read)
|
110
108
|
|
111
109
|
expect(called).to have_received(:call).with(object, :read)
|
112
110
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kartograph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '11.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "<"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '11.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Kartograph makes it easy to generate and convert JSON. It's intention
|
@@ -76,9 +76,9 @@ executables: []
|
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
|
-
- .gitignore
|
80
|
-
- .rspec
|
81
|
-
- .travis.yml
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
82
82
|
- Gemfile
|
83
83
|
- LICENSE.txt
|
84
84
|
- README.md
|
@@ -96,6 +96,8 @@ files:
|
|
96
96
|
- lib/kartograph/root_key.rb
|
97
97
|
- lib/kartograph/sculptor.rb
|
98
98
|
- lib/kartograph/version.rb
|
99
|
+
- spec/integration/allocations_spec.rb
|
100
|
+
- spec/integration/testdata/sample.json
|
99
101
|
- spec/lib/kartograph/artist_spec.rb
|
100
102
|
- spec/lib/kartograph/dsl_spec.rb
|
101
103
|
- spec/lib/kartograph/map_spec.rb
|
@@ -117,22 +119,24 @@ require_paths:
|
|
117
119
|
- lib
|
118
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
121
|
requirements:
|
120
|
-
- -
|
122
|
+
- - ">="
|
121
123
|
- !ruby/object:Gem::Version
|
122
124
|
version: '0'
|
123
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
126
|
requirements:
|
125
|
-
- -
|
127
|
+
- - ">="
|
126
128
|
- !ruby/object:Gem::Version
|
127
129
|
version: '0'
|
128
130
|
requirements: []
|
129
131
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.5.2
|
131
133
|
signing_key:
|
132
134
|
specification_version: 4
|
133
135
|
summary: Kartograph makes it easy to generate and convert JSON. It's intention is
|
134
136
|
to be used for API clients.
|
135
137
|
test_files:
|
138
|
+
- spec/integration/allocations_spec.rb
|
139
|
+
- spec/integration/testdata/sample.json
|
136
140
|
- spec/lib/kartograph/artist_spec.rb
|
137
141
|
- spec/lib/kartograph/dsl_spec.rb
|
138
142
|
- spec/lib/kartograph/map_spec.rb
|