module LightService::Generators::GeneratorUtils

Public Instance Methods

create_required_gen_vals_from(name) click to toggle source
# File lib/generators/light_service/generator_utils.rb, line 28
def create_required_gen_vals_from(name)
  path_parts = name.underscore.split('/')

  {
    :path_parts => path_parts,
    :file_path => path_parts.reverse.drop(1).reverse,
    :module_path => path_parts.reverse.drop(1).reverse.join('/').classify,
    :class_name => path_parts.last.classify,
    :file_name => "#{path_parts.last}.rb",
    :spec_file_name => "#{path_parts.last}_spec.rb",
    :full_class_name => name.classify
  }
end
make_nested_dir(dir) click to toggle source
# File lib/generators/light_service/generator_utils.rb, line 4
def make_nested_dir(dir)
  FileUtils.mkdir_p(dir)
end
must_gen_tests?() click to toggle source
# File lib/generators/light_service/generator_utils.rb, line 24
def must_gen_tests?
  options.tests? && test_framework_supported?
end
supported_test_frameworks() click to toggle source
# File lib/generators/light_service/generator_utils.rb, line 8
def supported_test_frameworks
  %i[rspec]
end
test_framework() click to toggle source

Don’t know a better way to get to this value, unfortunately.

# File lib/generators/light_service/generator_utils.rb, line 17
def test_framework
  # Rails.application.config.generators.options[:rails][:test_framework]
  # When/if Minitest is supported, this will need to be updated to detect
  # the selected test framework, and switch templates accordingly
  :rspec
end
test_framework_supported?() click to toggle source
# File lib/generators/light_service/generator_utils.rb, line 12
def test_framework_supported?
  supported_test_frameworks.include? test_framework
end