Class: Timebomb::CLI

Inherits:
Thor
  • Object
show all
Includes:
FileUtils
Defined in:
lib/timebomb.rb

Constant Summary collapse

DEFAULT_PATH =
Pathname.new("./timebomb").freeze
DEFAULT_PATTERN =
DEFAULT_PATH.join("**/**.tb").freeze
DEFAULT_DATE_FROM_NOW =
"1 month from today".freeze

Instance Method Summary collapse

Instance Method Details

#bump(path = DEFAULT_PATTERN) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
# 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

#createObject



71
72
73
74
75
76
77
78
79
80
81
# 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 = ".") ⇒ Object



28
29
30
31
32
# 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) ⇒ Object



19
20
21
22
23
24
25
# 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