Module: PoolParty::ResourcingDsl

Included in:
PoolParty::Resources::Resource
Defined in:
lib/poolparty/modules/resourcing_dsl.rb

Instance Method Summary collapse

Instance Method Details

#absentObject



21
22
23
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 21

def absent
  :remove
end

#cancel(*args) ⇒ Object



38
39
40
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 38

def cancel(*args)
  dsl_options[:cancelled] = args.empty? ? true : args[0]
end

#cancelled?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 41

def cancelled?
  dsl_options[:cancelled] || false
end

#client_template_exists?(filename) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
75
76
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 72

def client_template_exists?(filename)
  return true if ::File.file?(filename) && ::File.readable?(filename)
  file = ::File.join("#{Dir.pwd}/templates", filename)
  ::File.file?(file) && ::File.readable?(file)
end

#client_templates_directory_exists?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 68

def client_templates_directory_exists?
  ::File.directory?("#{Dir.pwd}/templates")
end

#ensures(str = :present) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 11

def ensures(str = :present)
  if [:absent, :present].include?(str) 
    str == :absent ? is_absent : is_present
  else
    str
  end
end

#get_client_or_gem_template(file) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 56

def get_client_or_gem_template(file)
  if ::File.file?(file) && ::File.readable?(file)
    file
  elsif client_templates_directory_exists? && client_template_exists?(file)
    vputs "using custom template #{::File.join(Dir.pwd, "templates/#{file}")}"
    ::File.join(Dir.pwd, "templates/#{file}")
  else
    vputs "using standard template: #{::File.join(::File.dirname(__FILE__), "..", "templates/#{file}")}"
    ::File.join(::File.dirname(__FILE__), "..", "templates/#{file}")
  end
end

#ifnot(str = "") ⇒ Object

Alias for unless



35
36
37
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 35

def ifnot(str="")
  dsl_options.merge!(:unless => str)
end

#is_absent(*args) ⇒ Object

Ensures that what we are sending is absent



30
31
32
33
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 30

def is_absent(*args)
  dsl_options.merge!(:ensures => absent)
  absent
end

#is_present(*args) ⇒ Object

Allows us to send an ensure to ensure the presence of a resource



25
26
27
28
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 25

def is_present(*args)
  dsl_options.merge!(:ensures => present)
  present
end

#on_change(str = nil) ⇒ Object



8
9
10
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 8

def on_change(str=nil)
  str ? dsl_options.merge!(:notify => send_if_method(str)) : dsl_options[:notify]
end

#presentObject



18
19
20
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 18

def present
  :install
end

#printed(*args) ⇒ Object



44
45
46
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 44

def printed(*args)
  dsl_options[:printed] = true
end

#printed?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 47

def printed?
  dsl_options[:printed] || false
end

#render_templateObject

TODO: Diet



52
53
54
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 52

def render_template
  # @templates.
end

#requires(str = nil) ⇒ Object

Overrides for syntax Allows us to send require to require a resource



5
6
7
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 5

def requires(str=nil)
  str ? dsl_options.merge!(:require => send_if_method(str)) : dsl_options[:require]
end