storage_room 0.3.22 → 0.3.23

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == Version 0.3.23
2
+ * Support the configuration of a custom connection timeout
3
+
1
4
  == Version 0.3.22
2
5
  * Move from Jeweler to Bundler for gem management
3
6
 
@@ -2,13 +2,17 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'authentication')
4
4
 
5
- path = ::File.expand_path(File.join(File.dirname(__FILE__) + '..', 'spec', 'fixtures', 'image.png'))
6
- collection = StorageRoom::Collection.find('4e034b8db65245b72600002b')
5
+ path = ::File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'image.png'))
6
+
7
+ collection = StorageRoom::Collection.find('4f7c9fa6421aa9e48a000092')
7
8
 
8
9
  # Upload Image or File
9
- entry = collection.entry_class.new(:name => "StorageRoom Logo", :image => StorageRoom::Image.new_with_filename(path))
10
+ entry = collection.entry_class.new(:name => "StorageRoom Logo", :file => StorageRoom::Image.new_with_filename(path))
11
+
12
+ # optionally change the request timeout if you upload big files
13
+ StorageRoom.timeout = 100
10
14
 
11
- if entry.save
15
+ if entry.save
12
16
  puts "Entry saved (#{entry[:@url]})"
13
17
  puts "URL of the uploaded image is #{entry.image.url}"
14
18
  puts "URL of the automatically generated thumbnail is #{entry.image.url(:thumbnail)}" # Multiple Image Versions can be specified in the interface
@@ -66,7 +66,7 @@ module StorageRoom
66
66
  return false unless new_record?
67
67
  _run_save_callbacks do
68
68
  _run_create_callbacks do
69
- httparty = self.class.post(self.class.index_path, :body => to_json, :query => query_parameters)
69
+ httparty = self.class.post(self.class.index_path, request_options.merge(:body => to_json))
70
70
  handle_save_response(httparty)
71
71
  end
72
72
  end
@@ -77,7 +77,7 @@ module StorageRoom
77
77
  return false if new_record?
78
78
  _run_save_callbacks do
79
79
  _run_update_callbacks do
80
- httparty = self.class.put(self[:@url], :body => to_json, :query => query_parameters)
80
+ httparty = self.class.put(self[:@url], request_options.merge(:body => to_json))
81
81
  handle_save_response(httparty)
82
82
  end
83
83
  end
@@ -88,7 +88,7 @@ module StorageRoom
88
88
  return false if new_record?
89
89
 
90
90
  _run_destroy_callbacks do
91
- httparty = self.class.delete(self[:@url], :query => query_parameters)
91
+ httparty = self.class.delete(self[:@url], request_options)
92
92
  self.class.handle_critical_response_errors(httparty)
93
93
  end
94
94
 
@@ -137,6 +137,10 @@ module StorageRoom
137
137
  def query_parameters
138
138
  skip_webhooks ? {:skip_webhooks => true} : nil
139
139
  end
140
+
141
+ def request_options
142
+ StorageRoom.request_options.merge(:query => query_parameters)
143
+ end
140
144
 
141
145
 
142
146
  end
@@ -29,7 +29,7 @@ module StorageRoom
29
29
 
30
30
  # Reload an object from the API. Optionally pass an URL.
31
31
  def reload(url = nil, parameters = {})
32
- httparty = self.class.get(url || self[:@url], parameters)
32
+ httparty = self.class.get(url || self[:@url], StorageRoom.request_options.merge(parameters))
33
33
  hash = httparty.parsed_response.first[1]
34
34
  reset!
35
35
  set_from_response_data(hash)
@@ -1,3 +1,3 @@
1
1
  module StorageRoom
2
- VERSION = '0.3.22'
2
+ VERSION = '0.3.23'
3
3
  end
data/lib/storage_room.rb CHANGED
@@ -68,7 +68,7 @@ module StorageRoom
68
68
 
