Class: Babushka::Base

Inherits:
Object show all
Defined in:
lib/babushka/base.rb

Constant Summary collapse

@@start_time =

The time at which babushka was loaded. This is used in LogHelpers to print profiling information via the '--profile' commandline option.

Time.now

Class Method Summary collapse

Class Method Details

.cmdlineObject

cmdline is an instance of Cmdline::Parser that represents the arguments that were passed via the commandline. It handles parsing those arguments, and choosing the task to perform based on the 'verb' supplied - e.g. 'meet', 'list', etc.



41
42
43
# File 'lib/babushka/base.rb', line 41

def cmdline
  @cmdline ||= Cmdline::Parser.for(ARGV)
end

.exit_on_interrupt!Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/babushka/base.rb', line 64

def exit_on_interrupt!
  if STDIN.tty?
    stty_save = `stty -g`.chomp
    trap("INT") {
      system "stty", stty_save
      unless Base.task.current_dep.nil?
        puts "\n#{Logging.closing_log_message("#{Base.task.current_dep.callstack.first.contextual_name} (cancelled)", false, :closing_status => true)}"
      end
      exit false
    }
  end
end

.program_nameObject



88
89
90
# File 'lib/babushka/base.rb', line 88

def program_name
  @program_name ||= ENV['PATH'].split(':').include?(File.dirname($0)) ? File.basename($0) : $0
end

.refObject



81
82
83
84
85
86
# File 'lib/babushka/base.rb', line 81

def ref
  @ref ||= begin
    repo = GitRepo.new(Path.path)
    repo.current_head if repo.exists?
  end
end

.runObject

The top-level entry point for babushka runs invoked at the command line. When the babushka command is run, bin/babushka.rb first triggers a load via lib/babushka.rb, and then calls this method.



60
61
62
# File 'lib/babushka/base.rb', line 60

def run
  cmdline.run
end

.runtime_infoObject



77
78
79
# File 'lib/babushka/base.rb', line 77

def runtime_info
  @runtime_info ||= "babushka@#{ref} | #{ShellHelpers.which('ruby')}@#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
end

.sourcesObject

sources is an instance of Babushka::SourcePool, contains all the sources that babushka can currently load deps from. This means all the sources found in ~/.babushka/sources, plus the default sources:

- anonymous (no source file; i.e. deps defined in an +irb+ session,
or similar)
- core (the builtin deps that babushka uses to install itself)
- current dir (the contents of ./babushka-deps)
- personal (the contents of ~/.babushka/deps)


53
54
55
# File 'lib/babushka/base.rb', line 53

def sources
  @sources ||= SourcePool.new(cmdline.opts.slice(:update))
end

.start_timeObject



27
28
29
# File 'lib/babushka/base.rb', line 27

def start_time
  @@start_time
end

.taskObject

task represents the overall job that is being run, and things that are external to running the corresponding dep tree itself, like logging.



33
34
35
# File 'lib/babushka/base.rb', line 33

def task
  @task ||= Task.new
end