Class: GitCommands::Aggregator
- Inherits:
-
Object
- Object
- GitCommands::Aggregator
show all
- Defined in:
- lib/git_commands/aggregator.rb
Defined Under Namespace
Classes: InvalidPatternError
Constant Summary
collapse
- PATTERN =
ENV.fetch("AGGREGATE_PATTERN") { "release/<timestamp>" }
- NAME =
ENV["AGGREGATE_NAME"]
Instance Method Summary
collapse
Constructor Details
#initialize(name: NAME, pattern: PATTERN) ⇒ Aggregator
Returns a new instance of Aggregator.
8
9
10
11
12
|
# File 'lib/git_commands/aggregator.rb', line 8
def initialize(name: NAME, pattern: PATTERN)
@name = name
@pattern = check_pattern(pattern)
define_methods
end
|
Instance Method Details
#call ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/git_commands/aggregator.rb', line 18
def call
return @name if @name
@pattern.gsub(/<[\w_]+>/) do |part|
msg = part.gsub(/<|>/, "")
send(msg)
end
end
|
#define_methods ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/git_commands/aggregator.rb', line 35
def define_methods
pattern_methods.each do |name|
define_singleton_method(name) do
ENV.fetch(name.upcase) { "" }
end
end
end
|
#timestamp ⇒ Object
14
15
16
|
# File 'lib/git_commands/aggregator.rb', line 14
def timestamp
@timestamp ||= Time.new.strftime("%Y%m%d")
end
|