storage_room 0.1.1 → 0.1.2
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.
- data/README.rdoc +7 -7
- data/TODO +0 -3
- data/VERSION +1 -1
- data/examples/create_entry.rb +24 -0
- data/examples/{destroy_resource.rb → destroy_entry.rb} +3 -3
- data/examples/get_collections.rb +1 -1
- data/examples/search_entries.rb +13 -0
- data/examples/update_entry.rb +15 -0
- data/lib/storage_room/array.rb +12 -12
- data/lib/storage_room/embeddeds/file.rb +1 -1
- data/lib/storage_room/embeddeds/location.rb +1 -1
- data/lib/storage_room/model.rb +3 -3
- data/lib/storage_room/models/collection.rb +6 -6
- data/lib/storage_room/models/{resource.rb → entry.rb} +7 -7
- data/lib/storage_room.rb +4 -4
- data/spec/fixtures/collection.json +1 -1
- data/spec/fixtures/collections.json +2 -2
- data/spec/storage_room/array_spec.rb +12 -12
- data/spec/storage_room/base_spec.rb +2 -2
- data/spec/storage_room/model_spec.rb +6 -6
- data/spec/storage_room/models/collection_spec.rb +6 -6
- data/spec/storage_room/models/{resource_spec.rb → entry_spec.rb} +8 -8
- data/spec/storage_room_spec.rb +2 -2
- data/storage_room.gemspec +64 -66
- metadata +20 -21
- data/.gitignore +0 -22
- data/examples/create_resource.rb +0 -24
- data/examples/search_resources.rb +0 -13
- data/examples/update_resource.rb +0 -15
data/README.rdoc
CHANGED
@@ -12,20 +12,20 @@ To install the library execute:
|
|
12
12
|
|
13
13
|
== Basic Usage
|
14
14
|
|
15
|
-
This is a walkthrough with all steps you need to setup a devise
|
15
|
+
This is a walkthrough with all steps you need to setup a devise entry, including model, migration, route files, and optional configuration.
|
16
16
|
|
17
17
|
StorageRoom.authenticate(YOUR_ACCOUNT_ID, YOUR_APPLICATION_API_KEY)
|
18
18
|
collection = StorageRoom::Collection.find('guidebooks')
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
entries = collection.entries
|
21
|
+
entry = entries.resources.first
|
22
22
|
|
23
|
-
|
23
|
+
entry[:name] = 'Foobar'
|
24
24
|
|
25
|
-
if
|
26
|
-
puts "
|
25
|
+
if entry.save
|
26
|
+
puts "Entry saved."
|
27
27
|
else
|
28
|
-
puts "Could not save
|
28
|
+
puts "Could not save Entry: #{entry.errors.join(', )}"
|
29
29
|
end
|
30
30
|
|
31
31
|
You can find the documentation at http://rdoc.info/github/thriventures/storage_room_gem.
|
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/authentication'
|
4
|
+
|
5
|
+
# create a entry without fetching the collection
|
6
|
+
klass = StorageRoom.class_for_name('Guidebook')
|
7
|
+
entry1 = klass.new(:name => 'Foo', :price => 1.23)
|
8
|
+
|
9
|
+
if entry1.save
|
10
|
+
puts "Entry saved"
|
11
|
+
else
|
12
|
+
puts "Entry could not be saved: #{entry1.errors.join(', ')}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# fetch the collection first
|
16
|
+
collection = StorageRoom::Collection.find('guidebooks')
|
17
|
+
|
18
|
+
entry2 = collection.entry_class.new(:name => 'Bar', :price => 2.23)
|
19
|
+
|
20
|
+
if entry2.save
|
21
|
+
puts "Entry saved"
|
22
|
+
else
|
23
|
+
puts "Entry could not be saved: #{entry2.errors.join(', ')}"
|
24
|
+
end
|
@@ -4,8 +4,8 @@ require File.dirname(__FILE__) + '/authentication'
|
|
4
4
|
|
5
5
|
collection = StorageRoom::Collection.find('guidebooks')
|
6
6
|
|
7
|
-
|
7
|
+
entry = collection.entries.resources.first
|
8
8
|
|
9
|
-
|
9
|
+
entry.destroy
|
10
10
|
|
11
|
-
puts "Destroyed #{
|
11
|
+
puts "Destroyed #{entry[:name]}"
|
data/examples/get_collections.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/authentication'
|
4
|
+
|
5
|
+
collection = StorageRoom::Collection.find('guidebooks')
|
6
|
+
|
7
|
+
entries = collection.entry_class.search(:name => 'Bar')
|
8
|
+
|
9
|
+
puts "Entries with name 'Bar':"
|
10
|
+
|
11
|
+
entries.resources.each do |entry|
|
12
|
+
puts "- #{entry[:name]}"
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/authentication'
|
4
|
+
|
5
|
+
collection = StorageRoom::Collection.find('guidebooks')
|
6
|
+
|
7
|
+
entry = collection.entries.resources.first
|
8
|
+
|
9
|
+
entry[:name] = 'Foobar'
|
10
|
+
|
11
|
+
if entry.save
|
12
|
+
puts "Entry saved"
|
13
|
+
else
|
14
|
+
puts "Entry could not be saved: #{entry.errors.join(', ')}"
|
15
|
+
end
|
data/lib/storage_room/array.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module StorageRoom
|
2
|
-
# A container object that contains many models (collections or
|
2
|
+
# A container object that contains many models (collections or entries)
|
3
3
|
class Array < Base
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :resources
|
5
5
|
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
8
|
-
self.
|
8
|
+
self.resources = []
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
@@ -13,20 +13,20 @@ module StorageRoom
|
|
13
13
|
def set_from_api(attributes)
|
14
14
|
super(attributes)
|
15
15
|
|
16
|
-
self.
|
17
|
-
attributes.delete('
|
16
|
+
self.resources = attributes['resources'].map{|item| self.class.create_from_api(item)} # transform hashes to real objects
|
17
|
+
attributes.delete('resources')
|
18
18
|
end
|
19
19
|
|
20
20
|
# Reset the Array to its default state with all attributes unset
|
21
21
|
def reset!
|
22
22
|
super
|
23
|
-
@
|
23
|
+
@resources = []
|
24
24
|
end
|
25
25
|
|
26
26
|
# Replaces the objects content with the next page of the array if a next page exists
|
27
27
|
def load_next_page!
|
28
|
-
if self[:@
|
29
|
-
reload(self[:@
|
28
|
+
if self[:@next_page_url].present?
|
29
|
+
reload(self[:@next_page_url])
|
30
30
|
true
|
31
31
|
else
|
32
32
|
false
|
@@ -35,8 +35,8 @@ module StorageRoom
|
|
35
35
|
|
36
36
|
# Replace the Collection with the privious page of elements if there is one
|
37
37
|
def load_previous_page!
|
38
|
-
if self[:@
|
39
|
-
reload(self[:@
|
38
|
+
if self[:@previous_page_url].present?
|
39
|
+
reload(self[:@previous_page_url])
|
40
40
|
true
|
41
41
|
else
|
42
42
|
false
|
@@ -51,10 +51,10 @@ module StorageRoom
|
|
51
51
|
end while(args[:reverse] == true ? load_previous_page! : load_next_page!)
|
52
52
|
end
|
53
53
|
|
54
|
-
# Iterate over all
|
54
|
+
# Iterate over all resources with pagination
|
55
55
|
def each_page_each_item(args={})
|
56
56
|
self.each_page(args) do |page|
|
57
|
-
page.
|
57
|
+
page.resources.each do |item|
|
58
58
|
yield(item)
|
59
59
|
end
|
60
60
|
end
|
data/lib/storage_room/model.rb
CHANGED
@@ -4,9 +4,9 @@ module StorageRoom
|
|
4
4
|
class << self
|
5
5
|
# Create a new model with the passed attributes
|
6
6
|
def create(attributes={})
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
entry = new(attributes)
|
8
|
+
entry.create
|
9
|
+
entry
|
10
10
|
end
|
11
11
|
|
12
12
|
# Get all models (could be paginated)
|
@@ -10,8 +10,8 @@ module StorageRoom
|
|
10
10
|
"#{index_path}/#{collection_id}"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
"#{show_path(collection_id)}/
|
13
|
+
def entries_path(collection_id) # :nodoc:
|
14
|
+
"#{show_path(collection_id)}/entries"
|
15
15
|
end
|
16
16
|
|
17
17
|
def json_name # :nodoc:
|
@@ -19,13 +19,13 @@ module StorageRoom
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
# Load all the
|
23
|
-
def
|
24
|
-
Array.load(self[:@
|
22
|
+
# Load all the entries of a collection
|
23
|
+
def entries
|
24
|
+
Array.load(self[:@entries_url])
|
25
25
|
end
|
26
26
|
|
27
27
|
# The class of the collection's objects
|
28
|
-
def
|
28
|
+
def entry_class
|
29
29
|
StorageRoom.class_for_name(self[:identifier].classify)
|
30
30
|
end
|
31
31
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module StorageRoom
|
2
|
-
class
|
2
|
+
class Entry < Model
|
3
3
|
class << self
|
4
4
|
def index_path # :nodoc:
|
5
|
-
"/collections/#{collection_id}/
|
5
|
+
"/collections/#{collection_id}/entries"
|
6
6
|
end
|
7
7
|
|
8
|
-
def show_path(
|
9
|
-
"#{index_path}/#{
|
8
|
+
def show_path(entry_id) # :nodoc:
|
9
|
+
"#{index_path}/#{entry_id}"
|
10
10
|
end
|
11
11
|
|
12
12
|
def collection_path # :nodoc:
|
@@ -18,7 +18,7 @@ module StorageRoom
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def json_name # :nodoc:
|
21
|
-
'
|
21
|
+
'entry'
|
22
22
|
end
|
23
23
|
|
24
24
|
def search_path(parameters = {}) # :nodoc:
|
@@ -31,7 +31,7 @@ module StorageRoom
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
# Sets a
|
34
|
+
# Sets a entry with a hash from the API.
|
35
35
|
def set_from_api(attributes)
|
36
36
|
super(attributes)
|
37
37
|
|
@@ -46,7 +46,7 @@ module StorageRoom
|
|
46
46
|
self.attributes
|
47
47
|
end
|
48
48
|
|
49
|
-
# The collection of a
|
49
|
+
# The collection of a entry
|
50
50
|
def collection
|
51
51
|
Collection.load(self[:@collection_url] || self.class.collection_path)
|
52
52
|
end
|
data/lib/storage_room.rb
CHANGED
@@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
4
4
|
begin; require 'rubygems'; rescue LoadError; end
|
5
5
|
|
6
6
|
require 'httparty'
|
7
|
-
require '
|
7
|
+
require 'active_support/all'
|
8
8
|
|
9
9
|
|
10
10
|
module StorageRoom
|
@@ -17,10 +17,10 @@ module StorageRoom
|
|
17
17
|
autoload :Model, 'storage_room/model'
|
18
18
|
autoload :Array, 'storage_room/array'
|
19
19
|
autoload :Field, 'storage_room/field'
|
20
|
-
autoload :Embedded,
|
20
|
+
autoload :Embedded, 'storage_room/embedded'
|
21
21
|
|
22
22
|
autoload :Collection, 'storage_room/models/collection'
|
23
|
-
autoload :
|
23
|
+
autoload :Entry, 'storage_room/models/entry'
|
24
24
|
|
25
25
|
autoload :File, 'storage_room/embeddeds/file'
|
26
26
|
autoload :Location, 'storage_room/embeddeds/location'
|
@@ -78,7 +78,7 @@ module StorageRoom
|
|
78
78
|
elsif Object.const_defined?(name)
|
79
79
|
name.constantize
|
80
80
|
else
|
81
|
-
klass = Class.new(
|
81
|
+
klass = Class.new(Entry)
|
82
82
|
Object.const_set(name, klass)
|
83
83
|
|
84
84
|
klass
|
@@ -2,7 +2,7 @@
|
|
2
2
|
"collection": {
|
3
3
|
"name": "Guidebooks",
|
4
4
|
"@updated_at": "2010-11-05T12:55:04Z",
|
5
|
-
"@
|
5
|
+
"@entries_url": "http://api.storageroomapp.com/accounts/4c8fd48542507175aa00002f/collections/guidebooks/entries",
|
6
6
|
"@created_at": "2010-09-14T20:01:13Z",
|
7
7
|
"fields": [{
|
8
8
|
"name": "Title",
|
@@ -2,10 +2,10 @@
|
|
2
2
|
"collections": {
|
3
3
|
"@type": "Array",
|
4
4
|
"@url": "http://api.storageroomapp.com/accounts/4c8fd48542507175aa00002f/collections",
|
5
|
-
"
|
5
|
+
"resources": [{
|
6
6
|
"name": "Guidebooks",
|
7
7
|
"@updated_at": "2010-11-05T12:55:04Z",
|
8
|
-
"@
|
8
|
+
"@entries_url": "http://api.storageroomapp.com/accounts/4c8fd48542507175aa00002f/collections/guidebooks/entries",
|
9
9
|
"@created_at": "2010-09-14T20:01:13Z",
|
10
10
|
"fields": [{
|
11
11
|
"name": "Title",
|
@@ -17,14 +17,14 @@ describe StorageRoom::Array do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#initialize" do
|
20
|
-
it "should set
|
21
|
-
@array.
|
20
|
+
it "should set resources" do
|
21
|
+
@array.resources.should == []
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#set_from_api" do
|
26
26
|
before(:each) do
|
27
|
-
@hash = {'@page' => 1, '
|
27
|
+
@hash = {'@page' => 1, 'resources' => [{'one' => 1, '@type' => 'Guidebook'}, {'two' => 2, '@type' => 'Guidebook'}]}
|
28
28
|
@array.set_from_api(@hash)
|
29
29
|
end
|
30
30
|
|
@@ -32,19 +32,19 @@ describe StorageRoom::Array do
|
|
32
32
|
@array['@page'].should == 1
|
33
33
|
end
|
34
34
|
|
35
|
-
it "should set
|
36
|
-
@array.
|
37
|
-
@array.
|
38
|
-
@array.
|
39
|
-
@array.
|
40
|
-
@array.
|
35
|
+
it "should set resources" do
|
36
|
+
@array.resources.should have(2).items
|
37
|
+
@array.resources[0].should be_an_instance_of(Guidebook)
|
38
|
+
@array.resources[0][:one].should == 1
|
39
|
+
@array.resources[1].should be_an_instance_of(Guidebook)
|
40
|
+
@array.resources[1][:two].should == 2
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "#reset!" do
|
45
45
|
it "should reset" do
|
46
46
|
@array.reset!
|
47
|
-
@array.
|
47
|
+
@array.resources.should == []
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -54,7 +54,7 @@ describe StorageRoom::Array do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should load when present" do
|
57
|
-
@array[:@
|
57
|
+
@array[:@next_page_url] = "url"
|
58
58
|
@array.stub(:reload)
|
59
59
|
@array.should_receive(:reload)
|
60
60
|
@array.load_next_page!.should be_true
|
@@ -67,7 +67,7 @@ describe StorageRoom::Array do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should load when present" do
|
70
|
-
@array[:@
|
70
|
+
@array[:@previous_page_url] = "url"
|
71
71
|
@array.stub(:reload)
|
72
72
|
@array.should_receive(:reload)
|
73
73
|
@array.load_previous_page!.should be_true
|
@@ -60,7 +60,7 @@ describe StorageRoom::Base do
|
|
60
60
|
|
61
61
|
describe "#create_from_api" do
|
62
62
|
it "should create array" do
|
63
|
-
hash = {'@type' => 'Array', '
|
63
|
+
hash = {'@type' => 'Array', 'resources' => []}
|
64
64
|
result = StorageRoom::Base.create_from_api(hash)
|
65
65
|
result.should be_an_instance_of(StorageRoom::Array)
|
66
66
|
result[:@type].should == 'Array'
|
@@ -73,7 +73,7 @@ describe StorageRoom::Base do
|
|
73
73
|
result[:name].should == 'Guidebook'
|
74
74
|
end
|
75
75
|
|
76
|
-
it "should create
|
76
|
+
it "should create entry" do
|
77
77
|
hash = {'@type' => 'Guidebook', 'title' => 'Something'}
|
78
78
|
result = StorageRoom::Base.create_from_api(hash)
|
79
79
|
result.should be_an_instance_of(Guidebook)
|
@@ -154,11 +154,11 @@ describe StorageRoom::Model do
|
|
154
154
|
|
155
155
|
describe "#as_json" do
|
156
156
|
it "should return hash without meta data" do
|
157
|
-
|
158
|
-
hash =
|
157
|
+
entry = StorageRoom::Entry.new(:field => 1, :@attr => 2)
|
158
|
+
hash = entry.as_json
|
159
159
|
|
160
|
-
hash['
|
161
|
-
hash['
|
160
|
+
hash['entry'][:field].should == 1
|
161
|
+
hash['entry'][:@attr].should_not be_present
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -178,7 +178,7 @@ describe StorageRoom::Model do
|
|
178
178
|
klass = StorageRoom.class_for_name('Guidebook')
|
179
179
|
guidebook = klass.new
|
180
180
|
|
181
|
-
stub_request(:post, stub_url('/collections/guidebooks/
|
181
|
+
stub_request(:post, stub_url('/collections/guidebooks/entries')).to_return(:body => fixture_file('collection.json'), :status => 200)
|
182
182
|
|
183
183
|
guidebook.create
|
184
184
|
guidebook[:name].should == 'Guidebooks'
|
@@ -188,7 +188,7 @@ describe StorageRoom::Model do
|
|
188
188
|
klass = StorageRoom.class_for_name('Guidebook')
|
189
189
|
guidebook = klass.new
|
190
190
|
|
191
|
-
stub_request(:post, stub_url('/collections/guidebooks/
|
191
|
+
stub_request(:post, stub_url('/collections/guidebooks/entries')).to_return(:body => fixture_file('validation_error.json'), :status => 422)
|
192
192
|
|
193
193
|
guidebook.create
|
194
194
|
guidebook[:name].should be_nil
|
@@ -15,9 +15,9 @@ describe StorageRoom::Collection do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe "#
|
18
|
+
describe "#entries_path" do
|
19
19
|
it "should be defined" do
|
20
|
-
StorageRoom::Collection.
|
20
|
+
StorageRoom::Collection.entries_path(1).should == '/collections/1/entries'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -35,17 +35,17 @@ describe StorageRoom::Collection do
|
|
35
35
|
@collection = StorageRoom::Collection.new
|
36
36
|
end
|
37
37
|
|
38
|
-
describe "#
|
38
|
+
describe "#entries" do
|
39
39
|
it "should load" do
|
40
40
|
StorageRoom::Array.should_receive(:load)
|
41
|
-
@collection.
|
41
|
+
@collection.entries
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe "#
|
45
|
+
describe "#entry_class" do
|
46
46
|
it "should return class" do
|
47
47
|
@collection[:identifier] = 'guidebook'
|
48
|
-
klass = @collection.
|
48
|
+
klass = @collection.entry_class
|
49
49
|
klass.should == Guidebook
|
50
50
|
end
|
51
51
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe StorageRoom::
|
3
|
+
describe StorageRoom::Entry do
|
4
4
|
context "Class" do
|
5
5
|
context "Methods" do
|
6
6
|
before(:each) do
|
@@ -9,13 +9,13 @@ describe StorageRoom::Resource do
|
|
9
9
|
|
10
10
|
describe "#show_path" do
|
11
11
|
it "should be defined" do
|
12
|
-
Guidebook.show_path(1).should == '/collections/guidebooks/
|
12
|
+
Guidebook.show_path(1).should == '/collections/guidebooks/entries/1'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#index_path" do
|
17
17
|
it "should be defined" do
|
18
|
-
Guidebook.index_path.should == '/collections/guidebooks/
|
18
|
+
Guidebook.index_path.should == '/collections/guidebooks/entries'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -27,14 +27,14 @@ describe StorageRoom::Resource do
|
|
27
27
|
|
28
28
|
describe "#search_path" do
|
29
29
|
it "should be defined" do
|
30
|
-
Guidebook.search_path(:test =>1).should == '/collections/guidebooks/
|
30
|
+
Guidebook.search_path(:test =>1).should == '/collections/guidebooks/entries?test=1'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#json_name" do
|
35
35
|
it "should be defined" do
|
36
|
-
StorageRoom::
|
37
|
-
Guidebook.json_name.should == '
|
36
|
+
StorageRoom::Entry.json_name.should == 'entry'
|
37
|
+
Guidebook.json_name.should == 'entry'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -55,13 +55,13 @@ describe StorageRoom::Resource do
|
|
55
55
|
|
56
56
|
context "Instance" do
|
57
57
|
before(:each) do
|
58
|
-
@
|
58
|
+
@entry = StorageRoom::Entry.new
|
59
59
|
end
|
60
60
|
|
61
61
|
describe "#collection" do
|
62
62
|
it "should load" do
|
63
63
|
StorageRoom::Collection.should_receive(:load)
|
64
|
-
@
|
64
|
+
@entry.collection
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/spec/storage_room_spec.rb
CHANGED
@@ -91,9 +91,9 @@ describe StorageRoom do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should get StorageRoom class" do
|
94
|
-
klass = StorageRoom.class_for_name('
|
94
|
+
klass = StorageRoom.class_for_name('Entry')
|
95
95
|
klass.should be_an_instance_of(Class)
|
96
|
-
klass.should == StorageRoom::
|
96
|
+
klass.should == StorageRoom::Entry
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
data/storage_room.gemspec
CHANGED
@@ -1,91 +1,89 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{storage_room}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
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{2010-
|
12
|
+
s.date = %q{2010-12-27}
|
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 = [
|
16
16
|
"LICENSE",
|
17
|
-
|
18
|
-
|
17
|
+
"README.rdoc",
|
18
|
+
"TODO"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
-
".
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
"storage_room.gemspec"
|
21
|
+
"History.txt",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"TODO",
|
26
|
+
"VERSION",
|
27
|
+
"examples/authentication.rb",
|
28
|
+
"examples/create_entry.rb",
|
29
|
+
"examples/destroy_entry.rb",
|
30
|
+
"examples/get_collections.rb",
|
31
|
+
"examples/guidebooks.csv",
|
32
|
+
"examples/import_csv.rb",
|
33
|
+
"examples/search_entries.rb",
|
34
|
+
"examples/update_entry.rb",
|
35
|
+
"lib/storage_room.rb",
|
36
|
+
"lib/storage_room/array.rb",
|
37
|
+
"lib/storage_room/attributes.rb",
|
38
|
+
"lib/storage_room/base.rb",
|
39
|
+
"lib/storage_room/embedded.rb",
|
40
|
+
"lib/storage_room/embeddeds/file.rb",
|
41
|
+
"lib/storage_room/embeddeds/location.rb",
|
42
|
+
"lib/storage_room/field.rb",
|
43
|
+
"lib/storage_room/model.rb",
|
44
|
+
"lib/storage_room/models/collection.rb",
|
45
|
+
"lib/storage_room/models/entry.rb",
|
46
|
+
"spec/fixtures/collection.json",
|
47
|
+
"spec/fixtures/collections.json",
|
48
|
+
"spec/fixtures/validation_error.json",
|
49
|
+
"spec/spec_helper.rb",
|
50
|
+
"spec/storage_room/array_spec.rb",
|
51
|
+
"spec/storage_room/attributes_spec.rb",
|
52
|
+
"spec/storage_room/base_spec.rb",
|
53
|
+
"spec/storage_room/embedded_spec.rb",
|
54
|
+
"spec/storage_room/embeddeds/file_spec.rb",
|
55
|
+
"spec/storage_room/embeddeds/location_spec.rb",
|
56
|
+
"spec/storage_room/field_spec.rb",
|
57
|
+
"spec/storage_room/model_spec.rb",
|
58
|
+
"spec/storage_room/models/collection_spec.rb",
|
59
|
+
"spec/storage_room/models/entry_spec.rb",
|
60
|
+
"spec/storage_room_spec.rb",
|
61
|
+
"storage_room.gemspec"
|
63
62
|
]
|
64
63
|
s.homepage = %q{http://github.com/thriventures/storage_room_gem}
|
65
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
66
64
|
s.require_paths = ["lib"]
|
67
65
|
s.rubygems_version = %q{1.3.7}
|
68
66
|
s.summary = %q{StorageRoom API Wrapper (ActiveModel style)}
|
69
67
|
s.test_files = [
|
68
|
+
"examples/authentication.rb",
|
69
|
+
"examples/create_entry.rb",
|
70
|
+
"examples/destroy_entry.rb",
|
71
|
+
"examples/get_collections.rb",
|
72
|
+
"examples/import_csv.rb",
|
73
|
+
"examples/search_entries.rb",
|
74
|
+
"examples/update_entry.rb",
|
70
75
|
"spec/spec_helper.rb",
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
"examples/authentication.rb",
|
83
|
-
"examples/create_resource.rb",
|
84
|
-
"examples/destroy_resource.rb",
|
85
|
-
"examples/get_collections.rb",
|
86
|
-
"examples/import_csv.rb",
|
87
|
-
"examples/search_resources.rb",
|
88
|
-
"examples/update_resource.rb"
|
76
|
+
"spec/storage_room/array_spec.rb",
|
77
|
+
"spec/storage_room/attributes_spec.rb",
|
78
|
+
"spec/storage_room/base_spec.rb",
|
79
|
+
"spec/storage_room/embedded_spec.rb",
|
80
|
+
"spec/storage_room/embeddeds/file_spec.rb",
|
81
|
+
"spec/storage_room/embeddeds/location_spec.rb",
|
82
|
+
"spec/storage_room/field_spec.rb",
|
83
|
+
"spec/storage_room/model_spec.rb",
|
84
|
+
"spec/storage_room/models/collection_spec.rb",
|
85
|
+
"spec/storage_room/models/entry_spec.rb",
|
86
|
+
"spec/storage_room_spec.rb"
|
89
87
|
]
|
90
88
|
|
91
89
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storage_room
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sascha Konietzke
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-27 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -91,7 +91,6 @@ extra_rdoc_files:
|
|
91
91
|
- README.rdoc
|
92
92
|
- TODO
|
93
93
|
files:
|
94
|
-
- .gitignore
|
95
94
|
- History.txt
|
96
95
|
- LICENSE
|
97
96
|
- README.rdoc
|
@@ -99,13 +98,13 @@ files:
|
|
99
98
|
- TODO
|
100
99
|
- VERSION
|
101
100
|
- examples/authentication.rb
|
102
|
-
- examples/
|
103
|
-
- examples/
|
101
|
+
- examples/create_entry.rb
|
102
|
+
- examples/destroy_entry.rb
|
104
103
|
- examples/get_collections.rb
|
105
104
|
- examples/guidebooks.csv
|
106
105
|
- examples/import_csv.rb
|
107
|
-
- examples/
|
108
|
-
- examples/
|
106
|
+
- examples/search_entries.rb
|
107
|
+
- examples/update_entry.rb
|
109
108
|
- lib/storage_room.rb
|
110
109
|
- lib/storage_room/array.rb
|
111
110
|
- lib/storage_room/attributes.rb
|
@@ -116,7 +115,7 @@ files:
|
|
116
115
|
- lib/storage_room/field.rb
|
117
116
|
- lib/storage_room/model.rb
|
118
117
|
- lib/storage_room/models/collection.rb
|
119
|
-
- lib/storage_room/models/
|
118
|
+
- lib/storage_room/models/entry.rb
|
120
119
|
- spec/fixtures/collection.json
|
121
120
|
- spec/fixtures/collections.json
|
122
121
|
- spec/fixtures/validation_error.json
|
@@ -130,7 +129,7 @@ files:
|
|
130
129
|
- spec/storage_room/field_spec.rb
|
131
130
|
- spec/storage_room/model_spec.rb
|
132
131
|
- spec/storage_room/models/collection_spec.rb
|
133
|
-
- spec/storage_room/models/
|
132
|
+
- spec/storage_room/models/entry_spec.rb
|
134
133
|
- spec/storage_room_spec.rb
|
135
134
|
- storage_room.gemspec
|
136
135
|
has_rdoc: true
|
@@ -138,8 +137,8 @@ homepage: http://github.com/thriventures/storage_room_gem
|
|
138
137
|
licenses: []
|
139
138
|
|
140
139
|
post_install_message:
|
141
|
-
rdoc_options:
|
142
|
-
|
140
|
+
rdoc_options: []
|
141
|
+
|
143
142
|
require_paths:
|
144
143
|
- lib
|
145
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -168,6 +167,13 @@ signing_key:
|
|
168
167
|
specification_version: 3
|
169
168
|
summary: StorageRoom API Wrapper (ActiveModel style)
|
170
169
|
test_files:
|
170
|
+
- examples/authentication.rb
|
171
|
+
- examples/create_entry.rb
|
172
|
+
- examples/destroy_entry.rb
|
173
|
+
- examples/get_collections.rb
|
174
|
+
- examples/import_csv.rb
|
175
|
+
- examples/search_entries.rb
|
176
|
+
- examples/update_entry.rb
|
171
177
|
- spec/spec_helper.rb
|
172
178
|
- spec/storage_room/array_spec.rb
|
173
179
|
- spec/storage_room/attributes_spec.rb
|
@@ -178,12 +184,5 @@ test_files:
|
|
178
184
|
- spec/storage_room/field_spec.rb
|
179
185
|
- spec/storage_room/model_spec.rb
|
180
186
|
- spec/storage_room/models/collection_spec.rb
|
181
|
-
- spec/storage_room/models/
|
187
|
+
- spec/storage_room/models/entry_spec.rb
|
182
188
|
- spec/storage_room_spec.rb
|
183
|
-
- examples/authentication.rb
|
184
|
-
- examples/create_resource.rb
|
185
|
-
- examples/destroy_resource.rb
|
186
|
-
- examples/get_collections.rb
|
187
|
-
- examples/import_csv.rb
|
188
|
-
- examples/search_resources.rb
|
189
|
-
- examples/update_resource.rb
|
data/.gitignore
DELETED
data/examples/create_resource.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -rubygems
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/authentication'
|
4
|
-
|
5
|
-
# create a resource without fetching the collection
|
6
|
-
klass = StorageRoom.class_for_name('Guidebook')
|
7
|
-
resource1 = klass.new(:name => 'Foo', :price => 1.23)
|
8
|
-
|
9
|
-
if resource1.save
|
10
|
-
puts "Resource saved"
|
11
|
-
else
|
12
|
-
puts "Resource could not be saved: #{resource1.errors.join(', ')}"
|
13
|
-
end
|
14
|
-
|
15
|
-
# fetch the collection first
|
16
|
-
collection = StorageRoom::Collection.find('guidebooks')
|
17
|
-
|
18
|
-
resource2 = collection.resource_class.new(:name => 'Bar', :price => 2.23)
|
19
|
-
|
20
|
-
if resource2.save
|
21
|
-
puts "Resource saved"
|
22
|
-
else
|
23
|
-
puts "Resource could not be saved: #{resource2.errors.join(', ')}"
|
24
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -rubygems
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/authentication'
|
4
|
-
|
5
|
-
collection = StorageRoom::Collection.find('guidebooks')
|
6
|
-
|
7
|
-
resources = collection.resource_class.search(:name => 'Bar')
|
8
|
-
|
9
|
-
puts "Resources with name 'Bar':"
|
10
|
-
|
11
|
-
resources.items.each do |resource|
|
12
|
-
puts "- #{resource[:name]}"
|
13
|
-
end
|
data/examples/update_resource.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -rubygems
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/authentication'
|
4
|
-
|
5
|
-
collection = StorageRoom::Collection.find('guidebooks')
|
6
|
-
|
7
|
-
resource = collection.resources.items.first
|
8
|
-
|
9
|
-
resource[:name] = 'Foobar'
|
10
|
-
|
11
|
-
if resource.save
|
12
|
-
puts "Resource saved"
|
13
|
-
else
|
14
|
-
puts "Resource could not be saved: #{resource.errors.join(', ')}"
|
15
|
-
end
|