Class: PoolParty::Resources::Line
- Inherits:
-
PoolParty::Resource
- Object
- Base
- PoolParty::Resource
- PoolParty::Resources::Line
- Defined in:
- lib/poolparty/resources/line.rb
Instance Attribute Summary
Attributes inherited from PoolParty::Resource
#exists, #graph_index, #meta_not_if, #meta_notifies, #meta_only_if, #meta_subscribes
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from PoolParty::Resource
#after_compile, #after_loaded_requires_parent, #before_compile, #case_of, #cloud, #compile, define_resource, define_resource_methods, defined, defined_resources, #does_not_exist!, #exists!, #has_method_name, inherited, #initialize, is_base_resource_class?, method_defined!, method_defined?, #not_if, #notifies, #only_if, #pool, #print_variable, #requires, #subscribes
Methods inherited from Base
#add_ordered_resources_to_result, #all_resources, #before_load, #clouds_dot_rb_dir, clouds_dot_rb_dir, #clouds_dot_rb_file, clouds_dot_rb_file, #compile_opts, #create_graph, #dependencies, #get_resource, #has_searchable_paths, #initialize, #method_missing, #ordered_resources, #output_resources_graph, #resources, #resources_graph, #resources_with_dependencies, #resources_without_dependencies, #run_in_context, #run_with_callbacks, #to_s, #valid?, #validations
Methods included from Delayed
Methods included from Callbacks
Methods included from SearchablePaths
Constructor Details
This class inherits a constructor from PoolParty::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PoolParty::Base
Class Method Details
.has_method_name ⇒ Object
26 27 28 |
# File 'lib/poolparty/resources/line.rb', line 26 def self.has_method_name "line_in_file" end |
Instance Method Details
#after_loaded ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/poolparty/resources/line.rb', line 34 def after_loaded opts = if exists? {:command => "grep -q \'#{line.safe_quote}\' #{filepath} || echo \'#{line.safe_quote}\' >> #{filepath}", :not_if => "grep -q \'#{line.safe_quote}\' #{filepath}"} else {:command => "cat #{filepath} | grep -v \'#{line.safe_quote}\' > tempfile && mv tempfile #{filepath}", :only_if => "grep -q \'#{line.safe_quote}\' #{filepath}"} end opts.merge!(:name => exists? ? "line in #{filepath}" : "no line in #{filepath}") e = has_exec opts # Not incredibly pretty. # {:file => [["pool_name", :reload]]} # TODO: Find an alternative e. = if e. = if # TODO: Figure out better solution deps = @dependencies e.instance_eval do @dependencies = deps end end |
#filepath ⇒ Object
30 31 32 |
# File 'lib/poolparty/resources/line.rb', line 30 def filepath file || name end |
#print_to_chef ⇒ Object
60 61 62 |
# File 'lib/poolparty/resources/line.rb', line 60 def print_to_chef :no_print end |