split-builder 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e671e123b348093ce0bb0b5683eb15c07f05ddea
4
+ data.tar.gz: 02e5187bbf695c0d879e187d018ba677c664b0f7
5
+ SHA512:
6
+ metadata.gz: 95daef950f43e6185a35c271c1f9fbcdb0d39bf08a2b1446727ed0daf2a88e720a8e6009ee3f79ef02d5b29a721c71700da3649af5dcf927d16eafdfd92aa9e1
7
+ data.tar.gz: 5bd21f33ef50d28c11a8e718cd4447fe249cf7507cb013c5340eaf0c6a59787e6414eeb10477bf7e188e2100e154a6206578760b8b35e3e3a3642395df8d66df
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.8
5
+ before_install: gem install bundler -v 1.13.5
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mark.allen@vydia.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Vydia, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # SplitBuilder
2
+
3
+ Keep your Routes, Controllers and Models thin.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'split-builder'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install split-builder
20
+
21
+ ## Usage
22
+
23
+ TODO
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Vydia/split-builder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["spec/**/*_spec.rb"]
8
+ end
9
+
10
+ task :spec => :test
11
+ task :default => :test
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "split-builder"
5
+ require "irb"
6
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ bundle install
@@ -0,0 +1,6 @@
1
+ module SplitBuilder
2
+ class BuilderError < StandardError; end
3
+ class MetricAlreadyDefinedError < BuilderError; end
4
+ class ExperimentAlreadyHasMetricError < BuilderError; end
5
+ class UndefinedGoalError < BuilderError; end
6
+ end
@@ -0,0 +1,37 @@
1
+ module SplitBuilder
2
+ class Experiment
3
+
4
+ def self.define(experiment_name, &block)
5
+ new(experiment_name, &block)
6
+ end
7
+
8
+ attr_reader :name, :metric_name
9
+
10
+ def initialize(experiment_name, &block)
11
+ @name = experiment_name
12
+ instance_exec(&block)
13
+ end
14
+
15
+ def alternatives
16
+ @alternatives ||= []
17
+ end
18
+
19
+ private
20
+
21
+ # Builder DSL
22
+
23
+ def metric(metric_name, &block)
24
+ if @metric_name
25
+ raise ExperimentAlreadyHasMetricError, "An experiment may not have more than one metric."
26
+ end
27
+
28
+ @metric_name = metric_name
29
+ end
30
+
31
+ def alternative(alternative_name, options = {})
32
+ # TODO: class Alternative
33
+ alternatives << options.merge(:name => alternative_name)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ module SplitBuilder
2
+ class Metric
3
+
4
+ def self.define(metric_name, &block)
5
+ new(metric_name, &block)
6
+ end
7
+
8
+ attr_reader :name
9
+
10
+ def initialize(metric_name, &block)
11
+ @name = metric_name
12
+ instance_exec(&block) if block_given?
13
+ goal(metric_name) if goals.empty?
14
+ end
15
+
16
+ def goals
17
+ @goals ||= []
18
+ end
19
+
20
+ private
21
+
22
+ # Builder DSL
23
+
24
+ def goal(goal_name)
25
+ goals << goal_name
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,51 @@
1
+ module SplitBuilder
2
+ class Schema
3
+
4
+ def self.define(&block)
5
+ new(&block)
6
+ end
7
+
8
+ def initialize(&block)
9
+ instance_exec(&block)
10
+ end
11
+
12
+ public
13
+
14
+ def get_metric_by_name(metric_name)
15
+ metrics.fetch(metric_name)
16
+ end
17
+
18
+ def goals
19
+ @goals ||= []
20
+ end
21
+
22
+ def metrics
23
+ @metrics ||= {}
24
+ end
25
+
26
+ def experiments
27
+ @experiments ||= []
28
+ end
29
+
30
+ private
31
+
32
+ # Builder DSL
33
+
34
+ def goal(goal_name)
35
+ goals << goal_name
36
+ end
37
+
38
+ def metric(metric_name, &block)
39
+ if metrics.key?(metric_name)
40
+ raise MetricAlreadyDefinedError, "Can't define another metric with the same name: #{metric_name.inspect}"
41
+ end
42
+
43
+ metrics[metric_name] = Metric.define(metric_name, &block)
44
+ end
45
+
46
+ def experiment(experiment_name, &block)
47
+ experiments << Experiment.define(experiment_name, &block)
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module SplitBuilder
2
+ VERSION = "0.0.1".freeze
3
+ end
@@ -0,0 +1,46 @@
1
+ module SplitBuilder
2
+
3
+ module_function
4
+
5
+ # Given a SplitBuilder::Schema, get an experiments hash formatted for Split gem.
6
+ def dump_experiments(schema)
7
+ schema.experiments.each_with_object({}) do |experiment, experiments|
8
+ metric = schema.get_metric_by_name(experiment.metric_name)
9
+
10
+ experiments[experiment.name.to_s] = {
11
+ :metric => metric.name,
12
+ :goals => dump_goals(metric.goals, schema.goals),
13
+ :alternatives => dump_alternatives(experiment.alternatives),
14
+ :resettable => false # TODO: Pull from a default config.
15
+ }
16
+ end
17
+ end
18
+
19
+ # Private
20
+
21
+ def dump_goals(metric_goals, schema_goals)
22
+ undefined_goals = metric_goals - schema_goals
23
+
24
+ if undefined_goals.any?
25
+ raise UndefinedGoalError, "Goals #{undefined_goals.inspect} must be present in schema's defined goals: #{schema_goals.inspect}"
26
+ end
27
+
28
+ metric_goals.map(&:to_s)
29
+ end
30
+
31
+ def dump_alternatives(alternatives)
32
+ alternatives.map do |options|
33
+ {
34
+ :name => options.fetch(:name).to_s,
35
+ :percent => options.fetch(:percent, 50)
36
+ }
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ require "builder/version"
43
+ require "builder/errors"
44
+ require "builder/experiment"
45
+ require "builder/metric"
46
+ require "builder/schema"
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "builder/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "split-builder"
8
+ spec.version = SplitBuilder::VERSION
9
+ spec.authors = ["TSMMark"]
10
+ spec.email = ["dev@vydia.com"]
11
+
12
+ spec.summary = %q{A nice DSL for defining Experiments for the Split gem.}
13
+ spec.description = %q{No more struggling with big dumb Hashes when defining your Split Tests.}
14
+ spec.homepage = "http://github.com/Vydia/split-builder"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "pry", "~>0.10"
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "minitest", "~> 5.0"
28
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: split-builder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - TSMMark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description: No more struggling with big dumb Hashes when defining your Split Tests.
70
+ email:
71
+ - dev@vydia.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/builder/errors.rb
86
+ - lib/builder/experiment.rb
87
+ - lib/builder/metric.rb
88
+ - lib/builder/schema.rb
89
+ - lib/builder/version.rb
90
+ - lib/split-builder.rb
91
+ - split-builder.gemspec
92
+ homepage: http://github.com/Vydia/split-builder
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.8
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A nice DSL for defining Experiments for the Split gem.
116
+ test_files: []