fluxapi 0.5.4 → 0.5.5
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/Rakefile +1 -1
- data/fluxapi.gemspec +1 -1
- data/lib/fluxapi/asset.rb +4 -2
- data/test/fluxapi/asset_test.rb +2 -1
- data/test/test_helper.rb +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
data/fluxapi.gemspec
CHANGED
data/lib/fluxapi/asset.rb
CHANGED
@@ -6,9 +6,11 @@ class Fluxiom::Asset < Fluxiom
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
def download(path_to_file)
|
9
|
-
Net::HTTP.
|
9
|
+
session = Net::HTTP.new(self.class.base_uri.gsub('https://', ''), 443)
|
10
|
+
session.use_ssl = true
|
11
|
+
session.start {|http|
|
10
12
|
req = Net::HTTP::Get.new("/api/assets/download/#{self.id}")
|
11
|
-
req.basic_auth
|
13
|
+
req.basic_auth self.class.default_options[:basic_auth][:username], self.class.default_options[:basic_auth][:password]
|
12
14
|
resp = http.request(req)
|
13
15
|
open(File.join(path_to_file, self.filename), 'wb') do |file|
|
14
16
|
file.write(resp.body)
|
data/test/fluxapi/asset_test.rb
CHANGED
@@ -5,12 +5,13 @@ class Fluxiom::AssetTest < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
set_account
|
7
7
|
@asset = @fluxiom.assets.first
|
8
|
-
@tmp_dir = File.join(File.dirname(__FILE__), '..', 'tmp')
|
8
|
+
@tmp_dir = File.join(File.dirname(__FILE__), '..', '..', 'tmp')
|
9
9
|
FileUtils.mkdir_p @tmp_dir
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_download
|
13
13
|
assert @asset.download(@tmp_dir).size > 0
|
14
|
+
assert File.exists?(File.join(@tmp_dir, @asset.filename))
|
14
15
|
end
|
15
16
|
|
16
17
|
def teardown
|
data/test/test_helper.rb
CHANGED
@@ -25,7 +25,7 @@ def register_requests
|
|
25
25
|
next if file == '.' || file == '..' || !file.include?('.xml')
|
26
26
|
stub_get('/api/' + file, file)
|
27
27
|
end
|
28
|
-
FakeWeb.register_uri(:get, "
|
28
|
+
FakeWeb.register_uri(:get, "https://user:password@account.fluxiom.com:443/api/assets/download/182535", :response => File.expand_path(File.dirname(__FILE__) + '/fixtures/download_response'))
|
29
29
|
end
|
30
30
|
|
31
31
|
def set_account
|