Class: Hone::HarnessGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/hone/harness_generator.rb

Constant Summary collapse

HARNESS_DIR =
".hone"
HARNESS_FILE =
"harness.rb"

Instance Method Summary collapse

Constructor Details

#initialize(rails: false) ⇒ HarnessGenerator

Returns a new instance of HarnessGenerator.



10
11
12
# File 'lib/hone/harness_generator.rb', line 10

def initialize(rails: false)
  @rails = rails
end

Instance Method Details

#generateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hone/harness_generator.rb', line 14

def generate
  FileUtils.mkdir_p(HARNESS_DIR)

  path = File.join(HARNESS_DIR, HARNESS_FILE)

  if File.exist?(path)
    puts "Harness already exists: #{path}"
    puts "Delete it first if you want to regenerate."
    return false
  end

  template = @rails ? rails_template : ruby_template
  File.write(path, template)

  puts "Created #{path}"
  puts
  puts "Next steps:"
  puts "  1. Edit #{path} to exercise your application's hot paths"
  puts "  2. Run: hone profile"
  puts "  3. Run: hone analyze ."
  puts

  true
end