Module: PoolParty::ResourcingDsl
- Included in:
- PoolParty::Resources::Resource
- Defined in:
- lib/poolparty/modules/resourcing_dsl.rb
Instance Method Summary collapse
- #absent ⇒ Object
- #client_template_exists?(filename) ⇒ Boolean
- #client_templates_directory_exists? ⇒ Boolean
- #ensures(str = :present) ⇒ Object
-
#get_client_or_gem_template(file) ⇒ Object
TODO: Diet.
-
#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.
- #present ⇒ Object
Instance Method Details
#absent ⇒ Object
13 14 15 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 13 def absent :remove end |
#client_template_exists?(filename) ⇒ Boolean
44 45 46 47 48 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 44 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
40 41 42 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 40 def client_templates_directory_exists? ::File.directory?("#{Dir.pwd}/templates") end |
#ensures(str = :present) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 3 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
TODO: Diet
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 28 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 |
#is_absent(*args) ⇒ Object
Ensures that what we are sending is absent
22 23 24 25 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 22 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
17 18 19 20 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 17 def is_present(*args) .merge!(:ensures => present) present end |
#present ⇒ Object
10 11 12 |
# File 'lib/poolparty/modules/resourcing_dsl.rb', line 10 def present :install end |