redbooth-ruby 0.1.1 → 0.1.3

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: 01798b910c79943d677dfcb2c6ae9e58069fd822
4
- data.tar.gz: df3746d0ce68062dae23b2ccebd4f1694227fa3e
3
+ metadata.gz: d6dd0b91631fad3635e4e0fc83d44f87a15760cb
4
+ data.tar.gz: a88346e81a79e57af855446b69af90d011ed0140
5
5
  SHA512:
6
- metadata.gz: e22496072c0dfb59a984540cc1625140c0e9094af7bfc9ff869727210198bc1fb127997d8196d23f2aac8578a8e3553d0e4be09b57587bbcf199f8245b8944fd
7
- data.tar.gz: dd57c0e165ec011a03a49d9d876e1ffbf680da091c5f0b6a8e3754a5696e7113d7ed326d6ad9d03cd01f6c04a42b47c025292ea0bb2c936d6c2f98fc3788fa3c
6
+ metadata.gz: 9ccde9979fff86dcc2c47c6f705d49c86770f16b6706f66dcc74a679dfde637cda88d077422c693e7fe232d46315542e8d1ede5729a2fd37868e6fd8e97cc674
7
+ data.tar.gz: c274f5514b38eb104dc5b6f0921d6051e6843b82b044b9a9f40e5165e13b21ce41d40083e6e62ac4702ed964aa7e0f93d03e6123b21421b071435c8157042dae
data/lib/redbooth-ruby.rb CHANGED
@@ -7,7 +7,7 @@ module RedboothRuby
7
7
  DOMAIN_BASE = nil
8
8
  API_BASE_PATH = 'api'
9
9
  API_VERSION = '3'
10
- ROOT_PATH = File.dirname(__FILE__)
10
+ ROOT_PATH = ::File.dirname(__FILE__)
11
11
 
12
12
  autoload :Base, 'redbooth-ruby/base'
13
13
  autoload :Client, 'redbooth-ruby/client'
@@ -123,4 +123,4 @@ module RedboothRuby
123
123
  @@configuration[:api_version] ||= '3'
124
124
  @@configuration[:use_ssl] ||= true
125
125
  end
126
- end
126
+ end
@@ -26,9 +26,13 @@ module RedboothRuby
26
26
 
27
27
  # Returns a blop with the file data
28
28
  #
29
+ # @param [String] style The style to use
30
+ # @param [String] path The path to save the file to
29
31
  # @return [String] the object metadata
30
- def download(style='original')
31
- request = RedboothRuby.request(:download, nil, "files/#{id}/download/#{style}/#{name}", {}, { session: session })
32
+ def download(style='original', path=nil)
33
+ options = { session: session }
34
+ options[:download_path] = path unless path.nil?
35
+ request = RedboothRuby.request(:download, nil, "files/#{id}/download/#{style}/#{name}", {}, options)
32
36
  request.body
33
37
  end
34
38
 
@@ -2,6 +2,7 @@ require 'net/http/post/multipart'
2
2
 
3
3
  module RedboothRuby
4
4
  module Request
5
+ # Connection class
5
6
  class Connection
6
7
  include Helpers
7
8
  attr_reader :access_token, :request_data
@@ -28,30 +29,69 @@ module RedboothRuby
28
29
  # amazon s3 without authentication headers
29
30
  #
30
31
  def download_file_with_redirect
