gemfury 0.12.1 → 0.13.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,70 +1,75 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'progressbar'
2
4
  require 'delegate'
3
5
 
4
6
  class Gemfury::Command::App < Thor
5
7
  include Gemfury::Command::Authorization
6
- UserAgent = "Gemfury CLI #{Gemfury::VERSION}".freeze
7
- PackageExtensions = %w(gem egg tar.gz tgz nupkg)
8
+ UserAgent = "Gemfury CLI #{Gemfury::VERSION}"
9
+ PackageExtensions = %w[gem egg tar.gz tgz nupkg].freeze
8
10
 
9
11
  # Impersonation
10
- class_option :as, :desc => 'Access an account other than your own'
11
- class_option :api_token, :desc => 'API token to use for commands'
12
+ class_option :as, desc: 'Access an account other than your own'
13
+ class_option :api_token, desc: 'API token to use for commands'
14
+ class_option :no_warnings, hide: true, type: :boolean
12
15
 
13
16
  # Make sure we retain the default exit behaviour of 0 even on argument errors
14
- def self.exit_on_failure?; false; end
17
+ def self.exit_on_failure?
18
+ false
19
+ end
15
20
 
16
- map "-v" => :version
17
- desc "version", "Show Gemfury version", :hide => true
21
+ map '-v' => :version
22
+ desc 'version', 'Show Gemfury version', hide: true
18
23
  def version
19
24
  shell.say Gemfury::VERSION
20
25
  end
21
26
 
22
27
  ### PACKAGE MANAGEMENT ###
23
- option :public, :type => :boolean, :desc => "Create as public package"
24
- option :quiet, :type => :boolean, :aliases => "-q", :desc => "Do not show progress bar", :default => false
25
- desc "push FILE", "Upload a new version of a package"
28
+ option :public, type: :boolean, desc: 'Create as public package'
29
+ option :quiet, type: :boolean, aliases: '-q', desc: 'Do not show progress bar', default: false
30
+ desc 'push FILE', 'Upload a new version of a package'
26
31
  def push(*gems)
27
32
  with_checks_and_rescues do
28
33
  push_files(:push, gems)
29
34
  end
30
35
  end
31
36
 
32
- desc "list", "List your packages"
37
+ desc 'list', 'List your packages'
33
38
  def list
34
39
  with_checks_and_rescues do
35
40
  gems = client.list
36
41
  shell.say "\n*** GEMFURY PACKAGES ***\n\n"
37
42
 
38
- va = [ %w{ name kind version privacy } ]
43
+ va = [%w[name kind version privacy]]
39
44
  gems.each do |g|
40
- va << [ g['name'], g['language'],
41
- g.dig('latest_version', 'version') || 'beta',
42
- g['private'] ? 'private' : 'public ' ]
45
+ va << [g['name'], g['language'],
46
+ g.dig('latest_version', 'version') || 'beta',
47
+ g['private'] ? 'private' : 'public ']
43
48
  end
44
49
 
45
50
  shell.print_table(va)
46
51
  end
47
52
  end
48
53
 
49
- desc "versions NAME", "List all the package versions"
54
+ desc 'versions NAME', 'List all the package versions'
50
55
  def versions(gem_name)
51
56
  with_checks_and_rescues do
52
57
  versions = client.versions(gem_name)
53
58
  shell.say "\n*** #{gem_name.capitalize} Versions ***\n\n"
54
59
 
55
60
  va = []
56
- va = [ %w{ version uploaded_by uploaded } ]
61
+ va = [%w[version uploaded_by uploaded]]
57
62
  versions.each do |v|
58
63
  uploaded = time_ago(Time.parse(v['created_at']).getlocal)
59
- va << [ v['version'], v['created_by']['name'], uploaded ]
64
+ va << [v['version'], v['created_by']['name'], uploaded]
60
65
  end
61
66
 
62
67
  shell.print_table(va)
63
68
  end
64
69
  end
65
70
 
66
- desc "yank NAME", "Delete a package version"
67
- method_options %w(version -v) => :required
71
+ desc 'yank NAME', 'Delete a package version'
72
+ method_options %w[version -v] => :required
68
73
  def yank(gem_name)
69
74
  with_checks_and_rescues do
70
75
  version = options[:version]
@@ -74,40 +79,44 @@ class Gemfury::Command::App < Thor
74
79
  end
75
80
 
76
81
  ### AUTHENTICATION ###
77
- desc "logout", "Remove Gemfury credentials"
82
+ desc 'logout', 'Remove Gemfury credentials'
78
83
  def logout
