kraken-io 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kraken-io/http_multi_part.rb +19 -0
- data/lib/kraken-io/response.rb +20 -0
- data/lib/kraken-io/version.rb +5 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dffb0fceb153e96f900cddfd1c65b12e68f0a2e
|
4
|
+
data.tar.gz: 758a47c56c407e79c1effdb03db1d33690e835dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de61b8800940331010b06bc9340af9217faabde88e653224fda2b495768a4442dc31bd694b36fa2afe9979c3f12e3dda7b130041bb8f097848ba179f3fa138b1
|
7
|
+
data.tar.gz: af8bac3e1d49d16d05c05b2406477fef09d7998f974f0819f4984f6fd370078da84f5361fae35f2344857499648224dec19b2bc640459540c1a56bb26ed0dc16
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'net/http/post/multipart'
|
2
|
+
|
3
|
+
module HTTPMultiPart
|
4
|
+
def multipart_post(url, params = {})
|
5
|
+
unless params.has_key?(:file)
|
6
|
+
post(url, params)
|
7
|
+
end
|
8
|
+
|
9
|
+
url = URI.parse(base_uri + url)
|
10
|
+
|
11
|
+
req = Net::HTTP::Post::Multipart.new(url.path, {
|
12
|
+
file: UploadIO.new(File.open(params[:file]), 'file'),
|
13
|
+
body: params[:body] })
|
14
|
+
|
15
|
+
https = Net::HTTP.new(url.host, url.port)
|
16
|
+
https.use_ssl = true
|
17
|
+
https.request(req)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active_support/ordered_options'
|
2
|
+
require 'forwardable'
|
3
|
+
require 'delegate'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Kraken
|
7
|
+
class Response < SimpleDelegator
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
def_delegators :@parsed, :success, :file_name, :original_size,
|
11
|
+
:kraked_size, :saved_bytes, :kraked_url
|
12
|
+
|
13
|
+
def initialize(response)
|
14
|
+
super(response)
|
15
|
+
@parsed = ActiveSupport::InheritableOptions.new(JSON.parse(response.body).with_indifferent_access)
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :original_response, :__getobj__
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kraken-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Przemek Matylla
|
@@ -130,6 +130,9 @@ executables: []
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
+
- lib/kraken-io/http_multi_part.rb
|
134
|
+
- lib/kraken-io/response.rb
|
135
|
+
- lib/kraken-io/version.rb
|
133
136
|
- lib/kraken-io.rb
|
134
137
|
homepage: http://github.com/kraken-io/kraken-ruby
|
135
138
|
licenses:
|