Class: VagrantPlugins::DevCommands::Commandfile::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/devcommands/commandfile/reader.rb

Overview

Provides the DSL to read the contents of a Commandfile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commandfile, env) ⇒ Reader

Returns a new instance of Reader.



10
11
12
13
14
15
# File 'lib/vagrant/devcommands/commandfile/reader.rb', line 10

def initialize(commandfile, env)
  @commandfile = commandfile
  @env         = env

  @entries = []
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



8
9
10
# File 'lib/vagrant/devcommands/commandfile/reader.rb', line 8

def entries
  @entries
end

Instance Method Details

#readObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant/devcommands/commandfile/reader.rb', line 17

def read
  global = @commandfile.path_global
  local  = @commandfile.path

  contents = ''
  contents += "\n#{global.read}" unless global.nil?
  contents += "\n#{local.read}" unless local.nil?

  instance_eval(contents)

  @entries
end