cloudfiles_cli 0.0.2 → 0.0.3

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.
@@ -11,21 +11,23 @@ module CloudfilesCli
11
11
  end
12
12
 
13
13
  def upload(container_name, localfile, remotefile)
14
- container = connection.directories.get(container_name)
15
- object = container.files.create(
14
+ container(container_name).files.create(
16
15
  :key => remotefile, :body => File.open(localfile)
17
16
  )
18
17
  end
19
18
 
20
19
  def download(container_name, remotefile, localfile)
21
- container = connection.directories.get(container_name)
22
- object = container.files.get(remotefile)
20
+ object = container(container_name).files.get(remotefile)
23
21
  if object.nil?
24
- STDERR.puts "File #{remotefile} not found on cloudfiles"
25
- exit 1
22
+ abort "File #{remotefile} not found on cloudfiles"
26
23
  else
27
24
  IO.binwrite(localfile, object.body)
28
25
  end
29
26
  end
27
+
28
+ def container(container_name)
29
+ connection.directories.get(container_name) ||
30
+ abort("Container #{container_name} not found on cloudfiles")
31
+ end
30
32
  end
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module CloudfilesCli
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudfiles_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-29 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor