sixpack-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/sixpack.rb +19 -3
  2. data/lib/sixpack/version.rb +1 -1
  3. 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 => "localhost", :port => 5000}
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 =~ /[a-z0-9][a-z0-9\-_ ]*/)
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 =~ /[a-z0-9][a-z0-9\-_ ]*/)
67
+ if !(alt =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
52
68
  raise ArgumentError, "Bad alternative name: #{alt}"
53
69
  end
54
70
  }
@@ -1,3 +1,3 @@
1
1
  module Sixpack
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixpack-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: