jets3t-rb 1.0.3 → 1.0.4

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.
@@ -30,8 +30,12 @@ module JetS3t
30
30
  object = test_bucket.get('hello_world.file')
31
31
  p object.data
32
32
 
33
- # this should fail and return nil
34
- object = test_bucket.get('hello_world.txt.apa')
35
- p object
36
-
37
- end
33
+ # this should fail and raise error
34
+ begin
35
+ object = test_bucket.get('hello_world.txt.apa')
36
+ p object
37
+ rescue Exception => e
38
+ puts "S3 exception: #{e}"
39
+ end
40
+
41
+ end
@@ -7,7 +7,7 @@ Dir['ext/*.jar'].each { |jar| require jar }
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = 'jets3t-rb'
10
- s.version = '1.0.3'
10
+ s.version = '1.0.4'
11
11
  s.platform = Gem::Platform::RUBY
12
12
  s.authors = ['Daniel Gaiottino', 'David Tollmyr']
13
13
  s.email = ['daniel@burtcorp.com', 'david@burtcorp.com']
@@ -1,6 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'java'
4
+
5
+ java.lang.System.set_property('org.apache.commons.logging.Log', 'org.apache.commons.logging.impl.NoOpLog')
6
+
4
7
  require 'ext/commons-httpclient-3.1'
5
8
  require 'ext/commons-logging-1.1.1'
6
9
  require 'ext/commons-codec-1.3'
@@ -13,6 +13,9 @@ module JetS3t
13
13
  end
14
14
 
15
15
  class S3Bucket
16
+ include_class org.jets3t.service.S3ServiceException
17
+ NO_SUCH_KEY = 'NoSuchKey'.freeze
18
+
16
19
  def initialize(s3_service, name)
17
20
  @s3_service = s3_service
18
21
  @bucket_name = name
@@ -41,15 +44,12 @@ module JetS3t
41
44
 
42
45
  def get(filename)
43
46
  clean_path(filename)
44
- begin
45
- d = @s3_service.list_objects(@bucket, filename, nil)
46
- if d && d.length > 0
47
- S3Object.new(@s3_service.get_object(@bucket, filename))
48
- end
49
- rescue Exception => e
50
- p e.message
51
- nil
47
+ S3Object.new(@s3_service.get_object(@bucket, filename))
48
+ rescue S3ServiceException => e
49
+ if e.cause.error_code != NO_SUCH_KEY
50
+ raise e
52
51
  end
52
+ nil
53
53
  end
54
54
 
55
55
  def delete(filename)
@@ -75,4 +75,4 @@ module JetS3t
75
75
  path.slice!(0) if path[0] == '/'
76
76
  end
77
77
  end
78
- end
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets3t-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-10-26 00:00:00.000000000Z
13
+ date: 2012-02-08 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: JRuby wrapper for JetS3t (http://jets3t.s3.amazonaws.com/)
16
16
  email:
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  requirements: []
57
57
  rubyforge_project: jets3t-rb
58
- rubygems_version: 1.8.6
58
+ rubygems_version: 1.8.10
59
59
  signing_key:
60
60
  specification_version: 3
61
61
  summary: JRuby wrapper for JetS3t