Module: PoolParty::ResourcingDsl
- Included in:
- PoolParty::Resources::Resource
- Defined in:
- lib/poolparty/modules/resourcing_dsl.rb
Instance Method Summary collapse
- #absent ⇒ Object
- #cancel(*args) ⇒ Object
- #cancelled? ⇒ Boolean
- #client_template_exists?(filename) ⇒ Boolean
- #client_templates_directory_exists? ⇒ Boolean
- #ensures(str = :present) ⇒ Object
- #get_client_or_gem_template(file) ⇒ Object
-
#ifnot(str = "") ⇒ Object
Alias for unless.
-
#is_absent(*args) ⇒ Object
Ensures that what we are sending is absent.
-
#is_present(*args) ⇒ Object
Allows us to send an ensure to ensure the presence of a resource.
- #on_change(str = nil) ⇒ Object
- #present ⇒ Object
- #printed(*args) ⇒ Object
- #printed? ⇒ Boolean
-
#render_template ⇒ Object
TODO: Diet.
-
#requires(str = nil) ⇒ Object
Overrides for syntax Allows us to send require to require a resource.
Instance Method Details
#absent ⇒ Object
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) [:cancelled] = args.empty? ? true : args[0] end |
#cancelled? ⇒ Boolean
41 42 43 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 41 def cancelled? [:cancelled] || false end |
#client_template_exists?(filename) ⇒ 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
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="") .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) .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) .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 ? .merge!(:notify => send_if_method(str)) : [:notify] end |
#present ⇒ Object
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) [:printed] = true end |
#printed? ⇒ Boolean
47 48 49 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 47 def printed? [:printed] || false end |
#render_template ⇒ Object
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 ? .merge!(:require => send_if_method(str)) : [:require] end |