hadupils 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/lib/hadupils/commands.rb +6 -2
- data/test/unit/commands_test.rb +18 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/lib/hadupils/commands.rb
CHANGED
@@ -4,13 +4,17 @@ module Hadupils::Commands
|
|
4
4
|
handler.run params
|
5
5
|
end
|
6
6
|
|
7
|
+
def self.normalize_command(command)
|
8
|
+
command.to_s.downcase
|
9
|
+
end
|
10
|
+
|
7
11
|
def self.handler_for(command)
|
8
|
-
@handlers and @handlers[command
|
12
|
+
@handlers and @handlers[normalize_command(command)]
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.register_handler(command, handler)
|
12
16
|
@handlers ||= {}
|
13
|
-
@handlers[command
|
17
|
+
@handlers[normalize_command(command)] = handler
|
14
18
|
end
|
15
19
|
|
16
20
|
class SimpleCommand
|
data/test/unit/commands_test.rb
CHANGED
@@ -8,6 +8,24 @@ class Hadupils::CommandsTest < Test::Unit::TestCase
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
# Addresses bug when run on older rubies
|
12
|
+
context 'handler pretty name normalization' do
|
13
|
+
context 'via handler_for' do
|
14
|
+
should 'not invoke downcase on requested handler' do
|
15
|
+
pretty = mock()
|
16
|
+
pretty.expects(:downcase).never
|
17
|
+
Hadupils::Commands.handler_for(pretty)
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'produce downcased string' do
|
21
|
+
pretty = mock()
|
22
|
+
pretty.expects(:to_s).returns(s = mock())
|
23
|
+
s.expects(:downcase)
|
24
|
+
Hadupils::Commands.handler_for(pretty)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
11
29
|
context 'Hive' do
|
12
30
|
setup do
|
13
31
|
@klass = Hadupils::Commands::Hive
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hadupils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|