sixpack-client 0.0.1 → 0.0.2
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/sixpack.rb +19 -3
- data/lib/sixpack/version.rb +1 -1
- metadata +1 -1
data/lib/sixpack.rb
CHANGED
@@ -6,6 +6,22 @@ require "uuid"
|
|
6
6
|
require "sixpack/version"
|
7
7
|
|
8
8
|
module Sixpack
|
9
|
+
@@host = "localhost"
|
10
|
+
def self.host
|
11
|
+
@@host
|
12
|
+
end
|
13
|
+
def self.host=(host)
|
14
|
+
@@host = host
|
15
|
+
end
|
16
|
+
|
17
|
+
@@port = 5000
|
18
|
+
def self.port
|
19
|
+
@@port
|
20
|
+
end
|
21
|
+
def self.port=(port)
|
22
|
+
@@port = port
|
23
|
+
end
|
24
|
+
|
9
25
|
def self.simple_participate(experiment_name, alternatives, client_id=nil, force=nil)
|
10
26
|
session = Session.new(client_id)
|
11
27
|
res = session.participate(experiment_name, alternatives, force)
|
@@ -26,7 +42,7 @@ module Sixpack
|
|
26
42
|
attr_accessor :host, :port, :client_id
|
27
43
|
|
28
44
|
def initialize(client_id=nil, options={})
|
29
|
-
default_options = {:host =>
|
45
|
+
default_options = {:host => Sixpack.host, :port => Sixpack.port}
|
30
46
|
options = default_options.merge(options)
|
31
47
|
@host = options[:host]
|
32
48
|
@port = options[:port]
|
@@ -39,7 +55,7 @@ module Sixpack
|
|
39
55
|
end
|
40
56
|
|
41
57
|
def participate(experiment_name, alternatives, force=nil)
|
42
|
-
if !(experiment_name =~
|
58
|
+
if !(experiment_name =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
|
43
59
|
raise ArgumentError, "Bad experiment_name"
|
44
60
|
end
|
45
61
|
|
@@ -48,7 +64,7 @@ module Sixpack
|
|
48
64
|
end
|
49
65
|
|
50
66
|
alternatives.each { |alt|
|
51
|
-
if !(alt =~
|
67
|
+
if !(alt =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
|
52
68
|
raise ArgumentError, "Bad alternative name: #{alt}"
|
53
69
|
end
|
54
70
|
}
|
data/lib/sixpack/version.rb
CHANGED