Module: CukeStepBm

Defined in:
lib/cuke-step-bm/cli.rb,
lib/cuke-step-bm.rb,
lib/cuke-step-bm/version.rb

Overview

require ‘ostruct’

Defined Under Namespace

Classes: Cli

Constant Summary collapse

BM_SUPPORTED_OUTPUT_MODES =

cuke_step_bm bm-cuke-step cuke-step-bm.rb :bm => BenchMark(only for display) :std => SimpleTimeDiff :std_with_log => SimpleTimeDiff log :off => Cucumber default do nothing

[:bm, :std, :std_with_log, :off]
VERSION =
"1.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.delimiterObject

Returns the value of attribute delimiter.



14
15
16
# File 'lib/cuke-step-bm.rb', line 14

def delimiter
  @delimiter
end

.log_fileObject

Returns the value of attribute log_file.



14
15
16
# File 'lib/cuke-step-bm.rb', line 14

def log_file
  @log_file
end

.output_modeObject

Returns the value of attribute output_mode.



14
15
16
# File 'lib/cuke-step-bm.rb', line 14

def output_mode
  @output_mode
end

.rootObject

Returns the value of attribute root.



14
15
16
# File 'lib/cuke-step-bm.rb', line 14

def root
  @root
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (CukeStepBm)

    the object that the method was called on



16
17
18
# File 'lib/cuke-step-bm.rb', line 16

def configure
  yield self
end

.remove_log!Object

remove log file before cuke working with :std_with_log



47
48
49
50
51
# File 'lib/cuke-step-bm.rb', line 47

def remove_log!
  File.delete log_file if File.exist?(log_file) && (output_mode == :std_with_log)
rescue Exception => e
  warn e.message
end

.suite!Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/cuke-step-bm.rb', line 20

def suite!
  use_defaults!
  paths = [
      File.expand_path("config/cuke_step_bm.rb", root),
      File.expand_path(".cuke_step_bm", root),
      "#{ENV["HOME"]}/.cuke_step_bm"
  ]
  paths.each { |path| load(path) if File.exist?(path) }
  self.output_mode = :std unless BM_SUPPORTED_OUTPUT_MODES.include? output_mode
end

.use_defaults!Object



31
32
33
34
35
36
37
38
# File 'lib/cuke-step-bm.rb', line 31

def use_defaults!
  configure do |config|
    config.root = File.expand_path('.', Dir.pwd)
    config.output_mode = :std
    config.log_file = File.join(config.root, 'features', 'steps_consuming.bms')
    config.delimiter = "-#{[20879].pack("U*")}-"
  end
end

.write_to_log(msg) ⇒ Object



40
41
42
43
44
# File 'lib/cuke-step-bm.rb', line 40

def write_to_log(msg)
  File.open(log_file, "a+") { |f| f.write msg }
rescue
  nil
end