cloudapp_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.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.1.0"
8
+ s.version = "0.1.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{2010-12-15}
12
+ s.date = %q{2011-01-30}
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 = [
data/lib/cloudapp/base.rb CHANGED
@@ -18,8 +18,9 @@ module CloudApp
18
18
  format :json
19
19
 
20
20
  # Sets the authentication credentials in a class variable.
21
- # @param [String] cl.ly username
22
- # @param [String] cl.ly password
21
+ #
22
+ # @param [String] username cl.ly username
23
+ # @param [String] password cl.ly password
23
24
  # @return [Hash] authentication credentials
24
25
  def self.authenticate(username, password)
25
26
  @@auth = {:username => username, :password => password}
@@ -28,6 +29,7 @@ module CloudApp
28
29
  private
29
30
 
30
31
  # Sets the attributes for object.
32
+ #
31
33
  # @param [Hash] attributes
32
34
  def load(attributes = {})
33
35
  attributes.each do |key, val|
@@ -31,9 +31,12 @@ module CloudApp
31
31
  class Client
32
32
 
33
33
  # Creates a new CloudApp::Client instance.
34
- # @example Optionally provide an authentication hash
35
- # { :username => "testuser@test.com", :password => "password" }
36
- # @param [Hash] authentication credentials.
34
+ #
35
+ # You can pass +:username+ and +:password+ parameters to the call.
36
+ #
37
+ # @param [Hash] opts authentication credentials.
38
+ # @option opts [String] :username cl.ly username
39
+ # @option opts [String] :password cl.ly username
37
40
  # @return [CloudApp::Client]
38
41
  def initialize(opts = {})
39
42
  if opts[:username] && opts[:password]
@@ -42,56 +45,67 @@ module CloudApp
42
45
  end
43
46
 
44
47
  # Sets the authentication credentials in a class variable.
45
- # @param [String] cl.ly username
46
- # @param [String] cl.ly password
48
+ #
49
+ # @param [String] username cl.ly username
50
+ # @param [String] password cl.ly password
47
51
  # @return [Hash] authentication credentials
48
52
  def authenticate(username, password)
49
53
  Base.authenticate(username, password)
50
54
  end
51
55
 
52
56
  # Get metadata about a cl.ly URL like name, type, or view count.
57
+ #
53
58
  # Finds the item by it's slug id, for example "2wr4".
54
- # @param [String] cl.ly slug id
59
+ #
60
+ # @param [String] id cl.ly slug id
55
61
  # @return [CloudApp::Item]
56
62
  def item(id)
57
63
  Item.find(id)
58
64
  end
59
65
 
60
66
  # Page through your items.
61
- # @example Optionally pass a hash of parameters.
62
- # :page => 1 # Page number starting at 1
63
- # :per_page => 5 # Number of items per page
64
- # :type => image # Filter items by type (image, bookmark, text, archive, audio, video, or unknown)
65
- # :deleted => true # Show trashed items
67
+ #
66
68
  # Requires authentication.
67
- # @param [Hash] options parameters
68
- # @return [Array] of CloudApp::Item items
69
+ #
70
+ # @param [Hash] opts options parameters
71
+ # @option opts [Integer] :page (1) Page number starting at 1
72
+ # @option opts [Integer] :per_page (5) Number of items per page
73
+ # @option opts [String] :type ('image') Filter items by type (image, bookmark, text, archive, audio, video, or unknown)
74
+ # @option opts [Boolean] :deleted (true) Show trashed items
75
+ # @return [Array[CloudApp::Item]]
69
76
  def items(opts = {})
70
77
  Item.all(opts)
71
78
  end
72
79
 
73
80
  # Create a new cl.ly item by bookmarking a link.
81
+ #
74
82
  # Requires authentication.
75
- # @param [String] url to bookmark
76
- # @param [String] name of bookmark
83
+ #
84
+ # @param [String] url url to bookmark
85
+ # @param [String] name name of bookmark
77
86
  # @return [CloudApp::Item]
78
87
  def bookmark(url, name = "")
79
88
  Item.create(:bookmark, {:name => name, :redirect_url => url})
80
89
  end
81
90
 
82
91
  # Create a new cl.ly item by uploading a file.
92
+ #
83
93
  # Requires authentication.
84
- # @param [String] local path to file
94
+ #
95
+ # @param [String] file local path to file
85
96
  # @return [CloudApp::Item]
86
97
  def upload(file)
87
98
  Item.create(:upload, :file => file)
88
99
  end
89
100
 
90
101
  # Change the name of an item.
102
+ #
91
103
  # Finds the item by it's slug id, for example "2wr4".
104
+ #
92
105
  # Requires authentication.
93
- # @param [String] cl.ly item id
94
- # @param [String] new item name
106
+ #
107
+ # @param [String] id cl.ly item id
108
+ # @param [String] name new item name
95
109
  # @return [CloudApp::Item]
96
110
  def rename(id, name = "")
97
111
  item = Item.find(id)
@@ -99,10 +113,13 @@ module CloudApp
99
113
  end
100
114
 
101
115
  # Modify an item with a private URL to have a public URL or vice versa.
116
+ #
102
117
  # Finds the item by it's slug id, for example "2wr4".
118
+ #
103
119
  # Requires authentication.
104
- # @param [String] cl.ly item id
105
- # @param [Boolean] privacy setting
120
+ #
121
+ # @param [String] id cl.ly item id
122
+ # @param [Boolean] privacy privacy setting
106
123
  # @return [CloudApp::Item]
107
124
  def privacy(id, privacy = false)
108
125
  item = Item.find(id)
@@ -110,9 +127,12 @@ module CloudApp
110
127
  end
111
128
 
112
129
  # Send an item to the trash.
130
+ #
113
131
  # Finds the item by it's slug id, for example "2wr4".
132
+ #
114
133
  # Requires authentication.
115
- # @param [String] cl.ly item id
134
+ #
135
+ # @param [String] id cl.ly item id
116
136
  # @return [CloudApp::Item]
117
137
  def delete(id)
118
138
  item = Item.find(id)
@@ -121,4 +141,4 @@ module CloudApp
121
141
 
122
142
  end
123
143
 
124
- end
144
+ end
data/lib/cloudapp/item.rb CHANGED
@@ -40,39 +40,40 @@ module CloudApp
40
40
  class Item < Base
41
41
 
42
42
  # Get metadata about a cl.ly URL like name, type, or view count.
43
+ #
43
44
  # Finds the item by it's slug id, for example "2wr4".
44
- # @param [String] cl.ly slug id
45
+ #
46
+ # @param [String] id cl.ly slug id
45
47
  # @return [CloudApp::Item]
46
48
  def self.find(id)
47
49
  res = get "http://cl.ly/#{id}"
48
50
  res.ok? ? Item.new(res) : res
49
51
  end
50
52
 
51
- # Page through your items. Optionally pass a hash of parameters.
52
- # @example Optionally pass a hash of parameters.
53
- # :page => 1 # Page number starting at 1
54
- # :per_page => 5 # Number of items per page
55
- # :type => image # Filter items by type (image, bookmark, text, archive, audio, video, or unknown)
56
- # :deleted => true # Show trashed items
53
+ # Page through your items.
54
+ #
57
55
  # Requires authentication.
58
- # @param [Hash] options parameters
59
- # @return [Array] of CloudApp::Item items
56
+ #
57
+ # @param [Hash] opts options parameters
58
+ # @option opts [Integer] :page Page number starting at 1
59
+ # @option opts [Integer] :per_page Number of items per page
60
+ # @option opts [String] :type Filter items by type (image, bookmark, text, archive, audio, video, or unknown)
61
+ # @option opts [Boolean] :deleted Show trashed items
62
+ # @return [Array[CloudApp::Item]]
60
63
  def self.all(opts = {})
61
64
  res = get "/items?#{opts.to_params}", :digest_auth => @@auth
62
65
  res.ok? ? res.collect{|i| Item.new(i)} : res
63
66
  end
64
67
 
65
- # Create a new cl.ly item. Can be one of two types:
66
- # :bookmark # Bookmark link
67
- # :upload # Upload file
68
- # Depending on the type of item, a parameter hash is required.
69
- # @example Options for a bookmark
70
- # { :name => "CloudApp", :redirect_url => "http://getcloudapp.com" }
71
- # @example Options for a file upload
72
- # { :file => "/path/to/image.png" }
68
+ # Create a new cl.ly item.
69
+ #
73
70
  # Requires authentication.
74
- # @param [Symbol] type of cl.ly item
75
- # @param [Hash] item parameters
71
+ #
72
+ # @param [Symbol] kind type of cl.ly item (can be :bookmark or :upload)
73
+ # @param [Hash] opts options paramaters
74
+ # @option opts [String] :name Name of bookmark (only required for +:bookmark+ kind)
75
+ # @option opts [String] :redirect_url Redirect URL (only required for +:bookmark+ kind)
76
+ # @option opts [String] :file Path to file (only required for +:upload+ kind)
76
77
  # @return [CloudApp::Item]
77
78
  def self.create(kind, opts = {})
78
79
  case kind
@@ -90,13 +91,13 @@ module CloudApp
90
91
  end
91
92
 
92
93
  # Modify a cl.ly item. Can currently modify it's name or security setting by passing parameters.
93
- # @example Options for renaming
94
- # { :name => "CloudApp" }
95
- # @example Options for modifying privacy
96
- # { :privacy => true }
94
+ #
97
95
  # Requires authentication.
98
- # @param [String] href of cl.ly item
99
- # @param [Hash] item parameters
96
+ #
97
+ # @param [String] href href attribute of cl.ly item
98
+ # @param [Hash] opts item parameters
99
+ # @option opts [String] :name for renaming the item
100
+ # @option opts [Boolean] :privacy set item privacy
100
101
  # @return [CloudApp::Item]
101
102
  def self.update(href, opts = {})
102
103
  res = put href, {:body => {:item => opts}, :digest_auth => @@auth}
@@ -104,8 +105,10 @@ module CloudApp
104
105
  end
105
106
 
106
107
  # Send an item to the trash.
108
+ #
107
109
  # Requires authentication.
108
- # @param [String] href of cl.ly item
110
+ #
111
+ # @param [String] href href attribute of cl.ly item
109
112
  # @return [CloudApp::Item]
110
113
  def self.delete(href)
111
114
  res = Base.delete href, :digest_auth => @@auth
@@ -116,27 +119,31 @@ module CloudApp
116
119
  :icon, :remote_url, :redirect_url, :created_at, :updated_at, :deleted_at
117
120
 
118
121
  # Create a new CloudApp::Item object.
119
- # Only used internally
122
+ #
123
+ # Only used internally.
124
+ #
120
125
  # @param [Hash] attributes
121
126
  # @param [CloudApp::Item]
122
127
  def initialize(attributes = {})
123
128
  load(attributes)
124
129
  end
125
130
 
126
- # Modify the cl.ly item. Can currently modify it's name or security setting by passing parameters.
127
- # @example Options for renaming
128
- # { :name => "CloudApp" }
129
- # @example Options for modifying privacy
130
- # { :privacy => true }
131
+ # Modify the item. Can currently modify it's name or security setting by passing parameters.
132
+ #
131
133
  # Requires authentication.
132
- # @param [Hash] item parameters
134
+ #
135
+ # @param [Hash] opts item parameters
136
+ # @option opts [String] :name for renaming the item
137
+ # @option opts [Boolean] :privacy set item privacy
133
138
  # @return [CloudApp::Item]
134
139
  def update(opts = {})
135
140
  self.class.update self.href, opts
136
141
  end
137
142
 
138
143
  # Send the item to the trash.
144
+ #
139
145
  # Requires authentication.
146
+ #
140
147
  # @return [CloudApp::Item]
141
148
  def delete
142
149
  self.class.delete self.href
data/lib/cloudapp_api.rb CHANGED
@@ -13,8 +13,9 @@ module CloudApp
13
13
  VERSION = "0.1.0"
14
14
 
15
15
  # Sets the authentication credentials in a class variable
16
- # @param [String] cl.ly username
17
- # @param [String] cl.ly password
16
+ #
17
+ # @param [String] username cl.ly username
18
+ # @param [String] password cl.ly password
18
19
  # @return [Hash] authentication credentials
19
20
  def CloudApp.authenticate(username, password)
20
21
  Base.authenticate(username, password)
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.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: 2010-12-15 00:00:00 +00:00
18
+ date: 2011-01-30 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency