split-export 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/Rakefile +6 -0
- data/Readme.mdown +52 -0
- data/lib/split/export.rb +36 -0
- data/lib/split/export/version.rb +5 -0
- data/spec/export_spec.rb +19 -0
- data/spec/spec_helper.rb +4 -0
- data/split-export.gemspec +23 -0
- metadata +118 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Andrew Nesbitt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/Readme.mdown
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Split::Export
|
2
|
+
|
3
|
+
An extension to [Split](http://github.com/andrew/split) to allow for easy exporting of AB testing data.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
The split gem and its dependencies.
|
8
|
+
|
9
|
+
## Setup
|
10
|
+
|
11
|
+
If you are using bundler add split to your Gemfile:
|
12
|
+
|
13
|
+
gem 'split-export', :require => 'split/export'
|
14
|
+
|
15
|
+
Then run:
|
16
|
+
|
17
|
+
bundle install
|
18
|
+
|
19
|
+
Otherwise install the gem:
|
20
|
+
|
21
|
+
gem install split-export
|
22
|
+
|
23
|
+
and require it in your project:
|
24
|
+
|
25
|
+
require 'split/export'
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
require 'split/export'
|
30
|
+
csv_data = Split::Export.to_csv
|
31
|
+
File.open('path/to/my.csv, 'w') {|f| f.write(csv_data) }
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
Source hosted at [GitHub](http://github.com/andrew/split-export).
|
36
|
+
Report Issues/Feature requests on [GitHub Issues](http://github.com/andrew/split-export/issues).
|
37
|
+
|
38
|
+
Tests can be ran with `rake spec`
|
39
|
+
|
40
|
+
### Note on Patches/Pull Requests
|
41
|
+
|
42
|
+
* Fork the project.
|
43
|
+
* Make your feature addition or bug fix.
|
44
|
+
* Add tests for it. This is important so I don't break it in a
|
45
|
+
future version unintentionally.
|
46
|
+
* Commit, do not mess with rakefile, version, or history.
|
47
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
48
|
+
* Send me a pull request. Bonus points for topic branches.
|
49
|
+
|
50
|
+
## Copyright
|
51
|
+
|
52
|
+
Copyright (c) 2011 Andrew Nesbitt. See LICENSE for details.
|
data/lib/split/export.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'split'
|
2
|
+
require 'csv'
|
3
|
+
require 'bigdecimal'
|
4
|
+
|
5
|
+
if CSV.const_defined? :Reader
|
6
|
+
require 'fastercsv'
|
7
|
+
CSV = FasterCSV
|
8
|
+
end
|
9
|
+
|
10
|
+
module Split
|
11
|
+
module Export
|
12
|
+
extend self
|
13
|
+
|
14
|
+
def round(number, precision = 2)
|
15
|
+
BigDecimal.new(number.to_s).round(precision).to_f
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_csv
|
19
|
+
csv = CSV.generate do |csv|
|
20
|
+
csv << ['Experiment', 'Alternative', 'Participants', 'Completed', 'Conversion Rate', 'Z score', 'Control', 'Winner']
|
21
|
+
Split::Experiment.all.each do |experiment|
|
22
|
+
experiment.alternatives.each do |alternative|
|
23
|
+
csv << [experiment.name,
|
24
|
+
alternative.name,
|
25
|
+
alternative.participant_count,
|
26
|
+
alternative.completed_count,
|
27
|
+
round(alternative.conversion_rate, 3),
|
28
|
+
round(alternative.z_score, 3),
|
29
|
+
alternative.control?,
|
30
|
+
alternative.to_s == experiment.winner.to_s]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/export_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Split::Export do
|
4
|
+
before :each do
|
5
|
+
experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red', 'green')
|
6
|
+
blue = Split::Alternative.find('blue', 'link_color')
|
7
|
+
blue.participant_count = 5
|
8
|
+
blue.completed_count = 3
|
9
|
+
blue.save
|
10
|
+
red = Split::Alternative.find('red', 'link_color')
|
11
|
+
red.participant_count = 6
|
12
|
+
red.completed_count = 4
|
13
|
+
red.save
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should generate a csv of split data" do
|
17
|
+
Split::Export.to_csv.should eql("Experiment,Alternative,Participants,Completed,Conversion Rate,Z score,Control,Winner\nlink_color,blue,5,3,0.6,0.0,true,false\nlink_color,red,6,4,0.667,0.215,false,false\n")
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "split/export/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "split-export"
|
7
|
+
s.version = Split::Export::VERSION
|
8
|
+
s.authors = ["Andrew Nesbitt"]
|
9
|
+
s.email = ["andrewnez@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/andrew/split-export"
|
11
|
+
s.summary = %q{Split extension to export your data}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_dependency(%q<split>, ["~> 0.2.2"])
|
19
|
+
s.add_dependency(%q<fastercsv>, ['>= 1.2.0'])
|
20
|
+
|
21
|
+
# Development Dependencies
|
22
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.6"])
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: split-export
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andrew Nesbitt
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-12 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: split
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 2
|
31
|
+
- 2
|
32
|
+
version: 0.2.2
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: fastercsv
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 2
|
46
|
+
- 0
|
47
|
+
version: 1.2.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 6
|
61
|
+
version: "2.6"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
description:
|
65
|
+
email:
|
66
|
+
- andrewnez@gmail.com
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files: []
|
72
|
+
|
73
|
+
files:
|
74
|
+
- .gitignore
|
75
|
+
- Gemfile
|
76
|
+
- LICENSE
|
77
|
+
- Rakefile
|
78
|
+
- Readme.mdown
|
79
|
+
- lib/split/export.rb
|
80
|
+
- lib/split/export/version.rb
|
81
|
+
- spec/export_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- split-export.gemspec
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: https://github.com/andrew/split-export
|
86
|
+
licenses: []
|
87
|
+
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.3.7
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: Split extension to export your data
|
116
|
+
test_files:
|
117
|
+
- spec/export_spec.rb
|
118
|
+
- spec/spec_helper.rb
|