dropio 1.0.8 → 1.0.10
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/dropio.gemspec +1 -1
- data/lib/dropio.rb +1 -1
- data/lib/dropio/api.rb +9 -9
- data/lib/dropio/client.rb +9 -9
- data/lib/dropio/drop.rb +7 -6
- data/spec/dropio/drop_spec.rb +11 -11
- metadata +1 -1
data/dropio.gemspec
CHANGED
data/lib/dropio.rb
CHANGED
data/lib/dropio/api.rb
CHANGED
@@ -50,18 +50,18 @@ class Dropio::Api
|
|
50
50
|
self.class.post("/drops/#{drop_name}/assets", :body => {:url => url, :title => title, :description => description, :token => token})
|
51
51
|
end
|
52
52
|
|
53
|
-
def create_note(drop_name, contents, title = nil, token = nil)
|
54
|
-
params = {:contents => contents, :title => title, :token => token}
|
53
|
+
def create_note(drop_name, contents, title = nil, description = nil, token = nil)
|
54
|
+
params = {:contents => contents, :title => title, :token => token, :description => description}
|
55
55
|
self.class.post("/drops/#{drop_name}/assets", :body => params)
|
56
56
|
end
|
57
57
|
|
58
|
-
def add_file(drop_name, file_path, convert_to = nil, pingback_url = nil, comment = nil, token = nil)
|
58
|
+
def add_file(drop_name, file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil, token = nil)
|
59
59
|
url = URI.parse("http://assets.drop.io/upload/")
|
60
60
|
r = nil
|
61
61
|
File.open(file_path) do |file|
|
62
62
|
mime_type = (MIME::Types.type_for(file_path)[0] || MIME::Types["application/octet-stream"][0])
|
63
63
|
req = Net::HTTP::Post::Multipart.new url.path,
|
64
|
-
{ 'api_key' => self.class.default_params[:api_key], 'drop_name' => drop_name, 'format' => 'json',
|
64
|
+
{ 'api_key' => self.class.default_params[:api_key], 'drop_name' => drop_name, 'format' => 'json', 'description' => description,
|
65
65
|
'token' => token, 'version' => '2.0', 'convert_to' => convert_to, 'pingback_url' => pingback_url,
|
66
66
|
'comment' => comment, 'file' => UploadIO.new(file, mime_type, file_path) }
|
67
67
|
http = Net::HTTP.new(url.host, url.port)
|
@@ -71,12 +71,12 @@ class Dropio::Api
|
|
71
71
|
(r.nil? or r.body.nil? or r.body.empty?) ? [] : HTTParty::Response.new(Crack::JSON.parse(r.body), r.body, r.code, r.message, r.to_hash)
|
72
72
|
end
|
73
73
|
|
74
|
-
def add_file_from_url(drop_name, url, convert_to = nil, pingback_url = nil, token = nil)
|
75
|
-
self.class.post("/drops/#{drop_name}/assets", :body => {:token => token, :file_url => url, :convert_to => convert_to, :pingback_url => pingback_url})
|
74
|
+
def add_file_from_url(drop_name, url, description = nil, convert_to = nil, pingback_url = nil, token = nil)
|
75
|
+
self.class.post("/drops/#{drop_name}/assets", :body => {:token => token, :file_url => url, :description => description, :convert_to => convert_to, :pingback_url => pingback_url})
|
76
76
|
end
|
77
77
|
|
78
78
|
def assets(drop_name, page = 1, order = :oldest, token = nil)
|
79
|
-
self.class.get("/drops/#{drop_name}/assets", :query => {:token => token, :page => page, :order => order.to_s})
|
79
|
+
self.class.get("/drops/#{drop_name}/assets", :query => {:token => token, :page => page, :order => order.to_s, :show_pagination_details => true})
|
80
80
|
end
|
81
81
|
|
82
82
|
def asset(drop_name, asset_name, token = nil)
|
@@ -123,7 +123,7 @@ class Dropio::Api
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def comments(drop_name, asset_name, page = 1, token = nil)
|
126
|
-
self.class.get("/drops/#{drop_name}/assets/#{asset_name}/comments", :query => {:token => token, :page => page})
|
126
|
+
self.class.get("/drops/#{drop_name}/assets/#{asset_name}/comments", :query => {:token => token, :page => page, :show_pagination_details => true})
|
127
127
|
end
|
128
128
|
|
129
129
|
def create_comment(drop_name, asset_name, contents, token = nil)
|
@@ -156,7 +156,7 @@ class Dropio::Api
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def subscriptions(drop_name, page, admin_token)
|
159
|
-
self.class.get("/drops/#{drop_name}/subscriptions", :query => {:token => admin_token, :page => page})
|
159
|
+
self.class.get("/drops/#{drop_name}/subscriptions", :query => {:token => admin_token, :page => page, :show_pagination_details => true})
|
160
160
|
end
|
161
161
|
|
162
162
|
|
data/lib/dropio/client.rb
CHANGED
@@ -53,20 +53,20 @@ class Dropio::Client
|
|
53
53
|
a
|
54
54
|
end
|
55
55
|
|
56
|
-
def create_note(drop, contents, title = nil)
|
57
|
-
a = handle(:asset, self.service.create_note(drop.name, contents, title, drop.default_token))
|
56
|
+
def create_note(drop, contents, title = nil, description = nil)
|
57
|
+
a = handle(:asset, self.service.create_note(drop.name, contents, title, description, drop.default_token))
|
58
58
|
a.drop = drop
|
59
59
|
a
|
60
60
|
end
|
61
61
|
|
62
|
-
def add_file(drop, file_path, convert_to = nil, pingback_url = nil, comment = nil)
|
63
|
-
a = handle(:asset, self.service.add_file(drop.name, file_path, convert_to, pingback_url, comment, drop.default_token))
|
62
|
+
def add_file(drop, file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)
|
63
|
+
a = handle(:asset, self.service.add_file(drop.name, file_path, description, convert_to, pingback_url, comment, drop.default_token))
|
64
64
|
a.drop = drop
|
65
65
|
a
|
66
66
|
end
|
67
67
|
|
68
|
-
def add_file_from_url(drop, url, convert_to = nil, pingback_url = nil)
|
69
|
-
a = handle(:asset, self.service.add_file_from_url(drop.name, url, convert_to, pingback_url, drop.default_token))
|
68
|
+
def add_file_from_url(drop, url, description = nil, convert_to = nil, pingback_url = nil)
|
69
|
+
a = handle(:asset, self.service.add_file_from_url(drop.name, url, description, convert_to, pingback_url, drop.default_token))
|
70
70
|
a.drop = drop
|
71
71
|
a
|
72
72
|
end
|
@@ -192,11 +192,11 @@ class Dropio::Client
|
|
192
192
|
case type
|
193
193
|
when :drop then return Dropio::Drop.new(response)
|
194
194
|
when :asset then return Dropio::Asset.new(response)
|
195
|
-
when :assets then return response.collect{|a| Dropio::Asset.new(a)}
|
195
|
+
when :assets then return response['assets'].collect{|a| Dropio::Asset.new(a)}
|
196
196
|
when :comment then return Comment.new(response)
|
197
|
-
when :comments then return response.collect{|c| Dropio::Comment.new(c)}
|
197
|
+
when :comments then return response['comments'].collect{|c| Dropio::Comment.new(c)}
|
198
198
|
when :subscription then return Dropio::Subscription.new(response)
|
199
|
-
when :subscriptions then return response.collect{|s| Dropio::Subscription.new(s)}
|
199
|
+
when :subscriptions then return response['subscriptions'].collect{|s| Dropio::Subscription.new(s)}
|
200
200
|
when :response then return parse_response(response)
|
201
201
|
end
|
202
202
|
end
|
data/lib/dropio/drop.rb
CHANGED
@@ -53,18 +53,18 @@ class Dropio::Drop < Dropio::Resource
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# Adds a file to the Drop from a given +url+
|
56
|
-
def add_file_from_url(url, convert_to = nil, pingback_url = nil)
|
57
|
-
Dropio::Resource.client.add_file_from_url(self,url, convert_to, pingback_url)
|
56
|
+
def add_file_from_url(url, description = nil, convert_to = nil, pingback_url = nil)
|
57
|
+
Dropio::Resource.client.add_file_from_url(self,url,description, convert_to, pingback_url)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Adds a file to the Drop given the +file_path+.
|
61
|
-
def add_file(file_path, convert_to = nil, pingback_url = nil, comment = nil)
|
62
|
-
Dropio::Resource.client.add_file(self, file_path, convert_to, pingback_url, comment)
|
61
|
+
def add_file(file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)
|
62
|
+
Dropio::Resource.client.add_file(self, file_path, description, convert_to, pingback_url, comment)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Creates a note with a +title+ and +contents+
|
66
|
-
def create_note(contents, title = nil)
|
67
|
-
Dropio::Resource.client.create_note(self, contents, title)
|
66
|
+
def create_note(contents, title = nil, description = nil)
|
67
|
+
Dropio::Resource.client.create_note(self, contents, title, description)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Creates a link with a +url+, +title+, and +description+.
|
@@ -72,6 +72,7 @@ class Dropio::Drop < Dropio::Resource
|
|
72
72
|
Dropio::Resource.client.create_link(self, url, title, description)
|
73
73
|
end
|
74
74
|
|
75
|
+
# Creates a subscription to receive POSTs from drop.io.
|
75
76
|
def create_pingback_subscription(url, events = {})
|
76
77
|
Dropio::Resource.client.create_pingback_subscription(self,url,events)
|
77
78
|
end
|
data/spec/dropio/drop_spec.rb
CHANGED
@@ -90,40 +90,40 @@ describe Drop do
|
|
90
90
|
@asset = stub(Asset)
|
91
91
|
@asset.should_receive(:drop=).once
|
92
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", nil, nil, @mydrop.default_token).and_return({})
|
94
|
-
@mydrop.add_file_from_url("http://myurl.com/myfile.txt").should == @asset
|
93
|
+
@api.should_receive(:add_file_from_url).with(@mydrop.name,"http://myurl.com/myfile.txt", "description", nil, nil, @mydrop.default_token).and_return({})
|
94
|
+
@mydrop.add_file_from_url("http://myurl.com/myfile.txt","description").should == @asset
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should add files from a url with conversion and pingback url" do
|
98
98
|
@asset = stub(Asset)
|
99
99
|
@asset.should_receive(:drop=).once
|
100
100
|
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
101
|
-
@api.should_receive(:add_file_from_url).with(@mydrop.name,"http://myurl.com/myfile.txt", 'H264_HIGH_RES', 'http://drop.io/test/pinged', @mydrop.default_token).and_return({})
|
102
|
-
@mydrop.add_file_from_url("http://myurl.com/myfile.txt", 'H264_HIGH_RES', 'http://drop.io/test/pinged').should == @asset
|
101
|
+
@api.should_receive(:add_file_from_url).with(@mydrop.name,"http://myurl.com/myfile.txt", "description", 'H264_HIGH_RES', 'http://drop.io/test/pinged', @mydrop.default_token).and_return({})
|
102
|
+
@mydrop.add_file_from_url("http://myurl.com/myfile.txt", "description", 'H264_HIGH_RES', 'http://drop.io/test/pinged').should == @asset
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should add files from a path" do
|
106
106
|
@asset = stub(Asset)
|
107
107
|
@asset.should_receive(:drop=).once
|
108
108
|
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
109
|
-
@api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt", nil, nil, nil, @mydrop.default_token).and_return({})
|
110
|
-
@mydrop.add_file("/mypath/myfile.txt").should == @asset
|
109
|
+
@api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt", "description", nil, nil, nil, @mydrop.default_token).and_return({})
|
110
|
+
@mydrop.add_file("/mypath/myfile.txt", "description").should == @asset
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should add files from a path with pingback url and convertsion target" do
|
114
114
|
@asset = stub(Asset)
|
115
115
|
@asset.should_receive(:drop=).once
|
116
116
|
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
117
|
-
@api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt", 'H264_HIGH_RES', 'http://drop.io/test/pinged', nil, @mydrop.default_token).and_return({})
|
118
|
-
@mydrop.add_file("/mypath/myfile.txt",
|
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({})
|
118
|
+
@mydrop.add_file("/mypath/myfile.txt","description",'H264_HIGH_RES', 'http://drop.io/test/pinged').should == @asset
|
119
119
|
end
|
120
120
|
|
121
|
-
it "should create notes from title and contents" do
|
121
|
+
it "should create notes from title and contents and description" do
|
122
122
|
@asset = stub(Asset)
|
123
123
|
@asset.should_receive(:drop=).once
|
124
124
|
@client.should_receive(:handle).with(:asset,{}).and_return(@asset)
|
125
|
-
@api.should_receive(:create_note).with(@mydrop.name,"contents", "title",@mydrop.default_token).and_return({})
|
126
|
-
@mydrop.create_note("contents","title").should == @asset
|
125
|
+
@api.should_receive(:create_note).with(@mydrop.name,"contents", "title","description",@mydrop.default_token).and_return({})
|
126
|
+
@mydrop.create_note("contents","title", "description").should == @asset
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should create links from a url, title, and description" do
|