dropio 3.0.0.pre3 → 3.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source :rubygems
2
+
3
+ # TODO have this generated from gem spec or vice versa
4
+
5
+ gem "mime-types"
6
+ gem "json"
7
+ gem "httparty", "0.6.1"
8
+ gem "multipart-post"
9
+
10
+ group :development, :test do
11
+ gem "echoe"
12
+ gem "rake"
13
+ gem "rspec"
14
+ gem "diff-lcs"
15
+ gem "fakeweb"
16
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Drop.io, Inc.
1
+ Copyright (c) 2010 Drop.io, Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/Manifest CHANGED
@@ -1,23 +1,24 @@
1
+ Gemfile
1
2
  History.rdoc
3
+ LICENSE.txt
4
+ Manifest
5
+ Rakefile
6
+ Readme.rdoc
7
+ Todo.rdoc
8
+ dropio.gemspec
9
+ lib/dropio.rb
2
10
  lib/dropio/api.rb
3
11
  lib/dropio/asset.rb
4
12
  lib/dropio/client.rb
5
- lib/dropio/comment.rb
6
13
  lib/dropio/drop.rb
7
14
  lib/dropio/resource.rb
8
15
  lib/dropio/subscription.rb
9
- lib/dropio.rb
10
- LICENSE.txt
11
- Manifest
12
- Rakefile
13
- Readme.rdoc
16
+ lib/dropio/version.rb
14
17
  spec/dropio/api_spec.rb
15
18
  spec/dropio/asset_spec.rb
16
19
  spec/dropio/client_spec.rb
17
- spec/dropio/comment_spec.rb
18
20
  spec/dropio/drop_spec.rb
19
21
  spec/dropio/subscription_spec.rb
20
22
  spec/dropio_spec.rb
21
23
  spec/spec.opts
22
24
  spec/spec_helper.rb
23
- Todo.rdoc
data/Rakefile CHANGED
@@ -1,26 +1,34 @@
1
- $: << 'lib'
2
- require 'dropio'
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :development, :test
4
+
5
+ $: << File.expand_path('./lib')
6
+ require 'dropio/version'
3
7
 
4
8
  ### Echoe
5
9
  begin
6
10
  require 'echoe'
7
11
 
8
12
  Echoe.new('dropio', Dropio::VERSION) do |echoe|
9
- echoe.summary = "A Ruby client library for the Drop.io API (http://api.drop.io)"
10
- echoe.author = ["Jake Good"]
11
- echoe.email = ["jake@dropio.com"]
13
+ echoe.summary = "A Ruby client library for the Drop.io Rich Media Backbone (RMB) API (http://backbone.drop.io)"
14
+ echoe.author = ["Jake Good", "Eric Skiff", "Kunal Shah", "Seth Thomas Rasmussen"]
15
+ echoe.email = ["jake@dropio.com", "eric@dropio.com", "kunal@dropio.com", "seth@dropio.com"]
12
16
  echoe.url = "http://github.com/dropio/dropio"
17
+ echoe.retain_gemspec = true
13
18
  echoe.changelog = "History.rdoc"
14
- echoe.ignore_pattern = "tmtags"
15
- echoe.runtime_dependencies = ["mime-types", "json"]
16
19
 
20
+ # TODO have this generated from Gemfile or vice versa
21
+ echoe.runtime_dependencies = ["mime-types", "json", "httparty 0.6.1", "multipart-post"]
22
+ echoe.development_dependencies = ["rspec", "diff-lcs", "fakeweb"]
23
+
24
+ echoe.ignore_pattern = "tmtags"
17
25
  # Use this rdoc_pattern when building docs locally or publishing docs.
18
26
  # echoe.rdoc_pattern = Regexp.union(echoe.rdoc_pattern, /\.rdoc$/)
19
- echoe.rdoc_pattern = /\.rdoc$/
27
+ echoe.rdoc_pattern = /\.rdoc$/
20
28
  end
21
29
 
22
30
  # Until we find a way to undefine rake tasks...
23
- %w{coverage clobber_coverage}.each { |name| Rake::Task[name].comment = "(don't use)" }
31
+ # %w{coverage clobber_coverage}.each { |name| Rake::Task[name].comment = "(don't use)" }
24
32
 
25
33
  # default depends on test, but we don't have a test task. Define a trivial one.
26
34
  task :test
@@ -61,4 +69,3 @@ namespace :docs do
61
69
  sh "open file://#{doc_index}"
62
70
  end
63
71
  end
64
-
data/Readme.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  = drop.io API library for Ruby
4
4
 
5
- Before using the Dropio library, the application must set an API key. This key will be used for all requests to the server. To get an API key, go to http://api.drop.io. Then make sure you set the API key before you use the API:
5
+ Before using the Dropio library, the application must set an API key. This key will be used for all requests to the server. To get an API key, go to http://backbone.drop.io. Then make sure you set the API key before you use the API:
6
6
 
7
7
  Dropio::Config.api_key = "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
8
8
 
