google-cloud-storage 1.7.1 → 1.8.0
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.
- checksums.yaml +5 -5
- data/README.md +2 -2
- data/lib/google-cloud-storage.rb +14 -11
- data/lib/google/cloud/storage.rb +24 -21
- data/lib/google/cloud/storage/credentials.rb +31 -5
- data/lib/google/cloud/storage/project.rb +6 -5
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2561a9dd9f138630b772a0f6ba3dcbe292892761a3dad92f5b5cab785625b11c
|
4
|
+
data.tar.gz: 5c6ff780bf83212017dd7b82d655925af91fff9653ebb8c8585222790f5501d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d2d95049bf9257957b7c2f5406015caa9e3411af768d79004c133ca25d2907a0e6cb008eb0d935b088818789ec77d91739aac89037e93dfec3de164764700a3
|
7
|
+
data.tar.gz: f3b3c0bc9422b651d378f361f274d1a4a5354dbe4dc862fb02199c5de40071079f2920a984d9bccd5081abfd2836aed5652aa86af97dd58329b724a6b1e54aee
|
data/README.md
CHANGED
@@ -24,8 +24,8 @@ Instructions and configuration options are covered in the [Authentication Guide]
|
|
24
24
|
require "google/cloud/storage"
|
25
25
|
|
26
26
|
storage = Google::Cloud::Storage.new(
|
27
|
-
|
28
|
-
|
27
|
+
project_id: "my-project",
|
28
|
+
credentials: "/path/to/keyfile.json"
|
29
29
|
)
|
30
30
|
|
31
31
|
bucket = storage.bucket "task-attachments"
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
##
|
16
|
-
# This file is here to be autorequired by bundler, so that the
|
17
|
-
# #
|
18
|
-
# be loaded until required and used.
|
16
|
+
# This file is here to be autorequired by bundler, so that the
|
17
|
+
# Google::Cloud.storage and Google::Cloud#storage methods can be available, but
|
18
|
+
# the library and all dependencies won't be loaded until required and used.
|
19
19
|
|
20
20
|
|
21
21
|
gem "google-cloud-core"
|
@@ -75,10 +75,12 @@ module Google
|
|
75
75
|
# For more information on connecting to Google Cloud see the [Authentication
|
76
76
|
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
77
77
|
#
|
78
|
-
# @param [String]
|
79
|
-
# connecting to.
|
80
|
-
#
|
81
|
-
#
|
78
|
+
# @param [String] project_id Project identifier for the Storage service
|
79
|
+
# you are connecting to. If not present, the default project for the
|
80
|
+
# credentials is used.
|
81
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
82
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
83
|
+
# Google::Auth::Credentials object. (See {Storage::Credentials})
|
82
84
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
83
85
|
# set of resources and operations that the connection can access. See
|
84
86
|
# [Using OAuth 2.0 to Access Google
|
@@ -96,16 +98,17 @@ module Google
|
|
96
98
|
# @example
|
97
99
|
# require "google/cloud/storage"
|
98
100
|
#
|
99
|
-
# storage = Google::Cloud.storage "my-
|
101
|
+
# storage = Google::Cloud.storage "my-project",
|
100
102
|
# "/path/to/keyfile.json"
|
101
103
|
#
|
102
104
|
# bucket = storage.bucket "my-bucket"
|
103
105
|
# file = bucket.file "path/to/my-file.ext"
|
104
106
|
#
|
105
|
-
def self.storage
|
106
|
-
timeout: nil
|
107
|
+
def self.storage project_id = nil, credentials = nil, scope: nil,
|
108
|
+
retries: nil, timeout: nil
|
107
109
|
require "google/cloud/storage"
|
108
|
-
Google::Cloud::Storage.new
|
110
|
+
Google::Cloud::Storage.new project_id: project_id,
|
111
|
+
credentials: credentials,
|
109
112
|
scope: scope, retries: retries,
|
110
113
|
timeout: timeout
|
111
114
|
end
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -37,8 +37,8 @@ module Google
|
|
37
37
|
# require "google/cloud/storage"
|
38
38
|
#
|
39
39
|
# storage = Google::Cloud::Storage.new(
|
40
|
-
#
|
41
|
-
#
|
40
|
+
# project_id: "my-project",
|
41
|
+
# credentials: "/path/to/keyfile.json"
|
42
42
|
# )
|
43
43
|
#
|
44
44
|
# bucket = storage.bucket "my-bucket"
|
@@ -551,10 +551,12 @@ module Google
|
|
551
551
|
# [Authentication
|
552
552
|
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
553
553
|
#
|
554
|
-
# @param [String]
|
555
|
-
# are connecting to.
|
556
|
-
#
|
557
|
-
#
|
554
|
+
# @param [String] project_id Project identifier for the Storage service
|
555
|
+
# you are connecting to. If not present, the default project for the
|
556
|
+
# credentials is used.
|
557
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
558
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
559
|
+
# Google::Auth::Credentials object. (See {Storage::Credentials})
|
558
560
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
559
561
|
# the set of resources and operations that the connection can access.
|
560
562
|
# See [Using OAuth 2.0 to Access Google
|
@@ -566,6 +568,9 @@ module Google
|
|
566
568
|
# @param [Integer] retries Number of times to retry requests on server
|
567
569
|
# error. The default value is `3`. Optional.
|
568
570
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
571
|
+
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
572
|
+
# @param [String] keyfile Alias for the `credentials` argument.
|
573
|
+
# Deprecated.
|
569
574
|
#
|
570
575
|
# @return [Google::Cloud::Storage::Project]
|
571
576
|
#
|
@@ -573,29 +578,27 @@ module Google
|
|
573
578
|
# require "google/cloud/storage"
|
574
579
|
#
|
575
580
|
# storage = Google::Cloud::Storage.new(
|
576
|
-
#
|
577
|
-
#
|
581
|
+
# project_id: "my-project",
|
582
|
+
# credentials: "/path/to/keyfile.json"
|
578
583
|
# )
|
579
584
|
#
|
580
585
|
# bucket = storage.bucket "my-bucket"
|
581
586
|
# file = bucket.file "path/to/my-file.ext"
|
582
587
|
#
|
583
|
-
def self.new
|
584
|
-
timeout: nil
|
585
|
-
|
586
|
-
|
587
|
-
fail ArgumentError, "
|
588
|
+
def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
|
589
|
+
timeout: nil, project: nil, keyfile: nil
|
590
|
+
project_id ||= (project || Storage::Project.default_project_id)
|
591
|
+
project_id = project_id.to_s # Always cast to a string
|
592
|
+
fail ArgumentError, "project_id is missing" if project_id.empty?
|
588
593
|
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
credentials = Google::Cloud::Storage::Credentials.new(
|
593
|
-
keyfile, scope: scope)
|
594
|
+
credentials ||= (keyfile || Storage::Credentials.default(scope: scope))
|
595
|
+
unless credentials.is_a? Google::Auth::Credentials
|
596
|
+
credentials = Storage::Credentials.new credentials, scope: scope
|
594
597
|
end
|
595
598
|
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
+
Storage::Project.new(
|
600
|
+
Storage::Service.new(
|
601
|
+
project_id, credentials, retries: retries, timeout: timeout))
|
599
602
|
end
|
600
603
|
end
|
601
604
|
end
|
@@ -13,18 +13,44 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "
|
16
|
+
require "googleauth"
|
17
17
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
20
20
|
module Storage
|
21
21
|
##
|
22
|
-
#
|
23
|
-
|
22
|
+
# # Credentials
|
23
|
+
#
|
24
|
+
# Represents the authentication and authorization used to connect to the
|
25
|
+
# Storage API.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# require "google/cloud/storage"
|
29
|
+
#
|
30
|
+
# keyfile = "/path/to/keyfile.json"
|
31
|
+
# creds = Google::Cloud::Storage::Credentials.new keyfile
|
32
|
+
#
|
33
|
+
# storage = Google::Cloud::Storage.new(
|
34
|
+
# project_id: "my-project",
|
35
|
+
# credentials: creds
|
36
|
+
# )
|
37
|
+
#
|
38
|
+
# storage.project_id #=> "my-project"
|
39
|
+
#
|
40
|
+
class Credentials < Google::Auth::Credentials
|
24
41
|
SCOPE = ["https://www.googleapis.com/auth/devstorage.full_control"]
|
25
|
-
PATH_ENV_VARS = %w(
|
26
|
-
|
42
|
+
PATH_ENV_VARS = %w(STORAGE_CREDENTIALS
|
43
|
+
STORAGE_KEYFILE
|
44
|
+
GOOGLE_CLOUD_CREDENTIALS
|
45
|
+
GOOGLE_CLOUD_KEYFILE
|
46
|
+
GCLOUD_KEYFILE)
|
47
|
+
JSON_ENV_VARS = %w(STORAGE_CREDENTIALS_JSON
|
48
|
+
STORAGE_KEYFILE_JSON
|
49
|
+
GOOGLE_CLOUD_CREDENTIALS_JSON
|
50
|
+
GOOGLE_CLOUD_KEYFILE_JSON
|
27
51
|
GCLOUD_KEYFILE_JSON)
|
52
|
+
DEFAULT_PATHS = \
|
53
|
+
["~/.config/gcloud/application_default_credentials.json"]
|
28
54
|
end
|
29
55
|
end
|
30
56
|
end
|
@@ -66,19 +66,20 @@ module Google
|
|
66
66
|
# require "google/cloud/storage"
|
67
67
|
#
|
68
68
|
# storage = Google::Cloud::Storage.new(
|
69
|
-
#
|
70
|
-
#
|
69
|
+
# project_id: "my-project",
|
70
|
+
# credentials: "/path/to/keyfile.json"
|
71
71
|
# )
|
72
72
|
#
|
73
|
-
# storage.
|
73
|
+
# storage.project_id #=> "my-project"
|
74
74
|
#
|
75
|
-
def
|
75
|
+
def project_id
|
76
76
|
service.project
|
77
77
|
end
|
78
|
+
alias_method :project, :project_id
|
78
79
|
|
79
80
|
##
|
80
81
|
# @private Default project.
|
81
|
-
def self.
|
82
|
+
def self.default_project_id
|
82
83
|
ENV["STORAGE_PROJECT"] ||
|
83
84
|
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
84
85
|
ENV["GCLOUD_PROJECT"] ||
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -17,28 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1.
|
27
|
+
version: '1.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: google-api-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: 0.17.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.17.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: googleauth
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.6.2
|
35
49
|
type: :runtime
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
53
|
- - "~>"
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.
|
55
|
+
version: 0.6.2
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: digest-crc
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
243
|
version: '0'
|
230
244
|
requirements: []
|
231
245
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
246
|
+
rubygems_version: 2.7.2
|
233
247
|
signing_key:
|
234
248
|
specification_version: 4
|
235
249
|
summary: API Client library for Google Cloud Storage
|