Module: LightService::Generators::GeneratorUtils

Included in:
ActionGenerator, OrganizerGenerator
Defined in:
lib/generators/light_service/generator_utils.rb

Instance Method Summary collapse

Instance Method Details

#create_required_gen_vals_from(name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# 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) ⇒ Object



4
5
6
# File 'lib/generators/light_service/generator_utils.rb', line 4

def make_nested_dir(dir)
  FileUtils.mkdir_p(dir)
end

#must_gen_tests?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/generators/light_service/generator_utils.rb', line 24

def must_gen_tests?
  options.tests? && test_framework_supported?
end

#supported_test_frameworksObject



8
9
10
# File 'lib/generators/light_service/generator_utils.rb', line 8

def supported_test_frameworks
  i[rspec]
end

#test_frameworkObject

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



17
18
19
20
21
22
# 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?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/generators/light_service/generator_utils.rb', line 12

def test_framework_supported?
  supported_test_frameworks.include? test_framework
end