Class: Workflow
- Inherits:
-
Object
- Object
- Workflow
- Extended by:
- Forwardable
- Defined in:
- lib/claws/workflow.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
-
#on ⇒ Object
Returns the value of attribute on.
-
#permissions ⇒ Object
Returns the value of attribute permissions.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #get_snippet(line, context: 3) ⇒ Object
- #ignores ⇒ Object
-
#initialize(raw_yaml) ⇒ Workflow
constructor
A new instance of Workflow.
- #line ⇒ Object
Constructor Details
#initialize(raw_yaml) ⇒ Workflow
Returns a new instance of Workflow.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/claws/workflow.rb', line 11 def initialize(raw_yaml) @workflow = YAMLWithLines.load(raw_yaml) # enriched metadata about the workflow as a whole @meta = {} normalize_dashes(@workflow) extract_normalized_on(@workflow) extract_normalized_jobs(@workflow) extract_normalized_name(@workflow) (@workflow) @raw_yaml = raw_yaml end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/claws/workflow.rb', line 7 def data @data end |
#jobs ⇒ Object
Returns the value of attribute jobs.
7 8 9 |
# File 'lib/claws/workflow.rb', line 7 def jobs @jobs end |
#meta ⇒ Object
Returns the value of attribute meta.
7 8 9 |
# File 'lib/claws/workflow.rb', line 7 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/claws/workflow.rb', line 7 def name @name end |
#on ⇒ Object
Returns the value of attribute on.
7 8 9 |
# File 'lib/claws/workflow.rb', line 7 def on @on end |
#permissions ⇒ Object
Returns the value of attribute permissions.
7 8 9 |
# File 'lib/claws/workflow.rb', line 7 def @permissions end |
Class Method Details
Instance Method Details
#[](key) ⇒ Object
34 35 36 37 38 |
# File 'lib/claws/workflow.rb', line 34 def [](key) return @on if key.to_s == "on" return @jobs if key.to_s == "jobs" return @name if key.to_s == "name" end |
#get_snippet(line, context: 3) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/claws/workflow.rb', line 40 def get_snippet(line, context: 3) buffer = "" (([0, line - context].max)..(line + context)).each do |i| next if @raw_yaml.lines[i].nil? buffer += if i + 1 == line ">>> #{@raw_yaml.lines[i]}" else @raw_yaml.lines[i] end end buffer end |
#ignores ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/claws/workflow.rb', line 55 def ignores ignores = {} @raw_yaml.lines.each_with_index do |line, i| i += 1 # line numbers are one indexed matches = line.match(/^\s*#.*ignore: (.*)/) next if matches.nil? matches = matches[1].split(",").map(&:strip) ignores[i] = matches end ignores end |
#line ⇒ Object
30 31 32 |
# File 'lib/claws/workflow.rb', line 30 def line @workflow.line end |