tomo 1.18.3 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/exe/tomo +1 -0
  3. data/lib/tomo/cli/command.rb +4 -2
  4. data/lib/tomo/cli/common_options.rb +2 -0
  5. data/lib/tomo/cli/completions.rb +3 -1
  6. data/lib/tomo/cli/deploy_options.rb +2 -0
  7. data/lib/tomo/cli/error.rb +2 -0
  8. data/lib/tomo/cli/interrupted_error.rb +2 -0
  9. data/lib/tomo/cli/options.rb +2 -0
  10. data/lib/tomo/cli/parser.rb +3 -1
  11. data/lib/tomo/cli/project_options.rb +2 -0
  12. data/lib/tomo/cli/rules/argument.rb +2 -0
  13. data/lib/tomo/cli/rules/switch.rb +2 -0
  14. data/lib/tomo/cli/rules/value_switch.rb +3 -1
  15. data/lib/tomo/cli/rules.rb +8 -6
  16. data/lib/tomo/cli/rules_evaluator.rb +6 -4
  17. data/lib/tomo/cli/state.rb +2 -0
  18. data/lib/tomo/cli/usage.rb +2 -0
  19. data/lib/tomo/cli.rb +2 -0
  20. data/lib/tomo/colors.rb +2 -0
  21. data/lib/tomo/commands/completion_script.rb +2 -0
  22. data/lib/tomo/commands/default.rb +2 -0
  23. data/lib/tomo/commands/deploy.rb +2 -0
  24. data/lib/tomo/commands/help.rb +2 -0
  25. data/lib/tomo/commands/init.rb +2 -0
  26. data/lib/tomo/commands/run.rb +2 -0
  27. data/lib/tomo/commands/setup.rb +2 -0
  28. data/lib/tomo/commands/tasks.rb +2 -0
  29. data/lib/tomo/commands/version.rb +2 -0
  30. data/lib/tomo/commands.rb +2 -0
  31. data/lib/tomo/configuration/dsl/batch_block.rb +3 -1
  32. data/lib/tomo/configuration/dsl/config_file.rb +8 -6
  33. data/lib/tomo/configuration/dsl/environment_block.rb +2 -0
  34. data/lib/tomo/configuration/dsl/error_formatter.rb +3 -1
  35. data/lib/tomo/configuration/dsl/hosts_and_settings.rb +6 -4
  36. data/lib/tomo/configuration/dsl/tasks_block.rb +5 -3
  37. data/lib/tomo/configuration/dsl.rb +2 -0
  38. data/lib/tomo/configuration/environment.rb +2 -0
  39. data/lib/tomo/configuration/glob.rb +2 -0
  40. data/lib/tomo/configuration/plugin_file_not_found_error.rb +2 -0
  41. data/lib/tomo/configuration/plugins_registry/file_resolver.rb +3 -1
  42. data/lib/tomo/configuration/plugins_registry/gem_resolver.rb +4 -2
  43. data/lib/tomo/configuration/plugins_registry.rb +2 -0
  44. data/lib/tomo/configuration/project_not_found_error.rb +2 -0
  45. data/lib/tomo/configuration/role_based_task_filter.rb +2 -0
  46. data/lib/tomo/configuration/unknown_environment_error.rb +4 -2
  47. data/lib/tomo/configuration/unknown_plugin_error.rb +4 -2
  48. data/lib/tomo/configuration/unspecified_environment_error.rb +2 -0
  49. data/lib/tomo/configuration.rb +7 -5
  50. data/lib/tomo/console/key_reader.rb +4 -2
  51. data/lib/tomo/console/menu.rb +6 -4
  52. data/lib/tomo/console/non_interactive_error.rb +4 -2
  53. data/lib/tomo/console.rb +3 -1
  54. data/lib/tomo/error/suggestions.rb +3 -1
  55. data/lib/tomo/error.rb +2 -0
  56. data/lib/tomo/host.rb +4 -2
  57. data/lib/tomo/logger/tagged_io.rb +2 -0
  58. data/lib/tomo/logger.rb +2 -0
  59. data/lib/tomo/path.rb +2 -0
  60. data/lib/tomo/paths.rb +2 -0
  61. data/lib/tomo/plugin/bundler/helpers.rb +2 -0
  62. data/lib/tomo/plugin/bundler/tasks.rb +2 -0
  63. data/lib/tomo/plugin/bundler.rb +2 -0
  64. data/lib/tomo/plugin/core/helpers.rb +2 -0
  65. data/lib/tomo/plugin/core/tasks.rb +2 -0
  66. data/lib/tomo/plugin/core.rb +2 -0
  67. data/lib/tomo/plugin/env/tasks.rb +17 -6
  68. data/lib/tomo/plugin/env.rb +2 -0
  69. data/lib/tomo/plugin/git/helpers.rb +2 -0
  70. data/lib/tomo/plugin/git/tasks.rb +2 -0
  71. data/lib/tomo/plugin/git.rb +2 -0
  72. data/lib/tomo/plugin/nodenv/tasks.rb +2 -0
  73. data/lib/tomo/plugin/nodenv.rb +2 -0
  74. data/lib/tomo/plugin/puma/tasks.rb +2 -0
  75. data/lib/tomo/plugin/puma.rb +2 -0
  76. data/lib/tomo/plugin/rails/helpers.rb +2 -0
  77. data/lib/tomo/plugin/rails/tasks.rb +2 -0
  78. data/lib/tomo/plugin/rails.rb +2 -0
  79. data/lib/tomo/plugin/rbenv/tasks.rb +3 -1
  80. data/lib/tomo/plugin/rbenv.rb +2 -0
  81. data/lib/tomo/plugin/testing.rb +2 -0
  82. data/lib/tomo/plugin.rb +2 -0
  83. data/lib/tomo/plugin_dsl.rb +2 -0
  84. data/lib/tomo/remote.rb +5 -3
  85. data/lib/tomo/result.rb +3 -1
  86. data/lib/tomo/runtime/concurrent_ruby_load_error.rb +2 -0
  87. data/lib/tomo/runtime/concurrent_ruby_thread_pool.rb +2 -0
  88. data/lib/tomo/runtime/context.rb +2 -0
  89. data/lib/tomo/runtime/current.rb +2 -0
  90. data/lib/tomo/runtime/execution_plan.rb +4 -2
  91. data/lib/tomo/runtime/explanation.rb +3 -1
  92. data/lib/tomo/runtime/host_execution_step.rb +3 -1
  93. data/lib/tomo/runtime/inline_thread_pool.rb +2 -0
  94. data/lib/tomo/runtime/no_tasks_error.rb +2 -0
  95. data/lib/tomo/runtime/privileged_task.rb +2 -0
  96. data/lib/tomo/runtime/settings_interpolation.rb +3 -1
  97. data/lib/tomo/runtime/settings_required_error.rb +3 -1
  98. data/lib/tomo/runtime/task_aborted_error.rb +2 -0
  99. data/lib/tomo/runtime/task_runner.rb +5 -3
  100. data/lib/tomo/runtime/template_not_found_error.rb +2 -0
  101. data/lib/tomo/runtime/unknown_task_error.rb +3 -1
  102. data/lib/tomo/runtime.rb +8 -6
  103. data/lib/tomo/script.rb +2 -0
  104. data/lib/tomo/shell_builder.rb +2 -0
  105. data/lib/tomo/ssh/child_process.rb +4 -2
  106. data/lib/tomo/ssh/connection.rb +4 -2
  107. data/lib/tomo/ssh/connection_error.rb +2 -0
  108. data/lib/tomo/ssh/connection_validator.rb +8 -6
  109. data/lib/tomo/ssh/error.rb +2 -0
  110. data/lib/tomo/ssh/executable_error.rb +2 -0
  111. data/lib/tomo/ssh/options.rb +4 -2
  112. data/lib/tomo/ssh/permission_error.rb +2 -0
  113. data/lib/tomo/ssh/script_error.rb +2 -0
  114. data/lib/tomo/ssh/unknown_error.rb +2 -0
  115. data/lib/tomo/ssh/unsupported_version_error.rb +2 -0
  116. data/lib/tomo/ssh.rb +2 -0
  117. data/lib/tomo/task_api.rb +3 -1
  118. data/lib/tomo/task_library.rb +2 -0
  119. data/lib/tomo/templates/config.rb.erb +1 -4
  120. data/lib/tomo/testing/Dockerfile +1 -1
  121. data/lib/tomo/testing/cli_extensions.rb +2 -0
  122. data/lib/tomo/testing/cli_tester.rb +4 -2
  123. data/lib/tomo/testing/connection.rb +2 -0
  124. data/lib/tomo/testing/docker_image.rb +4 -2
  125. data/lib/tomo/testing/host_extensions.rb +3 -1
  126. data/lib/tomo/testing/local.rb +14 -12
  127. data/lib/tomo/testing/log_capturing.rb +2 -0
  128. data/lib/tomo/testing/mock_plugin_tester.rb +2 -0
  129. data/lib/tomo/testing/mocked_exec_error.rb +2 -0
  130. data/lib/tomo/testing/mocked_exit_error.rb +2 -0
  131. data/lib/tomo/testing/remote_extensions.rb +2 -0
  132. data/lib/tomo/testing/ssh_extensions.rb +2 -0
  133. data/lib/tomo/testing/systemctl.rb +1 -0
  134. data/lib/tomo/testing/ubuntu_setup.sh +3 -1
  135. data/lib/tomo/testing.rb +2 -0
  136. data/lib/tomo/version.rb +3 -1
  137. data/lib/tomo.rb +3 -1
  138. metadata +4 -4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Console
