Class: Dragon::Options
- Inherits:
-
Object
- Object
- Dragon::Options
- Defined in:
- lib/dragon/options.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#local_settings ⇒ Object
Returns the value of attribute local_settings.
-
#release ⇒ Object
Returns the value of attribute release.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root_given) ⇒ Options
constructor
A new instance of Options.
- #release_dir ⇒ Object
- #shared_dir ⇒ Object
- #update_commands ⇒ Object
Constructor Details
#initialize(root_given) ⇒ Options
Returns a new instance of Options.
9 10 11 12 13 |
# File 'lib/dragon/options.rb', line 9 def initialize( root_given ) @root = root_given @release = Time.now.utc.strftime("%Y%m%d%H%M%S") @local_settings = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
7 8 9 |
# File 'lib/dragon/options.rb', line 7 def environment @environment end |
#local_settings ⇒ Object
Returns the value of attribute local_settings.
7 8 9 |
# File 'lib/dragon/options.rb', line 7 def local_settings @local_settings end |
#release ⇒ Object
Returns the value of attribute release.
7 8 9 |
# File 'lib/dragon/options.rb', line 7 def release @release end |
Class Method Details
.parse(root, args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dragon/options.rb', line 15 def self.parse( root, args ) depfile_loc = File.(File.join( root, "Depfile" )) raise Dragon::Exceptions::DragfileMissing, "Depfile must exists in current directory, please run `depify .`." unless File.exists?( depfile_loc ) output = self.new( root ) output.environment = args[0] output.release = args[1] if args.size > 1 output.local_settings = YAML.load_file( depfile_loc )[output.environment] output.update_commands output end |
Instance Method Details
#release_dir ⇒ Object
30 31 32 |
# File 'lib/dragon/options.rb', line 30 def release_dir File.join( @local_settings['destination_root'], "releases", @release ) end |
#shared_dir ⇒ Object
34 35 36 |
# File 'lib/dragon/options.rb', line 34 def shared_dir File.join( @local_settings['destination_root'], "shared" ) end |
#update_commands ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dragon/options.rb', line 38 def update_commands return nil unless !@local_settings.nil? && @local_settings.has_key?( "commands" ) @local_settings['commands'].each_with_index{|command,i| rendered_value = Liquid::Template.parse( @local_settings['commands'][ i ][ command.keys[0] ] ).render( command_liquid_args ) @local_settings['commands'][ i ][ command.keys[0] ] = rendered_value } end |