Class: Cimas::Repository
- Inherits:
-
Object
- Object
- Cimas::Repository
- Defined in:
- lib/cimas/repository.rb
Overview
Value object over one repositories: entry in cimas.yml. Always built
with real attributes — unknown repo names are the caller's problem
(see Cli::Command#repo_by_name, which returns nil for them).
Instance Attribute Summary collapse
-
#binding ⇒ Object
readonly
Returns the value of attribute binding.
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#with_values ⇒ Object
readonly
Returns the value of attribute with_values.
Instance Method Summary collapse
-
#initialize(name, attributes = {}) ⇒ Repository
constructor
A new instance of Repository.
Constructor Details
#initialize(name, attributes = {}) ⇒ Repository
Returns a new instance of Repository.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cimas/repository.rb', line 8 def initialize(name, attributes = {}) @name = name @remote = attributes.fetch("remote", nil) @branch = attributes.fetch("branch", nil) # `files:` in cimas.yml is typically a Hash (`local_path: template_path`), # but some entries use `files: []` (a YAML empty Array) to signal # "no sync mappings — track the repo but don't touch any file." # Normalise both shapes to a Hash so downstream `#files.keys` works. raw_files = attributes.fetch("files", nil) @files = raw_files.is_a?(Array) ? {} : (raw_files || {}) # Hash#dig doesn't accept a block — the `{ {} }` in the prior # version was silently ignored, so absent `template: binding:` # yielded `nil`. Explicit `|| {}` keeps the type stable (always a # Hash); the sole consumer at `Cli::Command#sync` wraps it in an # OpenStruct where nil and {} behave identically, so this is a # correctness-not-behaviour fix. @binding = attributes.dig("template", "binding") || {} # `with:` is a per-repo top-level hash rendered into ERB templates # as `with_values`. Semantically intended for reusable-workflow # `with:` block inputs (per metanorma/ci#300 Gap 1) but the values # are just a Hash — usable for any parametric rendering. @with_values = attributes.fetch("with", {}) || {} end |
Instance Attribute Details
#binding ⇒ Object (readonly)
Returns the value of attribute binding.
6 7 8 |
# File 'lib/cimas/repository.rb', line 6 def binding @binding end |
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
6 7 8 |
# File 'lib/cimas/repository.rb', line 6 def branch @branch end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/cimas/repository.rb', line 6 def files @files end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cimas/repository.rb', line 6 def name @name end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
6 7 8 |
# File 'lib/cimas/repository.rb', line 6 def remote @remote end |
#with_values ⇒ Object (readonly)
Returns the value of attribute with_values.
6 7 8 |
# File 'lib/cimas/repository.rb', line 6 def with_values @with_values end |