fastlane-plugin-ftps 0.1.19 → 0.1.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6253efd8bec0590c0eaa8ca180bcb948c321b2d07f00f6f153e9c624bd49fe1
4
- data.tar.gz: 76244498cccbaea80fae6278694afd75135aae7c41b7f385960a57478e33735d
3
+ metadata.gz: a02ea6c22ea4bc5911b711048a7c7d8bb6ded8cf2449398d5c87f8f35a4bd98d
4
+ data.tar.gz: e6b101846d991725b14cd9202ac409348ebb7c431ccb842d68f6b0431f66ad98
5
5
  SHA512:
6
- metadata.gz: 353c993df725fcb5673f58b8bbf02b46b222634a0a924a9c782f1f139fd0a33d9b1e06a8397a150876e247eb31354ed092ad4e65905442f5a23d7fe3f34184f3
7
- data.tar.gz: 7e27a728fca7ec07f851e4f2830195e12a4a0c82de90395ebfdf9fbfb4de7c814ba0ff01132a3ab042184423d5c19c06b78a116336460d8361d38f51822d6335
6
+ metadata.gz: 35864cbb68b6c7a4f80b257f11f67e580bb3cbc46b195f44ed0c60ca00d32d227faaf116a6fae97ac3dbc4c9b8c2b0988cbba9657aaf9c047963e7ab483c3c17
7
+ data.tar.gz: 182213b47348ad2b9bc86a92a475616c3691ca38d8a7885e3399c1d2c19fc2c6024f48d10b522619903ee1a4e48a3b47a08ffd67e634f59db2d0deacb2d2679d
@@ -5,25 +5,35 @@ module Fastlane
5
5
  module Actions
6
6
  class FtpsAction < Action
7
7
  def self.run(params)
8
-
9
- if params[:upload]
10
- FtpsAction.put(params)
11
- end
8
+ FtpsAction.put(params) if params[:upload]
12
9
 
13
- if params[:upload_multiple]
14
- FtpsAction.upload_multiple(params)
15
- end
10
+ FtpsAction.upload_multiple(params) if params[:upload_multiple]
11
+
12
+ return unless params[:download]
13
+
14
+ FtpsAction.get(params)
15
+ end
16
16
 
17
- if params[:download]
18
- FtpsAction.get(params)
17
+ def ensure_remote_path(ftp, folder)
18
+ parts = folder.split('/')
19
+ current_path = ''
20
+ parts.each do |part|
21
+ # Pomijamy puste elementy (np. jeśli folder zaczyna się od '/')
22
+ next if part.empty?
23
+
24
+ current_path = "#{current_path}/#{part}"
25
+ begin
26
+ ftp.chdir(current_path)
27
+ rescue Net::FTPPermError
28
+ ftp.mkdir(part)
29
+ ftp.chdir(current_path)
30
+ end
19
31
  end
20
32
  end
21
33
 
22
34
  def self.connect_ftp(params)
23
- ftp = open(params)
24
- ftp
35
+ open(params)
25
36
  end
26
-
27
37
 
28
38
  def self.open(params)
29
39
  ftp = Net::FTP.new(params[:host], params[:options])
@@ -38,12 +48,12 @@ module Fastlane
38
48
  ftp = connect_ftp(params)
39
49
  ensure_remote_path(ftp, params[:upload][:dest])
40
50
  ftp.chdir(params[:upload][:dest])
41
- filesize = File.size(params[:upload][:src])
51
+ filesize = File.size(params[:upload][:src])
42
52
  progressbar.total = filesize
43
- ftp.putbinaryfile(params[:upload][:src], params[:upload][:src].split("/").last) do |data|
53
+ ftp.putbinaryfile(params[:upload][:src], params[:upload][:src].split('/').last) do |data|
44
54
  progressbar.progress += data.size
45
55
  end
46
- ftp.close()
56
+ ftp.close
47
57
  UI.success("Successfully uploaded #{params[:upload][:src]}")
48
58
  end
49
59
 
@@ -52,155 +62,136 @@ module Fastlane
52
62
  UI.success("Successfully Login to #{params[:host]}:#{params[:port]}")
53
63
  ftp.getbinaryfile(params[:download][:src], params[:download][:dest]) do |data|
54
64
  end
55
- ftp.close()
65
+ ftp.close
56
66
  UI.success("Successfully download #{params[:download][:dest]}")
57
- end
67
+ end
58
68
 