3
5
  class NonInteractiveError < Tomo::Error
@@ -5,8 +7,8 @@ module Tomo
5
7
 
6
8
  def to_console
7
9
  error = ""
8
- error << "#{operation_name} requires an interactive console."
9
- error << "\n\n#{seems_like_ci}" if ci_var
10
+ error += "#{operation_name} requires an interactive console."
11
+ error += "\n\n#{seems_like_ci}" if ci_var
10
12
  error
11
13
  end
12
14
 
data/lib/tomo/console.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
  require "io/console"
3
5
 
@@ -56,7 +58,7 @@ module Tomo
56
58
  private_constant :CI_VARS
57
59
 
58
60
  def ci?
59
- (env.keys & CI_VARS).any?
61
+ env.keys.intersect?(CI_VARS)
60
62
  end
61
63
 
62
64
  def assert_interactive
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Error
3
5
  class Suggestions
@@ -12,7 +14,7 @@ module Tomo
12
14
 
13
15
  def to_a
14
16
  @_suggestions ||= if defined?(DidYouMean::SpellChecker)
15
- checker = DidYouMean::SpellChecker.new(dictionary: dictionary)
17
+ checker = DidYouMean::SpellChecker.new(dictionary:)
16
18
  suggestions = checker.correct(word)
17
19
  suggestions || []
