jaxx 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/lib/jaxx/download.rb +3 -12
- data/lib/jaxx/upload.rb +1 -1
- data/lib/jaxx/version.rb +1 -1
- data/spec/lib/jaxx/download_spec.rb +1 -18
- data/spec/lib/jaxx/upload_spec.rb +1 -1
- metadata +4 -4
data/.gitignore
CHANGED
data/lib/jaxx/download.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
require 'jaxx/process'
|
2
|
-
require 'fileutils'
|
3
2
|
|
4
3
|
module Jaxx
|
5
4
|
class Download
|
6
5
|
|
7
6
|
attr_reader :process, :filename
|
8
7
|
|
9
|
-
def initialize
|
8
|
+
def initialize args = {}
|
10
9
|
@process = Process.new(args)
|
11
10
|
end
|
12
11
|
|
13
|
-
def files
|
12
|
+
def files directory
|
14
13
|
if process.file.match(%r{/$})
|
15
14
|
directory.files.inject({}) do |hsh, f|
|
16
|
-
|
17
|
-
hsh[key] = f.key if !key.empty? and f.key.match(process.file)
|
15
|
+
hsh[f.key.gsub(process.file, '')] = f.key if f.key.match(process.file)
|
18
16
|
hsh
|
19
17
|
end
|
20
18
|
else
|
@@ -27,16 +25,9 @@ module Jaxx
|
|
27
25
|
directory = storage.directories.get(process.bucket)
|
28
26
|
|
29
27
|
files(directory).each do |target, source|
|
30
|
-
|
31
|
-
# Ensure directory exists
|
32
|
-
dir = File.dirname(target)
|
33
|
-
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
34
|
-
|
35
|
-
# Create file
|
36
28
|
File.open(target, 'wb') do |file|
|
37
29
|
directory.files.get(source) {|chunk, byt_remain, byt_total| file.write(chunk) }
|
38
30
|
end
|
39
|
-
|
40
31
|
end
|
41
32
|
end
|
42
33
|
end
|
data/lib/jaxx/upload.rb
CHANGED
data/lib/jaxx/version.rb
CHANGED
@@ -5,12 +5,7 @@ module Jaxx
|
|
5
5
|
describe Download do
|
6
6
|
|
7
7
|
describe "#process" do
|
8
|
-
let(:args) { ({
|
9
|
-
'access_key' => 'foo',
|
10
|
-
'access_secret' => 'bar',
|
11
|
-
'file' => File.expand_path('bar.txt', __FILE__),
|
12
|
-
'bucket' => 'temp'
|
13
|
-
}) }
|
8
|
+
let(:args) { ({ 'access_key' => 'foo', 'access_secret' => 'bar', 'file' => File.expand_path('bar.txt', __FILE__), 'bucket' => 'temp' }) }
|
14
9
|
|
15
10
|
subject { described_class.new(args) }
|
16
11
|
|
@@ -25,17 +20,5 @@ module Jaxx
|
|
25
20
|
end
|
26
21
|
end
|
27
22
|
|
28
|
-
describe "#files" do
|
29
|
-
|
30
|
-
it "does not process empty filenames" do
|
31
|
-
args['file'] = "foo/"
|
32
|
-
|
33
|
-
file = mock('file', key: "foo/")
|
34
|
-
directory = double('directory', :files => [file])
|
35
|
-
|
36
|
-
subject.files(directory).should eq({})
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
23
|
end
|
41
24
|
end
|
@@ -32,7 +32,7 @@ module Jaxx
|
|
32
32
|
File.stub(:exist?).with(args['file']).and_return(true)
|
33
33
|
File.stub(:basename).with(args['file']).and_return('bar.txt')
|
34
34
|
Fog::Storage::AWS::Directory.any_instance.stub(:files).and_return(files)
|
35
|
-
File.stub(:
|
35
|
+
File.stub(:open).with(args['file']).any_number_of_times.and_return("")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "to storage" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jaxx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -261,7 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
261
261
|
version: '0'
|
262
262
|
segments:
|
263
263
|
- 0
|
264
|
-
hash:
|
264
|
+
hash: 2671804250398414592
|
265
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
266
|
none: false
|
267
267
|
requirements:
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
version: '0'
|
271
271
|
segments:
|
272
272
|
- 0
|
273
|
-
hash:
|
273
|
+
hash: 2671804250398414592
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
276
|
rubygems_version: 1.8.25
|