dpl 2.0.3.beta.4 → 2.0.3.beta.5

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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -3
  3. data/Gemfile.lock +444 -211
  4. data/Rakefile +36 -34
  5. data/bin/dpl +3 -1
  6. data/dpl.gemspec +25 -0
  7. data/lib/dpl/cli.rb +19 -14
  8. data/lib/dpl/ctx/bash.rb +18 -12
  9. data/lib/dpl/ctx/test.rb +21 -15
  10. data/lib/dpl/ctx.rb +2 -0
  11. data/lib/dpl/helper/assets.rb +4 -2
  12. data/lib/dpl/helper/cmd.rb +20 -18
  13. data/lib/dpl/helper/config_file.rb +5 -3
  14. data/lib/dpl/helper/cookbook_site_streaming_uploader.rb +249 -0
  15. data/lib/dpl/helper/env.rb +26 -22
  16. data/lib/dpl/helper/github.rb +2 -0
  17. data/lib/dpl/helper/interpolate.rb +8 -4
  18. data/lib/dpl/helper/memoize.rb +4 -1
  19. data/lib/dpl/helper/squiggle.rb +3 -1
  20. data/lib/dpl/helper/transliterate.rb +3 -1
  21. data/lib/dpl/helper/wrap.rb +3 -1
  22. data/lib/dpl/helper/zip.rb +3 -1
  23. data/lib/dpl/provider/dsl.rb +18 -4
  24. data/lib/dpl/provider/examples.rb +6 -2
  25. data/lib/dpl/provider/status.rb +26 -24
  26. data/lib/dpl/providers/anynines.rb +22 -20
  27. data/lib/dpl/providers/azure_web_apps.rb +21 -19
  28. data/lib/dpl/providers/bintray.rb +44 -37
  29. data/lib/dpl/providers/bluemixcloudfoundry.rb +38 -36
  30. data/lib/dpl/providers/boxfuse.rb +12 -10
  31. data/lib/dpl/providers/cargo.rb +7 -5
  32. data/lib/dpl/providers/chef_supermarket.rb +82 -80
  33. data/lib/dpl/providers/cloud66.rb +17 -15
  34. data/lib/dpl/providers/cloudfiles.rb +8 -6
  35. data/lib/dpl/providers/cloudformation.rb +191 -187
  36. data/lib/dpl/providers/cloudfoundry.rb +32 -30
  37. data/lib/dpl/providers/codedeploy.rb +35 -33
  38. data/lib/dpl/providers/convox.rb +32 -25
  39. data/lib/dpl/providers/datica.rb +30 -28
  40. data/lib/dpl/providers/ecr.rb +66 -64
  41. data/lib/dpl/providers/elasticbeanstalk.rb +14 -12
  42. data/lib/dpl/providers/engineyard.rb +60 -58
  43. data/lib/dpl/providers/firebase.rb +6 -4
  44. data/lib/dpl/providers/flynn.rb +8 -6
  45. data/lib/dpl/providers/gae.rb +28 -25
  46. data/lib/dpl/providers/gcs.rb +59 -57
  47. data/lib/dpl/providers/git_push.rb +199 -195
  48. data/lib/dpl/providers/gleis.rb +19 -17
  49. data/lib/dpl/providers/hackage.rb +15 -13
  50. data/lib/dpl/providers/hephy.rb +18 -16
  51. data/lib/dpl/providers/heroku/api.rb +72 -70
  52. data/lib/dpl/providers/heroku/git.rb +15 -13
  53. data/lib/dpl/providers/heroku.rb +40 -38
  54. data/lib/dpl/providers/lambda.rb +134 -134
  55. data/lib/dpl/providers/launchpad.rb +45 -43
  56. data/lib/dpl/providers/netlify.rb +7 -5
  57. data/lib/dpl/providers/npm.rb +61 -58
  58. data/lib/dpl/providers/nuget.rb +8 -6
  59. data/lib/dpl/providers/openshift.rb +8 -6
  60. data/lib/dpl/providers/opsworks.rb +23 -21
  61. data/lib/dpl/providers/pages/api.rb +14 -14
  62. data/lib/dpl/providers/pages/git.rb +53 -47
  63. data/lib/dpl/providers/pages.rb +3 -1
  64. data/lib/dpl/providers/puppetforge.rb +6 -4
  65. data/lib/dpl/providers/pypi.rb +55 -54
  66. data/lib/dpl/providers/releases.rb +30 -23
  67. data/lib/dpl/providers/rubygems.rb +35 -31
  68. data/lib/dpl/providers/s3.rb +148 -142
  69. data/lib/dpl/providers/scalingo.rb +18 -16
  70. data/lib/dpl/providers/script.rb +4 -2
  71. data/lib/dpl/providers/snap.rb +12 -9
  72. data/lib/dpl/providers/surge.rb +7 -5
  73. data/lib/dpl/providers/testfairy.rb +47 -43
  74. data/lib/dpl/providers/transifex.rb +20 -18
  75. data/lib/dpl/providers.rb +3 -1
  76. data/lib/dpl/string_ext.rb +3 -1
  77. data/lib/dpl/support/aws_sdk_patch.rb +4 -1
  78. data/lib/dpl/support/gems.rb +7 -3
  79. data/lib/dpl/support/gstore_patch.rb +3 -1
  80. data/lib/dpl/support/version.rb +13 -12
  81. data/lib/dpl/version.rb +3 -1
  82. data/lib/dpl.rb +2 -0
  83. data/status.json +237 -0
  84. metadata +32 -15
  85. /data/lib/dpl/providers/{packagecloud.rb → packagecloud.rb_} +0 -0
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  require 'term/ansicolor'
3
5
  require 'pathname'
