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 Attribute Summary collapse
-
#generic_path ⇒ Object
readonly
Generic path, in the sense of “if there are any entities of this kind to load, where are they?”.
Instance Method Summary
collapse
Constructor Details
#initialize(loader) ⇒ SmartPath
Creates SmartPath for the given loader (loader knows how to check for existence etc.)
61
62
63
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 61
def initialize(loader)
@loader = loader
end
|
Instance Attribute Details
#generic_path ⇒ Object
Generic path, in the sense of “if there are any entities of this kind to load, where are they?”
58
59
60
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 58
def generic_path
@generic_path
end
|
Instance Method Details
#effective_path(typed_name, start_index_in_name) ⇒ Object
Effective path is the generic path + the name part(s) + extension.
86
87
88
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 86
def effective_path(typed_name, start_index_in_name)
"#{File.join(generic_path, typed_name.name_parts)}#{extension}"
end
|
#fuzzy_matching? ⇒ Boolean
72
73
74
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 72
def fuzzy_matching?
false
end
|
#instantiator ⇒ Object
116
117
118
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 116
def instantiator
raise NotImplementedError.new
end
|
#lib_root? ⇒ Boolean
80
81
82
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 80
def lib_root?
@loader.lib_root?
end
|
#relative_path ⇒ Object
112
113
114
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 112
def relative_path
raise NotImplementedError.new
end
|
#root_path ⇒ Object
76
77
78
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 76
def root_path
@loader.path
end
|
#typed_name(type, name_authority, relative_path, module_name) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 90
def typed_name(type, name_authority, relative_path, module_name)
n = ''
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
108
109
110
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 108
def valid_name?(typed_name)
true
end
|
#valid_path?(path) ⇒ Boolean
104
105
106
|
# File 'lib/puppet/pops/loader/loader_paths.rb', line 104
def valid_path?(path)
path.end_with?(extension) && path.start_with?(generic_path)
end
|