module Clapper
Constants
- VERSION
Public Class Methods
compare(example_list)
click to toggle source
# File lib/clapper.rb, line 5 def self.compare(example_list) f = Clapper.openFile old_examples = f.readlines f.close parsed_examples = Clapper.parse_examples(old_examples) will_clap = false f = CSV.open(Clapper.path_to_testfile, "w") example_list.each do |example| if parsed_examples[example.id] == nil && example.execution_result.status == :passed will_clap = true elsif parsed_examples[example.id] == :failed && example.execution_result.status == :passed will_clap = true end f << [example.id, example.execution_result.status] end f.close Clapper.clap(will_clap) end
Private Class Methods
clap(will_clap)
click to toggle source
# File lib/clapper.rb, line 41 def self.clap(will_clap) if will_clap `play #{Clapper.path_to_audio} trim 0 5` end end
openFile()
click to toggle source
# File lib/clapper.rb, line 26 def self.openFile if !File.exist?(Clapper.path_to_testfile) CSV.new(File.new(Clapper.path_to_testfile, "w+")) else CSV.open(Clapper.path_to_testfile, "r+") end end
parse_examples(old_examples)
click to toggle source
# File lib/clapper.rb, line 34 def self.parse_examples(old_examples) old_examples.reduce({}) do |acc, example_row| acc[example_row[0]] = example_row[1].to_sym acc end end
path_to_audio()
click to toggle source
# File lib/clapper.rb, line 47 def self.path_to_audio File.join(File.dirname(__FILE__), '../assets/Clapping.wav') end
path_to_testfile()
click to toggle source
# File lib/clapper.rb, line 51 def self.path_to_testfile # File.join(File.dirname(__FILE__), '../assets/tests.csv') "tests.csv" end