Class: Ace::GitCommit::Models::CommitGroup
- Inherits:
-
Object
- Object
- Ace::GitCommit::Models::CommitGroup
- Defined in:
- lib/ace/git_commit/models/commit_group.rb
Overview
CommitGroup represents a group of files that share the same effective config
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#scope_name ⇒ Object
readonly
Returns the value of attribute scope_name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #add_file(file) ⇒ Object
- #config_signature ⇒ Object
- #file_count ⇒ Object
-
#initialize(scope_name:, source:, config:, files: []) ⇒ CommitGroup
constructor
A new instance of CommitGroup.
Constructor Details
#initialize(scope_name:, source:, config:, files: []) ⇒ CommitGroup
Returns a new instance of CommitGroup.
13 14 15 16 17 18 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 13 def initialize(scope_name:, source:, config:, files: []) @scope_name = scope_name @source = source @config = config || {} @files = Array(files) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 11 def config @config end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
11 12 13 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 11 def files @files end |
#scope_name ⇒ Object (readonly)
Returns the value of attribute scope_name.
11 12 13 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 11 def scope_name @scope_name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
11 12 13 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 11 def source @source end |
Class Method Details
.normalize_config(value) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 38 def self.normalize_config(value) case value when Hash value.keys.sort.each_with_object({}) do |key, acc| acc[key.to_s] = normalize_config(value[key]) end when Array value.map { |item| normalize_config(item) } else value end end |
.signature_for(config) ⇒ Object
33 34 35 36 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 33 def self.signature_for(config) normalized = normalize_config(config || {}) Digest::SHA256.hexdigest(JSON.generate(normalized)) end |
Instance Method Details
#add_file(file) ⇒ Object
20 21 22 23 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 20 def add_file(file) @files << file self end |
#config_signature ⇒ Object
29 30 31 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 29 def config_signature self.class.signature_for(@config) end |
#file_count ⇒ Object
25 26 27 |
# File 'lib/ace/git_commit/models/commit_group.rb', line 25 def file_count @files.length end |