Module: AutotestCucumberNotification

Defined in:
lib/autotest-cucumber-notification/autotest-cucumber-notification.rb,
lib/autotest-cucumber-notification/version.rb

Overview

Usage

see README

Defined Under Namespace

Classes: Config

Constant Summary collapse

VERSION =

Current module version

"0.0.6"

Class Method Summary collapse

Class Method Details

.assemble_msg(scenarios, steps, scenario_stats = {}, step_stats = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/autotest-cucumber-notification/autotest-cucumber-notification.rb', line 68

def assemble_msg(scenarios, steps, scenario_stats = {}, step_stats = {})
  msg = ""
  if scenarios > 0
    msg += "#{pluralize('scenario',scenarios)}"
    msg += "\n#{stat_string(scenario_stats)}"
    msg += "\n\n" if steps > 0
  end
  if steps > 0
    msg += "#{pluralize('step',steps)}"
    msg += "\n#{stat_string(step_stats)}"
  end
  return msg
end

.notify(title, msg, img = Config.success_image) ⇒ Object



60
61
62
# File 'lib/autotest-cucumber-notification/autotest-cucumber-notification.rb', line 60

def notify(title, msg, img = Config.success_image)
  system "notify-send -i #{img} '#{title}' '#{msg}' -t #{Config.fade_timeout}"
end

.pluralize(text, number) ⇒ Object



64
65
66
# File 'lib/autotest-cucumber-notification/autotest-cucumber-notification.rb', line 64

def pluralize(text, number)
  "#{number} #{text}#{'s' if number != 1}"
end

.stat_string(hash) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/autotest-cucumber-notification/autotest-cucumber-notification.rb', line 82

def stat_string(hash)
  stat_str = "("
  hash.each do |key,value|
    if value > 0
      stat_str += "#{value} #{key},"
    end
  end
  stat_str += ")"
  stat_str.gsub!(",\)",")")
end