cloudapp_api 0.2.0 → 0.2.1

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.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A simple Ruby wrapper for the [CloudApp API](http://support.getcloudapp.com/faqs/developers/api). Uses [HTTParty](http://github.com/jnunemaker/httparty) with a simple ActiveResource-like interface.
4
4
 
5
- Two interfaces are provided for interacting with the CloudApp API. The first is a ActiveResource-like interface, directly calling methods on the Item and Account class. The second option is to interact through a Client interface.
5
+ Two interfaces are provided for interacting with the CloudApp API. The first is a ActiveResource-like interface, directly calling methods on the Drop and Account classes. The second option is to interact through a Client interface.
6
6
 
7
7
  * [Familiarise yourself with the documentation](http://rubydoc.info/github/aaronrussell/cloudapp_api/)
8
8
 
@@ -14,7 +14,7 @@ To install as a Gem:
14
14
 
15
15
  ## Authentication
16
16
 
17
- Authentication is necessary for most actions, the only exceptions being when creating a new Account or querying a specific Item.
17
+ Authentication is necessary for most actions, the only exceptions being when creating a new Account or querying a specific Drop.
18
18
 
19
19
  CloudApp.authenticate "email@address.com", "password"
20
20
 
@@ -154,6 +154,10 @@ Authentication is necessary for most actions, the only exceptions being when cre
154
154
  # or
155
155
  @gift.redeem
156
156
 
157
+ ## To do
158
+
159
+ * Much better error handling
160
+
157
161
  ## Note on Patches/Pull Requests
158
162
 
159
163
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/cloudapp_api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudapp_api}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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"]
12
- s.date = %q{2011-05-01}
12
+ s.date = %q{2011-05-03}
13
13
  s.description = %q{A simple Ruby wrapper for the CloudApp API. Uses HTTParty with a simple ActiveResource-like interface.}
14
14
  s.email = %q{aaron@gc4.co.uk}
15
15
  s.extra_rdoc_files = [
@@ -117,16 +117,6 @@ module CloudApp
117
117
  attr_reader :id, :email, :domain, :domain_home_page, :private_items,
118
118
  :subscribed, :alpha, :created_at, :updated_at, :activated_at
119
119
 
120
- # Create a new CloudApp::Account object.
121
- #
122
- # Only used internally
123
- #
124
- # @param [Hash] attributes
125
- # @param [CloudApp::Account]
126
- def initialize(attributes = {})
127
- load(attributes)
128
- end
129
-
130
120
  # Modify the authenticated accounts details. Can change the default security of newly
131
121
  # created drops, the accounts email address, password, and custom domain details.
132
122
  #
data/lib/cloudapp/base.rb CHANGED
@@ -26,6 +26,19 @@ module CloudApp
26
26
  @@auth = {:username => email, :password => password}
27
27
  end
28
28
 
29
+ attr_reader :data
30
+
31
+ # Create a new CloudApp::Base object.
32
+ #
33
+ # Only used internally
34
+ #
35
+ # @param [Hash] attributes
36
+ # @return [CloudApp::Base]
37
+ def initialize(attributes = {})
38
+ @data = attributes
39
+ load(@data)
40
+ end
41
+
29
42
  private
30
43
 
31
44
  # Sets the attributes for object.
data/lib/cloudapp/drop.rb CHANGED
@@ -153,16 +153,6 @@ module CloudApp
153
153
  attr_reader :href, :name, :private, :url, :content_url, :item_type, :view_counter,
154
154
  :icon, :remote_url, :redirect_url, :created_at, :updated_at, :deleted_at
155
155
 
156
- # Create a new CloudApp::Drop object.
157
- #
158
- # Only used internally.
159
- #
160
- # @param [Hash] attributes
161
- # @param [CloudApp::Drop]
162
- def initialize(attributes = {})
163
- load(attributes)
164
- end
165
-
166
156
  # Modify the drop. Can currently modify it's name or security setting by passing parameters.
167
157
  #
168
158
  # @param [Hash] opts options paramaters
@@ -186,6 +176,20 @@ module CloudApp
186
176
  def recover
187
177
  self.class.recover self.href
188
178
  end
179
+
180
+ # Is the drop a bookmark?
181
+ #
182
+ # @return [Boolean]
183
+ def bookmark?
184
+ item_type == 'bookmark'
185
+ end
186
+
187
+ # Is the drop an image?
188
+ #
189
+ # @return [Boolean]
190
+ def image?
191
+ item_type == 'image'
192
+ end
189
193
 
190
194
  end
191
195
 
@@ -35,23 +35,13 @@ module CloudApp
35
35
  # @param [String] code Gift card code
36
36
  # @return [CloudApp::GiftCard]
37
37
  def self.redeem(code)
38
- res = put "/gift_cards/#{code}", :digest_auth => @@auth
38
+ res = put "/gift_cards/#{code}", {:body => {}, :digest_auth => @@auth}
39
39
  res.ok? ? GiftCard.new(res) : res
40
40
  end
41
41
 
42
42
  attr_reader :id, :code, :plan, :months, :href,
43
43
  :created_at, :updated_at, :redeemed_at, :effective_at, :expires_at
44
-
45
- # Create a new CloudApp::GiftCard object.
46
- #
47
- # Only used internally
48
- #
49
- # @param [Hash] attributes
50
- # @param [CloudApp::GiftCard]
51
- def initialize(attributes = {})
52
- load(attributes)
53
- end
54
-
44
+
55
45
  # Apply the gift card to the authenticated account.
56
46
  #
57
47
  # @return [CloudApp::GiftCard]
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.0"
13
+ VERSION = "0.2.1"
14
14
 
15
15
  # Sets the authentication credentials in a class variable
16
16
  #
@@ -46,6 +46,11 @@ describe CloudApp::Account do
46
46
  @account.activated_at.should be_a_kind_of Time
47
47
  end
48
48
 
49
+ it "should return the raw data hash" do
50
+ @account.data.should be_a_kind_of Hash
51
+ @account.data['email'].should == "arthur@dent.com"
52
+ end
53
+
49
54
  end
50
55
 
51
56
 
@@ -57,6 +57,11 @@ describe CloudApp::Drop do
57
57
  @drop.deleted_at.should == nil
58
58
  end
59
59
 
60
+ it "should return the raw data hash" do
61
+ @drop.data.should be_a_kind_of Hash
62
+ @drop.data['name'].should == "CloudApp Logo.png"
63
+ end
64
+
60
65
  end
61
66
 
62
67
 
@@ -254,5 +259,3 @@ describe "Upload file with specific privacy" do
254
259
  end
255
260
 
256
261
  end
257
-
258
-
@@ -39,6 +39,11 @@ describe CloudApp::GiftCard do
39
39
  @gift.expires_at.should == nil
40
40
  end
41
41
 
42
+ it "should return the raw data hash" do
43
+ @gift.data.should be_a_kind_of Hash
44
+ @gift.data['code'].should == "ABC123"
45
+ end
46
+
42
47
  end
43
48
 
44
49
  describe "Redeem gift card" do
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Russell
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-01 00:00:00 Z
18
+ date: 2011-05-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement