Class: GithubActions::Workflow
- Inherits:
-
Object
- Object
- GithubActions::Workflow
- Defined in:
- lib/tasks/github_actions/github_actions/workflow.rb
Overview
Github Actions workflow
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#on ⇒ Object
readonly
Returns the value of attribute on.
Class Method Summary collapse
-
.read ⇒ Array<GithubActions::Workflow>
load all defined workflows from all YAML files.
Instance Method Summary collapse
-
#initialize(file) ⇒ Workflow
constructor
load the workflow from an YAML file.
Constructor Details
#initialize(file) ⇒ Workflow
load the workflow from an YAML file
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 39 def initialize(file) @file = file yml = YAML.load_file(file) @name = yml["name"] # "on" is autoconverted to Boolean "true" for this line # on: [push, pull_request] # see https://medium.com/@lefloh/lessons-learned-about-yaml-and-norway-13ba26df680 @on = yml[true] @jobs = yml["jobs"].map do |name, job| Job.new(name, job, self) end end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
27 28 29 |
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27 def file @file end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
27 28 29 |
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27 def jobs @jobs end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27 def name @name end |
#on ⇒ Object (readonly)
Returns the value of attribute on.
27 28 29 |
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27 def on @on end |
Class Method Details
.read ⇒ Array<GithubActions::Workflow>
load all defined workflows from all YAML files
31 32 33 34 35 |
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 31 def self.read Dir[".github/workflows/*.{yml,yaml}"].map do |file| new(file) end end |