peppers-ghost 0.0.1.alpha.1 → 0.0.1.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/peppers-ghost.rb +1 -0
- data/lib/peppers-ghost/frogger.rb +52 -0
- data/peppers-ghost.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a0487465e84b597109a5bd3e600d09b9a02074
|
4
|
+
data.tar.gz: 14e78905b03618a3a8570c8d355fc6703734e708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371331a815dbf3df8004981b5146ba3570813f99e8e95cf3366f361b2d33c17bd68170c3484d5426bec8a65dd253d0ad34f4f57bd032c81c6907b12cb8d96f74
|
7
|
+
data.tar.gz: daef6fad9568b0da290599042eab3dc32c6fe3721baed4f271e9698c8d308869d5d00e72b083bad1669544b3ecdfc40e86ab5cb5eba0f4be4bcf40b144c55288
|
data/lib/peppers-ghost.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
class Frogger
|
2
|
+
class << self
|
3
|
+
def log_resource(resource, exists)
|
4
|
+
resource = resource.to_s.singularize.to_sym
|
5
|
+
|
6
|
+
frog[resource] ||= 0
|
7
|
+
frog[resource] += 1 if exists
|
8
|
+
end
|
9
|
+
|
10
|
+
def frog
|
11
|
+
@frog ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def eat_the_fly!
|
15
|
+
untested, tested = frog.partition do |key, value|
|
16
|
+
value == 0
|
17
|
+
end
|
18
|
+
|
19
|
+
tested = tested.sort_by(&:last).reverse
|
20
|
+
|
21
|
+
if untested.any?
|
22
|
+
puts formatted_message(tested, untested)
|
23
|
+
burp untested
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def burp(untested)
|
28
|
+
pluralized_resource = 'resource'.pluralize(untested.count)
|
29
|
+
untested_list = untested.map(&:first).join(', ')
|
30
|
+
|
31
|
+
raise "Untested nested #{pluralized_resource}: #{untested_list}."
|
32
|
+
end
|
33
|
+
|
34
|
+
def formatted_message(tested, untested)
|
35
|
+
"\n\nTested: %s\nUntested: %s" % [
|
36
|
+
formatted_resources(tested),
|
37
|
+
formatted_resources(untested),
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def formatted_resources(resources)
|
42
|
+
mask = '%s (%d)'
|
43
|
+
resources.map { |resource| mask % resource }.join(', ')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec.configure do |config|
|
49
|
+
config.after(:suite) do
|
50
|
+
Frogger.eat_the_fly!
|
51
|
+
end
|
52
|
+
end
|
data/peppers-ghost.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peppers-ghost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.alpha.
|
4
|
+
version: 0.0.1.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Herrick
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/peppers-ghost.rb
|
51
51
|
- lib/peppers-ghost/ghost_factory.rb
|
52
52
|
- lib/peppers-ghost/matchers.rb
|
53
|
+
- lib/peppers-ghost/frogger.rb
|
53
54
|
homepage: http://www.bitbucket.org/ToadJamb/gems-peppers-ghost
|
54
55
|
licenses:
|
55
56
|
- LGPLv3
|