18
20
  else
data/lib/tomo/error.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Error < StandardError
3
5
  autoload :Suggestions, "tomo/error/suggestions"
data/lib/tomo/host.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Host
3
5
  PATTERN = /^(?:(\S+)@)?(\S*?)$/
@@ -10,7 +12,7 @@ module Tomo
10
12
  user, address = host.match(PATTERN).captures
11
13
  raise ArgumentError, "host cannot be blank" if address.empty?
12
14
 
13
- new(user: user, address: address, **kwargs)
15
+ new(user:, address:, **kwargs)
14
16
  end
15
17
 
16
18
  def initialize(address:, port: nil, log_prefix: nil, roles: nil, user: nil, privileged_user: "root")
@@ -31,7 +33,7 @@ module Tomo
31
33
 
32
34
  def to_s
33
35
  str = user ? "#{user}@#{address}" : address
34
- str << ":#{port}" unless port == 22
36
+ str += ":#{port}" unless port == 22
35
37
  str
36
38
  end
37
39
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Logger
3
5
  class TaggedIO
data/lib/tomo/logger.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
 
3
5
  module Tomo
data/lib/tomo/path.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "delegate"
2
4
  require "pathname"
3
5
 
data/lib/tomo/paths.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Paths
3
5
  def initialize(settings)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo::Plugin::Bundler