79
84
  if !has_credentials?
80
- shell.say "You are logged out"
81
- elsif shell.yes? "Are you sure you want to log out? [yN]"
85
+ shell.say 'You are logged out'
86
+ elsif shell.yes? 'Are you sure you want to log out? [yN]'
82
87
  with_checks_and_rescues { client.logout }
83
88
  wipe_credentials!
84
- shell.say "You have been logged out"
89
+ shell.say 'You have been logged out'
85
90
  end
86
91
  end
87
92
 
88
- desc "login", "Save Gemfury credentials"
93
+ desc 'login', 'Save Gemfury credentials'
89
94
  def login
90
95
  with_checks_and_rescues do
91
96
  me = client.account_info['name']
92
- shell.say %Q(You are logged in as "#{me}"), :green
97
+ shell.say %(You are logged in as "#{me}"), :green
93
98
  end
94
99
  end
95
100
 
96
- desc "whoami", "Show current user"
101
+ desc 'whoami', 'Show current user'
97
102
  def whoami
98
- has_credentials? ? self.login : begin
99
- shell.say %Q(You are not logged in), :green
103
+ if has_credentials?
104
+ login
105
+ else
106
+
107
+ shell.say 'You are not logged in', :green
108
+
100
109
  end
101
110
  end
102
111
 
103
- desc "accounts", "Show info about your Gemfury accounts"
112
+ desc 'accounts', 'Show info about your Gemfury accounts'
104
113
  def accounts
105
114
  with_checks_and_rescues do
106
115
  accounts = client.accounts
107
116
 
108
- va = [ %w{ name kind permission } ]
117
+ va = [%w[name kind permission]]
109
118
  accounts.each do |a|
110
- va << [ a['name'], a['type'], a['viewer_permission'].downcase ]
119
+ va << [a['name'], a['type'], a['viewer_permission'].downcase]
111
120
  end
112
121
 
113
122
  shell.print_table(va)
@@ -115,10 +124,10 @@ class Gemfury::Command::App < Thor
115
124
  end
116
125
 
117
126
  ### COLLABORATION MANAGEMENT ###
118
- map "sharing:add" => 'sharing_add'
119
- map "sharing:remove" => 'sharing_remove'
127
+ map 'sharing:add' => 'sharing_add'
128
+ map 'sharing:remove' => 'sharing_remove'
120
129
 
121
- desc "sharing", "List collaborators"
130
+ desc 'sharing', 'List collaborators'
122
131
  def sharing
123
132
  with_checks_and_rescues do
124
133
  account_info = client.account_info
@@ -126,24 +135,22 @@ class Gemfury::Command::App < Thor
126
135
 
127
136
  collaborators = client.list_collaborators
128
137
  if collaborators.empty?
