Module: Tap

Defined in:
lib/tap.rb,
lib/tap/app.rb,
lib/tap/env.rb,
lib/tap/join.rb,
lib/tap/root.rb,
lib/tap/task.rb,
lib/tap/utils.rb,
lib/tap/parser.rb,
lib/tap/signal.rb,
lib/tap/app/api.rb,
lib/tap/signals.rb,
lib/tap/version.rb,
lib/tap/env/path.rb,
lib/tap/workflow.rb,
lib/tap/app/queue.rb,
lib/tap/app/stack.rb,
lib/tap/app/state.rb,
lib/tap/env/cache.rb,
lib/tap/templater.rb,
lib/tap/joins/gate.rb,
lib/tap/joins/sync.rb,
lib/tap/middleware.rb,
lib/tap/tasks/dump.rb,
lib/tap/tasks/list.rb,
lib/tap/tasks/load.rb,
lib/tap/declarations.rb,
lib/tap/env/constant.rb,
lib/tap/joins/switch.rb,
lib/tap/signals/help.rb,
lib/tap/signals/load.rb,
lib/tap/tasks/prompt.rb,
lib/tap/tasks/signal.rb,
lib/tap/tasks/stream.rb,
lib/tap/env/string_ext.rb,
lib/tap/tasks/singleton.rb,
lib/tap/signals/configure.rb,
lib/tap/declarations/context.rb,
lib/tap/middlewares/debugger.rb,
lib/tap/signals/class_methods.rb,
lib/tap/signals/module_methods.rb,
lib/tap/declarations/description.rb

Defined Under Namespace

Modules: Declarations, Joins, Middlewares, Signals, Tasks, Utils Classes: App, Env, Join, Middleware, Parser, Root, Signal, Task, Templater, Workflow

Constant Summary collapse

MAJOR =
1
MINOR =
4
TINY =
0
VERSION =
"#{MAJOR}.#{MINOR}.#{TINY}"
WEBSITE =
"http://tap.rubyforge.org"

Class Method Summary collapse

Class Method Details

.optionsObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tap.rb', line 7

def options
  options = {
    :tapfile   => ENV['TAPFILE'],
    :gems      => ENV['TAP_GEMS'],
    :path      => ENV['TAP_PATH'],
    :tapenv    => ENV['TAPENV'],
    :taprc     => ENV['TAPRC'],
    :tap_cache => ENV['TAP_CACHE'],
    :debug     => ENV['TAP_DEBUG']
  }
  options
end

.setup(options = self.options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/tap.rb', line 20

def setup(options=self.options)
  env = Env.new
  app = App.new({}, :env => env)
  app.set('app', app)
  app.set('env', env)
  App.current = app
  
  def options.process(key, default=nil)
    value = self[key] || default
    if self[:debug] == 'true'
      $stderr.puts(App::LOG_FORMAT % [' ', nil, key, value])
    end
    value && block_given? ? yield(value) : nil
  end
  
  if options[:debug] == 'true'
    options.process(:ruby, "#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}-#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})")
    options.process(:tap, VERSION)
    app.debug = true
    app.verbose = true
    app.logger.level = Logger::DEBUG
  end
  
  options.process(:gems) do |gems|
    cache_dir = options[:tap_cache]
    
    if cache_dir.to_s.strip.empty?
      require 'tmpdir'
      cache_dir = Dir.tmpdir
    end
    
    env.signal(:load).call Env::Cache.new(cache_dir, options[:debug]).select(gems)
  end
  
  options.process(:path) do |path|
    Env::Path.split(path).each {|dir| env.auto(:dir => dir) }
  end
  
  options.process(:tapenv) do |tapenv_path|
    env.signal(:load).call Env::Path.split(tapenv_path)
  end
  
  options.process(:taprc) do |taprc_path|
    app.signal(:load).call Env::Path.split(taprc_path)
  end
  
  options.process(:tapfile) do |tapfile_path|
    Env::Path.split(tapfile_path).each do |tapfile|
      next unless File.file?(tapfile)
      Declarations::Context.new(app, File.basename(tapfile)).instance_eval(File.read(tapfile), tapfile, 1)
    end
  end
  
  app
end