storage_room 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/VERSION +1 -1
- data/examples/authentication.rb +1 -1
- data/examples/backup_uploads_from_export.rb +24 -0
- data/examples/create_entry.rb +1 -1
- data/examples/destroy_entry.rb +1 -1
- data/examples/get_collections.rb +1 -1
- data/examples/import_csv.rb +2 -2
- data/examples/search_entries.rb +1 -1
- data/examples/update_entry.rb +1 -1
- data/examples/upload_remove_image.rb +2 -2
- data/lib/storage_room/accessors.rb +7 -1
- data/lib/storage_room/embeddeds/fields/compound/file_field.rb +1 -1
- data/lib/storage_room/embeddeds/fields/compound/image_field.rb +1 -1
- data/lib/storage_room/embeddeds/file.rb +30 -0
- data/lib/storage_room/embeddeds/image.rb +13 -0
- data/lib/storage_room/models/entry.rb +4 -0
- data/lib/storage_room.rb +1 -1
- data/spec/fixtures/export_collection.json +108 -0
- data/spec/fixtures/export_entries.json +307 -0
- data/spec/fixtures/webhook_call.json +18 -16
- data/spec/spec_helper.rb +5 -2
- data/spec/storage_room/accessors_spec.rb +12 -1
- data/spec/storage_room/array_spec.rb +1 -1
- data/spec/storage_room/embedded_spec.rb +1 -1
- data/spec/storage_room/embeddeds/file_spec.rb +24 -1
- data/spec/storage_room/model_spec.rb +1 -1
- data/spec/storage_room/models/entry_spec.rb +11 -0
- data/spec/storage_room/resource_spec.rb +1 -1
- data/storage_room.gemspec +5 -2
- metadata +6 -3
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== Version 0.3.6
|
2
|
+
* Added methods to download files
|
3
|
+
* Added example on how to download all files from an Export
|
4
|
+
|
1
5
|
== Version 0.3.5
|
2
6
|
* Added WebhookDefinition as an array on Collection
|
3
7
|
* Added WebhookCall Resource to parse the POST body of StorageRoom Webhooks on a server
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/examples/authentication.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'storage_room')
|
2
2
|
|
3
3
|
ACCOUNT_ID = '4dda7761b65245fde1000051' # your account id
|
4
4
|
APPLICATION_API_KEY = 'kCWTmS1wxYnxzJyteuIn' # your application's API key with read/write access
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'storage_room')
|
4
|
+
|
5
|
+
collection_path = ::File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'export_collection.json'))
|
6
|
+
entry_path = ::File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'export_entries.json'))
|
7
|
+
download_path = ::File.expand_path(File.join(File.dirname(__FILE__), 'downloads'))
|
8
|
+
|
9
|
+
collection = StorageRoom::Resource.new_from_json_file(collection_path)
|
10
|
+
entry_class = collection.entry_class
|
11
|
+
|
12
|
+
attachment_fields = collection.fields.select{|f| f.is_a?(StorageRoom::AttachmentField)}
|
13
|
+
|
14
|
+
puts "Loaded Collection '#{collection.name}' with attachment fields: #{attachment_fields.map(&:name).join(', ')}"
|
15
|
+
puts "Downloading into '#{download_path}'"
|
16
|
+
|
17
|
+
StorageRoom::Array.new_from_json_file(entry_path).resources.each do |entry|
|
18
|
+
attachment_fields.each do |field|
|
19
|
+
if file = entry.send(field.identifier)
|
20
|
+
puts "Downloading #{file[:@url]} including all versions"
|
21
|
+
file.download_to_directory(download_path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/examples/create_entry.rb
CHANGED
data/examples/destroy_entry.rb
CHANGED
data/examples/get_collections.rb
CHANGED
data/examples/import_csv.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby -rubygems
|
2
2
|
|
3
|
-
require File.dirname(__FILE__)
|
3
|
+
require File.join(File.dirname(__FILE__), 'authentication')
|
4
4
|
|
5
5
|
require "csv" # faster_csv (ruby 1.9)
|
6
6
|
|
7
|
-
lines = CSV.read(File.dirname(__FILE__)
|
7
|
+
lines = CSV.read(File.join(File.dirname(__FILE__), 'guidebooks.csv')) # Exported an Excel file as CSV
|
8
8
|
|
9
9
|
lines.slice!(0) # remove header line
|
10
10
|
|
data/examples/search_entries.rb
CHANGED
data/examples/update_entry.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby -rubygems
|
2
2
|
|
3
|
-
require File.dirname(__FILE__)
|
3
|
+
require File.join(File.dirname(__FILE__), 'authentication')
|
4
4
|
|
5
|
-
path = ::File.expand_path(File.dirname(__FILE__) + '
|
5
|
+
path = ::File.expand_path(File.join(File.dirname(__FILE__) + '..', 'spec', 'fixtures', 'image.png'))
|
6
6
|
collection = StorageRoom::Collection.find('4e034b8db65245b72600002b')
|
7
7
|
|
8
8
|
# Upload Image or File
|
@@ -152,10 +152,16 @@ module StorageRoom
|
|
152
152
|
new_from_response_data(httparty.parsed_response.first[1])
|
153
153
|
end
|
154
154
|
|
155
|
+
# Build an object out of a local file
|
156
|
+
def new_from_json_file(path)
|
157
|
+
json = ::File.read(path)
|
158
|
+
new_from_json_string(json)
|
159
|
+
end
|
160
|
+
|
155
161
|
# Build an object out of the POST body
|
156
162
|
def new_from_json_string(json_string)
|
157
163
|
hash = JSON.parse(json_string)
|
158
|
-
new_from_response_data(hash)
|
164
|
+
new_from_response_data(hash.first[1])
|
159
165
|
end
|
160
166
|
|
161
167
|
# Creates a new object of the correct class and initializes it from the response data
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
1
3
|
|
2
4
|
module StorageRoom
|
3
5
|
# Any file
|
@@ -23,6 +25,34 @@ module StorageRoom
|
|
23
25
|
self.data = ::Base64.encode64(::File.read(path))
|
24
26
|
end
|
25
27
|
|
28
|
+
# Returns the file type based on the extension
|
29
|
+
def file_type
|
30
|
+
self[:@url] ? ::File.extname(self[:@url])[1..-1] : nil
|
31
|
+
end
|
32
|
+
|
33
|
+
# Download the file to the local disk
|
34
|
+
def download_to_directory(path)
|
35
|
+
Dir.mkdir(path) unless ::File.directory?(path)
|
36
|
+
download_file(self[:@url], ::File.join(path, local_filename))
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
# The localized filename built out of the URL
|
41
|
+
def local_filename
|
42
|
+
self[:@url] ? localize_filename(self[:@url]) : nil
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
def localize_filename(filename)
|
47
|
+
filename.gsub(/\Ahttps?:\/\//, '').gsub('/', '_')
|
48
|
+
end
|
49
|
+
|
50
|
+
def download_file(url, path)
|
51
|
+
file = open(path, "wb")
|
52
|
+
file.write(open(url).read)
|
53
|
+
file.close
|
54
|
+
end
|
55
|
+
|
26
56
|
|
27
57
|
end
|
28
58
|
end
|
@@ -24,5 +24,18 @@ module StorageRoom
|
|
24
24
|
self[:@processing]
|
25
25
|
end
|
26
26
|
|
27
|
+
def local_filename(name = nil)
|
28
|
+
localize_filename(url(name))
|
29
|
+
end
|
30
|
+
|
31
|
+
def download_to_directory(path)
|
32
|
+
super
|
33
|
+
|
34
|
+
version_identifiers.each do |version|
|
35
|
+
download_file(self.url(version), ::File.join(path, local_filename(version)))
|
36
|
+
end
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
27
40
|
end
|
28
41
|
end
|
data/lib/storage_room.rb
CHANGED
@@ -105,7 +105,7 @@ module StorageRoom
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def version
|
108
|
-
@version ||= ::File.read(::File.expand_path(::File.dirname(__FILE__)
|
108
|
+
@version ||= ::File.read(::File.expand_path(::File.join(::File.dirname(__FILE__), '..', 'VERSION')))
|
109
109
|
end
|
110
110
|
|
111
111
|
# Requests are made with SSL
|
@@ -0,0 +1,108 @@
|
|
1
|
+
{
|
2
|
+
"collection": {
|
3
|
+
"@type": "Collection",
|
4
|
+
"@url": "http://api.storageroomapp.com/accounts/4e1e9c234250712eba000052/collections/4e23f1ad42507165a3000002",
|
5
|
+
"@account_url": "http://api.storageroomapp.com/accounts/4e1e9c234250712eba000052",
|
6
|
+
"@entries_url": "http://api.storageroomapp.com/accounts/4e1e9c234250712eba000052/collections/4e23f1ad42507165a3000002/entries",
|
7
|
+
"@version": 1,
|
8
|
+
"@created_at": "2011-07-18T08:41:17Z",
|
9
|
+
"@updated_at": "2011-07-18T08:41:17Z",
|
10
|
+
"name": "Restaurants",
|
11
|
+
"primary_field_identifier": null,
|
12
|
+
"fields": [{
|
13
|
+
"@type": "StringField",
|
14
|
+
"name": "Name",
|
15
|
+
"identifier": "name",
|
16
|
+
"interface": true,
|
17
|
+
"input_type": "text_field",
|
18
|
+
"required": true,
|
19
|
+
"include_blank_choice": false
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"@type": "StringField",
|
23
|
+
"name": "Text",
|
24
|
+
"identifier": "text",
|
25
|
+
"interface": true,
|
26
|
+
"input_type": "text_area",
|
27
|
+
"required": true,
|
28
|
+
"include_blank_choice": false
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"@type": "StringField",
|
32
|
+
"name": "Address",
|
33
|
+
"identifier": "address",
|
34
|
+
"interface": true,
|
35
|
+
"input_type": "text_area",
|
36
|
+
"include_blank_choice": false
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"@type": "StringField",
|
40
|
+
"name": "Website",
|
41
|
+
"identifier": "website",
|
42
|
+
"interface": true,
|
43
|
+
"input_type": "text_field",
|
44
|
+
"include_blank_choice": false
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"@type": "DateField",
|
48
|
+
"name": "Last Visit",
|
49
|
+
"identifier": "last_visit",
|
50
|
+
"interface": true,
|
51
|
+
"input_type": "date_picker",
|
52
|
+
"include_blank_choice": false
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"@type": "LocationField",
|
56
|
+
"name": "Location",
|
57
|
+
"identifier": "location",
|
58
|
+
"interface": true,
|
59
|
+
"input_type": "location",
|
60
|
+
"required": true
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"@type": "IntegerField",
|
64
|
+
"name": "Price Range",
|
65
|
+
"identifier": "price_range",
|
66
|
+
"interface": true,
|
67
|
+
"input_type": "select",
|
68
|
+
"required": true,
|
69
|
+
"include_blank_choice": false,
|
70
|
+
"choices": [1, 2, 3]
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"@type": "IntegerField",
|
74
|
+
"name": "Stars",
|
75
|
+
"identifier": "stars",
|
76
|
+
"interface": true,
|
77
|
+
"input_type": "select",
|
78
|
+
"required": true,
|
79
|
+
"include_blank_choice": false,
|
80
|
+
"choices": [1, 2, 3, 4, 5]
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"@type": "BooleanField",
|
84
|
+
"name": "Vegetarian Menu",
|
85
|
+
"identifier": "vegetarian_menu",
|
86
|
+
"interface": true,
|
87
|
+
"input_type": "radio",
|
88
|
+
"include_blank_choice": false
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"@type": "FileField",
|
92
|
+
"name": "Image",
|
93
|
+
"identifier": "image",
|
94
|
+
"interface": true,
|
95
|
+
"input_type": "file",
|
96
|
+
"hint": "Upload an image"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"@type": "FileField",
|
100
|
+
"name": "Preview Image",
|
101
|
+
"identifier": "preview_image",
|
102
|
+
"interface": true,
|
103
|
+
"input_type": "file",
|
104
|
+
"hint": "Upload an preview image"
|
105
|
+
}],
|
106
|
+
"webhook_definitions": []
|
107
|
+
}
|
108
|
+
}
|
@@ -0,0 +1,307 @@
|
|
1
|
+
{
|
2
|
+
"array": {
|
3
|
+
"@total_resources": 10,
|
4
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries",
|
5
|
+
"@type": "Array",
|
6
|
+
"resources": [{
|
7
|
+
"@type": "Restaurant",
|
8
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091aba05617333000014",
|
9
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
10
|
+
"@version": 1,
|
11
|
+
"@trash": false,
|
12
|
+
"@created_at": "2011-04-01T17:19:22Z",
|
13
|
+
"@updated_at": "2011-04-01T17:19:22Z",
|
14
|
+
"name": "Peter Luger",
|
15
|
+
"text": "Rated No. 1 New York Steak House for 26 years in a Row.",
|
16
|
+
"address": "178 Broadway\nBrooklyn, N.Y. 11211",
|
17
|
+
"website": "http://www.peterluger.com/",
|
18
|
+
"last_visit": "2011-03-02",
|
19
|
+
"location": {
|
20
|
+
"@type": "Location",
|
21
|
+
"lat": 40.7097,
|
22
|
+
"lng": -73.962
|
23
|
+
},
|
24
|
+
"price_range": 3,
|
25
|
+
"stars": 4,
|
26
|
+
"vegetarian_menu": false,
|
27
|
+
"image": {
|
28
|
+
"@type": "File",
|
29
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000014/fields/k4d960916ba0561733300000f/file.png"
|
30
|
+
},
|
31
|
+
"preview_image": {
|
32
|
+
"@type": "File",
|
33
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000014/fields/k4d960916ba05617333000010/file.png"
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"@type": "Restaurant",
|
38
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d960917ba05617333000011",
|
39
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
40
|
+
"@version": 1,
|
41
|
+
"@trash": false,
|
42
|
+
"@created_at": "2011-04-01T17:19:19Z",
|
43
|
+
"@updated_at": "2011-04-01T17:19:19Z",
|
44
|
+
"name": "M-Steakhouse",
|
45
|
+
"text": "Probably the best beef in Germany.",
|
46
|
+
"address": "Feuerbachstrasse 11a\n60325 Frankfurt am Main\nGermany",
|
47
|
+
"website": "http://www.the-steakhouse.de/steakhouse/main-frames.html",
|
48
|
+
"last_visit": "2011-04-01",
|
49
|
+
"location": {
|
50
|
+
"@type": "Location",
|
51
|
+
"lat": 50.1158,
|
52
|
+
"lng": 8.6631
|
53
|
+
},
|
54
|
+
"price_range": 3,
|
55
|
+
"stars": 4,
|
56
|
+
"vegetarian_menu": true,
|
57
|
+
"image": {
|
58
|
+
"@type": "File",
|
59
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d960917ba05617333000011/fields/k4d960916ba0561733300000f/file.png"
|
60
|
+
},
|
61
|
+
"preview_image": {
|
62
|
+
"@type": "File",
|
63
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d960917ba05617333000011/fields/k4d960916ba05617333000010/file.png"
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"@type": "Restaurant",
|
68
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d960919ba05617333000012",
|
69
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
70
|
+
"@version": 1,
|
71
|
+
"@trash": false,
|
72
|
+
"@created_at": "2011-04-01T17:19:21Z",
|
73
|
+
"@updated_at": "2011-05-05T20:07:18Z",
|
74
|
+
"name": "Banyan Tree Bangkok - Vertigo",
|
75
|
+
"text": "A must-see on every Bangkok travel itinerary, Vertigo is unlike any other bar-restaurant in the world: some 61 floors above the streets of Bangkok, this open-air rooftop lounge gives true meaning to the word 'vertigo' as it grants views that simply take your breath away. Stylish, sophisticated and reaching for the clouds, there is no better place for a romantic t\u00eate-\u00e0-t\u00eate, glamorous cocktail party or fashion launch than this. Indulge in a variety of western-style fresh grilled seafood and premium steaks, champagne and a wide selection of cocktails, wines-by-the-glass and non-alcoholic drinks.",
|
76
|
+
"address": "21/100 South Sathon Road\r\nBangkok, 10120\r\n Thailand",
|
77
|
+
"website": "http://www.banyantree.com/en/bangkok/overview",
|
78
|
+
"last_visit": "2011-03-29",
|
79
|
+
"location": {
|
80
|
+
"@type": "Location",
|
81
|
+
"lat": 13.724,
|
82
|
+
"lng": 100.5411
|
83
|
+
},
|
84
|
+
"price_range": 2,
|
85
|
+
"stars": 3,
|
86
|
+
"vegetarian_menu": false,
|
87
|
+
"image": {
|
88
|
+
"@type": "File",
|
89
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d960919ba05617333000012/fields/k4d960916ba0561733300000f/file.png"
|
90
|
+
},
|
91
|
+
"preview_image": {
|
92
|
+
"@type": "File",
|
93
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d960919ba05617333000012/fields/k4d960916ba05617333000010/file.png"
|
94
|
+
}
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"@type": "Restaurant",
|
98
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091aba05617333000013",
|
99
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
100
|
+
"@version": 1,
|
101
|
+
"@trash": false,
|
102
|
+
"@created_at": "2011-04-01T17:19:22Z",
|
103
|
+
"@updated_at": "2011-04-01T17:19:22Z",
|
104
|
+
"name": "Wolfgang's Steakhouse",
|
105
|
+
"text": "Located in the heart of midtown Manhattan, the flagship Park Avenue Wolfgang\u2019s is splendidly situated in the former Vanderbilt Hotel dining room.",
|
106
|
+
"address": "4 Park Avenue\nNew York, NY 10016",
|
107
|
+
"website": "http://www.wolfgangssteakhouse.net/",
|
108
|
+
"last_visit": "2011-03-25",
|
109
|
+
"location": {
|
110
|
+
"@type": "Location",
|
111
|
+
"lat": 40.7465,
|
112
|
+
"lng": -73.682
|
113
|
+
},
|
114
|
+
"price_range": 2,
|
115
|
+
"stars": 2,
|
116
|
+
"vegetarian_menu": false,
|
117
|
+
"image": {
|
118
|
+
"@type": "File",
|
119
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000013/fields/k4d960916ba0561733300000f/file.png"
|
120
|
+
},
|
121
|
+
"preview_image": {
|
122
|
+
"@type": "File",
|
123
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000013/fields/k4d960916ba05617333000010/file.png"
|
124
|
+
}
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"@type": "Restaurant",
|
128
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091aba05617333000015",
|
129
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
130
|
+
"@version": 1,
|
131
|
+
"@trash": false,
|
132
|
+
"@created_at": "2011-04-01T17:19:22Z",
|
133
|
+
"@updated_at": "2011-04-01T17:19:22Z",
|
134
|
+
"name": "Pat's King of Steaks",
|
135
|
+
"text": "Creator of the Philly Steak and Cheese Steak",
|
136
|
+
"address": "1237 East Passyunk Avenue\n, Philadelphia, PA",
|
137
|
+
"website": "http://www.patskingofsteaks.com/",
|
138
|
+
"last_visit": "2011-03-29",
|
139
|
+
"location": {
|
140
|
+
"@type": "Location",
|
141
|
+
"lat": 39.933,
|
142
|
+
"lng": -75.159
|
143
|
+
},
|
144
|
+
"price_range": 1,
|
145
|
+
"stars": 3,
|
146
|
+
"vegetarian_menu": true,
|
147
|
+
"image": {
|
148
|
+
"@type": "File",
|
149
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000015/fields/k4d960916ba0561733300000f/file.png"
|
150
|
+
},
|
151
|
+
"preview_image": {
|
152
|
+
"@type": "File",
|
153
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000015/fields/k4d960916ba05617333000010/file.png"
|
154
|
+
}
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"@type": "Restaurant",
|
158
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091bba05617333000016",
|
159
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
160
|
+
"@version": 1,
|
161
|
+
"@trash": false,
|
162
|
+
"@created_at": "2011-04-01T17:19:23Z",
|
163
|
+
"@updated_at": "2011-04-01T17:19:23Z",
|
164
|
+
"name": "Shula's",
|
165
|
+
"text": "One of the best Steak Houses in Florida",
|
166
|
+
"address": "7601 Miami Lakes Drive\nMiami Lakes, FL 33014",
|
167
|
+
"website": "http://www.donshula.com/locations.php?sub=4&l=1&restid=7",
|
168
|
+
"last_visit": "2010-12-22",
|
169
|
+
"location": {
|
170
|
+
"@type": "Location",
|
171
|
+
"lat": 25.913,
|
172
|
+
"lng": -80.322
|
173
|
+
},
|
174
|
+
"price_range": 3,
|
175
|
+
"stars": 4,
|
176
|
+
"vegetarian_menu": false,
|
177
|
+
"image": {
|
178
|
+
"@type": "File",
|
179
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091bba05617333000016/fields/k4d960916ba0561733300000f/file.png"
|
180
|
+
},
|
181
|
+
"preview_image": {
|
182
|
+
"@type": "File",
|
183
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091bba05617333000016/fields/k4d960916ba05617333000010/file.png"
|
184
|
+
}
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"@type": "Restaurant",
|
188
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091bba05617333000017",
|
189
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
190
|
+
"@version": 1,
|
191
|
+
"@trash": false,
|
192
|
+
"@created_at": "2011-04-01T17:19:23Z",
|
193
|
+
"@updated_at": "2011-04-01T17:19:23Z",
|
194
|
+
"name": "LG's Steak House",
|
195
|
+
"text": "In December of 1997, a second LG's Prime Steakhouse opened in beautiful downtown Palm Springs, California. Located on South Palm Canyon Drive, between the cross streets of Arenas and Barristo, LG's Prime Steakhouse, Palm Springs features a large covered patio for dining and people watching on South Palm Canyon. The d\u00e9cor is eclectic and the restaurant has a private dining room for parties. French doors in the main dining area open onto the patio, which also has an indoor-outdoor bar.",
|
196
|
+
"address": "255 S. Palm Canyon Drive\nPalm Springs, CA 92262",
|
197
|
+
"website": "http://www.lgsprimesteakhouse.com/palmsprings.html",
|
198
|
+
"last_visit": "2010-04-01",
|
199
|
+
"location": {
|
200
|
+
"@type": "Location",
|
201
|
+
"lat": 33.82,
|
202
|
+
"lng": -116.546
|
203
|
+
},
|
204
|
+
"price_range": 3,
|
205
|
+
"stars": 5,
|
206
|
+
"vegetarian_menu": false,
|
207
|
+
"image": {
|
208
|
+
"@type": "File",
|
209
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091bba05617333000017/fields/k4d960916ba0561733300000f/file.png"
|
210
|
+
},
|
211
|
+
"preview_image": {
|
212
|
+
"@type": "File",
|
213
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091bba05617333000017/fields/k4d960916ba05617333000010/file.png"
|
214
|
+
}
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"@type": "Restaurant",
|
218
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091cba05617333000018",
|
219
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
220
|
+
"@version": 1,
|
221
|
+
"@trash": false,
|
222
|
+
"@created_at": "2011-04-01T17:19:24Z",
|
223
|
+
"@updated_at": "2011-04-01T17:19:24Z",
|
224
|
+
"name": "Hill Top Steak House",
|
225
|
+
"text": "In 1961 Frank Giuffrida bought a club in Saugus that he converted into a western-style steakhouse. Over the years Frank became known as the \"king of the Hill\" serving over three million customers annually. Now over 50 million meals later The Hilltop is still known today for it's generous portions at a great value winning numerous awards.",
|
226
|
+
"address": "855 Broadway, Saugus, MA",
|
227
|
+
"website": "http://hilltopsteakhouse.com",
|
228
|
+
"last_visit": "2011-02-06",
|
229
|
+
"location": {
|
230
|
+
"@type": "Location",
|
231
|
+
"lat": 42.474,
|
232
|
+
"lng": -71.023
|
233
|
+
},
|
234
|
+
"price_range": 2,
|
235
|
+
"stars": 1,
|
236
|
+
"vegetarian_menu": true,
|
237
|
+
"image": {
|
238
|
+
"@type": "File",
|
239
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091cba05617333000018/fields/k4d960916ba0561733300000f/file.png"
|
240
|
+
},
|
241
|
+
"preview_image": {
|
242
|
+
"@type": "File",
|
243
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091cba05617333000018/fields/k4d960916ba05617333000010/file.png"
|
244
|
+
}
|
245
|
+
},
|
246
|
+
{
|
247
|
+
"@type": "Restaurant",
|
248
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091cba05617333000019",
|
249
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
250
|
+
"@version": 1,
|
251
|
+
"@trash": false,
|
252
|
+
"@created_at": "2011-04-01T17:19:24Z",
|
253
|
+
"@updated_at": "2011-04-01T17:19:24Z",
|
254
|
+
"name": "Morton's Steak House",
|
255
|
+
"text": "Located in Toronto's trendy Yorkville at the Park Hyatt Hotel, Morton's the Steakhouse offers a classic dining experience. Welcoming decor, succulent steaks and fresh fish and seafood make Morton's a destination for Torontonians, celebrities and tourists alike. Whether you are looking for the perfect place to unwind with cocktails and Bar Bites or to book a private boardroom for a special occasion, Morton's offers impeccable service and a timeless menu.",
|
256
|
+
"address": "4 Avenue Road at Prince Arthur\nToronto, Canada",
|
257
|
+
"website": "http://www.mortons.com/toronto/",
|
258
|
+
"last_visit": "2010-11-29",
|
259
|
+
"location": {
|
260
|
+
"@type": "Location",
|
261
|
+
"lat": 43.668,
|
262
|
+
"lng": -79.394
|
263
|
+
},
|
264
|
+
"price_range": 3,
|
265
|
+
"stars": 3,
|
266
|
+
"vegetarian_menu": true,
|
267
|
+
"image": {
|
268
|
+
"@type": "File",
|
269
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091cba05617333000019/fields/k4d960916ba0561733300000f/file.png"
|
270
|
+
},
|
271
|
+
"preview_image": {
|
272
|
+
"@type": "File",
|
273
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091cba05617333000019/fields/k4d960916ba05617333000010/file.png"
|
274
|
+
}
|
275
|
+
},
|
276
|
+
{
|
277
|
+
"@type": "Restaurant",
|
278
|
+
"@url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091cba0561733300001a",
|
279
|
+
"@collection_url": "http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005",
|
280
|
+
"@version": 1,
|
281
|
+
"@trash": false,
|
282
|
+
"@created_at": "2011-04-01T17:19:24Z",
|
283
|
+
"@updated_at": "2011-04-01T17:19:24Z",
|
284
|
+
"name": "Ruth's Chris Honululu",
|
285
|
+
"text": "Whether it's a romantic steak dinner for two, an important business meeting, or a private party, Ruth's Chris Steak House can accommodate your needs. Our Honolulu steakhouse provides guests with a warm, comfortable atmosphere. The restaurant is also handicap accessible.",
|
286
|
+
"address": "500 Ala Moana Blvd,\nRestaurant Row,\nHonolulu, HI 96813",
|
287
|
+
"website": "http://www.ruthschris.com/Steak-House/6504/Honolulu/Oahu",
|
288
|
+
"last_visit": "2011-01-14",
|
289
|
+
"location": {
|
290
|
+
"@type": "Location",
|
291
|
+
"lat": 21.3,
|
292
|
+
"lng": -157.861
|
293
|
+
},
|
294
|
+
"price_range": 3,
|
295
|
+
"stars": 4,
|
296
|
+
"vegetarian_menu": false,
|
297
|
+
"image": {
|
298
|
+
"@type": "File",
|
299
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091cba0561733300001a/fields/k4d960916ba0561733300000f/file.png"
|
300
|
+
},
|
301
|
+
"preview_image": {
|
302
|
+
"@type": "File",
|
303
|
+
"@url": "http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091cba0561733300001a/fields/k4d960916ba05617333000010/file.png"
|
304
|
+
}
|
305
|
+
}]
|
306
|
+
}
|
307
|
+
}
|
@@ -1,18 +1,20 @@
|
|
1
1
|
{
|
2
|
-
"
|
3
|
-
|
4
|
-
|
5
|
-
"@
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
2
|
+
"webhook_call": {
|
3
|
+
"@attempts": 0,
|
4
|
+
"@created_at": "2011-07-14T18:25:42Z",
|
5
|
+
"@entry": {
|
6
|
+
"@collection_url": "http:\/\/api.storageroomapp.com\/accounts\/4e1e9c234250712eba000052\/collections\/4e1e9c234250712eba000062",
|
7
|
+
"@created_at": "2011-07-14T18:15:53Z",
|
8
|
+
"@type": "Announcement",
|
9
|
+
"@trash": false,
|
10
|
+
"@updated_at": "2011-07-14T18:25:42Z",
|
11
|
+
"@url": "http:\/\/api.storageroomapp.com\/accounts\/4e1e9c234250712eba000052\/collections\/4e1e9c234250712eba000062\/entries\/4e1f3259425071435e00004a",
|
12
|
+
"@version": 2,
|
13
|
+
"text": "WEBHOOK TEST"
|
14
|
+
},
|
15
|
+
"@event": "update",
|
16
|
+
"@last_attempt_at": null,
|
17
|
+
"@last_status_code": null,
|
18
|
+
"@type": "WebhookCall"
|
19
|
+
}
|
18
20
|
}
|
data/spec/spec_helper.rb
CHANGED
@@ -19,9 +19,12 @@ def stub_url(url)
|
|
19
19
|
"APPLICATION_API_KEY:X@api.storageroomapp.com/accounts/USER_ID#{url}"
|
20
20
|
end
|
21
21
|
|
22
|
+
def fixture_path(name)
|
23
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', name))
|
24
|
+
end
|
25
|
+
|
22
26
|
def fixture_file(name)
|
23
|
-
|
24
|
-
File.read(path)
|
27
|
+
File.read(fixture_path(name))
|
25
28
|
end
|
26
29
|
|
27
30
|
def mock_httparty(code)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
2
|
|
3
3
|
module StorageRoom
|
4
4
|
class TestAccessors
|
@@ -10,6 +10,17 @@ module StorageRoom
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe StorageRoom::TestAccessors do
|
13
|
+
context "Class" do
|
14
|
+
describe "new_from_json_file" do
|
15
|
+
it "should open file" do
|
16
|
+
path = fixture_path('export_collection.json')
|
17
|
+
object = StorageRoom::Resource.new_from_json_file(path)
|
18
|
+
object.should be_an_instance_of(StorageRoom::Collection)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
13
24
|
|
14
25
|
context "Instance" do
|
15
26
|
before(:each) do
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
3
3
|
describe StorageRoom::File do
|
4
4
|
before(:each) do
|
5
5
|
@file = StorageRoom::File.new
|
6
|
-
@name =
|
6
|
+
@name = fixture_path('image.png')
|
7
7
|
end
|
8
8
|
|
9
9
|
context "Class Methods" do
|
@@ -39,6 +39,29 @@ describe StorageRoom::File do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
describe "#file_type" do
|
43
|
+
it "should return type" do
|
44
|
+
@file.response_data[:@url] = 'http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000014/fields/k4d960916ba0561733300000f/file.png'
|
45
|
+
@file.file_type.should == 'png'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return nil" do
|
49
|
+
@file.file_type.should be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#local_filename" do
|
54
|
+
it "should return filename" do
|
55
|
+
@file.response_data[:@url] = 'http://files.storageroomapp.com/accounts/4d13574cba05613d25000004/collection/4d960916ba05617333000005/entries/4d96091aba05617333000014/fields/k4d960916ba0561733300000f/file.png'
|
56
|
+
@file.local_filename.should == 'files.storageroomapp.com_accounts_4d13574cba05613d25000004_collection_4d960916ba05617333000005_entries_4d96091aba05617333000014_fields_k4d960916ba0561733300000f_file.png'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return nil" do
|
60
|
+
@file.local_filename.should be_nil
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
42
65
|
end
|
43
66
|
end
|
44
67
|
end
|
@@ -55,6 +55,17 @@ describe StorageRoom::Entry do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
describe "#id" do
|
59
|
+
it "should return with url" do
|
60
|
+
@entry.response_data[:@url] = 'http://api.storageroomapp.com/accounts/4d13574cba05613d25000004/collections/4d960916ba05617333000005/entries/4d96091aba05617333000014'
|
61
|
+
@entry.id.should == '4d96091aba05617333000014'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return nil" do
|
65
|
+
@entry.id.should be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
58
69
|
describe "#trashed?" do
|
59
70
|
it "should return true" do
|
60
71
|
@entry.response_data[:@trash] = true
|
data/storage_room.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{storage_room}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.6"
|
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 = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-19}
|
13
13
|
s.description = %q{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 = %q{sascha@thriventures.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"TODO",
|
26
26
|
"VERSION",
|
27
27
|
"examples/authentication.rb",
|
28
|
+
"examples/backup_uploads_from_export.rb",
|
28
29
|
"examples/create_entry.rb",
|
29
30
|
"examples/destroy_entry.rb",
|
30
31
|
"examples/get_collections.rb",
|
@@ -72,6 +73,8 @@ Gem::Specification.new do |s|
|
|
72
73
|
"lib/storage_room/webhook_call.rb",
|
73
74
|
"spec/fixtures/collection.json",
|
74
75
|
"spec/fixtures/collections.json",
|
76
|
+
"spec/fixtures/export_collection.json",
|
77
|
+
"spec/fixtures/export_entries.json",
|
75
78
|
"spec/fixtures/image.png",
|
76
79
|
"spec/fixtures/validation_error.json",
|
77
80
|
"spec/fixtures/webhook_call.json",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 6
|
9
|
+
version: 0.3.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sascha Konietzke
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-07-
|
17
|
+
date: 2011-07-19 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- TODO
|
107
107
|
- VERSION
|
108
108
|
- examples/authentication.rb
|
109
|
+
- examples/backup_uploads_from_export.rb
|
109
110
|
- examples/create_entry.rb
|
110
111
|
- examples/destroy_entry.rb
|
111
112
|
- examples/get_collections.rb
|
@@ -153,6 +154,8 @@ files:
|
|
153
154
|
- lib/storage_room/webhook_call.rb
|
154
155
|
- spec/fixtures/collection.json
|
155
156
|
- spec/fixtures/collections.json
|
157
|
+
- spec/fixtures/export_collection.json
|
158
|
+
- spec/fixtures/export_entries.json
|
156
159
|
- spec/fixtures/image.png
|
157
160
|
- spec/fixtures/validation_error.json
|
158
161
|
- spec/fixtures/webhook_call.json
|