Class: Redbreast::Command::Setup

Inherits:
Object
  • Object
show all
Includes:
Helper::General, Helper::HashHelper, Helper::Terminal
Defined in:
lib/redbreast/commands/setup.rb

Overview

Class for setting up the program

Constant Summary

Constants included from Helper::General

Helper::General::ESCAPE_KEYWORDS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper::HashHelper

#compact

Methods included from Helper::General

#app_name, #bundles, #clean_case_name, #clean_enum_name, #clean_variable_name, #config, #escape_keyword_if_needed, #escape_with_underscore_if_needed, #indent, #programming_language, #upper_camel_case

Methods included from Helper::Terminal

#prompt, #success

Constructor Details

#initialize(options = Commander::Command::Options.new) ⇒ Setup

Returns a new instance of Setup.



16
17
18
# File 'lib/redbreast/commands/setup.rb', line 16

def initialize(options = Commander::Command::Options.new)
  @options = options
end

Class Method Details

.init(options = Commander::Command::Options.new) ⇒ Object



12
13
14
# File 'lib/redbreast/commands/setup.rb', line 12

def self.init(options = Commander::Command::Options.new)
  new(options).call
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/redbreast/commands/setup.rb', line 20

def call
  app_name = app_name_prompt
  bundle_names = bundle_names_prompt().split(' ')
  bundles = bundle_names.map do |bundle|
    language = language_prompt(bundle)
    assets_types = assets_types_prompt(bundle)
    reference = bundle_reference(bundle, language)
    assets_search_path = assets_search_path_prompt(bundle)
    output_source_path_images = assets_types == 1 ? nil : images_sources_path_prompt(bundle, language)
    output_source_path_colors = assets_types.zero? ? nil : colors_sources_path_prompt(bundle, language)
    include_tests = create_tests_path_prompt?(bundle)
    output_test_path_images = assets_types != 1 && include_tests ? images_tests_path_prompt(bundle, language) : nil
    output_test_path_colors = assets_types != 0 && include_tests ? colors_tests_path_prompt(bundle, language) : nil
    fields = {
      language: language,
      name: bundle,
      reference: reference,
      assetsSearchPath: assets_search_path,
      outputSourcePathImages: output_source_path_images,
      outputSourcePathColors: output_source_path_colors,
      outputTestPathImages: output_test_path_images,
      outputTestPathColors: output_test_path_colors,
      testableImport: include_tests ? testable_import_prompt(bundle, app_name, language) : nil
    }
    compact fields
  end
  config = {
    bundles: bundles,
    app_name: app_name
  }
  Redbreast::IO::Config.write(config)
  success
end