129
- shell.say %Q(You (#{me}) are the only collaborator\n), :green
138
+ shell.say %(You (#{me}) are the only collaborator\n), :green
130
139
  else
131
- shell.say %Q(\n*** Collaborators for "#{me}" ***\n), :green
140
+ shell.say %(\n*** Collaborators for "#{me}" ***\n), :green
132
141
 
133
- va = [ %w{ username permission } ]
142
+ va = [%w[username permission]]
134
143
 
135
- if account_info['type'] == 'user'
136
- va << [ me, 'owner' ]
137
- end
144
+ va << [me, 'owner'] if account_info['type'] == 'user'
138
145
 
139
- collaborators.each { |c| va << [ c['username'], c['permission'] ] }
146
+ collaborators.each { |c| va << [c['username'], c['permission']] }
140
147
 
141
148
  shell.print_table(va)
142
149
  end
143
150
  end
144
151
  end
145
152
 
146
- desc "sharing:add EMAIL", "Add a collaborator"
153
+ desc 'sharing:add EMAIL', 'Add a collaborator'
147
154
  def sharing_add(username)
148
155
  with_checks_and_rescues do
149
156
  client.add_collaborator(username)
@@ -151,7 +158,7 @@ class Gemfury::Command::App < Thor
151
158
  end
152
159
  end
153
160
 
154
- desc "sharing:remove EMAIL", "Remove a collaborator"
161
+ desc 'sharing:remove EMAIL', 'Remove a collaborator'
155
162
  def sharing_remove(username)
156
163
  with_checks_and_rescues do
157
164
  client.remove_collaborator(username)
@@ -160,7 +167,7 @@ class Gemfury::Command::App < Thor
160
167
  end
161
168
 
162
169
  ### MIGRATION (Pushing directories) ###
163
- desc "migrate DIR", "Upload all packages within a directory"
170
+ desc 'migrate DIR', 'Upload all packages within a directory'
164
171
  def migrate(*paths)
165
172
  with_checks_and_rescues do
166
173
  gem_paths = Dir.glob(paths.map do |p|
@@ -168,30 +175,26 @@ class Gemfury::Command::App < Thor
168
175
  PackageExtensions.map { |ext| "#{p}/**/*.#{ext}" }
169
176
  elsif File.file?(p)
170
177
  p
171
- else
172
- nil
173
178
  end
174
179
  end.flatten.compact)
175
180
 
176
181
  if gem_paths.empty?
177
- die!("Problem: No valid packages found", nil, :migrate)
182
+ die!('Problem: No valid packages found', nil, :migrate)
178
183
  else
179
- shell.say "Found the following packages:"
184
+ shell.say 'Found the following packages:'
180
185
  gem_paths.each { |p| shell.say " #{File.basename(p)}" }
181
- if shell.yes? "Upload these files to Gemfury? [yN]", :green
182
- push_files(:migrate, gem_paths)
183
- end
186
+ push_files(:migrate, gem_paths) if shell.yes? 'Upload these files to Gemfury? [yN]', :green
184
187
  end
185
188
  end
186
189
  end
187
190
 
188
191
  ### GIT REPOSITORY MANAGEMENT ###
189
- map "git:list" => 'git_list'
190
- map "git:reset" => 'git_reset'
191
- map "git:rename" => 'git_rename'
192
- map "git:rebuild" => 'git_rebuild'
192
+ map 'git:list' => 'git_list'
193
+ map 'git:reset' => 'git_reset'
194
+ map 'git:rename' => 'git_rename'
195
+ map 'git:rebuild' => 'git_rebuild'
193
196
 
194
- desc "git:list", "List Git repositories"
197
+ desc 'git:list', 'List Git repositories'
195
198
  def git_list
196
199
  with_checks_and_rescues do
197
200
  repos = client.git_repos['repos']
@@ -201,15 +204,15 @@ class Gemfury::Command::App < Thor
201
204
  end
202
205
  end
203
206
 
204
- desc "git:rename REPO_NAME NEW_NAME", "Rename a Git repository"
207
+ desc 'git:rename REPO_NAME NEW_NAME', 'Rename a Git repository'
205
208
  def git_rename(repo, new_name)
206
209
  with_checks_and_rescues do
207
- client.git_update(repo, :repo => { :name => new_name })
210
+ client.git_update(repo, repo: { name: new_name })
208
211
  shell.say "Renamed #{repo} repository to #{new_name}\n"
209
212
  end
210
213
  end
211
214
 
212
- desc "git:reset REPO_NAME", "Remove a Git repository"
215
+ desc 'git:reset REPO_NAME', 'Remove a Git repository'
213
216
  def git_reset(repo)
214
217
  with_checks_and_rescues do
215
218
  client.git_reset(repo)
@@ -217,13 +220,13 @@ class Gemfury::Command::App < Thor
217
220
  end
218
221
  end
219
222
 
220
- desc "git:rebuild REPO_NAME", "Rebuild a Git repository"
221
- method_options %w(revision -r) => :string
223
+ desc 'git:rebuild REPO_NAME', 'Rebuild a Git repository'
224
+ method_options %w[revision -r] => :string
222
225
  def git_rebuild(repo)
223
226
  with_checks_and_rescues do
224
- params = { :revision => options[:revision] }
227
+ params = { revision: options[:revision] }
225
228
  shell.say "\n*** Rebuilding #{repo} repository ***\n\n"
226
- shell.say client.git_rebuild(repo, :build => params)
229
+ shell.say client.git_rebuild(repo, build: params)
227
230
  end
228
231
  end
229
232
 
@@ -232,89 +235,85 @@ class Gemfury::Command::App < Thor
232
235
  map 'git:config:set' => 'git_config_set'
233
236
  map 'git:config:unset' => 'git_config_unset'
234
237
 
235
- desc "git:config REPO_NAME", "List Git repository's build environment"
238
+ desc 'git:config REPO_NAME', "List Git repository's build environment"
236
239
  def git_config(repo)
237
240
  with_checks_and_rescues do
238
241
  vars = client.git_config(repo)['config_vars']
239
242
  shell.say "*** #{repo} build config ***\n"
240
- shell.print_table(vars.map { |kv|
243
+ shell.print_table(vars.map do |kv|
241
244
  ["#{kv[0]}:", kv[1]]
242
- })
245
+ end)
243
246
  end
244
247
  end
245
248
 
246
- desc "git:config:set REPO_NAME KEY=VALUE ...", "Update Git repository's build environment"
249
+ desc 'git:config:set REPO_NAME KEY=VALUE ...', "Update Git repository's build environment"
247
250
  def git_config_set(repo, *vars)
248
251
  with_checks_and_rescues do
249
- updates = Hash[vars.map { |v| v.split("=", 2) }]
252
+ updates = vars.to_h { |v| v.split('=', 2) }
250
253
  client.git_config_update(repo, updates)
251
254
  shell.say "Updated #{repo} build config"
252
255
  end
253
256
  end
254
257
 
255
- desc "git:config:unset REPO_NAME KEY ...", "Remove variables from Git repository's build environment"
258
+ desc 'git:config:unset REPO_NAME KEY ...', "Remove variables from Git repository's build environment"
256
259
  def git_config_unset(repo, *vars)
257
260
  with_checks_and_rescues do
258
- updates = Hash[vars.map { |v| [v, nil] }]
261
+ updates = vars.to_h { |v| [v, nil] }
259
262
  client.git_config_update(repo, updates)
260
263
  shell.say "Updated #{repo} build config"
261
264
  end
262
265
  end
263
266
 
264
- private
267
+ private
268
+
265
269
  def client
266
270
  opts = {}
267
271
  opts[:user_api_key] = @user_api_key if @user_api_key
268
272
  opts[:account] = options[:as] if options[:as]
269
273
  client = Gemfury::Client.new(opts)
270
274
  client.user_agent = UserAgent
271
- return client
275
+ client
272
276
  end
273
277
 
274
278
  def with_checks_and_rescues(&block)
275
279
  @user_api_key = options[:api_token] if options[:api_token]
276
280
 
277
281
  msg = '[DEPRECATED] This CLI is no longer supported. Please upgrade to the new CLI: https://gemfury.com/guide/cli'
278
- shell.say(msg, :yellow) if !options[:quiet] && !current_command_chain.include?(:logout)
282
+ shell.say(msg, :yellow) if !options[:quiet] && !options[:no_warnings] && !current_command_chain.include?(:logout)
279
283
 
280
284
  with_authorization(&block)
281
-
282
285
  rescue Gemfury::InvalidGemVersion => e
283
- shell.say "You have a deprecated Gemfury client", :red
284
- if shell.yes? "Would you like to update it now? [yN]"
285
- exec("gem update gemfury")
286
+ shell.say 'You have a deprecated Gemfury client', :red
287
+ if shell.yes? 'Would you like to update it now? [yN]'
288
+ exec('gem update gemfury')
286
289
  else
287
- shell.say %q(No problem. You can also run "gem update gemfury")
290
+ shell.say 'No problem. You can also run "gem update gemfury"'
288
291
  end
289
292
  rescue Gemfury::Conflict => e
290
- die!("Oops! Locked for another user. Try again later.", e)
293
+ die!('Oops! Locked for another user. Try again later.', e)
291
294
  rescue Gemfury::Forbidden => e
292
295
  die!("Oops! You're not allowed to access this", e)
293
296
  rescue Gemfury::NotFound => e
294
297
  die!("Oops! Doesn't look like this exists", e)
295
298
  rescue Gemfury::Error => e
296
- die!("Oops! %s" % e.message, e)
299
+ die!('Oops! %s' % e.message, e)
297
300
  rescue StandardError => e
298
- die!("Oops! Something went wrong. Please contact support.", e)
301
+ die!('Oops! Something went wrong. Please contact support.', e)
299
302
  end
300
303
 
301
304
  def push_files(command, gem_paths)
302
305
  files = gem_paths.map do |g|
303
- g.is_a?(String) ? File.new(g) : g rescue nil
306
+ g.is_a?(String) ? File.new(g) : g
307
+ rescue StandardError
308
+ nil
304
309
  end.compact
305
310
 
306
- if !options[:quiet] && !shell.mute? && $stdout.tty?
307
- files = files.map { |g| ProgressIO.new(g) }
308
- end
311
+ files = files.map { |g| ProgressIO.new(g) } if !options[:quiet] && !shell.mute? && $stdout.tty?
309
312
 
310
- if files.empty?
311
- die!("Problem: No valid packages found", nil, command)
312
- end
313
+ die!('Problem: No valid packages found', nil, command) if files.empty?
313
314
 
314
- push_options = { }
315
- unless options[:public].nil?
316
- push_options[:public] = options[:public]
317
- end
315
+ push_options = {}
316
+ push_options[:public] = options[:public] unless options[:public].nil?
318
317
 
319
318
  error_ex = nil
320
319
 
@@ -335,32 +334,32 @@ private
335
334
  client.push_gem(file, push_options)
336
335
  end
337
336
 
338
- shell.say "- done"
337
+ shell.say '- done'
339
338
  rescue Gemfury::CorruptGemFile => e
340
- shell.say "- problem processing this package", :red
339
+ shell.say '- problem processing this package', :red
341
340
  error_ex = e
342
341
  rescue Gemfury::DupeVersion => e
343
- shell.say "- this version already exists", :red
342
+ shell.say '- this version already exists', :red
344
343
  error_ex = e
345
344
  rescue Gemfury::TimeoutError, Errno::EPIPE => e
346
- shell.say "- this file is too much to handle", :red
347
- shell.say " Visit http://www.gemfury.com/large-package for more info"
345
+ shell.say '- this file is too much to handle', :red
346
+ shell.say ' Visit http://www.gemfury.com/large-package for more info'
348
347
  error_ex = e
349
348
  rescue Gemfury::Error => e
350
349
  shell.say "- #{e.message.downcase}", :red
351
350
  error_ex = e
352
- rescue => e
353
- shell.say "- oops", :red
351
+ rescue StandardError => e
352
+ shell.say '- oops', :red
354
353
  error_ex = e
355
354
  end
356
355
  end
357
356
 
358
- unless error_ex.nil?
359
- die!('There was a problem uploading at least 1 package', error_ex)
360
- end
357
+ return if error_ex.nil?
358
+
359
+ die!('There was a problem uploading at least 1 package', error_ex)
361
360
  end
362
361
 
363
- C50K = 50000
362
+ C50K = 50_000
364
363
 
365
364
  class ProgressIO < SimpleDelegator
366
365
  attr_reader :content_type, :original_filename, :local_path
@@ -382,15 +381,15 @@ private
382
381
  @original_filename = File.basename(fname)
383
382
  @local_path = local_path
384
383
 
385
- if io.respond_to? :size
386
- filesize = io.size
387
- else
388
- filesize = io.stat.size
389
- end
384
+ filesize = if io.respond_to? :size
385
+ io.size
386
+ else
387
+ io.stat.size
388
+ end
390
389
 
391
390
  if filesize > C50K
392
391
  title = 'Uploading %s ' % File.basename(fname)
393
- @bar = ProgressBar.create(:title => title, :total => filesize)
392
+ @bar = ProgressBar.create(title: title, total: filesize)
394
393
  else
395
394
  @bar = nil
396
395
  end
@@ -404,9 +403,7 @@ private
404
403
 
405
404
  def read(length)
406
405
  buf = __getobj__.read(length)
407
- unless @bar.nil? || buf.nil?
408
- @bar.progress += buf.bytesize
409
- end
406
+ @bar.progress += buf.bytesize unless @bar.nil? || buf.nil?
410
407
 
411
408
  buf
412
409
  end
@@ -415,7 +412,7 @@ private
415
412
  def die!(msg, err = nil, command = nil)
416
413
  shell.say msg, :red
417
414
  help(command) if command
418
- shell.say %Q(#{err.class.name}: #{err}\n#{err.backtrace.join("\n")}) if err && ENV['DEBUG']
415
+ shell.say %(#{err.class.name}: #{err}\n#{err.backtrace.join("\n")}) if err && ENV['DEBUG']
419
416
  exit(1)
420
417
  end
421
418
 
@@ -1,18 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gemfury::Command::Authorization
2
4
  include Gemfury::Platform
3
5
 
4
6
  def wipe_credentials!
5
- FileUtils.rm(config_path, :force => true) # never raises exception
7
+ FileUtils.rm(config_path, force: true) # never raises exception
6
8
  each_netrc_host { |h| netrc_conf.delete(h) }
7
9
  netrc_conf.save
8
10
  end
9
11
 
10
12
  def has_credentials?
11
13
  !!netrc_conf[netrc_api_host] ||
12
- read_config_file.key?(:gemfury_api_key)
14
+ read_config_file.key?(:gemfury_api_key)
13
15
  end
14
16
 
15
- private
17
+ private
18
+
16
19
  def with_authorization(&block)
17
20
  # Load up the credentials if user_api_key is not already set
18
21
  load_credentials! if @user_api_key.nil?
@@ -24,9 +27,9 @@ private
24
27
  block.call
25
28
  rescue Gemfury::Unauthorized
26
29
  if acct = client.account
27
- shell.say %Q(Oops! You don't have access to "#{acct}"), :red
30
+ shell.say %(Oops! You don't have access to "#{acct}"), :red
28
31
  else
29
- shell.say "Oops! Authentication failure.", :red
32
+ shell.say 'Oops! Authentication failure.', :red
30
33
  @user_api_key = nil
31
34
  retry
32
35
  end
@@ -41,10 +44,10 @@ private
41
44
  passw = highline.ask('Password: ') { |q| q.echo = false }
42
45
 
43
46
  # Request and save the API access token
44
- if !email.empty? && !passw.empty?
45
- @user_api_key = client.get_access_token(email, passw)
46
- write_credentials!(email)
47
- end
47
+ return unless !email.empty? && !passw.empty?
48
+
49
+ @user_api_key = client.get_access_token(email, passw)
50
+ write_credentials!(email)
48
51
  end
49
52
 
50
53
  def load_credentials!
@@ -72,8 +75,8 @@ private
72
75
  end
73
76
 
74
77
  def each_netrc_host
75
- [:endpoint, :gitpoint].each do |c|
78
+ %i[endpoint gitpoint].each do |c|
76
79
  yield(URI.parse(client.send(c)).host)
77
80
  end
78
81
  end
79
- end
82
+ end
@@ -1,6 +1,8 @@
1
- gem "progressbar", ">= 1.10.1", "< 2.0.0.pre"
2
- gem "highline", ">= 1.6.0", "< 2.1.0.pre"
3
- gem "thor", ">= 0.14.0", "< 1.1.0.pre"
1
+ # frozen_string_literal: true
2
+
3
+ gem 'highline', '>= 1.6.0', '< 2.2.0.pre'
4
+ gem 'progressbar', '>= 1.10.1', '< 2.0.0.pre'
5
+ gem 'thor', '>= 0.14.0', '< 1.3.0.pre'
4
6
 
5
7
  require 'thor'
6
8
  require 'yaml'
@@ -1,15 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gemfury
2
4
  module Configuration
3
-
4
5
  CONFIGURATION_DEFAULTS = {
5
- :user_api_key => nil,
6
- :adapter => :net_http,
7
- :endpoint => 'https://api.fury.io/',
8
- :gitpoint => 'https://git.fury.io/',
9
- :pushpoint => 'https://push.fury.io/',
10
- :user_agent => "Gemfury RubyGem #{Gemfury::VERSION} (Ruby #{RUBY_VERSION})",
11
- :api_version => 1,
12
- :account => nil
6
+ user_api_key: nil,
7
+ adapter: :net_http,
8
+ endpoint: 'https://api.fury.io/',
9
+ gitpoint: 'https://git.fury.io/',
10
+ pushpoint: 'https://push.fury.io/',
11
+ user_agent: "Gemfury RubyGem #{Gemfury::VERSION} (Ruby #{RUBY_VERSION})",
12
+ api_version: 1,
13
+ account: nil
13
14
  }.freeze
14
15
 
15
16
  # user API key, also known as "full access token"
data/lib/gemfury/const.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gemfury
2
4
  module Const
3
5
  class << self
4
6
  def host
5
7
  'www.gemfury.com'
6
- #'localhost:3000'
8
+ # 'localhost:3000'
7
9
  end
8
10
 
9
11
  def welcome
@@ -11,11 +13,12 @@ module Gemfury
11
13
  end
12
14
 
13
15
  def email_error
14
- "Invalid email address. Please try again."
16
+ 'Invalid email address. Please try again.'
15
17
  end
16
18
 
17
19
  def email_regex
18
20
  return @email_regex if @email_regex
21
+
19
22
  email_name_regex = '[A-Z0-9_\.%\+\-\']+'
20
23
  domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
21
24
  domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
data/lib/gemfury/error.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gemfury
2
4
  # Base Error class
3
5
  Error = Class.new(StandardError)
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gemfury
2
4
  module Platform
3
5
  def home_directory
4
- on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
6
+ on_windows? ? ENV.fetch('USERPROFILE', nil) : Dir.home
5
7
  end
6
8
 
7
9
  def config_path
@@ -16,4 +18,4 @@ module Gemfury
16
18
  RUBY_PLATFORM =~ /-darwin\d/
17
19
  end
18
20
  end
19
- end
21
+ end