cloudapp_api 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/cloudapp_api.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudapp_api}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Russell"]
@@ -58,7 +58,7 @@ module CloudApp
58
58
  # @return [CloudApp::Account]
59
59
  def self.find
60
60
  res = get "/account", :digest_auth => @@auth
61
- res.ok? ? Account.new(res) : res
61
+ res.ok? ? Account.new(res) : raise(GenericError)
62
62
  end
63
63
 
64
64
  # Create a CloudApp account.
@@ -70,7 +70,7 @@ module CloudApp
70
70
  # @return [CloudApp::Account]
71
71
  def self.create(opts = {})
72
72
  res = post "/register", :body => {:user => opts}
73
- res.ok? ? Account.new(res) : res
73
+ res.ok? ? Account.new(res) : raise(GenericError)
74
74
  end
75
75
 
76
76
  # Modify the authenticated accounts details. Can change the default security of newly
@@ -91,7 +91,7 @@ module CloudApp
91
91
  # @return [CloudApp::Account]
92
92
  def self.update(opts = {})
93
93
  res = put "/account", {:body => {:user => opts}, :digest_auth => @@auth}
94
- res.ok? ? Account.new(res) : res
94
+ res.ok? ? Account.new(res) : raise(GenericError)
95
95
  end
96
96
 
97
97
  # Dispatch an email containing a link to reset the account's password.
@@ -101,7 +101,7 @@ module CloudApp
101
101
  # @return [Boolean]
102
102
  def self.reset(opts = {})
103
103
  res = post "/reset", :body => {:user => opts}
104
- res.ok? ? true : res
104
+ res.ok? ? true : raise(GenericError)
105
105
  end
106
106
 
107
107
  # Get the total number of drops created and total views for all drops.
@@ -111,7 +111,7 @@ module CloudApp
111
111
  # @return [Hash]
112
112
  def self.stats
113
113
  res = get "/account/stats", :digest_auth => @@auth
114
- res.ok? ? res.symbolize_keys! : res
114
+ res.ok? ? res.symbolize_keys! : raise(GenericError)
115
115
  end
116
116
 
117
117
  attr_reader :id, :email, :domain, :domain_home_page, :private_items,
data/lib/cloudapp/drop.rb CHANGED
@@ -61,7 +61,7 @@ module CloudApp
61
61
  # @return [CloudApp::Drop]
62
62
  def self.find(id)
63
63
  res = get "http://cl.ly/#{id}"
64
- res.ok? ? Drop.new(res) : res
64
+ res.ok? ? Drop.new(res) : raise(GenericError)
65
65
  end
66
66
 
67
67
  # Page through your drops.
@@ -76,7 +76,7 @@ module CloudApp
76
76
  # @return [Array[CloudApp::Drop]]
77
77
  def self.all(opts = {})
78
78
  res = get "/items", {:query => (opts.empty? ? nil : opts), :digest_auth => @@auth}
79
- res.ok? ? res.collect{|i| Drop.new(i)} : res
79
+ res.ok? ? res.collect{|i| Drop.new(i)} : raise(GenericError)
80
80
  end
81
81
 
82
82
  # Create a new drop. Multiple bookmarks can be created at once by
@@ -110,7 +110,7 @@ module CloudApp
110
110
  # TODO raise an error
111
111
  return false
112
112
  end
113
- res.ok? ? (res.is_a?(Array) ? res.collect{|i| Drop.new(i)} : Drop.new(res)) : res
113
+ res.ok? ? (res.is_a?(Array) ? res.collect{|i| Drop.new(i)} : Drop.new(res)) : raise(GenericError)
114
114
  end
115
115
 
116
116
  # Modify a drop. Can currently modify it's name or security setting by passing parameters.
@@ -136,7 +136,7 @@ module CloudApp
136
136
  def self.delete(href)
137
137
  # Use delete on the Base class to avoid recursion
138
138
  res = Base.delete href, :digest_auth => @@auth
139
- res.ok? ? Drop.new(res) : res
139
+ res.ok? ? Drop.new(res) : raise(GenericError)
140
140
  end
141
141
 
142
142
  # Recover a drop from the trash.
@@ -147,7 +147,7 @@ module CloudApp
147
147
  # @return [CloudApp::Drop]
148
148
  def self.recover(href)
149
149
  res = put href, {:body => {:deleted => true, :item => {:deleted_at => nil}}, :digest_auth => @@auth}
150
- res.ok? ? Drop.new(res) : res
150
+ res.ok? ? Drop.new(res) : raise(GenericError)
151
151
  end
152
152
 
153
153
  attr_reader :href, :name, :private, :url, :content_url, :item_type, :view_counter,
@@ -25,7 +25,7 @@ module CloudApp
25
25
  # @return [CloudApp::GiftCard]
26
26
  def self.find(code)
27
27
  res = get "/gift_cards/#{code}", :digest_auth => @@auth
28
- res.ok? ? GiftCard.new(res) : res
28
+ res.ok? ? GiftCard.new(res) : raise(GenericError)
29
29
  end
30
30
 
31
31
  # Apply a gift card to the authenticated account.
@@ -36,7 +36,7 @@ module CloudApp
36
36
  # @return [CloudApp::GiftCard]
37
37
  def self.redeem(code)
38
38
  res = put "/gift_cards/#{code}", {:body => {}, :digest_auth => @@auth}
39
- res.ok? ? GiftCard.new(res) : res
39
+ res.ok? ? GiftCard.new(res) : raise(GenericError)
40
40
  end
41
41
 
42
42
  attr_reader :id, :code, :plan, :months, :href,
data/lib/cloudapp_api.rb CHANGED
@@ -10,7 +10,7 @@ end
10
10
  module CloudApp
11
11
 
12
12
  # Version number
13
- VERSION = "0.2.1"
13
+ VERSION = "0.2.2"
14
14
 
15
15
  # Sets the authentication credentials in a class variable
16
16
  #
@@ -20,5 +20,10 @@ module CloudApp
20
20
  def CloudApp.authenticate(email, password)
21
21
  Base.authenticate(email, password)
22
22
  end
23
+
24
+ # Temporary generic error raised on all bad requests
25
+ #
26
+ # #TODO - implement MUCH better error handling
27
+ class GenericError < StandardError; end
23
28
 
24
29
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudapp_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Russell