Class: Boring::Ci::GithubAction::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/boring/ci/github_action/install/install_generator.rb

Constant Summary collapse

RUBY_VERSION_FILE =
".ruby-version"
DEFAULT_RUBY_VERSION =
".ruby-version"
DEFAULT_NODE_VERSION =
"14"
DEFAULT_REPOSITORY_NAME =
"boring_generators"

Instance Method Summary collapse

Instance Method Details

#add_github_actions_configurationObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/boring/ci/github_action/install/install_generator.rb', line 23

def add_github_actions_configuration
  @ruby_version = options[:ruby_version] ? options[:ruby_version] : DEFAULT_RUBY_VERSION
  @node_version = options[:node_version] ? options[:node_version] : DEFAULT_NODE_VERSION
  @repository_name = options[:repository_name] ? options[:repository_name] : DEFAULT_REPOSITORY_NAME

  template("ci.yml", ".github/workflows/ci.yml")

  if @ruby_version == DEFAULT_RUBY_VERSION && !ruby_version_file_exists?
    say "      WARNING: The action was configured to use the ruby version specified in the .ruby-version\n      file, but no such file was present. Either create an appropriate .ruby-version file, or\n      update .github/workflows/ci.yml to use an explicit ruby version.\n    WARNING\n  end\nend\n", :red

#ruby_version_file_exists?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/generators/boring/ci/github_action/install/install_generator.rb', line 39

def ruby_version_file_exists?
  Pathname.new(destination_root).join(RUBY_VERSION_FILE).exist?
end