Class: Cloudruler::Ruler
- Inherits:
-
Object
show all
- Defined in:
- lib/cloudruler/ruler.rb,
lib/cloudruler/ruler/content.rb,
lib/cloudruler/ruler/content/base.rb,
lib/cloudruler/ruler/content/outputs.rb,
lib/cloudruler/ruler/content/mappings.rb,
lib/cloudruler/ruler/content/metadata.rb,
lib/cloudruler/ruler/content/resources.rb,
lib/cloudruler/ruler/content/transform.rb,
lib/cloudruler/ruler/content/conditions.rb,
lib/cloudruler/ruler/content/parameters.rb
Defined Under Namespace
Classes: Content, EvalContext
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Ruler
Returns a new instance of Ruler.
7
8
9
|
# File 'lib/cloudruler/ruler.rb', line 7
def initialize(path)
@path = path
end
|
Instance Method Details
#erb ⇒ Object
21
22
23
|
# File 'lib/cloudruler/ruler.rb', line 21
def erb
@erb ||= ERB.new(File.read(@path))
end
|
#ext ⇒ Object
25
26
27
|
# File 'lib/cloudruler/ruler.rb', line 25
def ext
@ext ||= File.extname(@path.sub(/\.erb\z/, '')).sub('.', '')
end
|
#json? ⇒ Boolean
33
34
35
|
# File 'lib/cloudruler/ruler.rb', line 33
def json?
ext == 'json'
end
|
#name ⇒ Object
17
18
19
|
# File 'lib/cloudruler/ruler.rb', line 17
def name
@name ||= File.basename(@path).sub(/(\A[^\.]+).*/, '\1').to_sym
end
|
#resolve(options, &block) ⇒ Object
11
12
13
14
15
|
# File 'lib/cloudruler/ruler.rb', line 11
def resolve(options, &block)
context = EvalContext.new
context.instance_eval(&block)
Content.parse(self, context.result(self), options)
end
|
#yaml? ⇒ Boolean
29
30
31
|
# File 'lib/cloudruler/ruler.rb', line 29
def yaml?
%w(yml yaml).include?(ext)
end
|