Class: Flak::Target
- Inherits:
-
Object
- Object
- Flak::Target
- Includes:
- FileActions
- Defined in:
- lib/flak/rake/target.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#build ⇒ Object
After the Target has been constructed, generate settings and tasks.
-
#generate_settings ⇒ Object
Extend this Target with settings and methods from templates declared in the target file.
-
#generate_tasks ⇒ Object
Extend this Target with tasks from templates declared in the target file.
-
#initialize(root, target_file) ⇒ Target
constructor
Constructs a target object.
Methods included from FileActions
#make_directory_for, #rebuild_symlink, #remove_and_copy, #write_erb_template
Constructor Details
#initialize(root, target_file) ⇒ Target
Constructs a target object.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/flak/rake/target.rb', line 16 def initialize(root, target_file) tmp_env = YAML::load_file( root + '/config/environment.yml' ) tmp_goal = YAML::load_file( target_file ) @settings = Hash.new @settings[:configuration] = tmp_env['configuration'] @settings[:templates] = tmp_goal['templates'] @settings[:os] = Flak.os @settings[:root] = root @settings[:target_file] = target_file @settings[:full_target_file] = File.join(@settings[:root], target_file ) @settings[:relative_goal_root] = File.dirname(target_file) @settings[:goal_root] = File.dirname( @settings[:full_target_file] ) @settings[:templates] = (["environment"] | @settings[:templates]) end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
10 11 12 |
# File 'lib/flak/rake/target.rb', line 10 def settings @settings end |
Instance Method Details
#build ⇒ Object
After the Target has been constructed, generate settings and tasks.
36 37 38 39 |
# File 'lib/flak/rake/target.rb', line 36 def build generate_settings generate_tasks end |
#generate_settings ⇒ Object
Extend this Target with settings and methods from templates declared in the target file
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/flak/rake/target.rb', line 43 def generate_settings @settings[:templates].each do |template_name| mod = Flak::Template.const_get("#{template_name.camelize}") mod = mod.const_get("Settings") raise TypeError, "#{mod.inspect} must be a Module" unless mod.kind_of? Module self.extend( mod ) end yml = Flak::Template::MergeEngine.flatten_yaml_file(@settings, @settings[:target_file]) @settings = @settings.flak_merge(yml) end |
#generate_tasks ⇒ Object
Extend this Target with tasks from templates declared in the target file
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/flak/rake/target.rb', line 60 def generate_tasks @settings[:templates].each do |template_name| mod = Flak::Template.const_get("#{template_name.camelize}") mod = mod.const_get("Tasks") raise TypeError, "#{mod.inspect} must be a Module" unless mod.kind_of? Module self.extend( mod ) end end |