ambient_spec 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 117ede017b3a0e4d104161091ba7176b73a47a1b9af079a368f76f753ee240f1
4
- data.tar.gz: d6d03ec86aa6ca2a354f3896aaad551a2d1800aeacda1a884b10e3b689c0e1bd
3
+ metadata.gz: d52000c3fed3a2f700710b8f33ee235e82f03aaa9a054e1f4d342618de1e23e4
4
+ data.tar.gz: ea05b0d2625169c7eaf747abe60646d05f44d9e541a4caa4d9daec535c273516
5
5
  SHA512:
6
- metadata.gz: 832f2a558f66e0ee21257daf5ff746050c759c247e4e2e85b1984fe049e993001a2c75d4b27eb778cbcd7759c4bbeaef6ebf020cf7a74bb34efb4e09d0cafaae
7
- data.tar.gz: 6b97aaec1e434b83363ca9f8adda758e5014ed4ce0250f30f2fb4dd060cebc6255b94f3ef5155b12db193b9491854137a70886ec81ae501014183ee4b6c56e83
6
+ metadata.gz: dc8739f9841d47537a45395797164f08cb817b71871b96c13737a8814bbf3fb05e51496715e81e3ca59c6a97c65165a8a06c26572815c15787e6b9557dd8c0fa
7
+ data.tar.gz: e74a8342c48c5d33e8baab4c59c2135769297177eb8ce9fa80d896e2018a3df03bf83602afe6991a59af20177e6590d8124a256daf66251120a6ef67c3fc4167
@@ -4,6 +4,10 @@ class AmbientDocumentationFormatter < RSpec::Core::Formatters::DocumentationForm
4
4
 
5
5
  RSpec::Core::Formatters.register self, :example_passed, :example_failed
6
6
 
7
+ def example_started
8
+ @start_time = Time.now
9
+ end
10
+
7
11
  def example_passed(_)
8
12
  player.sing(:pass)
9
13
  super
@@ -4,26 +4,29 @@ module AmbientSpec
4
4
 
5
5
  class Player
6
6
 
7
- attr_accessor :counter
8
-
9
- def fifths
10
- ["c", "g", "d", "a", "e", "b", "f"]
11
- end
7
+ FIFTHS = %w{c g d a e b f}.freeze
8
+ PATCHES = %w{breathy dark ghost harp piano plasma swirl waves}.freeze
12
9
 
13
10
  def sing(status=:pass)
14
- increment_counter
15
- # return unless counter % 3 == 1 || status == :fail
16
11
  if status == :pass
17
- folder = %w{breathy dark ghost harp piano plasma swirl waves}.sample
18
- filename = fifths.sample
12
+ return unless should_play?
13
+ folder = PATCHES.sample
14
+ filename = FIFTHS.sample
19
15
  system("afplay #{path_to_files}/#{folder}/#{filename}.wav &>/dev/null &")
16
+ increment_timer
20
17
  else
21
18
  system("afplay #{path_to_files}/failure/failure.wav &>/dev/null &")
22
19
  end
23
20
  end
24
21
 
25
- def increment_counter
26
- self.counter ||= 0; self.counter += 1
22
+ private
23
+
24
+ def should_play?
25
+ @last_played_at.nil? || Time.now - @last_played_at > 1
26
+ end
27
+
28
+ def increment_timer
29
+ @last_played_at = Time.now
27
30
  end
28
31
 
29
32
  def path_to_files
@@ -1,3 +1,3 @@
1
1
  module AmbientSpec
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ambient_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coraline Ada Ehmke