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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcf2758e91edc0914df8ac3b0612094a0acd7afa
4
- data.tar.gz: 2d86b7c78d74482902a62682c6c7964c18c32a1d
3
+ metadata.gz: 8dffb0fceb153e96f900cddfd1c65b12e68f0a2e
4
+ data.tar.gz: 758a47c56c407e79c1effdb03db1d33690e835dd
5
5
  SHA512:
6
- metadata.gz: 1c58c080015aca348f142087ec49b33aa138fc912be1820e64993c22887f8e26c5db84d2485609accb458bf643a8cad62fc9c1ad9af8f70958f108456afde0fe
7
- data.tar.gz: f55daf3c1f69dece0381e434089160141fe3c60f25c6c71b933ad28bb511fd3b818b5103c50dd035eb9cdcb409526561e1f8d3283808c7895293ffb026430527
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
@@ -0,0 +1,5 @@
1
+ module Kraken
2
+ class API
3
+ VERSION = '0.1.1'
4
+ end
5
+ 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.0
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: