Class: Marso::Story

Inherits:
Object show all
Includes:
StoryLoad, StoryPublish
Defined in:
lib/marso/domain/story/story.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StoryPublish

#colorized_text, #indented_colorized_details

Methods included from TextHelper

#colorized_text, #indented_colorized_text

Methods included from StoryLoad

#load

Constructor Details

#initialize(description, ctx = {}) ⇒ Story

description (optional): Hash defined as follow

:id => Arbitrary number or string. Default is randomly generated
       (hex string (length 6))
:name => Story's name
:in_order_to => String that describes the fundamental story's business
                value
:as_a => String that describes the user(s)
:i => String that describes the feature that could deliver the story's
      business value(e.g. I want ... or I should ...)
:scenario_contexts => Array of all the scenario contexts that are part
                      of that story
:rootpath => Path to the folder that contain this current feature's file
             as well as its associated 'scenarios' and 'stories' folder
:status => Can only be set if :scenario_contexts is empty. Otherwise, it
           will be overidden by the status of :scenario_contexts


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
# File 'lib/marso/domain/story/story.rb', line 30

def initialize(description, ctx={})

  validate_arguments(description, ctx)

  @description = description.clone
  @ctx = ctx.clone

  @description[:scenario_contexts] = [] if description[:scenario_contexts].nil?
  @description[:id] = SecureRandom.hex(3) if description[:id].nil?
  @description[:rootpath] = File.dirname(caller[0]) if description[:rootpath].nil?

  @name = @description[:name]
  @fname = @description[:name].downcase.gsub(' ', '_')
  @rootpath = @description[:rootpath]
  @id = @description[:id]
  @scenario_contexts = @description[:scenario_contexts]

  if @scenario_contexts.empty? && !@description[:status].nil?
    @status = @description[:status]
  else
    @status = @scenario_contexts.status
  end

  @feature_id = ctx[:feature_id]
  @tree_position = @feature_id.nil? ? 0 : 1

  @header = get_header(@id, @status, @ctx, @description)
  @color_theme = get_color_theme(@status)
  @text = get_text(@header, @description)
end

Instance Attribute Details

#color_themeObject (readonly)

Returns the value of attribute color_theme.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def color_theme
  @color_theme
end

#ctxObject (readonly)

Returns the value of attribute ctx.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def ctx
  @ctx
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def description
  @description
end

#feature_idObject (readonly)

Returns the value of attribute feature_id.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def feature_id
  @feature_id
end

#fnameObject (readonly)

Returns the value of attribute fname.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def fname
  @fname
end

#headerObject (readonly)

Returns the value of attribute header.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def header
  @header
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def name
  @name
end

#rootpathObject (readonly)

Returns the value of attribute rootpath.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def rootpath
  @rootpath
end

#scenario_contextsObject (readonly)

Returns the value of attribute scenario_contexts.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def scenario_contexts
  @scenario_contexts
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def status
  @status
end

#textObject (readonly)

Returns the value of attribute text.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def text
  @text
end

#tree_positionObject (readonly)

Returns the value of attribute tree_position.



12
13
14
# File 'lib/marso/domain/story/story.rb', line 12

def tree_position
  @tree_position
end