fog-google 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edc956d3013b64f9bb12fbfa42a54b90c8887a31
4
- data.tar.gz: 032f27be0769facdb9e12681225e980c9a40e180
3
+ metadata.gz: 28b820a5dc7b807feb4752b1fbb3f6e90f05c612
4
+ data.tar.gz: 96049683a48c63bdcd071a63bf93ceb0638374b0
5
5
  SHA512:
6
- metadata.gz: fc35669ae2d7eae55a81a119ad69194e9d22893fd73df394ef94443c72c5185b1065046ddbbc6097abe563b727cc63bfa65c80510d4eccf53c0af2a6e528e566
7
- data.tar.gz: 2fab2b57c38cf4eebfedf33f01ddd29a98c0978c01c0bb48d8951d7290cfaf36423bc757eae75bc43d81803eaf8928609de7ceca0920636f8243cfaca19fe203
6
+ metadata.gz: 108ae3707ddb9ba0c96eba2ed16246911b7ccea06a8801a6f87ae59e53361d03baed08f64e1649c7787d74560a910820a8e978e00d9610b5f38e943d2531e13c
7
+ data.tar.gz: 0c9e5ef0a46e80d978c81f4ebf80f26ae6166b5ba43a902b087dc97c788153380cfff19f17970d89238254e6dd714b3a322501a991a8d7c8699d3afc9709e68e
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "1.0.1".freeze
3
+ VERSION = "1.1.0".freeze
4
4
  end
5
5
  end
@@ -9,10 +9,11 @@ module Fog
9
9
  load(data)
10
10
  end
11
11
 
12
- def get(bucket_name,
13
- if_metageneration_match: nil,
14
- if_metageneration_not_match: nil,
15
- projection: nil)
12
+ def get(bucket_name, options = {})
13
+ if_metageneration_match = options[:if_metageneration_match]
14
+ if_metageneration_not_match = options[:if_metageneration_not_match]
15
+ projection = options[:projection]
16
+
16
17
  data = service.get_bucket(
17
18
  bucket_name,
18
19
  :if_metageneration_match => if_metageneration_match,
@@ -52,6 +52,7 @@ module Fog
52
52
  rescue ::Google::Apis::ClientError
53
53
  nil
54
54
  end
55
+ alias_method :head, :metadata
55
56
 
56
57
  def new(opts = {})
57
58
  requires :directory
@@ -23,6 +23,9 @@ module Fog
23
23
  # Set of properties to return
24
24
  # @param options [Hash]
25
25
  # Request-specific options
26
+ # @param &block [Proc]
27
+ # Block to pass a streamed object response to. Expected format is
28
+ # same as Excon :response_block ({ |chunk, remaining_bytes, total_bytes| ... })
26
29
  # @return [Hash] Object metadata with :body attribute set to contents of object
27
30
  def get_object(bucket_name, object_name,
28
31
  generation: nil,
@@ -31,12 +34,10 @@ module Fog
31
34
  if_metageneration_match: nil,
32
35
  if_metageneration_not_match: nil,
33
36
  projection: nil,
34
- **options)
37
+ **options, &_block)
35
38
  raise ArgumentError.new("bucket_name is required") unless bucket_name
36
39
  raise ArgumentError.new("object_name is required") unless object_name
37
40
 
38
- # The previous semantics require returning the content of the request
39
- # rather than taking a filename to populate. Hence, tempfile.
40
41
  buf = Tempfile.new("fog-google-storage-temp")
41
42
 
42
43
  # Two requests are necessary, first for metadata, then for content.
@@ -59,8 +60,12 @@ module Fog
59
60
  all_opts.merge(:download_dest => buf.path)
60
61
  )
61
62
 
62
- object[:body] = buf.read
63
- buf.unlink
63
+ if block_given?
64
+ yield buf.read, nil, nil
65
+ else
66
+ object[:body] = buf.read
67
+ buf.unlink
68
+ end
64
69
 
65
70
  object
66
71
  end
@@ -17,7 +17,7 @@ module Fog
17
17
  data = service.get_bucket(key, options).body
18
18
  directory = new(:key => data["Name"])
19
19
  options = {}
20
- for k, v in data
20
+ data.each_pair do |k, v|
21
21
  if %w(CommonPrefixes Delimiter IsTruncated Marker MaxKeys Prefix).include?(k)
22
22
  options[k] = v
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Welch
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-12 00:00:00.000000000 Z
12
+ date: 2018-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog-core