storage_room 0.3.11 → 0.3.12

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/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == Version 0.3.12
2
+ * Reset Resource after reloading
3
+
1
4
  == Version 0.3.11
2
5
  * Fixed another cyclic dependency bug
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.11
1
+ 0.3.12
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'lib', 'storage_room')
2
2
 
3
- ACCOUNT_ID = '4e1e9c234250712eba000052' # your account id
4
- APPLICATION_API_KEY = 'fgK8Di4FYuRKtk2Xd12A' # your application's API key with read/write access
3
+ ACCOUNT_ID = '4d13574cba05613d25000004' # your account id
4
+ APPLICATION_API_KEY = 'DZHpRbsJ7VgFXhybKWmT' # your application's API key with read/write access
5
5
 
6
6
  StorageRoom.authenticate(ACCOUNT_ID, APPLICATION_API_KEY)
7
7
 
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.join(File.dirname(__FILE__), 'authentication')
4
+
5
+ collection = StorageRoom::Collection.find('4d960916ba05617333000005')
6
+
7
+ puts "Nested Loops:\n\n"
8
+
9
+ # Iterate over all pages of entries with nested loops
10
+ collection.entries.each_page do |array|
11
+ puts "== Page: #{array[:@page]} / #{array[:@pages]}"
12
+ array.resources.each do |entry|
13
+ puts "Entry: #{entry.name}"
14
+ end
15
+ end
16
+
17
+ puts "Single helper:\n\n"
18
+
19
+ # Iterate over all entries on all pages with one helper
20
+ collection.entries.each_page_each_resource do |entry|
21
+ puts "Entry: #{entry.name}"
22
+ end
@@ -32,7 +32,7 @@ module StorageRoom
32
32
  end
33
33
 
34
34
  # Iterate over all resources with pagination
35
- def each_page_each_item(args={})
35
+ def each_page_each_resource(args={})
36
36
  self.each_page(args) do |page|
37
37
  page.resources.each do |item|
38
38
  yield(item)
@@ -30,7 +30,9 @@ module StorageRoom
30
30
  # Reload an object from the API. Optionally pass an URL.
31
31
  def reload(url = nil, parameters = {})
32
32
  httparty = self.class.get(url || self[:@url], parameters)
33
- set_from_response_data(httparty.parsed_response.first[1])
33
+ hash = httparty.parsed_response.first[1]
34
+ reset!
35
+ set_from_response_data(hash)
34
36
  true
35
37
  end
36
38
 
@@ -76,6 +76,25 @@ describe StorageRoom::Resource do
76
76
  }.should raise_error(StorageRoom::RequestFailedError)
77
77
  end
78
78
  end
79
+
80
+ describe "#reload" do
81
+ it "should reset attributes before reload" do
82
+ array = StorageRoom::Array.new
83
+ array.response_data[:@next_page_url] = '/collections/1/entries?page=2'
84
+ array.response_data[:@url] = '/collections/1/entries'
85
+ hash = {:array => {:@url => '/collections/1/entries?page=2', :@previous_page_url => '/collections/1/entries?page=1'}}
86
+
87
+ stub_request(:get, stub_url('/collections/1/entries')).to_return(:body => hash.to_json, :status => 200)
88
+
89
+ array[:@next_page_url].should be_present
90
+ array[:@previous_page_url].should be_nil
91
+
92
+ array.reload
93
+
94
+ array[:@next_page_url].should be_nil
95
+ array[:@previous_page_url].should be_present
96
+ end
97
+ end
79
98
 
80
99
  describe "#meta_data?" do
81
100
  it "should detect" do
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.11"
8
+ s.version = "0.3.12"
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-08-04}
12
+ s.date = %q{2011-08-10}
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 = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "examples/get_collections.rb",
34
34
  "examples/guidebooks.csv",
35
35
  "examples/import_csv.rb",
36
+ "examples/pagination.rb",
36
37
  "examples/search_entries.rb",
37
38
  "examples/update_entry.rb",
38
39
  "examples/upload_remove_image.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 11
9
- version: 0.3.11
8
+ - 12
9
+ version: 0.3.12
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-08-04 00:00:00 +02:00
17
+ date: 2011-08-10 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -129,6 +129,7 @@ files:
129
129
  - examples/get_collections.rb
130
130
  - examples/guidebooks.csv
131
131
  - examples/import_csv.rb
132
+ - examples/pagination.rb
132
133
  - examples/search_entries.rb
133
134
  - examples/update_entry.rb
134
135
  - examples/upload_remove_image.rb