Class: Roro::Configurators::Configurator
- Inherits:
-
Object
- Object
- Roro::Configurators::Configurator
- Includes:
- Utilities
- Defined in:
- lib/roro/configurators/configurator.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#itinerary ⇒ Object
readonly
Returns the value of attribute itinerary.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
-
#structure ⇒ Object
readonly
Returns the value of attribute structure.
Instance Method Summary collapse
-
#accrete_story(story) ⇒ Object
def satisfy_dependencies @satisfier = DependencySatisfier.new @dependency_hash = @satisfier.satisfy_dependencies(manifest) end.
- #build_env ⇒ Object
- #choose_adventure ⇒ Object
-
#initialize(options = {}) ⇒ Configurator
constructor
A new instance of Configurator.
-
#itinerary_index(stage) ⇒ Object
def copy_stage_dummy(stage) location = Dir.pwd index = itinerary_index(stage).index(itinerary) test_dir = “#stack_parent_path(stage)/test” return unless File.exist?(test_dir) stage_dummy = “#test_dir/#index/dummy” generated = Dir.glob(“#location/*/”) dummies = Dir.glob(“#stage_dummy/*/”) dummies.each do |dummy| generated.select do |g| if dummy.split(stage_dummy).last.match?(g.split(Dir.pwd).last) if File.file?(g) FileUtils.cp_r(g, “#stage_dummy#gg.split(Dirg.split(Dir.pwd)g.split(Dir.pwd).last”) end end end end end.
- #override_environment_variables ⇒ Object
- #rollon ⇒ Object
- #validate_stack ⇒ Object
- #write_log ⇒ Object
- #write_story ⇒ Object
Methods included from Utilities
#adventure_name, #all_inflections, #build_paths, #children, #file_extension, #file_name, #read_yaml, #sanitize, #sentence_from, #sort_hash_deeply, #stack_is_adventure?, #stack_is_dotfile?, #stack_is_empty?, #stack_is_file?, #stack_is_ignored?, #stack_is_inflection?, #stack_is_inflection_stub?, #stack_is_itinerary_path?, #stack_is_nil?, #stack_is_node?, #stack_is_parent?, #stack_is_stack?, #stack_is_story?, #stack_is_story_path?, #stack_is_storyfile?, #stack_is_templates?, #stack_name, #stack_not_present?, #stack_parent, #stack_parent_path, #stack_stories, #stack_type, #stack_unpermitted?, #story_is_empty?, #story_name, #story_paths
Constructor Details
#initialize(options = {}) ⇒ Configurator
Returns a new instance of Configurator.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/roro/configurators/configurator.rb', line 13 def initialize( = {}) @options = ? : {} @stack = [:stack] || CatalogBuilder.build @validator = Validator.new(@stack) @adventure = AdventureChooser.new @builder = QuestionBuilder.new @structure = StructureBuilder.build @asker = QuestionAsker.new @writer = AdventureWriter.new @env = @structure[:env] @log = @structure end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
11 12 13 |
# File 'lib/roro/configurators/configurator.rb', line 11 def env @env end |
#itinerary ⇒ Object (readonly)
Returns the value of attribute itinerary.
11 12 13 |
# File 'lib/roro/configurators/configurator.rb', line 11 def itinerary @itinerary end |
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
11 12 13 |
# File 'lib/roro/configurators/configurator.rb', line 11 def manifest @manifest end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
11 12 13 |
# File 'lib/roro/configurators/configurator.rb', line 11 def stack @stack end |
#structure ⇒ Object (readonly)
Returns the value of attribute structure.
11 12 13 |
# File 'lib/roro/configurators/configurator.rb', line 11 def structure @structure end |
Instance Method Details
#accrete_story(story) ⇒ Object
def satisfy_dependencies
@satisfier = DependencySatisfier.new
@dependency_hash = @satisfier.satisfy_dependencies(manifest)
end
58 59 60 61 |
# File 'lib/roro/configurators/configurator.rb', line 58 def accrete_story(story) content = read_yaml(story)[:env] content.keys.each { |k| @structure[:env][k].merge!(content[k]) } if content end |
#build_env ⇒ Object
46 47 48 49 50 51 |
# File 'lib/roro/configurators/configurator.rb', line 46 def build_env manifest.each do |story| accrete_story(story) end override_environment_variables end |
#choose_adventure ⇒ Object
40 41 42 43 44 |
# File 'lib/roro/configurators/configurator.rb', line 40 def choose_adventure @adventure.build_itinerary(@stack) @itinerary = @adventure.itinerary @manifest = @adventure.manifest end |
#itinerary_index(stage) ⇒ Object
def copy_stage_dummy(stage)
location = Dir.pwd
index = itinerary_index(stage).index(itinerary)
test_dir = "#{stack_parent_path(stage)}/test"
return unless File.exist?(test_dir)
stage_dummy = "#{test_dir}/#{index}/dummy"
generated = Dir.glob("#{location}/**/*")
dummies = Dir.glob("#{stage_dummy}/**/*")
dummies.each do |dummy|
generated.select do |g|
if dummy.split(stage_dummy).last.match?(g.split(Dir.pwd).last)
if File.file?(g)
FileUtils.cp_r(g, "#{stage_dummy}#{g.split(Dir.pwd).last}")
end
end
end
end
end
90 91 92 93 94 95 96 |
# File 'lib/roro/configurators/configurator.rb', line 90 def itinerary_index(stage) itineraries = read_yaml("#{Roro.gem_root}/test/fixtures/matrixes/itineraries.yml") foo = itineraries.select! do |i| i.include?(stack_parent_path(stage.split(Roro::CLI.stacks).last)) end foo end |
#override_environment_variables ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/roro/configurators/configurator.rb', line 63 def override_environment_variables @structure[:env].each do |e, h| h.each do |k, v| answer = @asker.confirm_default(@builder.override(e, k, v), h) answer.eql?('') ? return : v[:value] = answer end end end |
#rollon ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/roro/configurators/configurator.rb', line 26 def rollon validate_stack choose_adventure # satisfy_dependencies build_env write_story # structure[:env] = structure[:env].merge(@dependency_hash) write_log end |
#validate_stack ⇒ Object
36 37 38 |
# File 'lib/roro/configurators/configurator.rb', line 36 def validate_stack @validator.validate(@stack) end |
#write_log ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/roro/configurators/configurator.rb', line 106 def write_log @log[:dependency_hash] = @dependency_hash @log[:itinerary] = @itinerary @log[:manifest] = @manifest @log[:stack] = @stack @log[:structure] = @structure @writer.write_log(@log) end |
#write_story ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/roro/configurators/configurator.rb', line 98 def write_story @manifest.each do |m| @structure[:itinerary] = @itinerary @writer.write(@structure, m) # copy_stage_dummy(m) if ENV['RORO_ENV'].eql?('test') end end |