Class: DroidProj::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/droidproj/runner.rb

Constant Summary collapse

POSSIBLE_FILES =
[
  'droidfile',
  'Droidfile',
  'droidfile.rb',
  'Droidfile.rb'
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



18
19
20
# File 'lib/droidproj/runner.rb', line 18

def initialize
  @possible_files = POSSIBLE_FILES.dup
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



10
11
12
# File 'lib/droidproj/runner.rb', line 10

def app
  @app
end

#droidfileObject

Returns the value of attribute droidfile.



10
11
12
# File 'lib/droidproj/runner.rb', line 10

def droidfile
  @droidfile
end

Class Method Details

.runObject



13
14
15
# File 'lib/droidproj/runner.rb', line 13

def run
  new.run
end

Instance Method Details

#eval_droidfileObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/droidproj/runner.rb', line 38

def eval_droidfile
  content = nil
  File.open(@droidfile, 'r') {|file|
    content = file.read
  }

  context = RunnerContext.new
  context.app = @app

  eval content, context.create_context.binding
end

#find_droidfile_locationObject



50
51
52
53
54
55
# File 'lib/droidproj/runner.rb', line 50

def find_droidfile_location
  @possible_files.each do |file|
    return file if File.exist?(file)
  end
  nil
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/droidproj/runner.rb', line 22

def run
  @droidfile = find_droidfile_location

  raise "You need to supply a Droidfile in the current directory" if !@droidfile

  @app = DroidProj::Android::App.new(File.dirname(@droidfile))

  DroidProj::Logger.log "Evaluating Droidfile...".green
  eval_droidfile

  DroidProj::Logger.log "Creating filesystem...".green
  @app.create_filesystem!

  DroidProj::Logger.log "Done!".green
end