class Timebomb::CLI

Constants

DEFAULT_DATE_FROM_NOW
DEFAULT_PATH
DEFAULT_PATTERN

Public Instance Methods

bump(path = DEFAULT_PATTERN) click to toggle source
# File lib/timebomb.rb, line 85
def bump(path = DEFAULT_PATTERN)
  date = options[:date]
  suite = Suite.new
  suite.load_files Dir.glob(path)
  suite.timebomb_files.each do |file|
    file.read
    if file.bomb.has_exploded?
      file.bomb.date = date
      file.write
      puts "Bumped #{file.path} to #{date}"
    end
  end
end
create() click to toggle source
# File lib/timebomb.rb, line 71
def create
  path = DEFAULT_PATH.join tb_file(options[:title])
  file = BombFile.new(path)
  file.bomb.tap do |b|
    b.title = options[:title]
    b.description = options[:description]
    b.date = options[:date]
  end
  file.write
  puts "Timebomb created at #{path}"
end
init(path = ".") click to toggle source
# File lib/timebomb.rb, line 28
def init(path = ".")
  path = Pathname.new(path).join(DEFAULT_PATH)
  mkdir path
  puts "Timebomb project initialized at #{path}"
end
report(path = DEFAULT_PATTERN) click to toggle source
# File lib/timebomb.rb, line 19
def report(path = DEFAULT_PATTERN)
  suite = Suite.new
  suite.load_files Dir.glob(path)
  report = CLIReport.new suite
  report.print $stdout
  exit suite.has_exploded? ? 1 : 0
end

Private Instance Methods

tb_file(title) click to toggle source
# File lib/timebomb.rb, line 104
def tb_file(title)
  "#{underscore(title)}.tb"
end
underscore(title) click to toggle source
# File lib/timebomb.rb, line 100
def underscore(title)
  title.downcase.split(/\W/).reject{ |word| word == "" || word.nil? }.join("_")
end