data/dropio.gemspec CHANGED
@@ -2,42 +2,50 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dropio}
5
- s.version = "3.0.0.pre3"
5
+ s.version = "3.0.0.pre4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Jake Good"]
9
- s.date = %q{2009-10-01}
10
- s.description = %q{A Ruby client library for the Drop.io API (http://api.drop.io). Please email jake@dropio.com with any questions.}
11
- s.email = ["jake@dropio.com"]
8
+ s.authors = ["Jake Good, Eric Skiff, Kunal Shah, Seth Thomas Rasmussen"]
9
+ s.date = %q{2010-08-31}
10
+ s.description = %q{A Ruby client library for the Drop.io Rich Media Backbone (RMB) API (http://backbone.drop.io). Please email support@dropio.com for any issues.}
11
+ s.email = ["jake@dropio.com", "eric@dropio.com", "kunal@dropio.com", "seth@dropio.com"]
12
12
  s.extra_rdoc_files = ["History.rdoc", "Readme.rdoc", "Todo.rdoc"]
13
- s.files = ["History.rdoc", "lib/dropio/api.rb", "lib/dropio/asset.rb", "lib/dropio/client.rb", "lib/dropio/comment.rb", "lib/dropio/drop.rb", "lib/dropio/resource.rb", "lib/dropio/subscription.rb","lib/dropio.rb", "LICENSE.txt", "Manifest", "Rakefile", "Readme.rdoc", "spec/dropio/api_spec.rb", "spec/dropio/asset_spec.rb", "spec/dropio/client_spec.rb", "spec/dropio/comment_spec.rb", "spec/dropio/drop_spec.rb","spec/dropio/subscription_spec.rb", "spec/dropio_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "Todo.rdoc", "dropio.gemspec"]
14
- s.has_rdoc = true
13
+ s.files = ["Gemfile", "History.rdoc", "LICENSE.txt", "Manifest", "Rakefile", "Readme.rdoc", "Todo.rdoc", "dropio.gemspec", "lib/dropio.rb", "lib/dropio/api.rb", "lib/dropio/asset.rb", "lib/dropio/client.rb", "lib/dropio/drop.rb", "lib/dropio/resource.rb", "lib/dropio/subscription.rb", "lib/dropio/version.rb", "spec/dropio/api_spec.rb", "spec/dropio/asset_spec.rb", "spec/dropio/client_spec.rb", "spec/dropio/drop_spec.rb", "spec/dropio/subscription_spec.rb", "spec/dropio_spec.rb", "spec/spec.opts", "spec/spec_helper.rb"]
15
14
  s.homepage = %q{http://github.com/dropio/dropio}
16
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Dropio", "--main", "Readme.rdoc"]
17
16
  s.require_paths = ["lib"]
18
17
  s.rubyforge_project = %q{dropio}
19
- s.rubygems_version = %q{1.3.0}
20
- s.summary = %q{A Ruby client library for the Drop.io API (http://api.drop.io)}
18
+ s.rubygems_version = %q{1.3.6}
19
+ s.summary = %q{A Ruby client library for the Drop.io Rich Media Backbone (RMB) API (http://backbone.drop.io)}
21
20
 
22
21
  if s.respond_to? :specification_version then
23
22
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 2
23
+ s.specification_version = 3
25
24
 
26
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
26
  s.add_runtime_dependency(%q<mime-types>, [">= 0"])
28
- s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
29
- s.add_runtime_dependency(%q<multipart-post>,[">= 0"])
30
- s.add_development_dependency(%q<echoe>, [">= 0"])
27
+ s.add_runtime_dependency(%q<json>, [">= 0"])
28
+ s.add_runtime_dependency(%q<httparty>, ["= 0.6.1"])
29
+ s.add_runtime_dependency(%q<multipart-post>, [">= 0"])
30
+ s.add_development_dependency(%q<rspec>, [">= 0"])
31
+ s.add_development_dependency(%q<diff-lcs>, [">= 0"])
32
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
31
33
  else
32
34
  s.add_dependency(%q<mime-types>, [">= 0"])
33
- s.add_dependency(%q<httparty>, [">= 0.6.1"])
35
+ s.add_dependency(%q<json>, [">= 0"])
36
+ s.add_dependency(%q<httparty>, ["= 0.6.1"])
34
37
  s.add_dependency(%q<multipart-post>, [">= 0"])
35
- s.add_dependency(%q<echoe>, [">= 0"])
38
+ s.add_dependency(%q<rspec>, [">= 0"])
39
+ s.add_dependency(%q<diff-lcs>, [">= 0"])
40
+ s.add_dependency(%q<fakeweb>, [">= 0"])
36
41
  end
37
42
  else
38
43
  s.add_dependency(%q<mime-types>, [">= 0"])
39
- s.add_dependency(%q<httparty>, [">= 0.6.1"])
44
+ s.add_dependency(%q<json>, [">= 0"])
45
+ s.add_dependency(%q<httparty>, ["= 0.6.1"])
40
46
  s.add_dependency(%q<multipart-post>, [">= 0"])
41
- s.add_dependency(%q<echoe>, [">= 0"])
47
+ s.add_dependency(%q<rspec>, [">= 0"])
48
+ s.add_dependency(%q<diff-lcs>, [">= 0"])
49
+ s.add_dependency(%q<fakeweb>, [">= 0"])
42
50
  end
43
51
  end
data/lib/dropio/api.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  require 'rbconfig'
2
+ require 'mime/types'
3
+ require 'httparty'
4
+ require 'net/http/post/multipart'
2
5
 
3
6
  class Dropio::Api
4
7
  include HTTParty
@@ -31,26 +34,25 @@ class Dropio::Api
31
34
  self.class.post("/drops",:body => sign_if_needed(params))
32
35
  end
33
36
 
34
- def update_drop(drop_name, admin_token, params = {})
35
- params[:token] = admin_token
37
+ def update_drop(drop_name, params = {})
36
38
  self.class.put("/drops/#{drop_name}", :body => sign_if_needed(params))
37
39
  end
38
40
 
39
- def change_drop_name(drop_name, admin_token, new_name)
40
- params = {:token => admin_token, :name => new_name}
41
+ def change_drop_name(drop_name, new_name)
42
+ params = {:name => new_name}
41
43
  self.class.put("/drops/#{drop_name}", :body => sign_if_needed(params))
42
44
  end
43
45
 
44
- def empty_drop(drop_name, admin_token)
45
- self.class.put("/drops/#{drop_name}/empty", :query => sign_if_needed({:token => admin_token}))
46
+ def empty_drop(drop_name)
47
+ self.class.put("/drops/#{drop_name}/empty", :query => {})
46
48
  end
47
49
 
48
- def delete_drop(drop_name, admin_token)
49
- self.class.delete("/drops/#{drop_name}", :query => sign_if_needed({:token => admin_token}))
50
+ def delete_drop(drop_name)
51
+ self.class.delete("/drops/#{drop_name}", :query => {})
50
52
  end
51
53
 
52
- def promote_nick(drop_name, nick, admin_token)
53
- self.class.post("/drops/#{drop_name}", :query => sign_if_needed({:nick => nick, :token => admin_token}))
54
+ def promote_nick(drop_name, nick)
55
+ self.class.post("/drops/#{drop_name}", :query => sign_if_needed({:nick => nick}))
54
56
  end
55
57
 
56
58
  def drop_upload_code(drop_name, token = nil)
@@ -66,15 +68,26 @@ class Dropio::Api
66
68
  self.class.post("/drops/#{drop_name}/assets", :body => sign_if_needed(params))
67
69
  end
68
70
 
69
- def add_file(drop_name, file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil, token = nil)
70
- url = URI.parse(Dropio::Config.upload_url)
71
- r = nil
71
+ def add_file(drop_name, file_path, description = nil, convert_to = nil, pingback_url = nil, output_locations = nil)
72
+ url = URI.parse(Dropio::Config.upload_url)
73
+ locs = output_locations.is_a?(Array) ? output_locations.join(',') : output_locations
74
+ r = nil
75
+
72
76
  File.open(file_path) do |file|
73
77
  mime_type = (MIME::Types.type_for(file_path)[0] || MIME::Types["application/octet-stream"][0])
74
- req = Net::HTTP::Post::Multipart.new url.path,
75
- sign_if_needed({ 'api_key' => self.class.default_params[:api_key], 'drop_name' => drop_name, 'format' => 'json', 'description' => description,
76
- 'token' => token, 'version' => Dropio::Config.version, 'convert_to' => convert_to, 'pingback_url' => pingback_url,
77
- 'comment' => comment, 'file' => UploadIO.new(file, mime_type, file_path) })
78
+
79
+ params = sign_if_needed({
80
+ 'api_key' => self.class.default_params[:api_key],
81
+ 'drop_name' => drop_name,
82
+ 'format' => 'json',
83
+ 'description' => description,
84
+ 'version' => Dropio::Config.version,
85
+ 'convert_to' => convert_to,
86
+ 'pingback_url' => pingback_url,
87
+ 'output_locations' => locs
88
+ }).merge('file' => UploadIO.new(file, mime_type, file_path))
89
+
90
+ req = Net::HTTP::Post::Multipart.new(url.path, params)
78
91
  http = Net::HTTP.new(url.host, url.port)
79
92
  http.set_debug_output $stderr if Dropio::Config.debug
80
93
  r = http.start{|http| http.request(req)}
@@ -127,22 +140,18 @@ class Dropio::Api
127
140
  self.class.put("/drops/#{drop_name}/assets/#{asset_name}", :body => sign_if_needed(params))
128
141
  end
129
142
 
130
- def delete_asset(drop_name, asset_name, token = nil)
131
- self.class.delete("/drops/#{drop_name}/assets/#{asset_name}", :body => sign_if_needed({:token => token}))
143
+ def delete_asset(drop_name, asset_name)
144
+ self.class.delete("/drops/#{drop_name}/assets/#{asset_name}", :body => sign_if_needed({}))
145
+ end
146
+
147
+ def delete_role(drop_name, asset_name, role, location=nil)
148
+ self.class.delete("/drops/#{drop_name}/assets/#{asset_name}", :body => sign_if_needed({:role => role, :output_location => location}))
132
149
  end
133
150
 
134
151
  def send_asset_to_drop(drop_name, asset_name, target_drop, drop_token = nil, token = nil)
135
152
  self.class.post("/drops/#{drop_name}/assets/#{asset_name}/send_to", :body => sign_if_needed({:medium => "drop", :drop_name => target_drop, :token => token, :drop_token => drop_token}))
136
153
  end
137
154
 
138
- def send_asset_to_fax(drop_name, asset_name, fax_number, token = nil)
139
- self.class.post("/drops/#{drop_name}/assets/#{asset_name}/send_to", :body => sign_if_needed({:medium => "fax", :fax_number => fax_number, :token => token}))
140
- end
141
-
142
- def send_asset_to_emails(drop_name, asset_name, emails, message = nil, token = nil)
143
- self.class.post("/drops/#{drop_name}/assets/#{asset_name}/send_to", :body => sign_if_needed({:medium => "emails", :emails => emails, message => message, :token => token}))
144
- end
145
-
146
155
  def copy_asset(drop_name, asset_name, target_drop, target_drop_token, token = nil)
147
156
  params = {:token => token, :drop_name => target_drop, :drop_token => target_drop_token}
148
157
  self.class.post("/drops/#{drop_name}/assets/#{asset_name}/copy", :body => sign_if_needed(params))
@@ -153,45 +162,16 @@ class Dropio::Api
153
162
  self.class.post("/drops/#{drop_name}/assets/#{asset_name}/move", :body => sign_if_needed(params))
154
163
  end
155
164
 
156
- def comments(drop_name, asset_name, page = 1, token = nil)
157
- self.class.get("/drops/#{drop_name}/assets/#{asset_name}/comments", :query => sign_if_needed({:token => token, :page => page, :show_pagination_details => true}))
158
- end
159
-
160
- def create_comment(drop_name, asset_name, contents, token = nil)
161
- self.class.post("/drops/#{drop_name}/assets/#{asset_name}/comments",:body => sign_if_needed({:contents => contents, :token => token}))
162
- end
163
-
164
- def comment(drop_name, asset_name, comment_id, token = nil)
165
- self.class.get("/drops/#{drop_name}/assets/#{asset_name}/comments/#{comment_id}", :query => sign_if_needed({:token => token}))
166
- end
167
-
168
- def update_comment(drop_name, asset_name, comment_id, contents, admin_token)
169
- self.class.put("/drops/#{drop_name}/assets/#{asset_name}/comments/#{comment_id}", :body => sign_if_needed({:contents => contents, :token => admin_token}))
170
- end
171
-
172
- def delete_comment(drop_name, asset_name, comment_id, admin_token)
173
- self.class.delete("/drops/#{drop_name}/assets/#{asset_name}/comments/#{comment_id}", :body => sign_if_needed({:token => admin_token}))
174
- end
175
-
176
- def create_twitter_subscription(drop_name, username, password, message = nil, events = {}, token = nil)
177
- self.class.post("/drops/#{drop_name}/subscriptions", :body => sign_if_needed({ :token => token, :type => "twitter", :username => username, :password => password, :message => message}.merge(events)))
178
- end
179
-
180
165
  def create_pingback_subscription(drop_name, url, events = {}, token = nil)
181
166
  self.class.post("/drops/#{drop_name}/subscriptions", :body => sign_if_needed({ :token => token, :type => "pingback", :url => url}.merge(events)))
182
167
  end
183
168
 
184
- def create_email_subscription(drop_name, emails, message = nil, welcome_message = nil, welcome_subject = nil, welcome_from = nil, events = {}, token = nil)
185
- params = {:token => token, :type => "email", :emails => emails, :message => message, :welcome_from => welcome_from , :welcome_subject => welcome_subject, :welcome_message => welcome_message }.merge(events)
186
- self.class.post("/drops/#{drop_name}/subscriptions", :body => sign_if_needed(params))
187
- end
188
-
189
- def subscriptions(drop_name, page, admin_token)
190
- self.class.get("/drops/#{drop_name}/subscriptions", :query => sign_if_needed({:token => admin_token, :page => page, :show_pagination_details => true}))
169
+ def subscriptions(drop_name, page)
170
+ self.class.get("/drops/#{drop_name}/subscriptions", :query => sign_if_needed({:page => page, :show_pagination_details => true}))
191
171
  end
192
172
 
193
- def delete_subscription(drop_name, subscription_id, admin_token)
194
- self.class.delete("/drops/#{drop_name}/subscriptions/#{subscription_id}", :body => sign_if_needed({:token => admin_token}))
173
+ def delete_subscription(drop_name, subscription_id)
174
+ self.class.delete("/drops/#{drop_name}/subscriptions/#{subscription_id}", :body => {})
195
175
  end
196
176
 
197
177
  def get_signature(params={})
data/lib/dropio/asset.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  class Dropio::Asset < Dropio::Resource
2
2
 
3
3
  attr_accessor :drop, :name, :type, :title, :description, :filesize, :created_at,
4
- :thumbnail, :status, :converted, :hidden_url, :pages, :fax_status,
5
- :duration, :artist, :track_title, :height, :width, :contents, :url,
4
+ :thumbnail, :status, :converted, :hidden_url, :pages, :duration,
5
+ :artist, :track_title, :height, :width, :contents, :url,
6
6
  :original_filename, :converted_filename, :can_download_original,
7
7
  :large_thumbnail, :roles, :locations
8
8
 
@@ -16,24 +16,11 @@ class Dropio::Asset < Dropio::Resource
16
16
  Dropio::Resource.client.change_asset_name(self,new_name)
17
17
  end
18
18
 
19
- # Returns the comments on this Asset. Comments are loaded lazily. The first
20
- # call to +comments+ will fetch the comments from the server. They are then
21
- # cached until the Asset is reloaded.
22
- def comments(page = 1)
23
- @comments = Dropio::Resource.client.comments(self, page)
24
- end
25
-
26
19
  # Gets the Assets's embed code
27
20
  def embed_code
28
21
  Dropio::Resource.client.asset_embed_code(self)
29
22
  end
30
23
 
31
- # Adds a comment to the Asset with the given +contents+. Returns the
32
- # new +Comment+.
33
- def create_comment(contents)
34
- Dropio::Resource.client.create_comment(self, contents)
35
- end
36
-
37
24
  # Saves the Asset back to drop.io.
38
25
  def save
39
26
  Dropio::Resource.client.update_asset(self)
@@ -42,7 +29,19 @@ class Dropio::Asset < Dropio::Resource
42
29
  # Destroys the Asset on drop.io. Don't try to use an Asset after destroying it.
43
30
  def destroy!
44
31
  Dropio::Resource.client.delete_asset(self)
45
- nil
32
+ return nil
33
+ end
34
+
35
+ # Destroys the given role on an Asset
36
+ def destroy_role!(role)
37
+ Dropio::Resource.client.delete_role(self, role)
38
+ return nil
39
+ end
40
+
41
+ # Destroys the given role at the specified location on an Asset
42
+ def destroy_location!(role, location)
43
+ Dropio::Resource.client.delete_role(self, role, location)
44
+ return nil
46
45
  end
47
46
 
48
47
  # Copies the Asset to the given drop. The +token+ is the target drop's token if required to add files.
@@ -55,24 +54,6 @@ class Dropio::Asset < Dropio::Resource
55
54
  Dropio::Resource.client.move_asset(self, target_drop)
56
55
  end
57
56
 
58
- # Returns true if the Asset can be faxed.
59
- def faxable?
60
- return type.downcase == "document"
61
- end
62
-
63
- # Fax the Asset to the given +fax_number+. Make sure the Asset is +faxable?+
64
- # first, or +send_to_fax+ will raise an error.
65
- def send_to_fax(fax_number)
66
- raise "Can't fax Asset: #{self.inspect} is not faxable" unless faxable?
67
- Dropio::Resource.client.send_asset_to_fax(self, fax_number)
68
- nil
69
- end
70
-
71
- # Sends the Asset to the given +emails+ with an optional +message+.
72
- def send_to_emails(emails = [], message = nil)
73
- Dropio::Resource.client.send_asset_to_emails(self, emails, message)
74
- end
75
-
76
57
  # Sends the Asset to a Drop by +drop_name+
77
58
  def send_to_drop(drop)
78
59
  Dropio::Resource.client.copy_asset(self, drop)
data/lib/dropio/client.rb CHANGED
@@ -22,33 +22,31 @@ class Dropio::Client
22
22
  end
23
23
 
24
24
  def change_drop_name(drop, new_name)
25
- handle(:drop, self.service.change_drop_name(drop.name,drop.admin_token,new_name))
25
+ handle(:drop, self.service.change_drop_name(drop.name,new_name))
26
26
  drop.name = new_name
27
27
  drop
28
28
  end
29
29
 
30
30
  def update_drop(drop)
31
31
  params = { :description => drop.description, :admin_email => drop.admin_email,
32
- :email_key => drop.email_key, :default_view => drop.default_view,
33
- :chat_password => drop.chat_password, :guests_can_comment => drop.guests_can_comment,
34
- :guests_can_add => drop.guests_can_add, :guests_can_delete => drop.guests_can_delete,
35
- :expiration_length => drop.expiration_length, :password => drop.password,
36
- :admin_password => drop.admin_password, :premium_code => drop.premium_code }
37
- handle(:drop, self.service.update_drop(drop.name,drop.admin_token,params))
32
+ :email_key => drop.email_key, :chat_password => drop.chat_password,
33
+ :expiration_length => drop.expiration_length, :password => drop.password,
34
+ :admin_password => drop.admin_password }
35
+ handle(:drop, self.service.update_drop(drop.name,params))
38
36
  end
39
37
 
40
38
  def empty_drop(drop)
41
- r = handle(:response, self.service.empty_drop(drop.name,drop.admin_token))
39
+ r = handle(:response, self.service.empty_drop(drop.name))
42
40
  r["result"]
43
41
  end
44
42
 
45
43
  def delete_drop(drop)
46
- r = handle(:response, self.service.delete_drop(drop.name,drop.admin_token))
44
+ r = handle(:response, self.service.delete_drop(drop.name))
47
45
  r["result"]
48
46
  end
49
47
 
50
48
  def promote_nick(drop,nick)
51
- r = handle(:response, self.service.promote_nick(drop.name,nick,drop.admin_token))
49
+ r = handle(:response, self.service.promote_nick(drop.name,nick))
52
50
  r["result"]
53
51
  end
54
52
 
@@ -69,8 +67,8 @@ class Dropio::Client
69
67
  a
70
68
  end
71
69
 
72
- def add_file(drop, file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)
73
- a = handle(:asset, self.service.add_file(drop.name, file_path, description, convert_to, pingback_url, comment, drop.default_token))
70
+ def add_file(drop, file_path, description = nil, convert_to = nil, pingback_url = nil, output_locations = nil)
71
+ a = handle(:asset, self.service.add_file(drop.name, file_path, description, convert_to, pingback_url, output_locations))
74
72
  a.drop = drop
75
73
  a
76
74
  end
@@ -120,22 +118,17 @@ class Dropio::Client
120
118
  end
121
119
 
122
120
  def delete_asset(asset)
123
- r = handle(:response, self.service.delete_asset(asset.drop.name,asset.name,asset.drop.default_token))
121
+ r = handle(:response, self.service.delete_asset(asset.drop.name,asset.name))
124
122
  r["result"]
125
123
  end
126
124
 
127
- def send_asset_to_drop(asset, target_drop)
128
- r = handle(:response, self.service.send_asset_to_drop(asset.drop.name, asset.name, target_drop.name, target_drop.default_token, asset.drop.default_token))
125
+ def delete_role(asset, role, location=nil)
126
+ r = handle(:response, self.service.delete_role(asset.drop.name,asset.name,role,location))
129
127
  r["result"]
130
128
  end
131
-
132
- def send_asset_to_fax(asset, fax_number)
133
- r = handle(:response, self.service.send_asset_to_fax(asset.drop.name, asset.name, fax_number, asset.drop.default_token))
134
- r["result"]
135
- end
136
-
137
- def send_asset_to_emails(asset, emails, message)
138
- r = handle(:response, self.service.send_asset_to_emails(asset.drop.name, asset.name, emails, message, asset.drop.default_token))
129
+
130
+ def send_asset_to_drop(asset, target_drop)
131
+ r = handle(:response, self.service.send_asset_to_drop(asset.drop.name, asset.name, target_drop.name, target_drop.default_token, asset.drop.default_token))
139
132
  r["result"]
140
133
  end
141
134
 
@@ -149,48 +142,6 @@ class Dropio::Client
149
142
  r["result"]
150
143
  end
151
144
 
152
- def comments(asset, page = 1)
153
- comments = handle(:comments, self.service.comments(asset.drop.name,asset.name,page,asset.drop.default_token))
154
- comments.each{|c| c.asset = asset}
155
- comments
156
- end
157
-
158
- def create_comment(asset, contents)
159
- c = handle(:comment, self.service.create_comment(asset.drop.name,asset.name,contents,asset.drop.default_token))
160
- c.asset = asset
161
- c
162
- end
163
-
164
- def comment(asset, comment_id)
165
- c = handle(:comment, self.service.comment(asset.drop.name,asset.name,comment_id,asset.drop.default_token))
166
- c.asset = asset
167
- c
168
- end
169
-
170
- def update_comment(comment)
171
- c = handle(:comment, self.service.update_comment(comment.asset.drop.name,comment.asset.name,comment.id,comment.contents,comment.asset.drop.admin_token))
172
- c.asset = comment.asset
173
- c
174
- end
175
-
176
- def delete_comment(comment)
177
- r = handle(:response, self.service.delete_comment(comment.asset.drop.name,comment.asset.name,comment.id,comment.asset.drop.admin_token))
178
- r["result"]
179
- end
180
-
181
- def create_twitter_subscription(drop, username,password, message, events)
182
- s = handle(:subscription, self.service.create_twitter_subscription(drop.name, username, password, message, events, drop.default_token))
183
- s.drop = drop
184
- s
185
- end
186
-
187
- def create_email_subscription(drop, emails, welcome_message, welcome_subject, welcome_from, message, events)
188
- s = handle(:subscriptions, self.service.create_email_subscription(drop.name, emails, welcome_message, welcome_subject, welcome_from, message, events, drop.default_token))
189
- s = s.first
190
- s.drop = drop
191
- s
192
- end
193
-
194
145
  def create_pingback_subscription(drop, url, events)
195
146
  s = handle(:subscription, self.service.create_pingback_subscription(drop.name, url, events, drop.default_token))
196
147
  s.drop = drop
@@ -198,7 +149,7 @@ class Dropio::Client
198
149
  end
199
150
 
200
151
  def subscriptions(drop, page = 1)
201
- subscriptions = handle(:subscriptions, self.service.subscriptions(drop.name,page,drop.admin_token))
152
+ subscriptions = handle(:subscriptions, self.service.subscriptions(drop.name,page))
202
153
  subscriptions.each{|s| s.drop = drop}
203
154
  subscriptions
204
155
  end
@@ -220,8 +171,6 @@ class Dropio::Client
220
171
  when :drops then return response['drops'].collect{|s| Dropio::Drop.new(d)}
221
172
  when :asset then return Dropio::Asset.new(response)
222
173
  when :assets then return response['assets'].collect{|a| Dropio::Asset.new(a)}
223
- when :comment then return Dropio::Comment.new(response)
224
- when :comments then return response['comments'].collect{|c| Dropio::Comment.new(c)}
225
174
  when :subscription then return Dropio::Subscription.new(response)
226
175
  when :subscriptions then return response['subscriptions'].collect{|s| Dropio::Subscription.new(s)}
227
176
  when :response then return parse_response(response)
data/lib/dropio/drop.rb CHANGED
@@ -1,13 +1,12 @@
1
1
  class Dropio::Drop < Dropio::Resource
2
2
 
3
- attr_accessor :name, :email, :voicemail, :conference, :fax, :rss, :guest_token, :description,
4
- :admin_token, :expires_at, :expiration_length, :guests_can_comment, :guests_can_add, :guests_can_delete,
5
- :max_bytes, :current_bytes, :hidden_upload_url, :asset_count, :chat_password, :default_view,
6
- :password, :admin_password, :premium_code, :admin_email, :email_key
3
+ attr_accessor :name, :email, :guest_token, :description, :expires_at, :expiration_length,
4
+ :max_bytes, :current_bytes, :asset_count, :chat_password, :password,
5
+ :admin_password, :admin_email, :email_key
7
6
 
8
7
  # Gets the default token to be used, prefers the admin token.
9
8
  def default_token
10
- self.admin_token || self.guest_token
9
+ self.guest_token
11
10
  end
12
11
 
13
12
  # Gets a list of assets associated with the Drop. Paginated at
@@ -26,13 +25,13 @@ class Dropio::Drop < Dropio::Resource
26
25
  end
27
26
 
28
27
  # Creates a drop with an +attributes+ hash.
29
- # Valid attributes: name (string), default_view (string), guests_can_comment (boolean), guests_can_add (boolean), guests_can_delete (boolean), expiration_length (string), password (string), admin_password (string), and premium_code (string)
28
+ # Valid attributes: name (string), expiration_length (string), password (string), and admin_password (string)
30
29
  # Descriptions can be found here: http://groups.google.com/group/dropio-api/web/full-api-documentation
31
30
  def self.create(attributes = {})
32
31
  Dropio::Resource.client.create_drop(attributes)
33
32
  end
34
33
 
35
- # Changes the name of a drop. Admin token required. Has to be 7 characters or more unless premium.
34
+ # Changes the name of a drop.
36
35
  def change_name(new_name)
37
36
  Dropio::Resource.client.change_drop_name(self,new_name)
38
37
  end
@@ -68,8 +67,8 @@ class Dropio::Drop < Dropio::Resource
68
67
  end
69
68
 
70
69
  # Adds a file to the Drop given the +file_path+.
71
- def add_file(file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)
72
- Dropio::Resource.client.add_file(self, file_path, description, convert_to, pingback_url, comment)
70
+ def add_file(file_path, description = nil, convert_to = nil, pingback_url = nil, output_locations = nil)
71
+ Dropio::Resource.client.add_file(self, file_path, description, convert_to, pingback_url, output_locations)
73
72
  end
74
73
 
75
74
  # Creates a note with a +title+ and +contents+
@@ -87,16 +86,6 @@ class Dropio::Drop < Dropio::Resource
87
86
  Dropio::Resource.client.create_pingback_subscription(self,url,events)
88
87
  end
89
88
 
90
- # Creates a Twitter Subscription
91
- def create_twitter_subscription(username,password,message = nil, events = {})
92
- Dropio::Resource.client.create_twitter_subscription(self,username,password,message,events)
93
- end
94
-
95
- # Creates an email Subscription
96
- def create_email_subscription(email, message = nil, welcome_message = nil, welcome_subject = nil, welcome_from = nil, events = {})
97
- Dropio::Resource.client.create_email_subscription(self,email,message,welcome_message,welcome_subject,welcome_from, events)
98
- end
99
-
100
89
  # Gets a list of Subscription objects.
101
90
  def subscriptions(page = 1)
102
91
  Dropio::Resource.client.subscriptions(self, page)
@@ -0,0 +1,3 @@
1
+ module Dropio
2
+ VERSION = '3.0.0.pre2'
3
+ end
data/lib/dropio.rb CHANGED
@@ -1,10 +1,12 @@
1
+ require 'dropio/version'
2
+
1
3
  module Dropio
2
- VERSION = '3.0.0'
4
+ class Error < StandardError; end
3
5
 
4
- class MissingResourceError < Exception; end
5
- class AuthorizationError < Exception; end
6
- class RequestError < Exception; end
7
- class ServerError < Exception; end
6
+ class MissingResourceError < Error; end
7
+ class AuthorizationError < Error; end
8
+ class RequestError < Error; end
9
+ class ServerError < Error; end
8
10
 
9
11
  class Config
10
12
  class << self
@@ -14,22 +16,16 @@ module Dropio
14
16
 
15
17
  end
16
18
 
17
- require 'rbconfig'
18
- require 'mime/types'
19
- require 'httparty'
20
- require 'net/http/post/multipart'
21
-
22
- Dropio::Config.base_url = "http://drop.io"
23
- Dropio::Config.api_url = "http://api.drop.io"
19
+ Dropio::Config.base_url = "http://drop.io"
20
+ Dropio::Config.api_url = "http://api.drop.io"
24
21
  Dropio::Config.upload_url = "http://assets.drop.io/upload"
25
- Dropio::Config.version = "3.0"
26
- Dropio::Config.debug = false
27
- Dropio::Config.timeout = 60 # Default in Ruby
22
+ Dropio::Config.version = "3.0"
23
+ Dropio::Config.debug = false
24
+ Dropio::Config.timeout = 60 # Default in Ruby
28
25
 
29
26
  require 'dropio/api'
30
27
  require 'dropio/client'
31
28
  require 'dropio/resource'
32
29
  require 'dropio/drop'
33
30
  require 'dropio/asset'
34
- require 'dropio/comment'
35
31
  require 'dropio/subscription'
@@ -19,25 +19,9 @@ describe Dropio::Asset do
19
19
 
20
20
  it "should have the attributes of an Asset" do
21
21
  @asset.should respond_to(:drop, :name, :type, :title, :description, :filesize, :created_at,
22
- :thumbnail, :status, :converted, :hidden_url, :pages, :fax_status,
23
- :duration, :artist, :track_title, :height, :width, :contents, :url,
24
- :original_filename, :converted_filename, :can_download_original, :large_thumbnail)
25
- end
26
-
27
- it "should have comments" do
28
- @comment = stub(Comment)
29
- @comment.should_receive(:asset=).once
30
- @client.should_receive(:handle).with(:comments,{}).and_return([@comment])
31
- @api.stub!(:comments).with(@drop.name, @asset.name, 1, @drop.default_token).and_return({})
32
- @asset.comments.should == [@comment]
33
- end
34
-
35
- it "should create comments" do
36
- @comment = stub(Comment)
37
- @comment.should_receive(:asset=).once
38
- @client.should_receive(:handle).with(:comment,{}).and_return(@comment)
39
- @api.stub!(:create_comment).with(@drop.name, @asset.name, "Totally rad asset, bro!",@drop.default_token).and_return({})
40
- @asset.create_comment("Totally rad asset, bro!").should == @comment
22
+ :thumbnail, :status, :converted, :hidden_url, :pages, :duration, :artist,
23
+ :track_title, :height, :width, :contents, :url, :original_filename, :converted_filename,
24
+ :large_thumbnail)
41
25
  end
42
26
 
43
27
  it "should save itself" do
@@ -50,34 +34,20 @@ describe Dropio::Asset do
50
34
 
51
35
  it "should destroy itself" do
52
36
  @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
53
- @api.stub!(:delete_asset).with(@drop.name, @asset.name,@drop.default_token).and_return({})
37
+ @api.stub!(:delete_asset).with(@drop.name, @asset.name).and_return({})
54
38
  @asset.destroy!
55
39
  end
56
-
57
- it "should be faxable if and only if it's a document" do
58
- @asset.type = "Document"
59
- @asset.should be_faxable
60
- @asset.type = "Video"
61
- @asset.should_not be_faxable
62
- end
63
-
64
- it "should fax itself to a phone number" do
65
- @asset.type = "Document"
66
-
40
+
41
+ it "should destroy roles" do
67
42
  @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
68
- @api.stub!(:send_asset_to_fax).with(@drop.name, @asset.name,"234-567-8901",@drop.default_token).and_return({})
69
- @asset.send_to_fax("234-567-8901")
43
+ @api.stub!(:delete_role).with(@drop.name, @asset.name, "thumbnail", nil).and_return({})
44
+ @asset.destroy_role!("thumbnail")
70
45
  end
71
-
72
- it "should email itself to a comma separated list of emails with an optional message" do
73
- @asset.type = "Document"
74
- @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
75
- @api.stub!(:send_asset_to_emails).with(@drop.name, @asset.name,"jake@dropio.com, jacob@dropio.com", "Awesome stuff!", @drop.default_token).and_return({})
76
- @asset.send_to_emails("jake@dropio.com, jacob@dropio.com","Awesome stuff!")
77
-
46
+
47
+ it "should destroy roles at locations" do
78
48
  @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
79
- @api.stub!(:send_asset_to_emails).with(@drop.name, @asset.name,"jake@dropio.com, jacob@dropio.com", nil, @drop.default_token).and_return({})
80
- @asset.send_to_emails("jake@dropio.com, jacob@dropio.com")
49
+ @api.stub!(:delete_role).with(@drop.name, @asset.name, "thumbnail", "DropioS3").and_return({})
50
+ @asset.destroy_location!("thumbnail","DropioS3")
81
51
  end
82
52
 
83
53
  it "should send itself to another drop." do
@@ -107,13 +77,6 @@ describe Dropio::Asset do
107
77
  @asset.move_to(@target_drop)
108
78
  end
109
79
 
110
- it "should not fax itself if it's not faxable" do
111
- @asset.type = "Video"
112
- @api.should_not_receive(:send_asset_to_fax)
113
- # TODO: Make this a specific error.
114
- lambda { @asset.send_to_fax("234-567-8901") }.should raise_error
115
- end
116
-
117
80
  it "should find itself" do
118
81
  @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
119
82
  @api.should_receive(:asset).with(@drop.name, @asset.name, @drop.default_token).and_return({})
@@ -121,7 +84,7 @@ describe Dropio::Asset do
121
84
  end
122
85
 
123
86
  it "should generate a signed url" do
124
- @api.should_receive(:generate_drop_url).with(@drop.name,@asset.name,@drop.default_token)
87
+ @api.should_receive(:generate_asset_url).with(@drop.name,@asset.name,@drop.default_token)
125
88
  @asset.generate_url
126
89
  end
127
90
 
@@ -11,14 +11,13 @@ describe Drop do
11
11
  Dropio::Resource.client.should == @client
12
12
  Dropio::Resource.client.service.should == @api
13
13
 
14
- @mydrop = Dropio::Drop.new(:name => "test_drop",:admin_token => "admin_token")
14
+ @mydrop = Dropio::Drop.new(:name => "test_drop")
15
15
  end
16
16
 
17
17
  it "should have the attributes of a Drop" do
18
- Drop.new.should respond_to(:name, :email, :voicemail, :conference, :fax, :rss, :guest_token, :description,
19
- :admin_token, :expires_at, :expiration_length, :guests_can_comment, :guests_can_add, :guests_can_delete,
20
- :max_bytes, :current_bytes, :hidden_upload_url, :asset_count, :chat_password, :default_view,
21
- :password, :admin_password, :premium_code, :admin_email, :email_key)
18
+ Drop.new.should respond_to(:name, :email, :guest_token, :description, :expires_at,
19
+ :expiration_length, :max_bytes, :current_bytes, :asset_count, :chat_password,
20
+ :password, :admin_password, :admin_email, :email_key)
22
21
  end
23
22
 
24
23
  it "should find drops by name" do
@@ -33,11 +32,6 @@ describe Drop do
33
32
  Drop.find("mydrop", "d85a6").should == @mydrop
34
33
  end
35
34
 
36
- it "should have a default token and it should default to the admin" do
37
- @mydrop.admin_token = "tester"
38
- @mydrop.default_token.should == "tester"
39
- end
40
-
41
35
  it "should find a set of related assets" do
42
36
  @asset = stub(Asset)
43
37
  @asset.should_receive(:drop=).once
@@ -60,29 +54,28 @@ describe Drop do
60
54
 
61
55
  it "should be able to empty itself" do
62
56
  @client.should_receive(:handle).with(:response,{}).and_return({})
63
- @api.should_receive(:empty_drop).with(@mydrop.name,@mydrop.admin_token).and_return({})
57
+ @api.should_receive(:empty_drop).with(@mydrop.name).and_return({})
64
58
  @mydrop.empty
65
59
  end
66
60
 
67
61
  it "should be able to promote a nick" do
68
62
  @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
69
- @api.should_receive(:promote_nick).with(@mydrop.name,"jake",@mydrop.admin_token).and_return({})
63
+ @api.should_receive(:promote_nick).with(@mydrop.name,"jake").and_return({})
70
64
  @mydrop.promote("jake")
71
65
  end
72
66
 
73
67
  it "should save itself" do
74
68
  @client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
75
- expected_hash = {:password=>"test_password", :expiration_length=>nil, :admin_password=>nil, :guests_can_comment=>nil,
76
- :premium_code=>nil, :guests_can_add=>nil, :chat_password=>nil, :guests_can_delete=>nil,
77
- :admin_email=>nil, :default_view=>nil, :email_key=>nil, :description=>nil}
78
- @api.should_receive(:update_drop).with(@mydrop.name,@mydrop.admin_token,expected_hash).and_return({})
69
+ expected_hash = {:password=>"test_password", :expiration_length=>nil, :admin_password=>nil,
70
+ :chat_password=>nil, :admin_email=>nil, :email_key=>nil, :description=>nil}
71
+ @api.should_receive(:update_drop).with(@mydrop.name,expected_hash).and_return({})
79
72
  @mydrop.password = "test_password"
80
73
  @mydrop.save
81
74
  end
82
75
 
83
76
  it "should destroy itself" do
84
77
  @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
85
- @api.should_receive(:delete_drop).with(@mydrop.name,@mydrop.admin_token).and_return({})
78
+ @api.should_receive(:delete_drop).with(@mydrop.name).and_return({})
86
79
  @mydrop.destroy!
87
80
  end
88
81
 
@@ -106,17 +99,25 @@ describe Drop do
106
99
  @asset = stub(Asset)
107
100
  @asset.should_receive(:drop=).once
108
101
  @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
109
- @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt", "description", nil, nil, nil, @mydrop.default_token).and_return({})
102
+ @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt", "description", nil, nil, nil).and_return({})
110
103
  @mydrop.add_file("/mypath/myfile.txt", "description").should == @asset
111
104
  end
112
105
 
113
- it "should add files from a path with pingback url and convertsion target" do
106
+ it "should add files from a path with pingback url and conversion target" do
114
107
  @asset = stub(Asset)
115
108
  @asset.should_receive(:drop=).once
116
109
  @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
117
- @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt","description", 'H264_HIGH_RES', 'http://drop.io/test/pinged', nil, @mydrop.default_token).and_return({})
110
+ @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt","description", 'H264_HIGH_RES', 'http://drop.io/test/pinged', nil).and_return({})
118
111
  @mydrop.add_file("/mypath/myfile.txt","description",'H264_HIGH_RES', 'http://drop.io/test/pinged').should == @asset
119
112
  end
113
+
114
+ it "should add files from a path with pingback url, conversion target, and output location" do
115
+ @asset = stub(Asset)
116
+ @asset.should_receive(:drop=).once
117
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
118
+ @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt","description", 'H264_HIGH_RES', 'http://drop.io/test/pinged','DropioS3').and_return({})
119
+ @mydrop.add_file("/mypath/myfile.txt","description",'H264_HIGH_RES', 'http://drop.io/test/pinged', 'DropioS3').should == @asset
120
+ end
120
121
 
121
122
  it "should create notes from title and contents and description" do
122
123
  @asset = stub(Asset)
@@ -134,22 +135,6 @@ describe Drop do
134
135
  @mydrop.create_link("http://drop.io","drop.io","The best!").should == @asset
135
136
  end
136
137
 
137
- it "should be able to create a twitter subscription" do
138
- @sub = stub(Subscription)
139
- @sub.should_receive(:drop=).once
140
- @client.should_receive(:handle).with(:subscription,{}).and_return(@sub)
141
- @api.should_receive(:create_twitter_subscription).with(@mydrop.name,"mytwitter","pass",nil,{},@mydrop.default_token).and_return({})
142
- @mydrop.create_twitter_subscription("mytwitter","pass")
143
- end
144
-
145
- it "should be able to create email subscriptions" do
146
- @sub = stub(Subscription)
147
- @sub.should_receive(:drop=).once
148
- @client.should_receive(:handle).with(:subscription,{}).and_return(@sub)
149
- @api.should_receive(:create_email_subscription).with(@mydrop.name,"jake@dropio.com","My welcome message",nil,nil,nil,{},@mydrop.default_token).and_return({})
150
- @mydrop.create_email_subscription("jake@dropio.com","My welcome message")
151
- end
152
-
153
138
  it "should be able to create pingback subscriptions" do
154
139
  @sub = stub(Subscription)
155
140
  @sub.should_receive(:drop=).once
@@ -162,7 +147,7 @@ describe Drop do
162
147
  @sub = stub(Subscription)
163
148
  @sub.should_receive(:drop=).once
164
149
  @client.should_receive(:handle).with(:subscriptions,{}).and_return([@sub])
165
- @api.stub!(:subscriptions).with(@mydrop.name, 1, @mydrop.admin_token).and_return({})
150
+ @api.stub!(:subscriptions).with(@mydrop.name, 1).and_return({})
166
151
  @mydrop.subscriptions.should == [@sub]
167
152
  end
168
153
 
data/spec/dropio_spec.rb CHANGED
@@ -5,4 +5,26 @@ describe Dropio do
5
5
  Dropio::Config.api_key = "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
6
6
  Dropio::Config.api_key.should == "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
7
7
  end
8
+
9
+ it "should define exceptions which inherit from StandardError" do
10
+ exception_names = [
11
+ :MissingResourceError,
12
+ :AuthorizationError,
13
+ :RequestError,
14
+ :ServerError
15
+ ]
16
+
17
+ exceptions = exception_names.map do |n|
18
+ Dropio.const_get n
19
+ end
20
+
21
+ exceptions.each do |e|
22
+ assert_nothing_raised do
23
+ begin
24
+ raise e
25
+ rescue StandardError
26
+ end
27
+ end
28
+ end
29
+ end
8
30
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,14 @@
1
1
  require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :default, :test
4
+
2
5
  require 'spec'
6
+ require 'spec/test/unit'
3
7
  require 'fakeweb'
4
8
 
5
9
  FakeWeb.allow_net_connect = false
6
10
 
7
- lib_dir = File.dirname(__FILE__) + '/../lib'
8
- $:.unshift lib_dir unless $:.include?(lib_dir)
11
+ $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
9
12
 
10
13
  require 'dropio'
11
14
  include Dropio
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropio
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1876988210
4
+ hash: -1876988209
5
5
  prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
- - pre3
11
- version: 3.0.0.pre3
10
+ - pre4
11
+ version: 3.0.0.pre4
12
12
  platform: ruby
13
13
  authors:
14
- - Jake Good
14
+ - Jake Good, Eric Skiff, Kunal Shah, Seth Thomas Rasmussen
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2009-10-01 00:00:00 -05:00
19
+ date: 2010-08-31 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -34,12 +34,26 @@ dependencies:
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: httparty
37
+ name: json
38
38
  prerelease: false
39
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: httparty
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - "="
43
57
  - !ruby/object:Gem::Version
44
58
  hash: 5
45
59
  segments:
@@ -48,11 +62,11 @@ dependencies:
48
62
  - 1
49
63
  version: 0.6.1
50
64
  type: :runtime
51
- version_requirements: *id002
65
+ version_requirements: *id003
52
66
  - !ruby/object:Gem::Dependency
53
67
  name: multipart-post
54
68
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
69
+ requirement: &id004 !ruby/object:Gem::Requirement
56
70
  none: false
57
71
  requirements:
58
72
  - - ">="
@@ -62,11 +76,11 @@ dependencies:
62
76
  - 0
63
77
  version: "0"
64
78
  type: :runtime
65
- version_requirements: *id003
79
+ version_requirements: *id004
66
80
  - !ruby/object:Gem::Dependency
67
- name: echoe
81
+ name: rspec
68
82
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
70
84
  none: false
71
85
  requirements:
72
86
  - - ">="
@@ -76,10 +90,41 @@ dependencies:
76
90
  - 0
77
91
  version: "0"
78
92
  type: :development
79
- version_requirements: *id004
80
- description: A Ruby client library for the Drop.io API (http://api.drop.io). Please email jake@dropio.com with any questions.
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: diff-lcs
96
+ prerelease: false
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ type: :development
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: fakeweb
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ type: :development
121
+ version_requirements: *id007
122
+ description: A Ruby client library for the Drop.io Rich Media Backbone (RMB) API (http://backbone.drop.io). Please email support@dropio.com for any issues.
81
123
  email:
82
124
  - jake@dropio.com
125
+ - eric@dropio.com
126
+ - kunal@dropio.com
127
+ - seth@dropio.com
83
128
  executables: []
84
129
 
85
130
  extensions: []
@@ -89,30 +134,30 @@ extra_rdoc_files:
89
134
  - Readme.rdoc
90
135
  - Todo.rdoc
91
136
  files:
137
+ - Gemfile
92
138
  - History.rdoc
139
+ - LICENSE.txt
140
+ - Manifest
141
+ - Rakefile
142
+ - Readme.rdoc
143
+ - Todo.rdoc
144
+ - dropio.gemspec
145
+ - lib/dropio.rb
93
146
  - lib/dropio/api.rb
94
147
  - lib/dropio/asset.rb
95
148
  - lib/dropio/client.rb
96
- - lib/dropio/comment.rb
97
149
  - lib/dropio/drop.rb
98
150
  - lib/dropio/resource.rb
99
151
  - lib/dropio/subscription.rb
100
- - lib/dropio.rb
101
- - LICENSE.txt
102
- - Manifest
103
- - Rakefile
104
- - Readme.rdoc
152
+ - lib/dropio/version.rb
105
153
  - spec/dropio/api_spec.rb
106
154
  - spec/dropio/asset_spec.rb
107
155
  - spec/dropio/client_spec.rb
108
- - spec/dropio/comment_spec.rb
109
156
  - spec/dropio/drop_spec.rb
110
157
  - spec/dropio/subscription_spec.rb
111
158
  - spec/dropio_spec.rb
112
159
  - spec/spec.opts
113
160
  - spec/spec_helper.rb
114
- - Todo.rdoc
115
- - dropio.gemspec
116
161
  has_rdoc: true
117
162
  homepage: http://github.com/dropio/dropio
118
163
  licenses: []
@@ -151,7 +196,7 @@ requirements: []
151
196
  rubyforge_project: dropio
152
197
  rubygems_version: 1.3.7
153
198
  signing_key:
154
- specification_version: 2
155
- summary: A Ruby client library for the Drop.io API (http://api.drop.io)
199
+ specification_version: 3
200
+ summary: A Ruby client library for the Drop.io Rich Media Backbone (RMB) API (http://backbone.drop.io)
156
201
  test_files: []
157
202
 
@@ -1,15 +0,0 @@
1
- class Dropio::Comment < Dropio::Resource
2
-
3
- attr_accessor :id, :contents, :created_at, :asset
4
-
5
- # Saves the comment back to drop.io
6
- def save
7
- Dropio::Resource.client.update_comment(self)
8
- end
9
-
10
- # Destroys the comment on drop.io. Don't try to use an Comment after destroying it.
11
- def destroy!
12
- Dropio::Resource.client.delete_comment(self)
13
- end
14
-
15
- end
@@ -1,38 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Dropio::Comment do
4
- before(:each) do
5
- @drop = Dropio::Drop.new
6
- @drop.name = "test_drop"
7
- @asset = Dropio::Asset.new
8
- @asset.drop = @drop
9
- @asset.name = "test_asset"
10
- @comment = Dropio::Comment.new
11
- @comment.asset = @asset
12
-
13
- @client = Dropio::Client.new
14
- @api = stub(Dropio::Api)
15
- @client.service = @api
16
-
17
- Dropio::Resource.stub!(:client).and_return(@client)
18
- Dropio::Resource.client.should == @client
19
- Dropio::Resource.client.service.should == @api
20
- end
21
-
22
- it "should have the attributes of an Comment" do
23
- @comment.should respond_to(:id, :contents, :created_at)
24
- end
25
-
26
- it "should save itself" do
27
- @client.should_receive(:handle).with(:comment,{}).and_return(@comment)
28
- @api.should_receive(:update_comment).with(@drop.name, @asset.name, @comment.id, "My new content", @drop.default_token).and_return({})
29
- @comment.contents = "My new content"
30
- @comment.save
31
- end
32
-
33
- it "should destroy itself" do
34
- @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
35
- @api.should_receive(:delete_comment).with(@drop.name, @asset.name, @comment.id, @drop.admin_token).and_return({})
36
- @comment.destroy!
37
- end
38
- end