@@ -26,7 +28,7 @@ def gem_version
26
28
  ENV['DPL_VERSION'] || Dpl::VERSION
27
29
  end
28
30
 
29
- def confirm(verb = "release")
31
+ def confirm(verb = 'release')
30
32
  unless @ready
31
33
  answer = cli.ask "Ready to #{verb} `dpl` version #{gem_version}? (y/n)"
32
34
  if answer !~ /^y/i
@@ -41,63 +43,63 @@ def dpl_bin
41
43
  File.join(Gem.bindir, 'dpl')
42
44
  end
43
45
 
44
- gemspecs = FileList[File.join(top, "dpl-*.gemspec")]
46
+ gemspecs = FileList[File.join(top, 'dpl-*.gemspec')]
45
47
 
46
48
  providers = gemspecs.map { |f| /dpl-(?<provider>.*)\.gemspec/ =~ f && provider }
47
49
 
48
- desc "Build dpl gem"
50
+ desc 'Build dpl gem'
49
51
  file "dpl-#{gem_version}.gem" do
50
- logger.info green("Building dpl gem")
51
- ruby "-S gem build dpl.gemspec"
52
+ logger.info green('Building dpl gem')
53
+ ruby '-S gem build dpl.gemspec'
52
54
  end
53
55
 
54
- desc "Install dpl gem"
56
+ desc 'Install dpl gem'
55
57
  file dpl_bin => "dpl-#{gem_version}.gem" do
56
- logger.info green("Installing dpl gem")
58
+ logger.info green('Installing dpl gem')
57
59
  ruby "-S gem install dpl-#{gem_version}.gem"
58
60
  end
59
61
 
60
- task :default => [:spec, Rake::FileTask[dpl_bin]] do
61
- Rake::Task["spec_providers"].invoke
62
- Rake::Task["check_providers"].invoke
62
+ task default: [:spec, Rake::FileTask[dpl_bin]] do
63
+ Rake::Task['spec_providers'].invoke
64
+ Rake::Task['check_providers'].invoke
63
65
  end
64
66
 
65
- desc "Run spec on all providers"
67
+ desc 'Run spec on all providers'
66
68
  task :spec_providers do
67
69
  providers.each do |provider|
68
70
  Rake::Task["spec-#{provider}"].invoke
69
71
  end
70
72
  end
71
73
 
72
- desc "Check all provider gems install correctly"
74
+ desc 'Check all provider gems install correctly'
73
75
  task :check_providers do
74
76
  providers.each do |provider|
75
77
  Rake::Task["check-#{provider}"].invoke
76
78
  end
77
79
  end
78
80
 
79
- desc "Build all gems"
80
- task :build => "dpl-#{gem_version}.gem" do
81
+ desc 'Build all gems'
82
+ task build: "dpl-#{gem_version}.gem" do
81
83
  providers.each do |provider|
