Module: Marso::FeaturePublish

Includes:
TextHelper
Included in:
Feature
Defined in:
lib/marso/domain/feature/feature_publish.rb

Instance Method Summary collapse

Methods included from TextHelper

#indented_colorized_text

Instance Method Details

#colorized_textObject



8
9
10
# File 'lib/marso/domain/feature/feature_publish.rb', line 8

def colorized_text
  self.text.colorize(self.color_theme)
end

#indented_colorized_details(include_mode = :none) ⇒ Object

include_mode => Symbol that defines what should be included in the

              feature's description. Possible values are:
:none - (Default) Only display the feature's description
:with_stories - Display the feature description as well as all its
                stories' description
:with_stories_scenarios - Display the feature description as well
                          as all its stories' description
                          (including their scenarios)
:with_scenarios - Display the feature description as well as all its
                  scenarios' description
:with_all - Display the feature description as well as both all its
            stories(including their scenarios) and scenarios descriptions


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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/marso/domain/feature/feature_publish.rb', line 24

def indented_colorized_details(include_mode=:none)

  get_scenario_ctxs_text_a = lambda { |f|
    f.scenario_contexts.map { |scn| scn.indented_colorized_text }
  }

  get_stories_text_a = lambda { |f|
    f.stories.map { |s| s.indented_colorized_text }
  }

  get_stories_scenarios_text_a = lambda { |f|
    f.stories.map { |s|
      [s.indented_colorized_text]
        .concat(s.scenario_contexts # add scenarios' text under each story
          .map { |scn| scn.indented_colorized_text })
        .join("\n") }
  }

  get_indented_colored_text = lambda { |f|
    case include_mode
    when :none
      f.indented_colorized_text
    when :with_scenarios
      [f.indented_colorized_text]
        .concat(get_scenario_ctxs_text_a.call(f)) # add scenarios' text under each feat
        .join("\n")
    when :with_stories
      [f.indented_colorized_text]
        .concat(get_stories_text_a.call(f)) # add stories' text under each feat
        .join("\n")
    when :with_stories_scenarios
      [f.indented_colorized_text]
        .concat(get_stories_scenarios_text_a.call(f)) # add stories' text under each feat
        .join("\n")
    when :with_all
      [f.indented_colorized_text]
        .concat(get_scenario_ctxs_text_a.call(f)) # add scenarios' text under each feat
        .concat(get_stories_scenarios_text_a.call(f)) # add stories' text under each feat
        .join("\n")
    else
      raise ArgumentError, ":#{include_mode} is not a valid argument. " +
      "Please choose one of the following:\n" +
      "- #{[:none, :with_scenarios, :with_stories, :with_stories_scenarios, :with_all].join('\n- ')}"
    end
  }

  return get_indented_colored_text.call(self)
end