Class: Roro::Configurators::AdventureChooser

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/roro/configurators/adventure_chooser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#initializeAdventureChooser

Returns a new instance of AdventureChooser.



11
12
13
14
15
# File 'lib/roro/configurators/adventure_chooser.rb', line 11

def initialize
  @asker     = AdventurePicker.new
  @itinerary = []
  @stack     = Roro::CLI.stacks
end

Instance Attribute Details

#itineraryObject (readonly)

Returns the value of attribute itinerary.



9
10
11
# File 'lib/roro/configurators/adventure_chooser.rb', line 9

def itinerary
  @itinerary
end

#manifestObject (readonly)

Returns the value of attribute manifest.



9
10
11
# File 'lib/roro/configurators/adventure_chooser.rb', line 9

def manifest
  @manifest
end

#stackObject (readonly)

Returns the value of attribute stack.



9
10
11
# File 'lib/roro/configurators/adventure_chooser.rb', line 9

def stack
  @stack
end

Instance Method Details

#build_itinerary(stack = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/roro/configurators/adventure_chooser.rb', line 17

def build_itinerary(stack=nil)
  @manifest ||= []
  stack ||= @stack
  case stack_type(stack)
  when :storyfile
    @manifest << stack
  when :story
    @itinerary << stack.split("#{Roro::CLI.stacks}/").last
    @manifest += stack_stories(stack)
  when :stack
    @manifest += stack_stories(stack)
    children(stack).each { |c| build_itinerary(c) }
  when :inflection_stub
    children(stack).each { |c| build_itinerary(c) }
  when :inflection
    child = choose_adventure(stack)
    build_itinerary(child)
  end
  @manifest.uniq!
  @itinerary.uniq!
end

#choose_adventure(inflection) ⇒ Object



44
45
46
# File 'lib/roro/configurators/adventure_chooser.rb', line 44

def choose_adventure(inflection)
  @asker.choose_adventure(inflection)
end

#stack_is_alias?(catalog) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/roro/configurators/adventure_chooser.rb', line 39

def stack_is_alias?(catalog)
  stack_is_storyfile?(catalog) &&
    !read_yaml(catalog)[:aliased_to].nil?
end