31
- max_redirects = access_token.options.fetch(:max_redirects, 20)
32
- response = access_token.send(:get, URI.encode(api_url), { redirect_count: max_redirects + 1 })
33
- if [302, 301].include? response.status
34
- url = response.headers['Location']
35
- uri = URI.parse(url)
36
- req = Net::HTTP::Get.new(uri)
37
- http = Net::HTTP.new(uri.host , Net::HTTP.https_default_port)
38
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
39
- http.use_ssl = RedboothRuby.configuration[:use_ssl]
40
- http.start do |inner_http|
41
- inner_http.request(req)
32
+ max_redirects = access_token.options.fetch(:max_redirects, 20)
33
+ response = access_token.send(
34
+ :get,
35
+ URI.encode(api_url),
36
+ redirect_count: max_redirects + 1
37
+ )
38
+ return response unless [302, 301].include? response.status
39
+
40
+ url = response.headers['Location']
41
+ uri = URI.parse(url)
42
+ http = download_http(uri)
43
+ http.start do |inner_http|
44
+ download_file(uri, inner_http)
45
+ end
46
+ end
47
+
48
+ # Generate a download http from a URI
49
+ #
50
+ # @param [URI] uri The URI to use
51
+ def download_http(uri)
52
+ http = Net::HTTP.new(uri.host, Net::HTTP.https_default_port)
53
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
54
+ http.use_ssl = RedboothRuby.configuration[:use_ssl]
55
+ http
56
+ end
57
+
58
+ # Download a file using different strategies
59
+ #
60
+ # @param [URI] uri The URI to use
61
+ # @param [Net::HTTP] http The http to use
62
+ # @return [Mixed] The downloaded file or the result of the download
63
+ def download_file(uri, http)
64
+ if @info.options.key?(:download_path)
65
+ download_to_path(uri, http, @info.options[:download_path])
66
+ else
67
+ http.request(Net::HTTP::Get.new(uri))
68
+ end
69
+ end
70
+
71
+ # Download a file to a path
72
+ #
73
+ # @param [URI] uri The URI to use
74
+ # @param [Net::HTTP] http The http to use
75
+ # @param [String] path The path to save the file to
76
+ # @return [Mixed] The result of the operation
77
+ def download_to_path(uri, http, path)
78
+ request = Net::HTTP::Get.new uri
79
+
80
+ http.request request do |response|
81
+ open path, 'w' do |io|
82
+ response.read_body do |chunk|
83
+ io.write chunk
42
84
  end
43
- else
44
- response
85
+ io.write "\n"
45
86
  end
87
+ end
46
88
  end
47
89
 
48
90
  def set_request_data
49
91
  @request_data = []
50
92
  @request_data << @info.http_method if @info
51
93
  @request_data << api_url
52
- unless use_url_params?
53
- @request_data << { body: body_hash }
54
- end
94
+ @request_data << { body: body_hash } unless use_url_params?
55
95
  end
56
96
 
57
97
  protected
@@ -62,18 +102,22 @@ module RedboothRuby
62
102
  def multipart_request
63
103
  ::File.open(body_file_attrs[:local_path]) do |file|
