split-cli 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0958070b7151290d8011d2fdfa7e17337fdac2c4
4
- data.tar.gz: ae86bef91f69ca966fb07278d1d2a6f3489d995c
3
+ metadata.gz: 3d9943bac628839750cdb4414d54897cb82843a5
4
+ data.tar.gz: 469fd82531164ef5ff62ef865d7ba57439539617
5
5
  SHA512:
6
- metadata.gz: 7bb0c94352340ea3176610a8d51fbc3c10456971e28b7b730f31865cc2323e05e56ab24354c627fd9068dcc00faffff3029c25bacee0992cf474ce955d3d8ea6
7
- data.tar.gz: 91d64ccbb9de27e5d5c2baad1f03b26e764a73621de21b48b7075c5507d9bc793222387db007a8c952c22f4bdefee970ce518458c58ba9557d550784b2c47ab7
6
+ metadata.gz: 71276804ef7293fa0ed8346a071206eeb2e348fc6dd9975868f796b6c443631f0c91f1319ae379067dc8c6e40ea6d6b71d0110a2c4d4348c304b8d4b69642d8f
7
+ data.tar.gz: 97ecee8f8087ad25329c351168790ca00d7e7fdd5f0fae7189fa05ed5304324e655ea1468cdae16497d2b4187ae401258f5893fb6d7a497ecb94d4de698c90a6
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in split-cli.gemspec
4
4
  gemspec
5
5
 
6
- gem 'autotest'
6
+ gem 'autotest'
7
+ gem 'pry'
data/README.md CHANGED
@@ -24,10 +24,10 @@ Or install it yourself as:
24
24
 
25
25
  Supported environment variables
26
26
  ```shell
27
+ SPLIT_YAML_CONFIG # required 'path/to.yml'
27
28
  REDIS_URL # default 'localhost:6379'
28
- SPLIT_YAML_CONFIG # required
29
29
  SPLIT_MULTI_EXPERIMENT # default true
30
- REDIS_NAMESPACE # optional
30
+ REDIS_NAMESPACE # default 'split'
31
31
  ```
32
32
 
33
33
  Basic Usage
@@ -25,6 +25,10 @@ parser = OptionParser.new do |opts|
25
25
  opts.on("-n", "--namespace [namespace]", "Redis namespace") do |n|
26
26
  options[:redis_namespace] = n
27
27
  end
28
+
29
+ opts.on("-u", "--user-agent [user_agent]", "User Agent String") do |u|
30
+ options[:user_agent] = u
31
+ end
28
32
  end
29
33
 
30
34
  parser.parse!
@@ -1,4 +1,5 @@
1
1
  require 'split'
2
+ require 'split/cli/request'
2
3
  require 'split/cli/session'
3
4
  require 'split/cli/version'
4
5
 
@@ -0,0 +1,12 @@
1
+ module Split
2
+ module Cli
3
+ class Request
4
+ attr_accessor :user_agent, :ip
5
+
6
+ def initialize(user_agent)
7
+ @user_agent = user_agent
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -5,28 +5,35 @@ module Split
5
5
  class Session
6
6
  include Split::Helper
7
7
 
8
- attr_accessor :session_id, :options
8
+ attr_accessor :session_id, :request, :options
9
9
 
10
10
  CONFIG_ERROR_MESSAGE = 'Set SPLIT_YAML_CONFIG to a valid path.'.freeze
11
11
 
12
12
  def initialize(session_id, options = {})
13
13
  @session_id = session_id
14
14
  @options = options
15
+ @request = Request.new(options.fetch(:user_agent, 'CLI'))
15
16
  config_split!
16
17
  end
17
18
 
18
19
  def ab_test(*args)
19
- raise(Split::Cli::CommandError, 'No experiment name provided') unless args.any?
20
+ raise_unless_valid_args!(args)
20
21
  super
21
22
  end
22
23
 
23
24
  def finished(*args)
24
- raise(Split::Cli::CommandError, 'No experiment name provided') unless args.any?
25
+ raise_unless_valid_args!(args)
25
26
  super
26
27
  end
27
28
 
29
+ public :is_robot?
30
+
28
31
  private
29
32
 
33
+ def raise_unless_valid_args!(args)
34
+ raise(Split::Cli::CommandError, 'No experiment name provided') unless args.any?
35
+ end
36
+
30
37
  def config_split!
31
38
  Split.redis = options.fetch :redis_url, ENV.fetch('REDIS_URL', 'localhost:6379')
32
39
  Split.redis.namespace = options.fetch :redis_namespace, ENV.fetch('REDIS_NAMESPACE', 'split')
@@ -1,5 +1,5 @@
1
1
  module Split
2
2
  module Cli
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig McNamara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-02 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,6 +100,7 @@ files:
100
100
  - bin/setup
101
101
  - bin/split-cli
102
102
  - lib/split/cli.rb
103
+ - lib/split/cli/request.rb
103
104
  - lib/split/cli/session.rb
104
105
  - lib/split/cli/version.rb
105
106
  - split-cli.gemspec