Module: TLDR::Run

Defined in:
lib/tldr.rb

Constant Summary collapse

@@at_exit_registered =
false

Class Method Summary collapse

Class Method Details

.at_exit!(config = Config.new) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tldr.rb', line 44

def self.at_exit! config = Config.new
  # Ignore at_exit when running tldr CLI, since that will run any tests
  return if $PROGRAM_NAME.end_with?("tldr")
  # Also ignore if we're running from within our rake task
  return if caller.any? { |line| line.include?("lib/tldr/rake.rb") }
  # Ignore at_exit when we've already registered an at_exit hook
  return if @@at_exit_registered

  Kernel.at_exit do
    Run.tests(config)
  end

  @@at_exit_registered = true
end

.cli(argv) ⇒ Object



28
29
30
31
# File 'lib/tldr.rb', line 28

def self.cli argv
  config = ArgvParser.new.parse(argv)
  tests(config)
end

.tests(config = Config.new) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/tldr.rb', line 33

def self.tests config = Config.new
  if config.watch
    Watcher.new.watch(config)
  else
    PathUtil.chdir_maybe(config.base_path) do
      Runner.new.run(config, Planner.new.plan(config))
    end
  end
end