2
4
  module Helpers
3
5
  def bundle(*args, **opts)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "yaml"
2
4
 
3
5
  module Tomo::Plugin::Bundler
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "bundler/helpers"
2
4
  require_relative "bundler/tasks"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shellwords"
2
4
 
3
5
  module Tomo::Plugin::Core
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "json"
2
4
  require "securerandom"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "core/helpers"
2
4
  require_relative "core/tasks"
3
5
 
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "monitor"
4
+ require "securerandom"
2
5
 
3
6
  module Tomo::Plugin::Env
4
7
  class Tasks < Tomo::TaskLibrary # rubocop:disable Metrics/ClassLength
@@ -14,17 +17,25 @@ module Tomo::Plugin::Env
14
17
  update
15
18
  end
16
19
 
17
- def update
20
+ def update # rubocop:disable Metrics/MethodLength
18
21
  return if settings[:env_vars].empty?
19
22
 
20
23
  modify_env_file do |env|
21
24
  settings[:env_vars].each do |name, value|
22
- next if value == :prompt && contains_entry?(env, name)
25
+ case value
26
+ when :prompt
27
+ next if contains_entry?(env, name)
28
+
29
+ value = prompt_for(name, message: <<~MSG)
30
+ The remote host needs a value for the $#{name} environment variable.
31
+ Please provide a value at the prompt.
32
+ MSG
33
+ when :generate_secret
34
+ next if contains_entry?(env, name)
35
+
36
+ value = SecureRandom.hex(64)
37
+ end
23
38
 
24
- value = prompt_for(name, message: <<~MSG) if value == :prompt
25
- The remote host needs a value for the $#{name} environment variable.
26
- Please provide a value at the prompt.
27
- MSG
28
39
  replace_entry(env, name, value)
29
40
  end
30
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "env/tasks"
2
4
 
3
5
  module Tomo::Plugin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo::Plugin::Git
2
4
  module Helpers
3
5
  def git(*args, **opts)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shellwords"
2
4
  require "time"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "git/helpers"
2
4
  require_relative "git/tasks"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shellwords"
2
4
 
3
5
  module Tomo::Plugin::Nodenv
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "nodenv/tasks"
2
4
 
3
5
  module Tomo::Plugin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo::Plugin::Puma
2
4
  class Tasks < Tomo::TaskLibrary
3
5
  SystemdUnit = Struct.new(:name, :template, :path)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "puma/tasks"
2
4
 
3
5
  module Tomo::Plugin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo::Plugin::Rails
2
4
  module Helpers
3
5
  def rails(*args, **opts)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo::Plugin::Rails
2
4
  class Tasks < Tomo::TaskLibrary
3
5
  def assets_precompile
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "rails/helpers"
2
4
  require_relative "rails/tasks"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shellwords"
2
4
 
3
5
  module Tomo::Plugin::Rbenv
@@ -19,7 +21,7 @@ module Tomo::Plugin::Rbenv
19
21
 
20
22
  def modify_bashrc
21
23
  existing_rc = remote.capture("cat", paths.bashrc, raise_on_error: false)
22
- return if existing_rc.include?("rbenv init")
24
+ return if existing_rc.include?("rbenv init") && existing_rc.include?("$HOME/.rbenv/bin")
23
25
 
24
26
  remote.write(text: <<~BASHRC + existing_rc, to: paths.bashrc)
25
27
  if [ -d $HOME/.rbenv ]; then
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "rbenv/tasks"
2
4
 
3
5
  module Tomo::Plugin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  raise "The testing plugin cannot be used outside of unit tests" unless defined?(Tomo::Testing)
2
4
 
3
5
  module Tomo::Plugin
data/lib/tomo/plugin.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Plugin
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module PluginDSL
3
5
  def self.extended(mod)
data/lib/tomo/remote.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
 
3
5
  module Tomo
@@ -20,14 +22,14 @@ module Tomo
20
22
  end
21
23
 
22
24
  def attach(*command, default_chdir: nil, **command_opts)
23
- full_command = shell_builder.build(*command, default_chdir: default_chdir)
25
+ full_command = shell_builder.build(*command, default_chdir:)
24
26
  ssh.ssh_exec(Script.new(full_command, pty: true, **command_opts))
