storage_room 0.3.18 → 0.3.19
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/VERSION +1 -1
- data/examples/manual_entry_definition.rb +14 -0
- data/lib/storage_room/accessors.rb +12 -4
- data/spec/fixtures/webhook_call.json +10 -1
- data/spec/fixtures/webhook_call_association.json +13 -0
- data/spec/storage_room/accessors_spec.rb +48 -0
- data/spec/storage_room/webhook_call_spec.rb +21 -0
- data/storage_room.gemspec +10 -2
- metadata +44 -20
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.19
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'authentication')
|
4
|
+
|
5
|
+
# define the class that's used for Collection with entry_type "Restaurant"
|
6
|
+
class Restaurant < StorageRoom::Entry
|
7
|
+
key :name
|
8
|
+
key :body
|
9
|
+
key :rating
|
10
|
+
|
11
|
+
one :location # A LocationField, any embedded Resource or a To-One Association
|
12
|
+
|
13
|
+
many :tags # ArrayField, or a To-Many Association
|
14
|
+
end
|
@@ -91,10 +91,7 @@ module StorageRoom
|
|
91
91
|
|
92
92
|
hash
|
93
93
|
end
|
94
|
-
end
|
95
|
-
# = Banner =
|
96
|
-
# ==========
|
97
|
-
|
94
|
+
end
|
98
95
|
|
99
96
|
# Optionally pass attributes to set up the object
|
100
97
|
def initialize(hash={})
|
@@ -177,6 +174,17 @@ module StorageRoom
|
|
177
174
|
false
|
178
175
|
end
|
179
176
|
|
177
|
+
# Compare Resources by comparing their attributes
|
178
|
+
def eql?(object)
|
179
|
+
self.class.equal?(object.class) && attributes == object.attributes
|
180
|
+
end
|
181
|
+
|
182
|
+
alias == eql?
|
183
|
+
|
184
|
+
def hash
|
185
|
+
self.class.hash ^ self.attributes.hash
|
186
|
+
end
|
187
|
+
|
180
188
|
protected
|
181
189
|
# Helper to not call to_hash with the wrong number of arguments
|
182
190
|
def call_method_with_optional_parameters(object, method_name, parameters)
|
@@ -10,7 +10,16 @@
|
|
10
10
|
"@updated_at": "2011-07-14T18:25:42Z",
|
11
11
|
"@url": "http:\/\/api.storageroomapp.com\/accounts\/4e1e9c234250712eba000052\/collections\/4e1e9c234250712eba000062\/entries\/4e1f3259425071435e00004a",
|
12
12
|
"@version": 2,
|
13
|
-
"text": "WEBHOOK TEST"
|
13
|
+
"text": "WEBHOOK TEST",
|
14
|
+
"location": {
|
15
|
+
"@type": "Location",
|
16
|
+
"lat": 1.2,
|
17
|
+
"lng": 2.3
|
18
|
+
},
|
19
|
+
"shop": {
|
20
|
+
"@type": "Shop",
|
21
|
+
"url": "http:\/\/api.storageroomapp.com\/accounts\/4e1e9c234250712eba000052\/collections\/4e1e9c234250712eba000063\/entries\/4e1f3259425071435e000099"
|
22
|
+
}
|
14
23
|
},
|
15
24
|
"@event": "update",
|
16
25
|
"@last_attempt_at": null,
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"entry": {
|
3
|
+
"@created_at": "2011-07-14T18:25:42Z",
|
4
|
+
"@collection_url": "http:\/\/api.storageroomapp.com\/accounts\/4e1e9c234250712eba000052\/collections\/4e1e9c234250712eba000063",
|
5
|
+
"@created_at": "2011-07-14T18:15:53Z",
|
6
|
+
"@type": "Shop",
|
7
|
+
"@trash": false,
|
8
|
+
"@updated_at": "2011-07-14T18:25:42Z",
|
9
|
+
"@url": "http:\/\/api.storageroomapp.com\/accounts\/4e1e9c234250712eba000052\/collections\/4e1e9c234250712eba000063\/entries\/4e1f3259425071435e000099",
|
10
|
+
"@version": 2,
|
11
|
+
"name": "SHOP"
|
12
|
+
}
|
13
|
+
}
|
@@ -164,6 +164,54 @@ describe StorageRoom::TestAccessors do
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
describe "#eql?" do
|
168
|
+
it "should return true for same class and same attributes but different object ids" do
|
169
|
+
one = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
170
|
+
two = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
171
|
+
|
172
|
+
one.eql?(two).should be_true
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should return false for same class and different attributes" do
|
176
|
+
one = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
177
|
+
two = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => 1, :test5 => {:key => 'value'})
|
178
|
+
|
179
|
+
one.eql?(two).should be_false
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should return false for different classes" do
|
183
|
+
one = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
184
|
+
two = StorageRoom::TestAccessors2.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
185
|
+
|
186
|
+
one.eql?(two).should be_false
|
187
|
+
one.eql?('asdf').should be_false
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "#hash" do
|
192
|
+
it "should return same hash for same class and same attributes" do
|
193
|
+
one = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
194
|
+
two = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
195
|
+
|
196
|
+
one.hash.should == two.hash
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should return different hash for same class and different attributes" do
|
200
|
+
one = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
201
|
+
two = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => 1, :test5 => {:key => 'value'})
|
202
|
+
|
203
|
+
one.hash.should_not == two.hash
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should return different hash for different classes" do
|
207
|
+
one = StorageRoom::TestAccessors3.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
208
|
+
two = StorageRoom::TestAccessors2.new(:test => 1, :test2 => '2', :test3 => ['tag1', 'tag2'], :test4 => nil, :test5 => {:key => 'value'})
|
209
|
+
|
210
|
+
one.hash.should_not == two.hash
|
211
|
+
one.hash.should_not == 'asdf'.hash
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
167
215
|
describe "#reset!" do
|
168
216
|
it "should reset" do
|
169
217
|
@test.response_data = {'test' => 1}
|
@@ -2,6 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
class Announcement < StorageRoom::Entry
|
4
4
|
key :text
|
5
|
+
|
6
|
+
one :location
|
7
|
+
one :shop
|
8
|
+
end
|
9
|
+
|
10
|
+
class Shop < StorageRoom::Entry
|
11
|
+
key :name
|
5
12
|
end
|
6
13
|
|
7
14
|
describe StorageRoom::WebhookCall do
|
@@ -19,6 +26,20 @@ describe StorageRoom::WebhookCall do
|
|
19
26
|
webhook_call[:@event].should == 'update'
|
20
27
|
webhook_call.entry.should be_an_instance_of(Announcement)
|
21
28
|
webhook_call.entry.text.should == 'WEBHOOK TEST'
|
29
|
+
|
30
|
+
webhook_call.entry.location.should be_an_instance_of(StorageRoom::Location)
|
31
|
+
webhook_call.entry.location.lat.should == 1.2
|
32
|
+
webhook_call.entry.location.lng.should == 2.3
|
33
|
+
|
34
|
+
stub_request(:get, "http://APPLICATION_API_KEY:X@api.storageroomapp.com/accounts/4e1e9c234250712eba000052/collections/4e1e9c234250712eba000063/entries/4e1f3259425071435e000099").
|
35
|
+
to_return(:status => 200, :body => fixture_file('webhook_call_association.json'))
|
36
|
+
|
37
|
+
shop = webhook_call.entry.shop
|
38
|
+
shop.loaded?.should be_false
|
39
|
+
shop.should be_an_instance_of(Shop)
|
40
|
+
shop.loaded?.should be_true
|
41
|
+
shop['@url'].should == 'http://api.storageroomapp.com/accounts/4e1e9c234250712eba000052/collections/4e1e9c234250712eba000063/entries/4e1f3259425071435e000099'
|
42
|
+
shop.name.should == 'SHOP'
|
22
43
|
end
|
23
44
|
end
|
24
45
|
end
|
data/storage_room.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "storage_room"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.19"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sascha Konietzke"]
|
12
|
-
s.date = "2012-02-
|
12
|
+
s.date = "2012-02-08"
|
13
13
|
s.description = "StorageRoom is a CMS system for Mobile Applications (iPhone, Android, BlackBerry, ...). This library gives you an ActiveModel-like interface to your data."
|
14
14
|
s.email = "sascha@thriventures.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"examples/get_collections.rb",
|
35
35
|
"examples/guidebooks.csv",
|
36
36
|
"examples/import_csv.rb",
|
37
|
+
"examples/manual_entry_definition.rb",
|
37
38
|
"examples/pagination.rb",
|
38
39
|
"examples/search_entries.rb",
|
39
40
|
"examples/update_entry.rb",
|
@@ -84,6 +85,7 @@ Gem::Specification.new do |s|
|
|
84
85
|
"spec/fixtures/image.png",
|
85
86
|
"spec/fixtures/validation_error.json",
|
86
87
|
"spec/fixtures/webhook_call.json",
|
88
|
+
"spec/fixtures/webhook_call_association.json",
|
87
89
|
"spec/spec_helper.rb",
|
88
90
|
"spec/storage_room/accessors_spec.rb",
|
89
91
|
"spec/storage_room/array_spec.rb",
|
@@ -138,6 +140,8 @@ Gem::Specification.new do |s|
|
|
138
140
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
139
141
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
140
142
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
143
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
144
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
141
145
|
s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
|
142
146
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
|
143
147
|
s.add_runtime_dependency(%q<activemodel>, [">= 3.0.0"])
|
@@ -148,6 +152,8 @@ Gem::Specification.new do |s|
|
|
148
152
|
s.add_dependency(%q<webmock>, [">= 0"])
|
149
153
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
150
154
|
s.add_dependency(%q<webmock>, [">= 0"])
|
155
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
156
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
151
157
|
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
152
158
|
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
153
159
|
s.add_dependency(%q<activemodel>, [">= 3.0.0"])
|
@@ -159,6 +165,8 @@ Gem::Specification.new do |s|
|
|
159
165
|
s.add_dependency(%q<webmock>, [">= 0"])
|
160
166
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
161
167
|
s.add_dependency(%q<webmock>, [">= 0"])
|
168
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
169
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
162
170
|
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
163
171
|
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
164
172
|
s.add_dependency(%q<activemodel>, [">= 3.0.0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storage_room
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.19
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: storage_room
|
16
|
-
requirement: &
|
16
|
+
requirement: &70319313153340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70319313153340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70319313152860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.9
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70319313152860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: webmock
|
38
|
-
requirement: &
|
38
|
+
requirement: &70319313152380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70319313152380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70319313151900 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.2.9
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70319313151900
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: webmock
|
60
|
-
requirement: &
|
60
|
+
requirement: &70319313151420 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,32 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70319313151420
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &70319313150940 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.2.9
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70319313150940
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: webmock
|
82
|
+
requirement: &70319313150460 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70319313150460
|
69
91
|
- !ruby/object:Gem::Dependency
|
70
92
|
name: httparty
|
71
|
-
requirement: &
|
93
|
+
requirement: &70319313149980 !ruby/object:Gem::Requirement
|
72
94
|
none: false
|
73
95
|
requirements:
|
74
96
|
- - ! '>='
|
@@ -76,10 +98,10 @@ dependencies:
|
|
76
98
|
version: 0.6.1
|
77
99
|
type: :runtime
|
78
100
|
prerelease: false
|
79
|
-
version_requirements: *
|
101
|
+
version_requirements: *70319313149980
|
80
102
|
- !ruby/object:Gem::Dependency
|
81
103
|
name: activesupport
|
82
|
-
requirement: &
|
104
|
+
requirement: &70319313165860 !ruby/object:Gem::Requirement
|
83
105
|
none: false
|
84
106
|
requirements:
|
85
107
|
- - ! '>='
|
@@ -87,10 +109,10 @@ dependencies:
|
|
87
109
|
version: 3.0.0
|
88
110
|
type: :runtime
|
89
111
|
prerelease: false
|
90
|
-
version_requirements: *
|
112
|
+
version_requirements: *70319313165860
|
91
113
|
- !ruby/object:Gem::Dependency
|
92
114
|
name: activemodel
|
93
|
-
requirement: &
|
115
|
+
requirement: &70319313165380 !ruby/object:Gem::Requirement
|
94
116
|
none: false
|
95
117
|
requirements:
|
96
118
|
- - ! '>='
|
@@ -98,10 +120,10 @@ dependencies:
|
|
98
120
|
version: 3.0.0
|
99
121
|
type: :runtime
|
100
122
|
prerelease: false
|
101
|
-
version_requirements: *
|
123
|
+
version_requirements: *70319313165380
|
102
124
|
- !ruby/object:Gem::Dependency
|
103
125
|
name: mime-types
|
104
|
-
requirement: &
|
126
|
+
requirement: &70319313164900 !ruby/object:Gem::Requirement
|
105
127
|
none: false
|
106
128
|
requirements:
|
107
129
|
- - ! '>='
|
@@ -109,7 +131,7 @@ dependencies:
|
|
109
131
|
version: '0'
|
110
132
|
type: :runtime
|
111
133
|
prerelease: false
|
112
|
-
version_requirements: *
|
134
|
+
version_requirements: *70319313164900
|
113
135
|
description: StorageRoom is a CMS system for Mobile Applications (iPhone, Android,
|
114
136
|
BlackBerry, ...). This library gives you an ActiveModel-like interface to your data.
|
115
137
|
email: sascha@thriventures.com
|
@@ -136,6 +158,7 @@ files:
|
|
136
158
|
- examples/get_collections.rb
|
137
159
|
- examples/guidebooks.csv
|
138
160
|
- examples/import_csv.rb
|
161
|
+
- examples/manual_entry_definition.rb
|
139
162
|
- examples/pagination.rb
|
140
163
|
- examples/search_entries.rb
|
141
164
|
- examples/update_entry.rb
|
@@ -186,6 +209,7 @@ files:
|
|
186
209
|
- spec/fixtures/image.png
|
187
210
|
- spec/fixtures/validation_error.json
|
188
211
|
- spec/fixtures/webhook_call.json
|
212
|
+
- spec/fixtures/webhook_call_association.json
|
189
213
|
- spec/spec_helper.rb
|
190
214
|
- spec/storage_room/accessors_spec.rb
|
191
215
|
- spec/storage_room/array_spec.rb
|