59
- def self.upload_multiple(params)
60
- ftp = connect_ftp(params)
61
-
62
- # Upewniamy się, że ścieżka (folder) do której wgrywamy istnieje.
63
- base_file_path = params[:upload_multiple][:base_file_path]
64
- file_paths = params[:upload_multiple][:src]
65
-
66
- ensure_remote_path(ftp, params[:upload_multiple][:dest])
67
-
68
- total_size = file_paths.reduce(0) { |sum, file_path| sum + File.size(file_path) }
69
- progressbar = ProgressBar.create(
70
- format: '%a |%b>>%i| %p%% %t',
71
- total: total_size,
72
- starting_at: 0
73
- )
74
-
75
- file_paths.each do |local_file|
76
- relative_path = local_file.sub(%r{\A#{Regexp.escape(base_file_path)}/?}, '')
77
- dir_name = File.dirname(relative_path)
78
- file_name = File.basename(relative_path)
79
-
80
- dir_name = "" if dir_name == "."
81
-
82
- remote_path = if dir_name.empty?
83
- remote_base
84
- else
85
- File.join(remote_base, dir_name)
86
- end
69
+ def self.upload_multiple(params)
70
+ ftp = connect_ftp(params)
87
71
 
88
- ensure_remote_path(ftp, remote_path)
89
- ftp.chdir(remote_path)
90
- ftp.putbinaryfile(local_file, file_name)
91
- UI.message("Uploaded #{local_file} -> #{File.join(remote_path, file_name)}")
92
- end
93
-
94
- ftp.close
95
- UI.success("Successfully uploaded all files to #{params[:upload][:dest]}")
96
- end
72
+ # Upewniamy się, że ścieżka (folder) do której wgrywamy istnieje.
73
+ base_file_path = params[:upload_multiple][:base_file_path]
74
+ file_paths = params[:upload_multiple][:src]
75
+
76
+ ensure_remote_path(ftp, params[:upload_multiple][:dest])
77
+
78
+ total_size = file_paths.reduce(0) { |sum, file_path| sum + File.size(file_path) }
79
+ progressbar = ProgressBar.create(
80
+ format: '%a |%b>>%i| %p%% %t',
81
+ total: total_size,
82
+ starting_at: 0
83
+ )
84
+
85
+ file_paths.each do |local_file|
86
+ relative_path = local_file.sub(%r{\A#{Regexp.escape(base_file_path)}/?}, '')
87
+ dir_name = File.dirname(relative_path)
88
+ file_name = File.basename(relative_path)
97
89
 
98
- def ensure_remote_path(ftp, folder)
99
- parts = folder.split('/')
100
- current_path = ''
101
- parts.each do |part|
102
- # Pomijamy puste elementy (np. jeśli folder zaczyna się od '/')
103
- next if part.empty?
104
-
105
- current_path = "#{current_path}/#{part}"
106
- begin
107
- ftp.chdir(current_path)
108
- rescue Net::FTPPermError
109
- ftp.mkdir(part)
110
- ftp.chdir(current_path)
90
+ dir_name = '' if dir_name == '.'
91
+
92
+ remote_path = if dir_name.empty?
93
+ remote_base
94
+ else
95
+ File.join(remote_base, dir_name)
96
+ end
97
+
98
+ ensure_remote_path(ftp, remote_path)
99
+ ftp.chdir(remote_path)
100
+ ftp.putbinaryfile(local_file, file_name)
101
+ UI.message("Uploaded #{local_file} -> #{File.join(remote_path, file_name)}")
111
102
  end
103
+
104
+ ftp.close
105
+ UI.success("Successfully uploaded all files to #{params[:upload][:dest]}")
112
106
  end
113
- end
114
107
 
115
- #####################################################
116
- # @!group Documentation
117
- #####################################################
108
+ #####################################################
109
+ # @!group Documentation
110
+ #####################################################
118
111
 
119
- def self.description
120
- "Upload and Download files via FTP"
121
- end
112
+ def self.description
113
+ 'Upload and Download files via FTP'
114
+ end
122
115
 
123
- def self.details
124
- # Optional:
125
- # this is your chance to provide a more detailed description of this action
126
- "Transfer files via FTP, and create recursively folder for upload action"
127
- end
116
+ def self.details
117
+ # Optional:
118
+ # this is your chance to provide a more detailed description of this action
119
+ 'Transfer files via FTP, and create recursively folder for upload action'
120
+ end
128
121
 
129
- def self.available_options
130
- [
131
- FastlaneCore::ConfigItem.new(key: :username,
132
- short_option: "-u",
133
- env_name: "FL_FTP_USERNAME",
134
- description: "Username",
135
- is_string: true),
136
- FastlaneCore::ConfigItem.new(key: :password,
137
- short_option: "-p",
138
- env_name: "FL_FTP_PASSWORD",
139
- description: "Password",
140
- optional: false,
141
- is_string: true),
142
- FastlaneCore::ConfigItem.new(key: :host,
143
- short_option: "-H",
144
- env_name: "FL_FTP_HOST",
145
- description: "Hostname",
146
- is_string: true),
147
- FastlaneCore::ConfigItem.new(key: :folder,
148
- short_option: "-f",
149
- env_name: "FL_FTP_FOLDER",
150
- description: "repository",
151
- is_string: true),
152
- FastlaneCore::ConfigItem.new(key: :upload,
153
- short_option: "-U",
154
- env_name: "FL_FTP_UPLOAD",
155
- description: "Upload",
156
- optional: true,
157
- is_string: false,
158
- type: Hash),
159
- FastlaneCore::ConfigItem.new(key: :upload_multiple,
160
- short_option: "-I",
161
- env_name: "FL_FTP_UPLOAD_MULTIPLE",
162
- description: "Upload",
163
- optional: true,
164
- is_string: false,
165
- type: Hash),
166
- FastlaneCore::ConfigItem.new(key: :download,
167
- short_option: "-D",
168
- env_name: "FL_FTP_DOWNLOAD",
169
- description: "Download",
170
- optional: true,
171
- is_string: false,
172
- type: Hash),
173
- FastlaneCore::ConfigItem.new(key: :options,
174
- short_option: "-O",
175
- env_name: "FL_FTP_OPTIONS",
176
- description: "options",
177
- optional: true,
178
- is_string: false,
179
- type: Hash),
180
- FastlaneCore::ConfigItem.new(key: :port,
181
- short_option: "-P",
182
- env_name: "FL_FTP_PORT",
183
- description: "Port",
184
- optional: true,
185
- default_value: 21,
186
- is_string: false,
187
- type: Integer),
188
- ]
189
- end
122
+ def self.available_options
123
+ [
124
+ FastlaneCore::ConfigItem.new(key: :username,
125
+ short_option: '-u',
126
+ env_name: 'FL_FTP_USERNAME',
127
+ description: 'Username',
128
+ is_string: true),
129
+ FastlaneCore::ConfigItem.new(key: :password,
130
+ short_option: '-p',
131
+ env_name: 'FL_FTP_PASSWORD',
132
+ description: 'Password',
133
+ optional: false,
134
+ is_string: true),
135
+ FastlaneCore::ConfigItem.new(key: :host,
136
+ short_option: '-H',
137
+ env_name: 'FL_FTP_HOST',
138
+ description: 'Hostname',
139
+ is_string: true),
140
+ FastlaneCore::ConfigItem.new(key: :folder,
141
+ short_option: '-f',
142
+ env_name: 'FL_FTP_FOLDER',
143
+ description: 'repository',
144
+ is_string: true),
145
+ FastlaneCore::ConfigItem.new(key: :upload,
146
+ short_option: '-U',
147
+ env_name: 'FL_FTP_UPLOAD',
148
+ description: 'Upload',
149
+ optional: true,
150
+ is_string: false,
151
+ type: Hash),
152
+ FastlaneCore::ConfigItem.new(key: :upload_multiple,
153
+ short_option: '-I',
154
+ env_name: 'FL_FTP_UPLOAD_MULTIPLE',
155
+ description: 'Upload',
156
+ optional: true,
157
+ is_string: false,
158
+ type: Hash),
159
+ FastlaneCore::ConfigItem.new(key: :download,
160
+ short_option: '-D',
161
+ env_name: 'FL_FTP_DOWNLOAD',
162
+ description: 'Download',
163
+ optional: true,
164
+ is_string: false,
165
+ type: Hash),
166
+ FastlaneCore::ConfigItem.new(key: :options,
167
+ short_option: '-O',
168
+ env_name: 'FL_FTP_OPTIONS',
169
+ description: 'options',
170
+ optional: true,
171
+ is_string: false,
172
+ type: Hash),
173
+ FastlaneCore::ConfigItem.new(key: :port,
174
+ short_option: '-P',
175
+ env_name: 'FL_FTP_PORT',
176
+ description: 'Port',
177
+ optional: true,
178
+ default_value: 21,
179
+ is_string: false,
180
+ type: Integer)
181
+ ]
182
+ end
190
183
 
191
- def self.output
192
- end
184
+ def self.output; end
193
185
 
194
- def self.return_value
195
- end
186
+ def self.return_value; end
196
187
 
197
- def self.authors
198
- ["Allan Vialatte, Rafał Dziuryk"]
199
- end
188
+ def self.authors
189
+ ['Allan Vialatte, Rafał Dziuryk']
190
+ end
200
191
 
201
- def self.is_supported?(platform)
202
- true
192
+ def self.is_supported?(_platform)
193
+ true
194
+ end
203
195
  end
204
196
  end
205
197
  end
206
- end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Ftps
3
- VERSION = "0.1.19"
3
+ VERSION = '0.1.21'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ftps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafał Dziuryk