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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7be159189aa32ca0143ab318466b1b0e8b8c9f16940eb410d9ca5119ac75dcc9
4
- data.tar.gz: 5c6a16311a72ccc75b79ae06a62b3fd83a8d0b7f47382b167e9a2866efd1a5c2
3
+ metadata.gz: 818e5cca74aa96ed436ea031e78780f927b07fdbdfd9cf43a52b35ddca393a48
4
+ data.tar.gz: cfacd1ee7b6d7bd0748c55493f7b3e0e2d1aedb022ff095b406bfaec85129254
5
5
  SHA512:
6
- metadata.gz: 6cd5a644af7d6303051c6ae903ff3e35206005629e23df3211303d28136d0547bd094719ddb99ceb84f57470cfe8f6197b33ceeb416b323c20d202e97aca67ee
7
- data.tar.gz: 508a44c49b78be4264bbb6d5b0ee011140f6cca91456a28b7e89786c98a9b4225a7099a7ad61667c8051b575a3a9484ceae4dd684eae3784e4cc5bf9a0b56629
6
+ metadata.gz: ad640825bf0973ef78e3a29d79290487f1a7fa73550fc40e26bb464df1438bb66d8659035588f3219a9661ad7be5aafbd43e28e0cf62e95a8977fafa68a210fc
7
+ data.tar.gz: d329fb4f7bfa764532f453f9cadd92ae83060503de15ba97a235eeec0ce47faa1e520b6113622bebc63a00b93822ea0de662a247117554fba0d478e11baf8ba9
data/exe/tomo CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "tomo"
4
5
  Tomo::CLI.new.call(ARGV)
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class Command
4
6
  class << self
5
7
  def arg(spec, values: [])
6
- parser.arg(spec, values: values)
8
+ parser.arg(spec, values:)
7
9
  end
8
10
 
9
11
  def option(key, spec, desc=nil, values: [], &block)
10
- parser.option(key, spec, desc, values: values, &block)
12
+ parser.option(key, spec, desc, values:, &block)
11
13
  end
12
14
 
13
15
  def after_parse(context_method_name)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  module CommonOptions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class Completions
@@ -35,7 +37,7 @@ module Tomo
35
37
 
36
38
  def all_candidates(rules, prefix_args, state)
37
39
  rules.flat_map do |rule|
38
- rule.candidates(*prefix_args, literal: literal, state: state)
40
+ rule.candidates(*prefix_args, literal:, state:)
39
41
  end
40
42
  end
41
43
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  module DeployOptions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class Error < ::Tomo::Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class InterruptedError < Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class Options
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
 
3
5
  module Tomo
@@ -46,7 +48,7 @@ module Tomo
46
48
  attr_reader :rules, :usage, :after_parse_methods
47
49
 
48
50
  def evaluate(argv, state, literal:)
49
- RulesEvaluator.evaluate(rules: rules.to_a, argv: argv, state: state, literal: literal)
51
+ RulesEvaluator.evaluate(rules: rules.to_a, argv:, state:, literal:)
50
52
  end
51
53
 
52
54
  def check_required_rules(state)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  module ProjectOptions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tomo::CLI::Rules
2
4
  class Argument
3
5
  def initialize(label, values_proc:, multiple: false, required: false)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tomo::CLI::Rules
2
4
  class Switch
3
5
  def initialize(key, *switches, callback_proc:, required: false, &convert_proc)
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tomo::CLI::Rules
2
4
  class ValueSwitch < Switch
3
5
  include Tomo::Colors
4
6
 
5
7
  def initialize(key, *switches, values_proc:, callback_proc:)
6
- super(key, *switches, callback_proc: callback_proc)
8
+ super(key, *switches, callback_proc:)
7
9
 
8
10
  @values_proc = values_proc
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class Rules
@@ -51,29 +53,29 @@ module Tomo
51
53
  attr_reader :rules
52
54
 
