fastlane-plugin-google_cloud_storage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49bb8085f44725213a52d0a854813ab71ea0956a
4
+ data.tar.gz: 3c161dadbc3ff826d1cd073200162a03dd7ea7b7
5
+ SHA512:
6
+ metadata.gz: 346c739d59ef4090388e0d573933a40c03abbd842b002ba94c20d80d4c272f7bf829482f8fe78188a71c4d7995468987d284a92736ba126d4c850079578c4c12
7
+ data.tar.gz: 7743d5a72f0ed7483cc56cffca23a624e8dd55ecd4062b8a607d11b5befef361c206f2578bc30f3447f4085cd1585aa91488733d85eeefd9cab947c5c0411d44
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Fernando Saragoca <fsaragoca@me.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # google_cloud_storage plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-google_cloud_storage)
4
+ [![Twitter: @fsaragoca](https://img.shields.io/badge/contact-@fsaragoca-blue.svg?style=flat)](https://twitter.com/fsaragoca)
5
+
6
+ [![CircleCI](https://circleci.com/gh/fsaragoca/fastlane-plugin-google_cloud_storage.svg?style=svg)](https://circleci.com/gh/fsaragoca/fastlane-plugin-google_cloud_storage)
7
+
8
+ ## Getting Started
9
+
10
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-google_cloud_storage`, add it to your project by running:
11
+
12
+ ```bash
13
+ fastlane add_plugin google_cloud_storage
14
+ ```
15
+
16
+ ## About google_cloud_storage
17
+
18
+ Download and upload files from Google Cloud Storage.
19
+
20
+ ## Example
21
+
22
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
23
+
24
+ ## Run tests for this plugin
25
+
26
+ To run both the tests, and code style validation, run
27
+
28
+ ```
29
+ rake
30
+ ```
31
+
32
+ To automatically fix many of the styling issues, use
33
+ ```
34
+ rubocop -a
35
+ ```
36
+
37
+ ## Issues and Feedback
38
+
39
+ For any other issues and feedback about this plugin, please submit it to this repository.
40
+
41
+ ## Troubleshooting
42
+
43
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
44
+
45
+ ## Using `fastlane` Plugins
46
+
47
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
48
+
49
+ ## About `fastlane`
50
+
51
+ `fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/google_cloud_storage/version'
2
+
3
+ module Fastlane
4
+ module GoogleCloudStorage
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::GoogleCloudStorage.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,79 @@
1
+ require 'google/cloud/storage'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class GoogleCloudStorageCheckFileAction < Action
6
+ def self.run(params)
7
+ Actions.verify_gem!('google-cloud-storage')
8
+
9
+ storage = Helper::GoogleCloudStorageHelper.setup_storage(
10
+ project: params[:project],
11
+ keyfile: params[:keyfile]
12
+ )
13
+
14
+ bucket = Helper::GoogleCloudStorageHelper.find_bucket(
15
+ storage: storage,
16
+ bucket_name: params[:bucket]
17
+ )
18
+
19
+ begin
20
+ Helper::GoogleCloudStorageHelper.find_file(
21
+ bucket: bucket,
22
+ file_name: params[:file_name]
23
+ )
24
+ true
25
+ rescue
26
+ false
27
+ end
28
+ end
29
+
30
+ def self.description
31
+ "Check if file exists in Google Cloud Storage"
32
+ end
33
+
34
+ def self.authors
35
+ ["Fernando Saragoca"]
36
+ end
37
+
38
+ def self.return_value
39
+ "Returns 'true' if object exists, 'false' if not"
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ FastlaneCore::ConfigItem.new(key: :project,
45
+ env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
46
+ description: "Google Cloud Storage project identifier",
47
+ optional: false,
48
+ type: String),
49
+ FastlaneCore::ConfigItem.new(key: :keyfile,
50
+ env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
51
+ description: "Google Cloud Storage keyfile",
52
+ optional: false,
53
+ type: String,
54
+ verify_block: proc do |value|
55
+ if value.nil? || value.empty?
56
+ UI.user_error!("No keyfile for Google Cloud Storage action given, pass using `keyfile_path: 'path/to/file.txt'`")
57
+ elsif File.file?(value) == false
58
+ UI.user_error!("Keyfile '#{value}' not found")
59
+ end
60
+ end),
61
+ FastlaneCore::ConfigItem.new(key: :bucket,
62
+ env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
63
+ description: "Google Cloud Storage bucket",
64
+ optional: false,
65
+ type: String),
66
+ FastlaneCore::ConfigItem.new(key: :file_name,
67
+ env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_FILE_NAME",
68
+ description: "File name",
69
+ optional: false,
70
+ type: String)
71
+ ]
72
+ end
73
+
74
+ def self.is_supported?(platform)
75
+ true
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,83 @@
1
+ require 'google/cloud/storage'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class GoogleCloudStorageDownloadAction < Action
6
+ def self.run(params)
7
+ Actions.verify_gem!('google-cloud-storage')
8
+
9
+ output_path = params[:output_path]
10
+ output_directory = File.dirname(output_path)
11
+ unless File.exist?(output_directory)
12
+ Actions.sh("mkdir #{output_directory}", log: $verbose)
13
+ end
14
+
15
+ storage = Helper::GoogleCloudStorageHelper.setup_storage(
16
+ project: params[:project],
17
+ keyfile: params[:keyfile]
18
+ )
19
+
20
+ bucket = Helper::GoogleCloudStorageHelper.find_bucket(
21
+ storage: storage,
22
+ bucket_name: params[:bucket]
23
+ )
24
+
25
+ file = Helper::GoogleCloudStorageHelper.find_file(
26
+ bucket: bucket,
27
+ file_name: params[:file_name]
28
+ )
29
+
30
+ file.download(output_path)
31
+ end
32
+
33
+ def self.description
34
+ "Download a file from Google Cloud Storage"
35
+ end
36
+
37
+ def self.authors
38
+ ["Fernando Saragoca"]
39
+ end
40
+
41
+ def self.available_options
42
+ [
43
+ FastlaneCore::ConfigItem.new(key: :project,
44
+ env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
45
+ description: "Google Cloud Storage project identifier",
46
+ optional: false,
47
+ type: String),
48
+ FastlaneCore::ConfigItem.new(key: :keyfile,
49
+ env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
50
+ description: "Google Cloud Storage keyfile",
51
+ optional: false,
52
+ type: String,
53
+ verify_block: proc do |value|
54
+ if value.nil? || value.empty?
55
+ UI.user_error!("No keyfile for Google Cloud Storage action given, pass using `keyfile_path: 'path/to/file.txt'`")
56
+ elsif File.file?(value) == false
57
+ UI.user_error!("Keyfile '#{value}' not found")
58
+ end
59
+ end),
60
+ FastlaneCore::ConfigItem.new(key: :bucket,
61
+ env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
62
+ description: "Google Cloud Storage bucket",
63
+ optional: false,
64
+ type: String),
65
+ FastlaneCore::ConfigItem.new(key: :output_path,
66
+ env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_OUTPUT_PATH",
67
+ description: "Path to save downloaded file",
68
+ optional: false,
69
+ type: String),
70
+ FastlaneCore::ConfigItem.new(key: :file_name,
71
+ env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_FILE_NAME",
72
+ description: "File name",
73
+ optional: false,
74
+ type: String)
75
+ ]
76
+ end
77
+
78
+ def self.is_supported?(platform)
79
+ true
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,80 @@
1
+ require 'google/cloud/storage'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class GoogleCloudStorageUploadAction < Action
6
+ def self.run(params)
7
+ Actions.verify_gem!('google-cloud-storage')
8
+
9
+ storage = Helper::GoogleCloudStorageHelper.setup_storage(
10
+ project: params[:project],
11
+ keyfile: params[:keyfile]
12
+ )
13
+
14
+ bucket = Helper::GoogleCloudStorageHelper.find_bucket(
15
+ storage: storage,
16
+ bucket_name: params[:bucket]
17
+ )
18
+
19
+ file_name = params[:name] || File.basename(params[:content_path])
20
+ bucket.create_file(params[:content_path], file_name)
21
+ end
22
+
23
+ def self.description
24
+ "Upload a file to Google Cloud Storage"
25
+ end
26
+
27
+ def self.authors
28
+ ["Fernando Saragoca"]
29
+ end
30
+
31
+ def self.available_options
32
+ [
33
+ FastlaneCore::ConfigItem.new(key: :project,
34
+ env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
35
+ description: "Google Cloud Storage project identifier",
36
+ optional: false,
37
+ type: String),
38
+ FastlaneCore::ConfigItem.new(key: :keyfile,
39
+ env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
40
+ description: "Google Cloud Storage keyfile",
41
+ optional: false,
42
+ type: String,
43
+ verify_block: proc do |value|
44
+ if value.nil? || value.empty?
45
+ UI.user_error!("No keyfile for Google Cloud Storage action given, pass using `keyfile_path: 'path/to/file.txt'`")
46
+ elsif File.file?(value) == false
47
+ UI.user_error!("Keyfile '#{value}' not found")
48
+ end
49
+ end),
50
+ FastlaneCore::ConfigItem.new(key: :bucket,
51
+ env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
52
+ description: "Google Cloud Storage bucket",
53
+ optional: false,
54
+ type: String),
55
+ FastlaneCore::ConfigItem.new(key: :content_path,
56
+ env_name: "GOOGLE_CLOUD_STORAGE_UPLOAD_CONTENT_PATH",
57
+ description: "Path for file to upload",
58
+ optional: false,
59
+ type: String,
60
+ verify_block: proc do |value|
61
+ if value.nil? || value.empty?
62
+ UI.user_error!("No content path for google_cloud_storage_upload action given, pass using `content_path: 'path/to/file.txt'`")
63
+ elsif File.file?(value) == false
64
+ UI.user_error!("File for path '#{value}' not found")
65
+ end
66
+ end),
67
+ FastlaneCore::ConfigItem.new(key: :name,
68
+ env_name: "GOOGLE_CLOUD_STORAGE_UPLOAD_NAME",
69
+ description: "File name",
70
+ optional: true,
71
+ type: String)
72
+ ]
73
+ end
74
+
75
+ def self.is_supported?(platform)
76
+ true
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,32 @@
1
+ require 'google/cloud/storage'
2
+
3
+ module Fastlane
4
+ module Helper
5
+ class GoogleCloudStorageHelper
6
+ def self.setup_storage(project: nil, keyfile: nil)
7
+ Google::Cloud::Storage.new(
8
+ project: project,
9
+ keyfile: keyfile
10
+ )
11
+ rescue
12
+ UI.user_error! "Invalid Google Cloud Storage credentials 🚫"
13
+ end
14
+
15
+ def self.find_bucket(storage: nil, bucket_name: nil)
16
+ bucket = storage.bucket(bucket_name)
17
+ if bucket.nil?
18
+ UI.user_error! "Bucket '#{bucket_name}' not found 🚫"
19
+ end
20
+ bucket
21
+ end
22
+
23
+ def self.find_file(bucket: nil, file_name: nil)
24
+ file = bucket.file(file_name)
25
+ if file.nil?
26
+ UI.user_error! "Object '#{file_name}' not found 🚫"
27
+ end
28
+ file
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module GoogleCloudStorage
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-google_cloud_storage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fernando Saragoca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-cloud-storage
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.23.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.23.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fastlane
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.5
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.5
111
+ description:
112
+ email: fsaragoca@me.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - LICENSE
118
+ - README.md
119
+ - lib/fastlane/plugin/google_cloud_storage.rb
120
+ - lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_check_file_action.rb
121
+ - lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_download_action.rb
122
+ - lib/fastlane/plugin/google_cloud_storage/actions/google_cloud_storage_upload_action.rb
123
+ - lib/fastlane/plugin/google_cloud_storage/helper/google_cloud_storage_helper.rb
124
+ - lib/fastlane/plugin/google_cloud_storage/version.rb
125
+ homepage: https://github.com/fsaragoca/fastlane-plugin-google_cloud_storage
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.5.1
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Google Cloud Storage
149
+ test_files: []