82
84
  Rake::Task["dpl-#{provider}-#{gem_version}.gem"].invoke
83
85
  end
84
86
  end
85
87
 
86
- desc "Uninstall all gems"
88
+ desc 'Uninstall all gems'
87
89
  task :uninstall do
88
90
  providers.each do |provider|
89
91
  Rake::Task["uninstall-#{provider}"].invoke
90
92
  end
91
- logger.info red("Uninstalling dpl")
92
- sh "gem uninstall -aIx dpl"
93
+ logger.info red('Uninstalling dpl')
94
+ sh 'gem uninstall -aIx dpl'
93
95
  end
94
96
 
95
- desc "Release all gems"
97
+ desc 'Release all gems'
96
98
  task :release do
97
99
  confirm
98
100
  released = []
99
101
  providers.each do |provider|
100
- while !released.include? provider
102
+ until released.include? provider
101
103
  logger.info "checking dpl-#{provider}"
102
104
 
103
105
  cli = Faraday.new url: 'https://rubygems.org'
@@ -113,12 +115,12 @@ task :release do
113
115
  if Rake::Task["release-#{provider}"].invoke
114
116
  released << provider
115
117
  end
116
- rescue => e
118
+ rescue StandardError
117
119
  Rake::Task["release-#{provider}"].reenable
118
120
  end
119
121
  end
120
- rescue Faraday::Error => e
121
- logger.info yellow("connection failed. retrying")
122
+ rescue Faraday::Error
123
+ logger.info yellow('connection failed. retrying')
122
124
  retry
123
125
  end
124
126
  end
@@ -127,10 +129,10 @@ task :release do
127
129
  sh "gem push dpl-#{gem_version}.gem"
128
130
  end
129
131
 
130
- desc "Yank all gems"
131
- task :yank, [:version] do |t, args|
132
+ desc 'Yank all gems'
133
+ task :yank, [:version] do |_t, args|
132
134
  version = args.version
133
- confirm "yank"
135
+ confirm 'yank'
134
136
  logger.info green("Yanking `dpl` version #{version}")
135
137
  sh "gem yank dpl -v #{version}"
136
138
  providers.each do |provider|
@@ -140,17 +142,17 @@ end
140
142
 
141
143
  task :deep_clean do
142
144
  Rake::Task[:clean].invoke
143
- sh "git clean -dfx"
145
+ sh 'git clean -dfx'
144
146
  end
145
147
 
146
148
  task :clean do
147
- rm_rf "stubs"
148
- rm_rf "vendor"
149
- rm_rf "dpl-*.gem"
149
+ rm_rf 'stubs'
150
+ rm_rf 'vendor'
151
+ rm_rf 'dpl-*.gem'
150
152
  Rake::Task[:uninstall].invoke
151
153
  end
152
154
 
153
- desc "Run dpl specs"
155
+ desc 'Run dpl specs'
154
156
  task :spec do
155
157
  ruby '-S rspec spec/cli_spec.rb spec/provider_spec.rb'
156
158
  end
@@ -160,13 +162,13 @@ providers.each do |provider|
160
162
  file "Gemfile-#{provider}" do |t|
161
163
  gemfile = top + t.name
162
164
  logger.info green("Writing #{gemfile}")
163
- gemfile.write %Q(source 'https://rubygems.org'\ngemspec :name => "dpl-#{provider}"\n)
165
+ gemfile.write %(source 'https://rubygems.org'\ngemspec :name => "dpl-#{provider}"\n)
164
166
  end
165
167
 