64
104
  req = Net::HTTP::Post::Multipart.new(
65
- api_url,
66
- body_hash.merge(
67
- 'asset' => UploadIO.new(file,
68
- 'application/octet-stream',
69
- body_file_attrs[:name]
70
- )
105
+ api_url,
106
+ body_hash.merge(
107
+ 'asset' => UploadIO.new(
108
+ file,
109
+ 'application/octet-stream',
110
+ body_file_attrs[:name]
71
111
  )
112
+ )
72
113
  )
73
114
  req['Authorization'] = "Bearer #{access_token.token}"
74
115
  # access_token.sign! req
75
116
  if RedboothRuby.configuration[:use_ssl]
76
- http = Net::HTTP.new(RedboothRuby.configuration[:api_base] , Net::HTTP.https_default_port)
117
+ http = Net::HTTP.new(
118
+ RedboothRuby.configuration[:api_base],
119
+ Net::HTTP.https_default_port
120
+ )
77
121
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
122
  http.use_ssl = RedboothRuby.configuration[:use_ssl]
79
123
  else
@@ -138,13 +182,11 @@ module RedboothRuby
138
182
  def api_url
139
183
  url = "#{ api_url_method}#{api_url_domain }"
140
184
  url += "#{ RedboothRuby.configuration[:api_base] }"
141
- url += "#{ api_url_path }"
142
- url += "#{ api_url_version }"
185
+ url += "#{ api_url_path }#{ api_url_version }"
143
186
  if @info
144
187
  url += @info.url
145
- if use_url_params? && !body_hash.empty?
146
- url += '?' + encoded_www_body
147
- end
188
+ url += '?' + encoded_www_body if use_url_params? &&
189
+ !body_hash.empty?
148
190
  end
149
191
  url
150
192
  end
@@ -1,7 +1,7 @@
1
1
  module RedboothRuby
2
2
  module Request
3
3
  class Info
4
- attr_accessor :http_method, :api_url, :data, :subdomain, :session, :base_path
4
+ attr_accessor :http_method, :api_url, :data, :subdomain, :session, :base_path, :options
5
5
 
6
6
  def initialize(http_method, subdomain, api_url, data, options = {})
7
7
  @http_method = http_method
@@ -10,6 +10,7 @@ module RedboothRuby
10
10
  @data = data
11
11
  @base_path = RedboothRuby.configuration[:api_base_path]
12
12
  @session = options[:session]
13
+ @options = options
13
14
  end
14
15
 
15
16
  def url
@@ -1,3 +1,3 @@
1
1
  module RedboothRuby
2
- VERSION = '0.1.1'
3
- end
2
+ VERSION = '0.1.3'
3
+ end
@@ -6,7 +6,7 @@ require 'redbooth-ruby/version'
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'redbooth-ruby'
8
8
  s.version = RedboothRuby::VERSION
9
- s.authors = ['Andres Bravo', 'Carlos Saura']
9
+ s.authors = ['Andres Bravo', 'Carlos Saura', 'Bruno Pedro']
10
10
  s.email = ['support@redbooth.com']
11
11
  s.homepage = 'https://github.com/teambox/redbooth-ruby'
12
12
  s.summary = %q{API wrapper for Redbooth.}
@@ -0,0 +1,179 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3000/api/3/files?per_page=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Authorization:
13
+ - Bearer _frank_access_token_
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Redbooth-From-Cache:
24
+ - 'off'
25
+ Paginationlinks:
26
+ - <http://localhost:3000/api/3/files?page=2&per_page=1>; rel="next", <http://localhost:3000/api/3/files?page=11&per_page=1>;
27
+ rel="last"
28
+ Paginationtotalpages:
29
+ - '11'
30
+ Paginationperpage:
31
+ - '1'
32
+ Paginationcurrentpage:
33
+ - '1'
34
+ Paginationtotalobjects:
35
+ - '11'
36
+ Content-Type:
37
+ - application/json; charset=utf-8
38
+ X-Ua-Compatible:
39
+ - IE=Edge,chrome=1
40
+ Etag:
41
+ - '"ae01415e8048e399fd81f25d26c6e310"'
42
+ Cache-Control:
43
+ - max-age=0, private, must-revalidate
44
+ X-Request-Id:
45
+ - 0bfe336727051d89857050ce15c31358
46
+ X-Runtime:
47
+ - '0.213858'
48
+ Connection:
49
+ - close
50
+ Server:
51
+ - thin 1.6.1 codename Death Proof
52
+ body:
53
+ encoding: UTF-8
54
+ string: '[{"created_at":1436345699,"updated_at":1436353739,"id":11,"name":"Security
55
+ Report <script>alert(''filename'').txt","backend":"redbooth","project_id":14,"parent_id":10,"backend_id":"8","is_dir":false,"is_downloadable":true,"is_previewable":true,"is_embeddable":false,"is_private":false,"mime_type":"text/plain","public_token":null,"pinned":false,"size":0,"user_id":8,"can_be_moved":true,"can_be_deleted":true,"type":"File"}]'
56
+ http_version:
57
+ recorded_at: Wed, 08 Jul 2015 13:14:29 GMT
58
+ - request:
59
+ method: get
60
+ uri: http://localhost:3000/api/3/files/11/download/original/Security%20Report%20%3Cscript%3Ealert('filename').txt
61
+ body:
62
+ encoding: US-ASCII
63
+ string: ''
64
+ headers:
65
+ User-Agent:
66
+ - Faraday v0.9.1
67
+ Authorization:
68
+ - Bearer _frank_access_token_
69
+ Accept-Encoding:
70
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
71
+ Accept:
72
+ - "*/*"
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ Cache-Control:
79
+ - private, max-age=31557600
80
+ Content-Disposition:
81
+ - attachment; filename="Security Report <script>alert('filename').txt"
82
+ Content-Transfer-Encoding:
83
+ - binary
84
+ Content-Type:
85
+ - text/plain
86
+ X-Ua-Compatible:
87
+ - IE=Edge,chrome=1
88
+ X-Request-Id:
89
+ - cd130f8e7b0b9e1e2cde9936b0fcaeb6
90
+ X-Runtime:
91
+ - '0.227045'
92
+ Connection:
93
+ - close
94
+ Server:
95
+ - thin 1.6.1 codename Death Proof
96
+ body:
97
+ encoding: ASCII-8BIT
98
+ string: !binary |-
99
+ UEsDBBQACAgIAHA8u0QAAAAAAAAAAAAAAAAYAAAAeGwvZHJhd2luZ3MvZHJh
100
+ d2luZzEueG1sndBBTsMwEAXQE3CHaPatAwuEoqbdRJwADjDYk9jCY1szLm1v
101
+ j0XJvsry62uevuZwunLsfkg05DTC876HjpLNLqRlhM+P990bdFoxOYw50Qg3
102
+ Ujgdnw5XJ8NFJ+nafdKhxRF8rWUwRq0nRt3nQqm1cxbG2qIsxglemszRvPT9
103
+ q9EihE49UZ3uDfx7uEFjDGm9f2hNnudgacr2zJTqHRGKWNsv1Ieiq2Y3rLEe
104
+ pa4APyQwyve57Gzm0jZ8hRjq7Q9bGbfwhiUu4CLIYI6/UEsHCB+aYCjMAAAA
105
+ 7gEAAFBLAwQUAAgICABwPLtEAAAAAAAAAAAAAAAAGAAAAHhsL3dvcmtzaGVl
106
+ dHMvc2hlZXQxLnhtbI2SzXLCIBCAn6DvwHA3xFbbmknioY5Tb51Of84IG8PI
107
+ TwaIiW9fEjVTJ5fclmX5+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AAB4
173
+ bC9fcmVscy93b3JrYm9vay54bWwucmVsc1BLAQIUABQACAgIAHA8u0Rpz+ua
174
+ sgAAACgBAAALAAAAAAAAAAAAAAAAAOUIAABfcmVscy8ucmVsc1BLAQIUABQA
175
+ CAgIAHA8u0TZpyj5KwEAAKgDAAATAAAAAAAAAAAAAAAAANAJAABbQ29udGVu
176
+ dF9UeXBlc10ueG1sUEsFBgAAAAAJAAkAWQIAADwLAAAAAA==
177
+ http_version:
178
+ recorded_at: Wed, 08 Jul 2015 13:14:30 GMT
179
+ recorded_with: VCR 2.9.3
@@ -93,4 +93,12 @@ describe RedboothRuby::File, vcr: 'files' do
93
93
  open("#{ File.dirname(__FILE__) }/../../temp/spec/files/test_download.txt", 'w') { |f| f.puts subject }
94
94
  end
95
95
  end
96
+
97
+ describe '.download_to_path' do
98
+ it 'downloads a file to a path' do
99
+ collection = client.file(:index, per_page: 1)
100
+ file = collection.all.first
101
+ file.download('original', "#{ File.dirname(__FILE__) }/../../temp/spec/files/test_download_to_path.txt")
102
+ end
103
+ end
96
104
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redbooth-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andres Bravo
8
8
  - Carlos Saura
9
+ - Bruno Pedro
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-02-25 00:00:00.000000000 Z
13
+ date: 2015-07-08 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: json
@@ -202,6 +203,7 @@ files:
202
203
  - spec/cassettes/RedboothRuby_File/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_file.yml
203
204
  - spec/cassettes/RedboothRuby_File/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_comment.yml
204
205
  - spec/cassettes/RedboothRuby_File/_download/downloads_a_file.yml
206
+ - spec/cassettes/RedboothRuby_File/_download_to_path/downloads_a_file_to_a_path.yml
205
207
  - spec/cassettes/RedboothRuby_File/_index/.yml
206
208
  - spec/cassettes/RedboothRuby_File/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_comments_collection.yml
207
209
  - spec/cassettes/RedboothRuby_File/_initialize/.yml
@@ -391,7 +393,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
393
  version: '0'
392
394
  requirements: []
393
395
  rubyforge_project:
394
- rubygems_version: 2.4.1
396
+ rubygems_version: 2.4.3
395
397
  signing_key:
396
398
  specification_version: 4
397
399
  summary: API wrapper for Redbooth.
@@ -424,6 +426,7 @@ test_files:
424
426
  - spec/cassettes/RedboothRuby_File/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_file.yml
425
427
  - spec/cassettes/RedboothRuby_File/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_comment.yml
426
428
  - spec/cassettes/RedboothRuby_File/_download/downloads_a_file.yml
429
+ - spec/cassettes/RedboothRuby_File/_download_to_path/downloads_a_file_to_a_path.yml
427
430
  - spec/cassettes/RedboothRuby_File/_index/.yml
428
431
  - spec/cassettes/RedboothRuby_File/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_comments_collection.yml
429
432
  - spec/cassettes/RedboothRuby_File/_initialize/.yml