25
27
  end
26
28
 
27
29
  def run(*command, attach: false, default_chdir: nil, **command_opts)
28
- attach(*command, default_chdir: default_chdir, **command_opts) if attach
30
+ attach(*command, default_chdir:, **command_opts) if attach
29
31
 
30
- full_command = shell_builder.build(*command, default_chdir: default_chdir)
32
+ full_command = shell_builder.build(*command, default_chdir:)
31
33
  ssh.ssh_subprocess(Script.new(full_command, **command_opts))
32
34
  end
33
35
 
data/lib/tomo/result.rb CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Result
3
5
  def self.empty_success
4
- new(stdout: "", stderr: "", exit_status: 0)
6
+ new(stdout: +"", stderr: +"", exit_status: 0)
5
7
  end
6
8
 
7
9
  attr_reader :stdout, :stderr, :exit_status
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class ConcurrentRubyLoadError < Tomo::Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  concurrent_ver = "~> 1.1"
2
4
 
3
5
  begin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class Context
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  module Current
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
 
3
5
  module Tomo
@@ -35,7 +37,7 @@ module Tomo
35
37
  open_connections do |remotes|
36
38
  plan.each do |steps|
37
39
  steps.each do |step|
38
- step.execute(thread_pool: thread_pool, remotes: remotes)
40
+ step.execute(thread_pool:, remotes:)
39
41
  end
40
42
  thread_pool.run_to_completion
41
43
  end
@@ -76,7 +78,7 @@ module Tomo
76
78
  def build_plan(tasks, task_filter)
77
79
  tasks.each_with_object([]) do |task, result|
78
80
  steps = hosts.map do |host|
79
- HostExecutionStep.new(tasks: task, host: host, task_filter: task_filter, task_runner: task_runner)
81
+ HostExecutionStep.new(tasks: task, host:, task_filter:, task_runner:)
80
82
  end
81
83
  steps.reject!(&:empty?)
82
84
  result << steps unless steps.empty?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class Explanation
@@ -22,7 +24,7 @@ module Tomo
22
24
  indent = threads > 1 ? " = " : ""
23
25
  if threads > 1 && step.applicable_tasks.length > 1
24
26
  desc << "#{indent}IN SEQUENCE:"
25
- indent.sub!("=", " ")
27
+ indent = indent.sub("=", " ")
26
28
  end
27
29
  desc << step.explain.gsub(/^/, indent)
28
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class HostExecutionStep
@@ -25,7 +27,7 @@ module Tomo
25
27
 
26
28
  task_host = task.is_a?(PrivilegedTask) ? host.as_privileged : host
27
29
  remote = remotes[task_host]
28
- task_runner.run(task: task, remote: remote)
30
+ task_runner.run(task:, remote:)
29
31
  end
30
32
  end
31
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class InlineThreadPool
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class NoTasksError < Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  module PrivilegedTask
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class SettingsInterpolation
@@ -40,7 +42,7 @@ module Tomo
40
42
 
41
43
  def dump_settings(hash)
42
44
  key_len = hash.keys.map { |k| k.to_s.length }.max
43
- dump = "Settings: {\n"
45
+ dump = +"Settings: {\n"
44
46
  hash.to_a.sort_by(&:first).each do |key, value|
45
47
  justified_key = "#{key}:".ljust(key_len + 1)
46
48
  dump << " #{justified_key} #{value.inspect},\n"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class SettingsRequiredError < Tomo::Error
@@ -24,7 +26,7 @@ module Tomo
24
26
  return "a value for the #{yellow(settings.first.to_s)} setting." if settings.length == 1
25
27
 
26
28
  sentence = "values for these settings:\n\n "
27
- sentence << settings.map { |s| yellow(s.to_s) }.join("\n ")
29
+ sentence + settings.map { |s| yellow(s.to_s) }.join("\n ")
28
30
  end
29
31
  end
30
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class TaskAbortedError < Tomo::Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class TaskRunner
@@ -24,15 +26,15 @@ module Tomo
24
26
 
25
27
  def run(task:, remote:)
