sanford-protocol 0.5.0 → 0.5.1

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.
@@ -11,7 +11,6 @@ module Sanford::Protocol
11
11
  attr_reader :value
12
12
 
13
13
  def initialize(called_from=nil, &get_value)
14
- @called_from = called_from || caller
15
14
 
16
15
  # By default, any exceptions from getting the value are "hidden" behind a
17
16
  # more general `BadMessageError`. In non-debug scenarios this is ideal and
@@ -21,6 +20,7 @@ module Sanford::Protocol
21
20
  begin
22
21
  @value = get_value.call
23
22
  rescue Exception => err
23
+ @called_from = called_from || caller
24
24
  ENV['SANFORD_PROTOCOL_DEBUG'] ? raise(err) : self.error!(self.get_value_error)
25
25
  end
26
26
  end
@@ -16,13 +16,13 @@ module Sanford::Protocol
16
16
 
17
17
  def initialize(version, name, params)
18
18
  self.validate!(version, name, params)
19
- @version, @name, @params = version, name, self.stringify(params)
19
+ @version, @name, @params = version, name, params
20
20
  end
21
21
 
22
22
  def to_hash
23
23
  { 'version' => version,
24
24
  'name' => name,
25
- 'params' => params
25
+ 'params' => self.stringify(params)
26
26
  }
27
27
  end
28
28
 
@@ -1,5 +1,5 @@
1
1
  module Sanford
2
2
  module Protocol
3
- GEM_VERSION = "0.5.0"
3
+ GEM_VERSION = "0.5.1"
4
4
  end
5
5
  end
@@ -17,15 +17,6 @@ class Sanford::Protocol::Request
17
17
  assert_equal "[#{subject.version}] #{subject.name}", subject.to_s
18
18
  end
19
19
 
20
- should "stringify params keys" do
21
- request = Sanford::Protocol::Request.new('v1', 'service', {
22
- 1 => 1,
23
- :symbol => :symbol
24
- })
25
- expected = { "1" => 1, "symbol" => :symbol }
26
- assert_equal expected, request.params
27
- end
28
-
29
20
  should "return an instance of a Sanford::Protocol::Request given a hash using #parse" do
30
21
  # using BSON messages are hashes
31
22
  hash = {
@@ -41,16 +32,21 @@ class Sanford::Protocol::Request
41
32
  assert_equal hash['params'], request.params
42
33
  end
43
34
 
44
- should "return the request as a hash with #to_hash" do
45
- # using BSON messages are hashes
35
+ should "return the request as a hash with stringified params with #to_hash" do
36
+ # using BSON, messages are hashes
37
+ request = Sanford::Protocol::Request.new('v1', 'service', {
38
+ 1 => 1,
39
+ :symbol => :symbol
40
+ })
46
41
  expected = {
47
42
  'version' => 'v1',
48
- 'name' => 'some_service',
49
- 'params' => { 'key' => 'value' }
43
+ 'name' => 'service',
44
+ 'params' => { '1' => 1, 'symbol' => :symbol }
50
45
  }
51
46
 
52
- assert_equal expected, subject.to_hash
47
+ assert_equal expected, request.to_hash
53
48
  end
49
+
54
50
  end
55
51
 
56
52
  class ValidTests < BaseTests
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanford-protocol
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Collin Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-11-30 00:00:00 Z
19
+ date: 2013-01-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false