dropio 0.9.1 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +12 -0
- data/LICENSE.txt +1 -1
- data/Manifest +4 -3
- data/Rakefile +3 -3
- data/Readme.rdoc +1 -1
- data/dropio.gemspec +13 -10
- data/lib/dropio/api.rb +169 -0
- data/lib/dropio/asset.rb +40 -20
- data/lib/dropio/client.rb +159 -261
- data/lib/dropio/comment.rb +3 -3
- data/lib/dropio/drop.rb +58 -17
- data/lib/dropio/resource.rb +4 -0
- data/lib/dropio/subscription.rb +15 -0
- data/lib/dropio.rb +17 -18
- data/spec/dropio/api_spec.rb +0 -0
- data/spec/dropio/asset_spec.rb +90 -16
- data/spec/dropio/client_spec.rb +0 -322
- data/spec/dropio/comment_spec.rb +22 -7
- data/spec/dropio/drop_spec.rb +138 -12
- data/spec/dropio/subscription_spec.rb +0 -0
- data/spec/dropio_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -0
- metadata +23 -11
- data/lib/dropio/client/mapper.rb +0 -47
- data/lib/dropio/client/multipart_post.rb +0 -35
- data/spec/dropio/client/mapper_spec.rb +0 -169
data/spec/dropio/drop_spec.rb
CHANGED
@@ -1,24 +1,150 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
3
|
describe Drop do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@client = Dropio::Client.new
|
7
|
+
@api = stub(Dropio::Api)
|
8
|
+
@client.service = @api
|
9
|
+
|
10
|
+
Dropio::Resource.stub!(:client).and_return(@client)
|
11
|
+
Dropio::Resource.client.should == @client
|
12
|
+
Dropio::Resource.client.service.should == @api
|
13
|
+
|
14
|
+
@mydrop = Dropio::Drop.new(:name => "test_drop",:admin_token => "admin_token")
|
15
|
+
end
|
16
|
+
|
4
17
|
it "should have the attributes of a Drop" do
|
5
|
-
Drop.new.should respond_to(:name, :email, :voicemail, :conference, :fax,
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:current_bytes, :hidden_upload_url,
|
10
|
-
:upload_url, :password, :admin_password, :premium_code)
|
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)
|
11
22
|
end
|
12
23
|
|
13
24
|
it "should find drops by name" do
|
14
|
-
|
15
|
-
|
16
|
-
Drop.find("mydrop").should == mydrop
|
25
|
+
@client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
|
26
|
+
@api.should_receive(:drop).with("mydrop", nil).and_return({})
|
27
|
+
Drop.find("mydrop").should == @mydrop
|
17
28
|
end
|
18
29
|
|
19
30
|
it "should find drops by name and token" do
|
20
|
-
|
21
|
-
|
22
|
-
Drop.find("mydrop", "d85a6").should == mydrop
|
31
|
+
@client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
|
32
|
+
@api.should_receive(:drop).with("mydrop", "d85a6").and_return({})
|
33
|
+
Drop.find("mydrop", "d85a6").should == @mydrop
|
34
|
+
end
|
35
|
+
|
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
|
+
it "should find a set of related assets" do
|
42
|
+
@asset = stub(Asset)
|
43
|
+
@asset.should_receive(:drop=).once
|
44
|
+
@client.should_receive(:handle).with(:assets,{}).and_return([@asset])
|
45
|
+
@api.stub!(:assets).with(@mydrop.name,1,:oldest,@mydrop.default_token).and_return({})
|
46
|
+
@mydrop.assets.should == [@asset]
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be able to create a new Drop" do
|
50
|
+
@client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
|
51
|
+
@api.should_receive(:create_drop).with({:name => "tester"}).and_return({})
|
52
|
+
Drop.create({:name => "tester"}).should == @mydrop
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should fetch the upload embed code" do
|
56
|
+
@client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
|
57
|
+
@api.should_receive(:drop_upload_code).with(@mydrop.name,@mydrop.default_token).and_return({})
|
58
|
+
@mydrop.upload_code
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should be able to empty itself" do
|
62
|
+
@client.should_receive(:handle).with(:response,{}).and_return({})
|
63
|
+
@api.should_receive(:empty_drop).with(@mydrop.name,@mydrop.admin_token).and_return({})
|
64
|
+
@mydrop.empty
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should be able to promote a nick" do
|
68
|
+
@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({})
|
70
|
+
@mydrop.promote("jake")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should save itself" do
|
74
|
+
@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({})
|
79
|
+
@mydrop.password = "test_password"
|
80
|
+
@mydrop.save
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should destroy itself" do
|
84
|
+
@client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
|
85
|
+
@api.should_receive(:delete_drop).with(@mydrop.name,@mydrop.admin_token).and_return({})
|
86
|
+
@mydrop.destroy!
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should add files from a url" do
|
90
|
+
@asset = stub(Asset)
|
91
|
+
@asset.should_receive(:drop=).once
|
92
|
+
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
93
|
+
@api.should_receive(:add_file_from_url).with(@mydrop.name,"http://myurl.com/myfile.txt",@mydrop.default_token).and_return({})
|
94
|
+
@mydrop.add_file_from_url("http://myurl.com/myfile.txt").should == @asset
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should add files from a path" do
|
98
|
+
@asset = stub(Asset)
|
99
|
+
@asset.should_receive(:drop=).once
|
100
|
+
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
101
|
+
@api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt",@mydrop.default_token, nil).and_return({})
|
102
|
+
@mydrop.add_file("/mypath/myfile.txt").should == @asset
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should create notes from title and contents" do
|
106
|
+
@asset = stub(Asset)
|
107
|
+
@asset.should_receive(:drop=).once
|
108
|
+
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
109
|
+
@api.should_receive(:create_note).with(@mydrop.name,"contents", "title",@mydrop.default_token).and_return({})
|
110
|
+
@mydrop.create_note("contents","title").should == @asset
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should create links from a url, title, and description" do
|
114
|
+
@asset = stub(Asset)
|
115
|
+
@asset.should_receive(:drop=).once
|
116
|
+
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
117
|
+
@api.should_receive(:create_link).with(@mydrop.name,"http://drop.io","drop.io","The best!",@mydrop.default_token).and_return({})
|
118
|
+
@mydrop.create_link("http://drop.io","drop.io","The best!").should == @asset
|
23
119
|
end
|
120
|
+
|
121
|
+
it "should be able to create a twitter subscription" do
|
122
|
+
@sub = stub(Subscription)
|
123
|
+
@sub.should_receive(:drop=).once
|
124
|
+
@client.should_receive(:handle).with(:subscription,{}).and_return(@sub)
|
125
|
+
@api.should_receive(:create_twitter_subscription).with(@mydrop.name,"mytwitter","pass",nil,{},@mydrop.default_token).and_return({})
|
126
|
+
@mydrop.create_twitter_subscription("mytwitter","pass")
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should be able to create email subscriptions" do
|
130
|
+
@sub = stub(Subscription)
|
131
|
+
@sub.should_receive(:drop=).once
|
132
|
+
@client.should_receive(:handle).with(:subscription,{}).and_return(@sub)
|
133
|
+
@api.should_receive(:create_email_subscription).with(@mydrop.name,"jake@dropio.com","My welcome message",nil,nil,nil,{},@mydrop.default_token).and_return({})
|
134
|
+
@mydrop.create_email_subscription("jake@dropio.com","My welcome message")
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should be able to get a list of subscriptions back" do
|
138
|
+
@sub = stub(Subscription)
|
139
|
+
@sub.should_receive(:drop=).once
|
140
|
+
@client.should_receive(:handle).with(:subscriptions,{}).and_return([@sub])
|
141
|
+
@api.stub!(:subscriptions).with(@mydrop.name, @mydrop.admin_token).and_return({})
|
142
|
+
@mydrop.subscriptions.should == [@sub]
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should generate a signed url" do
|
146
|
+
@api.should_receive(:generate_drop_url).with(@mydrop.name,@mydrop.default_token)
|
147
|
+
@mydrop.generate_url
|
148
|
+
end
|
149
|
+
|
24
150
|
end
|
File without changes
|
data/spec/dropio_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Dropio do
|
4
4
|
it "should store the API key" do
|
5
|
-
Dropio.api_key = "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
|
6
|
-
Dropio.api_key.should == "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
|
5
|
+
Dropio::Config.api_key = "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
|
6
|
+
Dropio::Config.api_key.should == "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
|
7
7
|
end
|
8
8
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: "1.0"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Jake Good
|
7
|
+
- Jake Good
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-09-09 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,7 +23,17 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: httparty
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: multipart-post
|
27
37
|
type: :runtime
|
28
38
|
version_requirement:
|
29
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,10 +52,9 @@ dependencies:
|
|
42
52
|
- !ruby/object:Gem::Version
|
43
53
|
version: "0"
|
44
54
|
version:
|
45
|
-
description: A Ruby client library for the Drop.io API (http://api.drop.io)
|
55
|
+
description: A Ruby client library for the Drop.io API (http://api.drop.io). Please email jake@dropio.com with any questions.
|
46
56
|
email:
|
47
57
|
- jake@dropio.com
|
48
|
-
- peeja@dropio.com
|
49
58
|
executables: []
|
50
59
|
|
51
60
|
extensions: []
|
@@ -56,30 +65,33 @@ extra_rdoc_files:
|
|
56
65
|
- Todo.rdoc
|
57
66
|
files:
|
58
67
|
- History.rdoc
|
68
|
+
- lib/dropio/api.rb
|
59
69
|
- lib/dropio/asset.rb
|
60
|
-
- lib/dropio/client/mapper.rb
|
61
|
-
- lib/dropio/client/multipart_post.rb
|
62
70
|
- lib/dropio/client.rb
|
63
71
|
- lib/dropio/comment.rb
|
64
72
|
- lib/dropio/drop.rb
|
65
73
|
- lib/dropio/resource.rb
|
74
|
+
- lib/dropio/subscription.rb
|
66
75
|
- lib/dropio.rb
|
67
76
|
- LICENSE.txt
|
68
77
|
- Manifest
|
69
78
|
- Rakefile
|
70
79
|
- Readme.rdoc
|
80
|
+
- spec/dropio/api_spec.rb
|
71
81
|
- spec/dropio/asset_spec.rb
|
72
|
-
- spec/dropio/client/mapper_spec.rb
|
73
82
|
- spec/dropio/client_spec.rb
|
74
83
|
- spec/dropio/comment_spec.rb
|
75
84
|
- spec/dropio/drop_spec.rb
|
85
|
+
- spec/dropio/subscription_spec.rb
|
76
86
|
- spec/dropio_spec.rb
|
77
87
|
- spec/spec.opts
|
78
88
|
- spec/spec_helper.rb
|
79
89
|
- Todo.rdoc
|
80
90
|
- dropio.gemspec
|
81
91
|
has_rdoc: true
|
82
|
-
homepage: http://github.com/
|
92
|
+
homepage: http://github.com/dropio/dropio
|
93
|
+
licenses: []
|
94
|
+
|
83
95
|
post_install_message:
|
84
96
|
rdoc_options:
|
85
97
|
- --line-numbers
|
@@ -105,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
117
|
requirements: []
|
106
118
|
|
107
119
|
rubyforge_project: dropio
|
108
|
-
rubygems_version: 1.3.
|
120
|
+
rubygems_version: 1.3.5
|
109
121
|
signing_key:
|
110
122
|
specification_version: 2
|
111
123
|
summary: A Ruby client library for the Drop.io API (http://api.drop.io)
|
data/lib/dropio/client/mapper.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
class Dropio::Client::Mapper
|
2
|
-
|
3
|
-
def self.map_drops(response_body)
|
4
|
-
return parse_and_map(Dropio::Drop, response_body)
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.map_assets(drop, response_body)
|
8
|
-
assets = parse_and_map(Dropio::Asset, response_body)
|
9
|
-
|
10
|
-
assets.drop = drop if assets.is_a?(Dropio::Asset)
|
11
|
-
assets.each{ |a| a.drop = drop } if assets.is_a?(Array)
|
12
|
-
|
13
|
-
return assets
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.map_comments(asset, response_body)
|
17
|
-
comments = parse_and_map(Dropio::Comment, response_body)
|
18
|
-
|
19
|
-
comments.asset = asset if comments.is_a?(Dropio::Comment)
|
20
|
-
comments.each{ |c| c.asset = asset } if comments.is_a?(Array)
|
21
|
-
|
22
|
-
return comments
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def self.parse_and_map(model_class, response_body)
|
28
|
-
h = JSON.parse(response_body)
|
29
|
-
|
30
|
-
# single model
|
31
|
-
return model_class.new(h) if h.is_a?(Hash)
|
32
|
-
|
33
|
-
# multiple models
|
34
|
-
models = []
|
35
|
-
|
36
|
-
h.each do |model_hash|
|
37
|
-
if model_hash.is_a?(Hash)
|
38
|
-
model = model_class.new(model_hash)
|
39
|
-
models << model
|
40
|
-
end
|
41
|
-
end if h.is_a?(Array)
|
42
|
-
|
43
|
-
return models
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Dropio::Client::MultipartPost
|
2
|
-
def multipart_params=(param_hash={})
|
3
|
-
boundary_token = [Array.new(8) {rand(256)}].join
|
4
|
-
self.content_type = "multipart/form-data; boundary=#{boundary_token}"
|
5
|
-
boundary_marker = "--#{boundary_token}\r\n"
|
6
|
-
self.body = param_hash.map { |param_name, param_value|
|
7
|
-
unless param_value.nil?
|
8
|
-
boundary_marker + case param_value
|
9
|
-
when String
|
10
|
-
text_to_multipart(param_name, param_value.to_s)
|
11
|
-
when File
|
12
|
-
file_to_multipart(param_name, param_value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
}.join('') + "--#{boundary_token}--\r\n"
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
def file_to_multipart(key,file)
|
20
|
-
filename = File.basename(file.path)
|
21
|
-
mime_types = MIME::Types.of(filename)
|
22
|
-
mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
23
|
-
part = "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{filename}\"\r\n"
|
24
|
-
part += "Content-Transfer-Encoding: binary\r\n"
|
25
|
-
part += "Content-Type: #{mime_type}\r\n\r\n#{file.read}\r\n"
|
26
|
-
end
|
27
|
-
|
28
|
-
def text_to_multipart(key,value)
|
29
|
-
"Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n#{value}\r\n"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Net::HTTP::Post
|
34
|
-
include Dropio::Client::MultipartPost
|
35
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
|
3
|
-
describe Client::Mapper do
|
4
|
-
it "should parse Drops" do
|
5
|
-
test_drop = Client::Mapper.map_drops <<-RESPONSE
|
6
|
-
{"rss":"http:\/\/drop.io\/k4gpvnty6tw9ho8u3j4w\/b9b2c8f2b8e655679d2fb62b83f8efec4fb4c8af\/test_drop.rss",
|
7
|
-
"voicemail":"646-495-9201 x 02302",
|
8
|
-
"email":"test_drop@drop.io",
|
9
|
-
"admin_token":"A97KQ4Vk7qQU90",
|
10
|
-
"fax":"856-632-1999",
|
11
|
-
"conference":" 218-486-3891 x 915088666",
|
12
|
-
"name":"test_drop",
|
13
|
-
"upload_url":"http:\/\/assets.drop.io\/upload",
|
14
|
-
"guests_can_add":"true",
|
15
|
-
"guests_can_comment":"true",
|
16
|
-
"guests_can_delete":"false",
|
17
|
-
"current_bytes":51488,
|
18
|
-
"max_bytes":104857600.0,
|
19
|
-
"expiration_length":"1_YEAR_FROM_LAST_VIEW",
|
20
|
-
"delete_permission_type":"ALLOWED"}
|
21
|
-
RESPONSE
|
22
|
-
|
23
|
-
test_drop.should be_an_instance_of(Drop)
|
24
|
-
test_drop.rss.should == "http:\/\/drop.io\/k4gpvnty6tw9ho8u3j4w\/b9b2c8f2b8e655679d2fb62b83f8efec4fb4c8af\/test_drop.rss"
|
25
|
-
test_drop.voicemail.should == "646-495-9201 x 02302"
|
26
|
-
test_drop.email.should == "test_drop@drop.io"
|
27
|
-
test_drop.admin_token.should == "A97KQ4Vk7qQU90"
|
28
|
-
test_drop.fax.should == "856-632-1999"
|
29
|
-
test_drop.conference.should == " 218-486-3891 x 915088666"
|
30
|
-
test_drop.name.should == "test_drop"
|
31
|
-
test_drop.upload_url.should == "http:\/\/assets.drop.io\/upload"
|
32
|
-
test_drop.guests_can_add.should == "true"
|
33
|
-
test_drop.guests_can_comment.should == "true"
|
34
|
-
test_drop.guests_can_delete.should == "false"
|
35
|
-
test_drop.current_bytes.should == 51488
|
36
|
-
test_drop.max_bytes.should == 104857600.0
|
37
|
-
test_drop.expiration_length.should == "1_YEAR_FROM_LAST_VIEW"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should parse lists of Drops" do
|
41
|
-
drops = Client::Mapper.map_drops <<-RESPONSE
|
42
|
-
[{"rss":"http:\/\/drop.io\/k4gpvnty6tw9ho8u3j4w\/b9b2c8f2b8e655679d2fb62b83f8efec4fb4c8af\/test_drop.rss",
|
43
|
-
"voicemail":"646-495-9201 x 02302",
|
44
|
-
"email":"test_drop@drop.io",
|
45
|
-
"admin_token":"A97KQ4Vk7qQU90",
|
46
|
-
"fax":"856-632-1999",
|
47
|
-
"conference":" 218-486-3891 x 915088666",
|
48
|
-
"name":"test_drop",
|
49
|
-
"upload_url":"http:\/\/assets.drop.io\/upload",
|
50
|
-
"guests_can_add":"true",
|
51
|
-
"guests_can_comment":"true",
|
52
|
-
"guests_can_delete":"false",
|
53
|
-
"current_bytes":51488,
|
54
|
-
"max_bytes":104857600.0,
|
55
|
-
"expiration_length":"1_YEAR_FROM_LAST_VIEW"},
|
56
|
-
{"current_bytes":178857,
|
57
|
-
"max_bytes":104857600.0,
|
58
|
-
"voicemail":"646-495-9201 x 72025",
|
59
|
-
"admin_token":"8a8vfzfvs2",
|
60
|
-
"email":"0sdcmz7@drop.io",
|
61
|
-
"upload_url":"http:\/\/assets.drop.io\/upload",
|
62
|
-
"guests_can_add":"true",
|
63
|
-
"guests_can_comment":"true",
|
64
|
-
"guests_can_delete":"false",
|
65
|
-
"conference":" 218-486-3891 x 680277944",
|
66
|
-
"name":"0sdcmz7",
|
67
|
-
"expiration_length":"1_YEAR_FROM_LAST_VIEW",
|
68
|
-
"fax":"856-632-1999",
|
69
|
-
"rss":"http:\/\/drop.io\/no9mbevuq3ttmfi6kqen\/3ec4f87d720032bae579cca40740e5e4b267e090\/0sdcmz7.rss"}]
|
70
|
-
RESPONSE
|
71
|
-
|
72
|
-
drops.should be_an_instance_of(Array)
|
73
|
-
drops.each_should be_an_instance_of(Drop)
|
74
|
-
drops[0].name.should == "test_drop"
|
75
|
-
drops[1].name.should == "0sdcmz7"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should parse Assets" do
|
79
|
-
parent_drop = stub(Drop)
|
80
|
-
audio = Client::Mapper.map_assets parent_drop, <<-RESPONSE
|
81
|
-
{"type":"audio",
|
82
|
-
"thumbnail":"http:\/\/drop.io\/download\/public\/vhahbqybv2dx2vdh0z7c\/8c525895399b8eafcd1621b4bd001ee1797e6679\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/",
|
83
|
-
"status":"converted",
|
84
|
-
"filesize":178857,
|
85
|
-
"name":"audio",
|
86
|
-
"file":"http:\/\/drop.io\/download\/48f660ba\/b3c057eb4ce606f2f9f478379ea94ab703416ab3\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/audio.mp3\/audio.mp3",
|
87
|
-
"duration":11,
|
88
|
-
"track_title":"Unknown",
|
89
|
-
"artist":"Unknown",
|
90
|
-
"created_at":"2008/10/15 21:28:55 +0000",
|
91
|
-
"converted":"http:\/\/drop.io\/download\/48f660ba\/26f6688a110f481b169daaa0a023656d4688dac0\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/converted-audio_converted.mp3"}
|
92
|
-
RESPONSE
|
93
|
-
|
94
|
-
audio.should be_an_instance_of(Asset)
|
95
|
-
audio.drop.should == parent_drop
|
96
|
-
audio.type.should == "audio"
|
97
|
-
audio.thumbnail.should == "http:\/\/drop.io\/download\/public\/vhahbqybv2dx2vdh0z7c\/8c525895399b8eafcd1621b4bd001ee1797e6679\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/"
|
98
|
-
audio.status.should == "converted"
|
99
|
-
audio.filesize.should == 178857
|
100
|
-
audio.name.should == "audio"
|
101
|
-
audio.file.should == "http:\/\/drop.io\/download\/48f660ba\/b3c057eb4ce606f2f9f478379ea94ab703416ab3\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/audio.mp3\/audio.mp3"
|
102
|
-
audio.duration.should == 11
|
103
|
-
audio.track_title.should == "Unknown"
|
104
|
-
audio.artist.should == "Unknown"
|
105
|
-
audio.created_at.should == "2008/10/15 21:28:55 +0000"
|
106
|
-
audio.converted.should == "http:\/\/drop.io\/download\/48f660ba\/26f6688a110f481b169daaa0a023656d4688dac0\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/converted-audio_converted.mp3"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should parse lists of Assets" do
|
110
|
-
parent_drop = stub(Drop)
|
111
|
-
assets = Client::Mapper.map_assets parent_drop, <<-RESPONSE
|
112
|
-
[{"type":"note",
|
113
|
-
"status":"converted",
|
114
|
-
"filesize":109,
|
115
|
-
"name":"about-these-files",
|
116
|
-
"contents":"These files are vital to our mission. <strong>Please<\/strong> do not delete them.<br \/><br \/>Thank you.",
|
117
|
-
"title":"About these files",
|
118
|
-
"created_at":"2008/10/15 21:21:49 +0000"},
|
119
|
-
{"type":"audio",
|
120
|
-
"thumbnail":"http:\/\/drop.io\/download\/public\/vhahbqybv2dx2vdh0z7c\/8c525895399b8eafcd1621b4bd001ee1797e6679\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/",
|
121
|
-
"status":"converted",
|
122
|
-
"filesize":178857,
|
123
|
-
"name":"audio",
|
124
|
-
"file":"http:\/\/drop.io\/download\/48f660ba\/b3c057eb4ce606f2f9f478379ea94ab703416ab3\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/audio.mp3\/audio.mp3",
|
125
|
-
"duration":11,
|
126
|
-
"track_title":"Unknown",
|
127
|
-
"artist":"Unknown",
|
128
|
-
"created_at":"2008/10/15 21:28:55 +0000",
|
129
|
-
"converted":"http:\/\/drop.io\/download\/48f660ba\/26f6688a110f481b169daaa0a023656d4688dac0\/1c073ae0-7d29-012b-f659-002241261481\/316995b0-7d2e-012b-b8db-002241261481\/converted-audio_converted.mp3"}]
|
130
|
-
RESPONSE
|
131
|
-
|
132
|
-
assets.should be_an_instance_of(Array)
|
133
|
-
assets.each_should be_an_instance_of(Asset)
|
134
|
-
assets[0].name.should == "about-these-files"
|
135
|
-
assets[1].name.should == "audio"
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should parse Comments" do
|
139
|
-
parent_asset = stub(Asset)
|
140
|
-
comment = Client::Mapper.map_comments parent_asset, <<-RESPONSE
|
141
|
-
{"created_at":"2008/09/17 20:47:47 +0000",
|
142
|
-
"id":1,
|
143
|
-
"contents":"This is my comment content."}
|
144
|
-
RESPONSE
|
145
|
-
|
146
|
-
comment.should be_an_instance_of(Comment)
|
147
|
-
comment.asset.should == parent_asset
|
148
|
-
comment.created_at.should == "2008/09/17 20:47:47 +0000"
|
149
|
-
comment.id.should == 1
|
150
|
-
comment.contents.should == "This is my comment content."
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should parse lists of Comments" do
|
154
|
-
parent_asset = stub(Asset)
|
155
|
-
comments = Client::Mapper.map_comments parent_asset, <<-RESPONSE
|
156
|
-
[{"contents":"Really? Looks like a waste of space to me. I'm going to delete some of these...",
|
157
|
-
"created_at":"2008/10/15 21:44:24 +0000",
|
158
|
-
"id":1},
|
159
|
-
{"contents":"DON'T DO IT!!",
|
160
|
-
"created_at":"2008/10/15 21:44:36 +0000",
|
161
|
-
"id":2}]
|
162
|
-
RESPONSE
|
163
|
-
|
164
|
-
comments.should be_an_instance_of(Array)
|
165
|
-
comments.each_should be_an_instance_of(Comment)
|
166
|
-
comments[0].contents.should =~ /waste of space/
|
167
|
-
comments[1].contents.should =~ /DON'T/
|
168
|
-
end
|
169
|
-
end
|