26
28
  validate_task!(task)
27
- Current.with(task: task, remote: remote) do
29
+ Current.with(task:, remote:) do
28
30
  Tomo.logger.task_start(task)
29
31
  tasks_by_name[task].call
30
32
  end
31
33
  end
32
34
 
33
35
  def connect(host)
34
- Current.with(host: host) do
35
- conn = SSH.connect(host: host, options: ssh_options)
36
+ Current.with(host:) do
37
+ conn = SSH.connect(host:, options: ssh_options)
36
38
  remote = Remote.new(conn, context, helper_modules)
37
39
  return remote unless block_given?
38
40
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class TemplateNotFoundError < Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Runtime
3
5
  class UnknownTaskError < Error
@@ -10,7 +12,7 @@ module Tomo
10
12
  ERROR
11
13
 
12
14
  sugg = spelling_suggestion || missing_plugin_suggestion
13
- error << sugg if sugg
15
+ error += sugg if sugg
14
16
  error
15
17
  end
16
18
 
data/lib/tomo/runtime.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "time"
2
4
 
3
5
  module Tomo
@@ -51,15 +53,15 @@ module Tomo
51
53
  end
52
54
 
53
55
  def run!(task, *args, privileged: false)
54
- task = task.dup.extend(PrivilegedTask) if privileged
55
- execution_plan_for([task], release: :current, args: args).execute
56
+ task = String.new(task).extend(PrivilegedTask) if privileged
57
+ execution_plan_for([task], release: :current, args:).execute
56
58
  end
57
59
 
58
60
  def execution_plan_for(tasks, release: :current, args: [])
59
61
  ExecutionPlan.new(
60
- tasks: tasks,
61
- hosts: hosts,
62
- task_filter: task_filter,
62
+ tasks:,
63
+ hosts:,
64
+ task_filter:,
63
65
  task_runner: new_task_runner(release, args)
64
66
  )
65
67
  end
@@ -74,7 +76,7 @@ module Tomo
74
76
  .merge(settings)
75
77
  .merge(run_args: args)
76
78
 
77
- TaskRunner.new(plugins_registry: plugins_registry, settings: run_settings)
79
+ TaskRunner.new(plugins_registry:, settings: run_settings)
78
80
  end
79
81
 
80
82
  def release_path_for(type)
data/lib/tomo/script.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Script
3
5
  attr_reader :script
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shellwords"
2
4
 
3
5
  module Tomo
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "open3"
2
4
  require "shellwords"
3
5
  require "stringio"
@@ -6,7 +8,7 @@ module Tomo
6
8
  module SSH
7
9
  class ChildProcess
8
10
  def self.execute(*command, on_data: ->(data) {})
9
- process = new(*command, on_data: on_data)
11
+ process = new(*command, on_data:)
10
12
  process.wait_for_exit
11
13
  process.result
12
14
  end
@@ -31,7 +33,7 @@ module Tomo
31
33
  end
32
34
 
33
35
  def result
34
- Result.new(exit_status: exit_status, stdout: stdout_buffer.string, stderr: stderr_buffer.string)
36
+ Result.new(exit_status:, stdout: stdout_buffer.string, stderr: stderr_buffer.string)
35
37
  end
36
38
 
37
39
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "fileutils"
2
4
  require "securerandom"
3
5
  require "tmpdir"
@@ -26,7 +28,7 @@ module Tomo
26
28
  end
27
29
 
28
30
  def ssh_subprocess(script, verbose: false)
29
- ssh_args = build_args(script, verbose: verbose)
31
+ ssh_args = build_args(script, verbose:)
30
32
  handle_data = ->(data) { logger.script_output(script, data) }
31
33
 
32
34
  logger.script_start(script)
@@ -62,7 +64,7 @@ module Tomo
62
64
  end
63
65
 
64
66
  def raise_run_error(script, ssh_args, result)
65
- ScriptError.raise_with(result.output, host: host, result: result, script: script, ssh_args: ssh_args)
67
+ ScriptError.raise_with(result.output, host:, result:, script:, ssh_args:)
66
68
  end
67
69
  end
68
70
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module SSH
3
5
  class ConnectionError < Error