Class: ForemanTemplates::Action
- Inherits:
-
Object
- Object
- ForemanTemplates::Action
show all
- Defined in:
- app/services/foreman_templates/action.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args = {}) ⇒ Action
Returns a new instance of Action.
21
22
23
|
# File 'app/services/foreman_templates/action.rb', line 21
def initialize(args = {})
assign_attributes args
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
9
10
11
12
13
14
15
|
# File 'app/services/foreman_templates/action.rb', line 9
def method_missing(method, *args, &block)
if self.class.setting_overrides.include?(method)
instance_variable_get("@#{method}")
else
super
end
end
|
Class Method Details
.setting_overrides ⇒ Object
5
6
7
|
# File 'app/services/foreman_templates/action.rb', line 5
def self.setting_overrides
%i(verbose prefix dirname filter repo negate branch)
end
|
Instance Method Details
#get_absolute_repo_path ⇒ Object
40
41
42
|
# File 'app/services/foreman_templates/action.rb', line 40
def get_absolute_repo_path
File.expand_path(@repo)
end
|
#get_default_branch(repo) ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'app/services/foreman_templates/action.rb', line 25
def get_default_branch(repo)
branch_names = repo.branches.map(&:name).uniq
target = SETTINGS[:version].tag == 'develop' ? 'develop' : "#{SETTINGS[:version].short}-stable"
return target if branch_names.include?(target)
nil
end
|
#git_repo? ⇒ Boolean
36
37
38
|
# File 'app/services/foreman_templates/action.rb', line 36
def git_repo?
@repo.start_with?('http://', 'https://', 'git://', 'ssh://', 'git+ssh://', 'ssh+git://')
end
|
#repond_to_missing?(method, include_private = false) ⇒ Boolean
17
18
19
|
# File 'app/services/foreman_templates/action.rb', line 17
def repond_to_missing?(method, include_private = false)
self.class.setting_overrides.include?(method)
end
|
#verify_path!(path) ⇒ Object
44
45
46
|
# File 'app/services/foreman_templates/action.rb', line 44
def verify_path!(path)
raise "Using file-based synchronization, but couldn't find #{path}" unless Dir.exist?(path)
end
|