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 +4 -4
- data/lib/ambient_spec/ambient_documentation_formatter.rb +4 -0
- data/lib/ambient_spec/player.rb +14 -11
- data/lib/ambient_spec/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d52000c3fed3a2f700710b8f33ee235e82f03aaa9a054e1f4d342618de1e23e4
|
4
|
+
data.tar.gz: ea05b0d2625169c7eaf747abe60646d05f44d9e541a4caa4d9daec535c273516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/ambient_spec/player.rb
CHANGED
@@ -4,26 +4,29 @@ module AmbientSpec
|
|
4
4
|
|
5
5
|
class Player
|
6
6
|
|
7
|
-
|
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
|
-
|
18
|
-
|
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
|
-
|
26
|
-
|
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
|
data/lib/ambient_spec/version.rb
CHANGED