jaxx 0.0.20 → 0.0.21

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/.gitignore CHANGED
@@ -16,4 +16,3 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  log/
19
- .DS_Store
@@ -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(args = {})
8
+ def initialize args = {}
10
9
  @process = Process.new(args)
11
10
  end
12
11
 
13
- def files(directory)
12
+ def files directory
14
13
  if process.file.match(%r{/$})
15
14
  directory.files.inject({}) do |hsh, f|
16
- key = f.key.gsub(process.file, '')
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
@@ -63,7 +63,7 @@ module Jaxx
63
63
  def create_file dir, file, name
64
64
  dir.files.create(
65
65
  :key => name || file,
66
- :body => File.read(file),
66
+ :body => File.open(file),
67
67
  :public => process.public?,
68
68
  :content_type => MIME::Types.type_for(file).last
69
69
  )
@@ -1,3 +1,3 @@
1
1
  module Jaxx
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
3
3
  end
@@ -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(:read).with(args['file']).any_number_of_times.and_return("")
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.20
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-07-23 00:00:00.000000000 Z
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: 698514907351388838
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: 698514907351388838
273
+ hash: 2671804250398414592
274
274
  requirements: []
275
275
  rubyforge_project:
276
276
  rubygems_version: 1.8.25