69
69
 
70
70
  class << self
71
- attr_reader :api_key, :user_agent, :account_id, :ssl, :proxy_server, :proxy_port
71
+ attr_reader :api_key, :user_agent, :account_id, :ssl, :proxy_server, :proxy_port, :timeout
72
72
  attr_accessor :debug
73
73
 
74
74
  # Authenticate once before making any requests with your account id and the application's api key
@@ -95,6 +95,22 @@ module StorageRoom
95
95
  @server || 'api.storageroomapp.com'
96
96
  end
97
97
 
98
+ # Change the connection timeout
99
+ def timeout=(timeout) #:nodoc:
100
+ @timeout = timeout
101
+ end
102
+
103
+ def timeout #:nodoc:
104
+ @timeout || 10
105
+ end
106
+
107
+ # Return the request options used by HTTParty
108
+ def request_options
109
+ {
110
+ :timeout => timeout
111
+ }
112
+ end
113
+
98
114
  # Hash of all mappings from an Entry's @type to a local Ruby class, if a mapping doesn't exist a class name will be created automatically
99
115
  def entry_class_mappings
100
116
  @entry_class_mappings ||= {}
@@ -57,6 +57,24 @@ describe StorageRoom do
57
57
  end
58
58
  end
59
59
 
60
+ describe "#timeout" do
61
+ it "return default timeout" do
62
+ StorageRoom.timeout.should == 10
63
+ end
64
+
65
+ it "should set variables" do
66
+ StorageRoom.timeout = 20
67
+ StorageRoom.timeout.should == 20
68
+ StorageRoom.timeout = 10
69
+ end
70
+ end
71
+
72
+ describe "#request_options" do
73
+ it "should return a hash" do
74
+ StorageRoom.request_options[:timeout].should == 10
75
+ end
76
+ end
77
+
60
78
  describe "#ssl" do
61
79
  before(:each) do
62
80
  StorageRoom.ssl = true
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.22
4
+ version: 0.3.23
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-03-02 00:00:00.000000000 Z
12
+ date: 2012-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70342461718360 !ruby/object:Gem::Requirement
16
+ requirement: &70271550602000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.9
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70342461718360
24
+ version_requirements: *70271550602000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: webmock
27
- requirement: &70342461717880 !ruby/object:Gem::Requirement
27
+ requirement: &70271550601480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70342461717880
35
+ version_requirements: *70271550601480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70342461717400 !ruby/object:Gem::Requirement
38
+ requirement: &70271550600900 !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: :runtime
45
45
  prerelease: false
46
- version_requirements: *70342461717400
46
+ version_requirements: *70271550600900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: httparty
49
- requirement: &70342461716920 !ruby/object:Gem::Requirement
49
+ requirement: &70271550600240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.6.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70342461716920
57
+ version_requirements: *70271550600240
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activesupport
60
- requirement: &70342461716440 !ruby/object:Gem::Requirement
60
+ requirement: &70271550599520 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.1.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70342461716440
68
+ version_requirements: *70271550599520
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activemodel
71
- requirement: &70342461715960 !ruby/object:Gem::Requirement
71
+ requirement: &70271550598620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 3.1.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70342461715960
79
+ version_requirements: *70271550598620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: mime-types
82
- requirement: &70342461715480 !ruby/object:Gem::Requirement
82
+ requirement: &70271550598040 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70342461715480
90
+ version_requirements: *70271550598040
91
91
  description: StorageRoom is a CMS system for Mobile Applications (iPhone, Android,
92
92
  BlackBerry, ...). This library gives you an ActiveModel-like interface to your data.
93
93
  email: sascha@thriventures.com
@@ -273,4 +273,3 @@ test_files:
273
273
  - spec/storage_room/resource_spec.rb
274
274
  - spec/storage_room/webhook_call_spec.rb
275
275
  - spec/storage_room_spec.rb
276
- has_rdoc: