Class: CIJoe::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/cijoe/config.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(command, parent = nil) ⇒ Config
Returns a new instance of Config.
7
8
9
10
|
# File 'lib/cijoe/config.rb', line 7
def initialize(command, parent = nil)
@command = command
@parent = parent
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(command, *args) ⇒ Object
12
13
14
|
# File 'lib/cijoe/config.rb', line 12
def method_missing(command, *args)
Config.new(command, self)
end
|
Class Method Details
.method_missing(command, *args) ⇒ Object
3
4
5
|
# File 'lib/cijoe/config.rb', line 3
def self.method_missing(command, *args)
new(command)
end
|
Instance Method Details
#config_string ⇒ Object
28
29
30
|
# File 'lib/cijoe/config.rb', line 28
def config_string
@parent ? "#{@parent.config_string}.#{@command}" : @command
end
|
#to_s ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/cijoe/config.rb', line 16
def to_s
git_command = "git config #{config_string}"
result = `#{git_command} 2>&1`.chomp
process_status = $?
if successful_command?(process_status) || config_command_with_empty_value?(result,process_status)
return result
else
raise "Error calling git config, is a recent version of git installed? Command: #{git_command}, Error: #{result}"
end
end
|