53
55
  def optional_arg_rule(spec, values_proc)
54
- Rules::Argument.new(spec, values_proc: values_proc, required: false, multiple: false)
56
+ Rules::Argument.new(spec, values_proc:, required: false, multiple: false)
55
57
  end
56
58
 
57
59
  def required_arg_rule(spec, values_proc)
58
- Rules::Argument.new(spec, values_proc: values_proc, required: true, multiple: false)
60
+ Rules::Argument.new(spec, values_proc:, required: true, multiple: false)
59
61
  end
60
62
 
61
63
  def mutiple_optional_args_rule(spec, values_proc)
62
- Rules::Argument.new(spec, multiple: true, values_proc: values_proc)
64
+ Rules::Argument.new(spec, multiple: true, values_proc:)
63
65
  end
64
66
 
65
67
  def on_off_switch_rule(key, name, _values_proc, callback_proc)
66
- Rules::Switch.new(key, "--#{name}", "--no-#{name}", callback_proc: callback_proc) do |arg|
68
+ Rules::Switch.new(key, "--#{name}", "--no-#{name}", callback_proc:) do |arg|
67
69
  arg == "--#{name}"
68
70
  end
69
71
  end
70
72
 
71
73
  def basic_switch_rule(key, *switches, _values_proc, callback_proc)
72
- Rules::Switch.new(key, *switches, callback_proc: callback_proc)
74
+ Rules::Switch.new(key, *switches, callback_proc:)
73
75
  end
74
76
 
75
77
  def value_switch_rule(key, *switches, values_proc, callback_proc)
76
- Rules::ValueSwitch.new(key, *switches, values_proc: values_proc, callback_proc: callback_proc)
78
+ Rules::ValueSwitch.new(key, *switches, values_proc:, callback_proc:)
77
79
  end
78
80
  end
79
81
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class RulesEvaluator
@@ -10,7 +12,7 @@ module Tomo
10
12
  @argv = argv.dup
11
13
  @state = state
12
14
  @literal = literal
13
- @completions = completions || Completions.new(literal: literal)
15
+ @completions = completions || Completions.new(literal:)
14
16
  end
15
17
 
16
18
  def call
@@ -18,7 +20,7 @@ module Tomo
18
20
  complete_if_needed(remaining_rules, *argv) if argv.length == 1
19
21
  rule, matched_args = match_next_rule
20
22
  complete_if_needed([rule], *matched_args) if argv.empty?
21
- rule.process(*matched_args, state: state)
23
+ rule.process(*matched_args, state:)
22
24
  state.processed_rule(rule)
23
25
  end
24
26
  end
@@ -29,7 +31,7 @@ module Tomo
29
31
 
30
32
  def match_next_rule
31
33
  matched_rule, length = remaining_rules.find do |rule|
32
- matching_length = rule.match(argv.first, literal: literal)
34
+ matching_length = rule.match(argv.first, literal:)
33
35
  break [rule, matching_length] if matching_length
34
36
  end
35
37
  raise_unrecognized_args if matched_rule.nil?
@@ -41,7 +43,7 @@ module Tomo
41
43
  def complete_if_needed(matched_rules, *matched_args)
42
44
  return unless Completions.active?
43
45
 
44
- completions.print_completions_and_exit(matched_rules, *matched_args, state: state)
46
+ completions.print_completions_and_exit(matched_rules, *matched_args, state:)
45
47
  end
46
48
 
47
49
  def remaining_rules
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class State
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  class Usage
data/lib/tomo/cli.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class CLI
3
5
  autoload :Command, "tomo/cli/command"
