jaxx 0.0.9 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jaxx/cli.rb +7 -6
- data/lib/jaxx/upload.rb +6 -1
- data/lib/jaxx/version.rb +1 -1
- data/spec/lib/jaxx/upload_spec.rb +13 -2
- metadata +4 -4
data/lib/jaxx/cli.rb
CHANGED
@@ -25,12 +25,13 @@ module Jaxx
|
|
25
25
|
OptionParser.new do |o|
|
26
26
|
o.banner = "jaxx [options]"
|
27
27
|
|
28
|
-
o.on('-b',
|
29
|
-
o.on('-k',
|
30
|
-
o.on('-s',
|
31
|
-
o.on('-f',
|
32
|
-
o.on('-
|
33
|
-
o.on('-
|
28
|
+
o.on('-b', '--bucket [BUCKET]') { |b| options['bucket'] = b }
|
29
|
+
o.on('-k', '--access-key [ACCESS_KEY]') { |k| options['access_key'] = k }
|
30
|
+
o.on('-s', '--access-secret [ACCESS_SECRET]') { |s| options['access_secret'] = s }
|
31
|
+
o.on('-f', '--file [FILE]') { |f| options['file'] = f }
|
32
|
+
o.on('-n', '--name [name]') { |f| options['filename'] = f }
|
33
|
+
o.on('-p', '--privacy [privacy]') { |p| options['privacy'] = p }
|
34
|
+
o.on('-h', '--help') { o }
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
data/lib/jaxx/upload.rb
CHANGED
@@ -7,13 +7,18 @@ module Jaxx
|
|
7
7
|
|
8
8
|
def initialize args = {}
|
9
9
|
@process = Process.new(args.merge('validations' => [:privacy, :file_exists]))
|
10
|
+
@filename = args['filename']
|
11
|
+
end
|
12
|
+
|
13
|
+
def filename
|
14
|
+
@filename || File.basename(process.file)
|
10
15
|
end
|
11
16
|
|
12
17
|
def execute
|
13
18
|
process.start do |storage|
|
14
19
|
directory = storage.directories.get(process.bucket)
|
15
20
|
directory ||= storage.directories.create(:key => process.bucket, :public => process.public?)
|
16
|
-
directory.files.create(:key =>
|
21
|
+
directory.files.create(:key => filename, :body => File.read(process.file), :public => process.public?)
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
data/lib/jaxx/version.rb
CHANGED
@@ -8,15 +8,26 @@ module Jaxx
|
|
8
8
|
|
9
9
|
subject { described_class.new(args) }
|
10
10
|
|
11
|
-
|
11
|
+
before :each do
|
12
12
|
Fog.mock!
|
13
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
it "sends file to storage" do
|
14
16
|
File.stub(:exist?).with(args['file']).and_return(true)
|
15
17
|
File.should_receive(:read).with(args['file']).and_return("")
|
16
18
|
File.should_receive(:basename).with(args['file']).and_return('bar.txt')
|
17
19
|
|
18
20
|
subject.execute
|
19
21
|
end
|
22
|
+
|
23
|
+
it "defaults filename to original filename" do
|
24
|
+
subject.filename.should eq('bar.txt')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "allows assignment of filename" do
|
28
|
+
args['filename'] = 'foo.txt'
|
29
|
+
subject.filename.should eq('foo.txt')
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
33
|
end
|
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.11
|
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-02-
|
12
|
+
date: 2013-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -228,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
228
|
version: '0'
|
229
229
|
segments:
|
230
230
|
- 0
|
231
|
-
hash: -
|
231
|
+
hash: -3120191955893654967
|
232
232
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
233
|
none: false
|
234
234
|
requirements:
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
segments:
|
239
239
|
- 0
|
240
|
-
hash: -
|
240
|
+
hash: -3120191955893654967
|
241
241
|
requirements: []
|
242
242
|
rubyforge_project:
|
243
243
|
rubygems_version: 1.8.25
|