myna_eventmachine 1.2 → 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/lib/myna/response.rb CHANGED
@@ -120,19 +120,21 @@ module Response
120
120
 
121
121
  class Variant < Response
122
122
  def self.from_json(json)
123
- variant = Variant.new(json['name'], json['views'], json['totalReward'], json['confidenceBound'])
123
+ variant = Variant.new(json['name'], json['views'], json['totalReward'], json['lowerConfidenceBound'], json['upperConfidenceBound'])
124
124
  end
125
125
 
126
126
  attr_reader :name
127
127
  attr_reader :views
128
128
  attr_reader :totalReward
129
- attr_reader :confidenceBound
129
+ attr_reader :lowerConfidenceBound
130
+ attr_reader :upperConfidenceBound
130
131
 
131
- def initialize(name, views, totalReward, confidenceBound)
132
+ def initialize(name, views, totalReward, lowerConfidenceBound, upperConfidenceBound)
132
133
  @name = name
133
134
  @views = views
134
135
  @totalReward = totalReward
135
- @confidenceBound = confidenceBound
136
+ @lowerConfidenceBound = lowerConfidenceBound
137
+ @upperConfidenceBound = upperConfidenceBound
136
138
  end
137
139
  end
138
140
  end
data/lib/myna/version.rb CHANGED
@@ -20,5 +20,5 @@
20
20
  #
21
21
 
22
22
  module Myna
23
- VERSION = "1.2"
23
+ VERSION = "1.3"
24
24
  end
@@ -93,12 +93,30 @@ describe Myna do
93
93
  info.name.must_equal "test"
94
94
  info.uuid.must_equal '45923780-80ed-47c6-aa46-15e2ae7a0e8c'
95
95
  info.variants.length.must_equal 2
96
+
97
+ v1 = nil
98
+ v2 = nil
96
99
  if info.variants[0].name == 'variant1'
97
100
  info.variants[1].name.must_equal 'variant2'
101
+ v1 = info.variants[0]
102
+ v2 = info.variants[1]
98
103
  else
99
104
  info.variants[0].name.must_equal 'variant2'
100
105
  info.variants[1].name.must_equal 'variant1'
106
+ v1 = info.variants[1]
107
+ v2 = info.variants[0]
108
+ end
109
+
110
+ # Check attributes are all present
111
+ def check_attributes(variant)
112
+ variant.views.must_be_kind_of Fixnum
113
+ variant.totalReward.must_be_kind_of Float
114
+ variant.upperConfidenceBound.must_be_kind_of Float
115
+ variant.lowerConfidenceBound.must_be_kind_of Float
101
116
  end
117
+
118
+ check_attributes(v1)
119
+ check_attributes(v2)
102
120
  end
103
121
  end
104
122
  end
@@ -68,12 +68,14 @@ describe Response do
68
68
  "name":"variant1",
69
69
  "views":36,
70
70
  "totalReward":1.0,
71
- "confidenceBound":0.252904521564191},
71
+ "lowerConfidenceBound":0.252904521564191,
72
+ "upperConfidenceBound":0.452904521564191},
72
73
  {"typename":"variant",
73
74
  "name":"variant2",
74
75
  "views":9672,
75
76
  "totalReward":0.0,
76
- "confidenceBound":0.015429423531830728}]}'
77
+ "lowerConfidenceBound":0.015429423531830728,
78
+ "upperConfidenceBound":0.03429423531830728}]}'
77
79
  ans = Response.parse(txt)
78
80
 
79
81
  ans.must_be_kind_of Response::Experiment
@@ -87,12 +89,14 @@ describe Response do
87
89
  v0.name.must_equal "variant1"
88
90
  v0.views.must_equal 36
89
91
  v0.totalReward.must_equal 1.0
90
- v0.confidenceBound.must_equal 0.252904521564191
92
+ v0.lowerConfidenceBound.must_equal 0.252904521564191
93
+ v0.upperConfidenceBound.must_equal 0.452904521564191
91
94
 
92
95
  v1.name.must_equal "variant2"
93
96
  v1.views.must_equal 9672
94
97
  v1.totalReward.must_equal 0.0
95
- v1.confidenceBound.must_equal 0.015429423531830728
98
+ v1.lowerConfidenceBound.must_equal 0.015429423531830728
99
+ v1.upperConfidenceBound.must_equal 0.03429423531830728
96
100
  end
97
101
  end
98
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myna_eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 1.8.6
55
+ rubygems_version: 1.8.10
56
56
  signing_key:
57
57
  specification_version: 3
58
58
  summary: Ruby/EventMachine client library for Myna (http://www.mynaweb.com)