data/lib/tomo/colors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Colors
3
5
  ANSI_CODES = {
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class CompletionScript
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Default < CLI::Command
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Deploy < CLI::Command
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Help
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "erb"
2
4
  require "fileutils"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Run < CLI::Command
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Setup < CLI::Command
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Tasks < CLI::Command
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  class Version < CLI::Command
data/lib/tomo/commands.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  module Commands
3
5
  autoload :CompletionScript, "tomo/commands/completion_script"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -7,7 +9,7 @@ module Tomo
7
9
  end
8
10
 
9
11
  def run(task, privileged: false)
10
- task.extend(Runtime::PrivilegedTask) if privileged
12
+ task = String.new(task).extend(Runtime::PrivilegedTask) if privileged
11
13
  @batch << task
12
14
  self
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -18,19 +20,19 @@ module Tomo
18
20
  self
19
21
  end
20
22
 
21
- def environment(name, &block)
23
+ def environment(name, &)
22
24
  environment = @config.environments[name.to_s] ||= Environment.new
23
- EnvironmentBlock.new(environment).instance_eval(&block)
25
+ EnvironmentBlock.new(environment).instance_eval(&)
24
26
  self
25
27
  end
26
28
 
27
- def deploy(&block)
28
- TasksBlock.new(@config.deploy_tasks).instance_eval(&block)
29
+ def deploy(&)
30
+ TasksBlock.new(@config.deploy_tasks).instance_eval(&)
29
31
  self
30
32
  end
31
33
 
32
- def setup(&block)
33
- TasksBlock.new(@config.setup_tasks).instance_eval(&block)
34
+ def setup(&)
35
+ TasksBlock.new(@config.setup_tasks).instance_eval(&)
34
36
  self
35
37
  end
36
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -55,7 +57,7 @@ module Tomo
55
57
  last = [dsl_lines.length, error_line_no + 1].min
56
58
  width = last.to_s.length
57
59
 
58
- (first..last).each_with_object("") do |line_no, result|
60
+ (first..last).each_with_object(+"") do |line_no, result|
59
61
  line = dsl_lines[line_no - 1]
60
62
  line_no_prefix = line_no.to_s.rjust(width)
61
63
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -10,10 +12,10 @@ module Tomo
10
12
  def host(address, port: 22, roles: [], log_prefix: nil, privileged_user: "root")
11
13
  @config.hosts << Host.parse(
12
14
  address,
13
- privileged_user: privileged_user,
14
- port: port,
15
- roles: roles,
16
- log_prefix: log_prefix
15
+ privileged_user:,
16
+ port:,
17
+ roles:,
18
+ log_prefix:
17
19
  )
18
20
  self
19
21
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -6,15 +8,15 @@ module Tomo
6
8
  @tasks = tasks
7
9
  end
8
10
 
9
- def batch(&block)
11
+ def batch(&)
10
12
  batch = []
11
- BatchBlock.new(batch).instance_eval(&block)
13
+ BatchBlock.new(batch).instance_eval(&)
12
14
  @tasks << batch unless batch.empty?
13
15
  self
14
16
  end
15
17
 
16
18
  def run(task, privileged: false)
17
- task.extend(Runtime::PrivilegedTask) if privileged
19
+ task = String.new(task).extend(Runtime::PrivilegedTask) if privileged
18
20
  @tasks << task
19
21
  self
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  module DSL
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class Environment
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class Glob
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class PluginFileNotFoundError < Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class PluginsRegistry::FileResolver
@@ -25,7 +27,7 @@ module Tomo
25
27
  attr_reader :path
26
28
 
27
29
  def raise_file_not_found(path)
28
- PluginFileNotFoundError.raise_with(path: path)
30
+ PluginFileNotFoundError.raise_with(path:)
29
31
  end
30
32
 
31
33
  def define_anonymous_plugin_class
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class PluginsRegistry::GemResolver
4
- PLUGIN_PREFIX = "tomo/plugin".freeze
6
+ PLUGIN_PREFIX = "tomo/plugin"
5
7
  private_constant :PLUGIN_PREFIX
6
8
 
7
9
  def self.resolve(name)
@@ -47,7 +49,7 @@ module Tomo
47
49
  def raise_unknown_plugin_error(error)
48
50
  UnknownPluginError.raise_with(
49
51
  error.message,
50
- name: name,
52
+ name:,
51
53
  gem_name: "#{PLUGIN_PREFIX}/#{name}".tr("/", "-"),
52
54
  known_plugins: scan_for_plugins
53
55
  )
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class PluginsRegistry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class ProjectNotFoundError < Tomo::Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class RoleBasedTaskFilter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class UnknownEnvironmentError < Tomo::Error
@@ -23,10 +25,10 @@ module Tomo
23
25
  ERROR
24
26
 
25
27
  if suggestions.any?
26
- error << suggestions.to_console
28
+ error + suggestions.to_console
27
29
  else
28
30
  envs = known_environments.map { |env| blue(" #{env}") }
29
- error << <<~ENVS
31
+ error + <<~ENVS
30
32
 
31
33
  The following environments are available:
32
34
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class UnknownPluginError < Tomo::Error
@@ -9,9 +11,9 @@ module Tomo
9
11
  ERROR
10
12
 
11
13
  sugg = Error::Suggestions.new(dictionary: known_plugins, word: name)
12
- error << sugg.to_console if sugg.any?
14
+ error += sugg.to_console if sugg.any?
13
15
 
14
- error << gem_suggestion
16
+ error + gem_suggestion
15
17
  end
16
18
 
17
19
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  class UnspecifiedEnvironmentError < Tomo::Error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tomo
2
4
  class Configuration
3
5
  autoload :DSL, "tomo/configuration/dsl"
@@ -12,7 +14,7 @@ module Tomo
12
14
  autoload :UnspecifiedEnvironmentError, "tomo/configuration/unspecified_environment_error"
13
15
 
14
16
  def self.from_config_rb(path=DEFAULT_CONFIG_PATH)
15
- ProjectNotFoundError.raise_with(path: path) unless File.file?(path)
17
+ ProjectNotFoundError.raise_with(path:) unless File.file?(path)
16
18
  Tomo.logger.debug("Loading configuration from #{path.inspect}")
17
19
  config_rb = File.read(path)
18
20
 
@@ -51,12 +53,12 @@ module Tomo
51
53
  plugins_registry = register_plugins
52
54
 
53
55
  Runtime.new(
54
- deploy_tasks: deploy_tasks,
55
- setup_tasks: setup_tasks,
56
- plugins_registry: plugins_registry,
56
+ deploy_tasks:,
57
+ setup_tasks:,
58
+ plugins_registry:,
57
59
  hosts: add_log_prefixes(hosts),
58
60
  settings: { tomo_config_file_path: path }.merge(settings),
59
- task_filter: task_filter
61
+ task_filter:
60
62
  )
61
63
  end
62
64
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
  require "io/console"
3
5
  require "time"
@@ -8,7 +10,7 @@ module Tomo
8
10
  extend Forwardable
9
11
 
10
12
  def initialize(input=$stdin)
11
- @buffer = ""
13
+ @buffer = +""
12
14
  @input = input
13
15
  end
14
16
 
@@ -35,7 +37,7 @@ module Tomo
35
37
  end
36
38
 
37
39
  def read_chars_nonblock
38
- chars = ""
40
+ chars = +""
39
41
  loop do
40
42
  next_char = raw { read_nonblock(1) }
41
43
  break if next_char.nil?
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
  require "io/console"
3
5
 
4
6
  module Tomo
5
7
  class Console
6
8
  class Menu
7
- ARROW_UP = "\e[A".freeze
8
- ARROW_DOWN = "\e[B".freeze
9
- RETURN = "\r".freeze
10
- ENTER = "\n".freeze
9
+ ARROW_UP = "\e[A"
10
+ ARROW_DOWN = "\e[B"
11
+ RETURN = "\r"
12
+ ENTER = "\n"
11
13
 
12
14
  extend Forwardable
13
15
  include Colors