166
- desc %Q(Run dpl-#{provider} specs)
168
+ desc %(Run dpl-#{provider} specs)
167
169
  task "spec-#{provider}", [:lines] => [Rake::FileTask[dpl_bin], "Gemfile-#{provider}"] do |_t, args|
168
- tail = args.lines ? ":#{args.lines}" : ""
169
- sh "rm -f $HOME/.npmrc"
170
+ tail = args.lines ? ":#{args.lines}" : ''
171
+ sh 'rm -f $HOME/.npmrc'
170
172
  logger.info green("Running `bundle install` for #{provider}")
171
173
  sh 'bash', '-cl', "bundle install --gemfile=Gemfile-#{provider} --path=vendor/cache/dpl-#{provider} --retry=3 --binstubs=stubs"
172
174
  logger.info green("Running specs for #{provider}")
data/bin/dpl CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- $: << File.expand_path('../../lib', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH << File.expand_path('../lib', __dir__)
3
5
 
4
6
  $stdout.sync = true
5
7
  $stderr.sync = true
data/dpl.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH << 'lib'
4
+
5
+ require 'dpl/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.version = Dpl::VERSION
9
+ s.name = 'dpl'
10
+ s.authors = ['Konstantin Haase', 'Hiro Asari', 'Sven Fuchs']
11
+ s.email = ['konstantin@travis-ci.com', 'hiro@travis-ci.com', 'sven@travis-ci.com']
12
+ s.homepage = 'https://github.com/travis-ci/dpl'
13
+ s.summary = 'Dpl runs deployments at Travis CI'
14
+ s.description = 'Dpl (dee-pee-ell) is a tool made for continuous deployment, running deployments at Travis CI.'
15
+ s.license = 'MIT'
16
+ s.require_path = 'lib'
17
+ s.required_ruby_version = '>= 3'
18
+
19
+ s.executables = ['dpl']
20
+ s.files = Dir['{config/**/*,lib/**/*,[A-Z]*}'].reject { _1.match(/dpl.+\.gem/) }
21
+
22
+ s.add_runtime_dependency 'travis-cl'
23
+ s.add_runtime_dependency 'travis-packagecloud-ruby'
24
+ s.add_development_dependency 'rake', '~> 13.0'
25
+ end
data/lib/dpl/cli.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cl'
2
4
 
3
5
  module Dpl
@@ -47,6 +49,7 @@ module Dpl
47
49
 
48
50
  def with_cmd_opt(args, cmd, pos)
49
51
  return args unless opt = args.detect { |arg| arg.start_with?("--#{cmd}") }
52
+
50
53
  ix = args.index(opt)
51
54
  args.delete(opt)
52
55
  value = opt.include?('=') ? opt.split('=').last : args.delete_at(ix)
@@ -56,39 +59,41 @@ module Dpl
56
59
 
57
60
  STRATEGIES = {
58
61
  'heroku' => 'api',
59
- 'pages' => 'git'
60
- }
62
+ 'pages' => 'git'
63
+ }.freeze
61
64
 
62
- def with_strategy_default(args, cmd)
65
+ def with_strategy_default(args, _cmd)
63
66
  return args unless default = STRATEGIES[args.first]
67
+
64
68
  args.insert(1, default) if args[1].nil? || args[1].to_s.start_with?('--')
65
69
  args
66
70
  end
67
71
 
68
- def error(e)
69
- msg = "\e[31m#{e.message}\e[0m"
70
- msg = [msg, *e.backtrace].join("\n") if backtrace?(e)
72
+ def error(err)
73
+ msg = "\e[31m#{err.message}\e[0m"
74
+ msg = [msg, *err.backtrace].join("\n") if backtrace?(err)
71
75
  abort msg
72
76
  end
73
77
 
74
- def backtrace?(e)
75
- e.respond_to?(:backtrace?) && e.backtrace?
78
+ def backtrace?(err)
79
+ err.respond_to?(:backtrace?) && err.backtrace?
76
80
  end
77
81
 
78
- def unknown_provider(e)
79
- msg = "\e[31m#{e.message}\e[0m"
80
- msg << "\nDid you mean: #{e.suggestions.join(', ')}?" if e.suggestions.any?
82
+ def unknown_provider(err)
83
+ msg = "\e[31m#{err.message}\e[0m"
84
+ msg << "\nDid you mean: #{err.suggestions.join(', ')}?" if err.suggestions.any?
81
85
  abort msg
82
86
  end
83
87
 
84
- def unknown_option(e)
85
- msg = "\e[31m#{e.message}\e[0m"
86
- msg << "\nDid you mean: #{e.suggestions.join(', ')}?" if e.suggestions.any?
88
+ def unknown_option(err)
89
+ msg = "\e[31m#{err.message}\e[0m"
90
+ msg << "\nDid you mean: #{err.suggestions.join(', ')}?" if err.suggestions.any?
87
91
  abort msg
88
92
  end
89
93
 
90
94
  def suggestions(name)
91
95
  return [] unless defined?(DidYouMean)
96
+
92
97
  DidYouMean::SpellChecker.new(dictionary: providers).correct(name)
93
98
  end
94
99
  end
data/lib/dpl/ctx/bash.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
1
4
  require 'cl'
2
5
  require 'fileutils'
3
6
  require 'logger'
@@ -14,7 +17,8 @@ module Dpl
14
17
  attr_accessor :folds, :stdout, :stderr, :last_out, :last_err
15
18
 
16
19
  def initialize(stdout = $stdout, stderr = $stderr)
17
- @stdout, @stderr = stdout, stderr
20
+ @stdout = stdout
21
+ @stderr = stderr
18
22
  @folds = 0
19
23
  super('dpl', abort: false)
20
24
  end
@@ -25,7 +29,7 @@ module Dpl
25
29
  # closes the fold.
26
30
  #
27
31
  # @param msg [String] the message that will appear on the log fold
28
- def fold(msg, &block)
32
+ def fold(msg)
29
33
  self.folds += 1
30
34
  print "travis_fold:start:dpl.#{folds}\r\e[K"
31
35
  time do
@@ -41,13 +45,13 @@ module Dpl
41
45
  # Starts a travis time log tag, calls the block, and closes the tag,
42
46
  # including timing information. This makes a timing badge appear on
43
47
  # the surrounding log fold.
44
- def time(&block)
48
+ def time
45
49
  id = SecureRandom.hex[0, 8]
46
- start = Time.now.to_i * (10 ** 9)
50
+ start = Time.now.to_i * (10**9)
47
51
  print "travis_time:start:#{id}\r\e[K"
48
52
  yield
49
53
  ensure
50
- finish = Time.now.to_i * (10 ** 9)
54
+ finish = Time.now.to_i * (10**9)
51
55
  duration = finish - start
52
56
  print "\ntravis_time:end:#{id}:start=#{start},finish=#{finish},duration=#{duration}\r\e[K"
53
57
  end
@@ -135,6 +139,7 @@ module Dpl
135
139
  def apts_get(packages)
136
140
  packages = packages.reject { |name, cmd = name| which(cmd || name) }
137
141
  return unless packages.any?
142
+
138
143
  apt_update
139
144
  packages.each { |package, cmd| apt_get(package, cmd || package, update: false) }
140
145
  end
@@ -148,6 +153,7 @@ module Dpl
148
153
  # @param cmd [String] an executable installed by the package, defaults to the package name
149
154
  def apt_get(package, cmd = package, opts = {})
150
155
  return if which(cmd)
156
+
151
157
  apt_update unless opts[:update].is_a?(FalseClass)
152
158
  shell "sudo apt-get -qq install #{package}", retry: true
153
159
  end
@@ -177,7 +183,7 @@ module Dpl
177
183
  # Gem.loaded_specs.clear
178
184
  gemfile do
179
185
  source 'https://rubygems.org'
180
- gems.each { |g| gem *g }
186
+ gems.each { |g| gem(*g) }
181
187
  end
182
188
  # https://github.com/bundler/bundler/issues/7181
183
189
  ENV.replace(env)
@@ -265,8 +271,8 @@ module Dpl
265
271
  send(cmd.capture? ? :open3 : :system, cmd.cmd, cmd.opts)
266
272
  end
267
273
 
268
- info cmd.success % { out: last_out } if success? && cmd.success?
269
- error cmd.error % { err: last_err } if failed? && cmd.assert?
274
+ info format(cmd.success, out: last_out) if success? && cmd.success?
275
+ error format(cmd.error, err: last_err) if failed? && cmd.assert?
270
276
 
271
277
  success? && cmd.capture? ? last_out.chomp : @last_status
272
278
  end
@@ -324,12 +330,12 @@ module Dpl
324
330
  # Internal, and not to be used by implementors. $? is a read-only
325
331
  # variable, so we use a method that we can stub during tests.
326
332
  def last_process_status
327
- $?.success?
333
+ $CHILD_STATUS.success?
328
334
  end
329
335
 
330
336
  # Whether or not the current Ruby process runs with superuser priviledges.
331
337
  def sudo?
332
- Process::UID.eid == 0
338
+ Process::UID.eid.zero?
333
339
  end
334
340
 
335
341
  # Returns current repository name
@@ -491,14 +497,14 @@ module Dpl
491
497
  def move_files(paths)
492
498
  paths.each do |path|
493
499
  target = "#{tmp_dir}/#{File.basename(path)}"
494
- mv(path, target) if File.exists?(path)
500
+ mv(path, target) if File.exist?(path)
495
501
  end
496
502
  end
497
503
 
498
504
  def unmove_files(paths)
499
505
  paths.each do |path|
500
506
  source = "#{tmp_dir}/#{File.basename(path)}"
501
- mv(source, path) if File.exists?(source)
507
+ mv(source, path) if File.exist?(source)
502
508
  end
503
509
  end
504
510
 
data/lib/dpl/ctx/test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cl'
2
4
  require 'stringio'
3
5
  require 'dpl/helper/squiggle'
@@ -42,7 +44,11 @@ module Dpl
42
44
  def gem_require(name, version = nil, opts = {})
43
45
  # not sure why this is needed. bundler should take care of this, but
44
46
  # it does not for octokit for whatever reason
45
- require opts[:require] || name rescue nil
47
+ begin
48
+ require opts[:require] || name
49
+ rescue StandardError
50
+ nil
51
+ end
46
52
  cmds << "[gem:require] #{name} (#{version}, #{opts})"
47
53
  end
48
54
 
@@ -54,16 +60,17 @@ module Dpl
54
60
  cmds << "[pip:install] #{name} (#{cmd}, #{version})"
55
61
  end
56
62
 
57
- def ssh_keygen(name, file)
63
+ def ssh_keygen(_name, file)
58
64
  File.open(file, 'w+') { |f| f.write('private-key') }
59
65
  File.open("#{file}.pub", 'w+') { |f| f.write('ssh-rsa public-key') }
60
66
  end
61
67
 
62
- def shell(cmd, opts = {})
68
+ def shell(cmd, _opts = {})
63
69
  info cmd.msg if cmd.msg?
64
70
  info cmd.echo if cmd.echo?
65
71
  cmds << cmd.cmd
66
72
  return stdout[cmd.key] if stdout.key?(cmd.key)
73
+
67
74
  cmd.capture? ? 'captured_stdout' : true
68
75
  end
69
76
 
@@ -128,15 +135,15 @@ module Dpl
128
135
  true
129
136
  end
130
137
 
131
- def git_log(args)
138
+ def git_log(_args)
132
139
  'commits'
133
140
  end
134
141
 
135
142
  def git_ls_files
136
- %w(one two)
143
+ %w[one two]
137
144
  end
138
145
 
139
- def git_ls_remote?(url, ref)
146
+ def git_ls_remote?(_url, _ref)
140
147
  true
141
148
  end
142
149
 
@@ -168,7 +175,7 @@ module Dpl
168
175
  '1'
169
176
  end
170
177
 
171
- def which(cmd)
178
+ def which(_cmd)
172
179
  false
173
180
  end
174
181
 
@@ -177,10 +184,9 @@ module Dpl
177
184
  'tmp'
178
185
  end
179
186
 
180
- def sleep(*)
181
- end
187
+ def sleep(*); end
182
188
 
183
- def encoding(path)
189
+ def encoding(_path)
184
190
  'text'
185
191
  end
186
192
 
@@ -195,7 +201,7 @@ module Dpl
195
201
  end
196
202
 
197
203
  def file_size(path)
198
- File.size(path.sub("#{File.expand_path('~')}", './home'))
204
+ File.size(path.sub(File.expand_path('~').to_s, './home'))
199
205
  end
200
206
 
201
207
  def move_files(paths)
@@ -222,19 +228,19 @@ module Dpl
222
228
  cmds << [:chmod, perm, path].join(' ')
223
229
  end
224
230
 
225
- def write_file(path, content, chmod = nil)
231
+ def write_file(path, content, _chmod = nil)
226
232
  path = File.expand_path(path)
227
- path = path.sub("#{File.expand_path('~')}", './home')
233
+ path = path.sub(File.expand_path('~').to_s, './home')
228
234
  FileUtils.mkdir_p(File.dirname(path))
229
235
  File.open(path, 'w+') { |f| f.write(content) }
230
236
  end
231
237
 
232
238
  def write_netrc(machine, login, password)
233
- write_file('~/.netrc', sq(<<-rc))
239
+ write_file('~/.netrc', sq(<<-RC))
234
240
  machine #{machine}
235
241
  login #{login}
236
242
  password #{password}
237
- rc
243
+ RC
238
244
  end
239
245
 
240
246
  def tty?
data/lib/dpl/ctx.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dpl/ctx/bash'
2
4
  require 'dpl/ctx/test'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
 
3
5
  module Dpl
@@ -5,7 +7,7 @@ module Dpl
5
7
  class Asset < Struct.new(:provider, :namespace, :name)
6
8
  include FileUtils
7
9
 
8
- DIR = File.expand_path('../../assets', __FILE__)
10
+ DIR = File.expand_path('../assets', __dir__)
9
11
 
10
12
  def copy(target)
11
13
  cp path, File.expand_path(target)
@@ -16,7 +18,7 @@ module Dpl
16
18
  end
17
19
 
18
20
  def exists?
19
- File.exists?(path)
21
+ File.exist?(path)
20
22
  end
21
23
 
22
24
  def unknown
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  # Represents a shell command
3
5
  class Cmd < Struct.new(:provider, :key, :opts)
@@ -141,27 +143,27 @@ module Dpl
141
143
 
142
144
  private
143
145
 
144
- def lookup(type, *keys)
145
- str = provider.send(type, *keys) if provider
146
- str || keys.detect { |key| key.is_a?(String) }
147
- end
146
+ def lookup(type, *keys)
147
+ str = provider.send(type, *keys) if provider
148
+ str || keys.detect { |key| key.is_a?(String) }
149
+ end
148
150
 
149
- def missing(type, *keys)
150
- raise("Could not find #{type}: #{keys.compact.map(&:inspect).join(', ')}")
151
- end
151
+ def missing(type, *keys)
152
+ raise("Could not find #{type}: #{keys.compact.map(&:inspect).join(', ')}")
153
+ end
152
154
 
153
- def interpolate(str, args, opts = {})
154
- provider ? provider.interpolate(str, args, opts) : str
155
- end
155
+ def interpolate(str, args, opts = {})
156
+ provider ? provider.interpolate(str, args, opts) : str
157
+ end
156
158
 
157
- def silence(str)
158
- "#{str} > /dev/null 2>&1"
159
- end
159
+ def silence(str)
160
+ "#{str} > /dev/null 2>&1"
161
+ end
160
162
 
161
- # Activates the Python virtualenv for the given Python version.
162
- def python(cmd)
163
- # "bash -c 'source $HOME/virtualenv/python#{opts[:python]}/bin/activate; #{cmd.gsub(/'/, "'\\\\''")}'"
164
- "source $HOME/virtualenv/python#{opts[:python]}/bin/activate && #{cmd}"
165
- end
163
+ # Activates the Python virtualenv for the given Python version.
164
+ def python(cmd)
165
+ # "bash -c 'source $HOME/virtualenv/python#{opts[:python]}/bin/activate; #{cmd.gsub(/'/, "'\\\\''")}'"
166
+ "source $HOME/virtualenv/python#{opts[:python]}/bin/activate && #{cmd}"
167
+ end
166
168
  end
167
169
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  module ConfigFile
3
5
  def self.included(base)
@@ -29,14 +31,14 @@ module Dpl
29
31
  end
30
32
 
31
33
  def parse(path)
32
- str = File.exists?(path) ? File.read(path) : ''
34
+ str = File.exist?(path) ? File.read(path) : ''
33
35
  opts = str.lines.select { |line| line.include?('=') }.map(&:strip)
34
36
  opts = opts.map { |pair| pair.split('=', 2) }.to_h
35
- opts.map { |key, value| [strip_prefix(key).to_sym, value] }.to_h
37
+ opts.transform_keys { |key| strip_prefix(key).to_sym }
36
38
  end
37
39
 
38
40
  def strip_prefix(str)
39
- opts[:prefix] ? str.sub(/^#{opts[:prefix]}[\-_]?/, '') : str
41
+ opts[:prefix] ? str.sub(/^#{opts[:prefix]}[-_]?/, '') : str
40
42
  end
41
43
  end
42
44