Class: Puppet::Pops::Loader::LoaderPaths::SmartPath
- Inherits:
-
Object
- Object
- Puppet::Pops::Loader::LoaderPaths::SmartPath
show all
- Defined in:
- lib/puppet/pops/loader/loader_paths.rb
Overview
# DO NOT REMOVE YET. needed later? when there is the need to decamel a classname
def de_camel(fq_name)
fq_name.to_s.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
Instance Method Summary
collapse
Constructor Details
#initialize(loader) ⇒ SmartPath
Creates SmartPath for the given loader (loader knows how to check for existence etc.)
59
60
61
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 59
def initialize(loader)
@loader = loader
end
|
Instance Method Details
#effective_path(typed_name, start_index_in_name) ⇒ Object
Effective path is the generic path + the name part(s) + extension.
85
86
87
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 85
def effective_path(typed_name, start_index_in_name)
"#{File.join(generic_path, typed_name.name_parts)}#{extension}"
end
|
#fuzzy_matching? ⇒ Boolean
71
72
73
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 71
def fuzzy_matching?
false
end
|
#generic_path ⇒ Object
Generic path, in the sense of “if there are any entities of this kind to load, where are they?”
64
65
66
67
68
69
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 64
def generic_path
return @generic_path unless @generic_path.nil?
the_root_path = root_path @generic_path = (the_root_path.nil? ? relative_path : File.join(the_root_path, relative_path))
end
|
#instantiator ⇒ Object
115
116
117
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 115
def instantiator
raise NotImplementedError.new
end
|
#lib_root? ⇒ Boolean
79
80
81
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 79
def lib_root?
@loader.lib_root?
end
|
#relative_path ⇒ Object
111
112
113
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 111
def relative_path
raise NotImplementedError.new
end
|
#root_path ⇒ Object
75
76
77
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 75
def root_path
@loader.path
end
|
#typed_name(type, name_authority, relative_path, module_name) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 89
def typed_name(type, name_authority, relative_path, module_name)
n = ''.dup
unless extension.empty?
relative_path = relative_path[0..-(extension.length+1)]
end
relative_path.split('/').each do |segment|
n << '::' if n.size > 0
n << segment
end
TypedName.new(type, n, name_authority)
end
|
#valid_name?(typed_name) ⇒ Boolean
107
108
109
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 107
def valid_name?(typed_name)
true
end
|
#valid_path?(path) ⇒ Boolean
103
104
105
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 103
def valid_path?(path)
path.end_with?(extension) && path.start_with?(generic_path)
end
|