Class: UpgradeTools::CLI::RubyVersion::Set

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/upgrade_tools/cli/ruby_version/set.rb

Constant Summary collapse

POST_CMD_MSG =
<<~MSG
  Done! Make sure to:
    - Install the new Ruby version
    - Run `bundle install`
MSG
ERR_NOT_RUBY_VERSION =
'Error: FILENAME must be a path to a `.ruby-version` file'
ERR_INVALID_VERSION =
'Error: NEW_VERSION must be a string in Semver format MAJ.MIN[.PATCH]'

Instance Method Summary collapse

Instance Method Details

#call(new_version:, filename:) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/upgrade_tools/cli/ruby_version/set.rb', line 26

def call(new_version:, filename:, **)
  assert_ruby_version!(filename)
  assert_file_exists!(filename)
  assert_version!(new_version)

  File.open(filename, 'w') { it.puts(new_version) }

  puts POST_CMD_MSG
end