splut 0.0.0 → 0.0.1

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
  SHA256:
3
- metadata.gz: 0e1c05291d4af2b51489b791fc575c2f969d89b4f419643c3faca727da485816
4
- data.tar.gz: d8b4a1e6048fc88aea0f986bfb9a596af2e7d33283fe8d7c1dc1f97447e070b5
3
+ metadata.gz: 63f7aee30ef4c49e78226f4adf3fa3b81f80cc6d530210588915e1a8686cb660
4
+ data.tar.gz: a1e4eea2407a15836f7e85070ebd8bffaafcdfc33a163ed1a3d5b38fed4fe27f
5
5
  SHA512:
6
- metadata.gz: 32e9bbd83a3a0939e7e6241a4b3e24d9cbac802d393c640fe1c1a5e94688c0ea653bdecad84d0872a8d6fb85767df14f1140444be988d0198231c31fb4528ce5
7
- data.tar.gz: 12bd1b2c9ddc94f941a18f9ca008b777d433f45a208021b781c71574224f1f19f78c61111012228c7c40343f3d115c5a2c6ab6be5b021ad5186f3d3a70b686e3
6
+ metadata.gz: 3bab50c05a714608459eb4e9438d002a1d708f54ef3f612938fe0d3b1ef27ed9f7508030eda6066259d8573a67e617fc8d91080741e43cf533a82ab8796d3020
7
+ data.tar.gz: 2ed3375c2b39139cd73c08381b1d10456a40f8f2a161caa3a8b0e179b5dc6d93f88749309cde9a58f75da56d89c1e0c2ec31ae699397b9d24b5f0a69bd28cf3b
@@ -0,0 +1,27 @@
1
+
2
+ require 'rails/generators'
3
+
4
+ module Splut
5
+ class InstallGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ desc "Creates a Splut Initializer"
9
+
10
+ source_root File.expand_path('../templates', __dir__)
11
+
12
+ def self.next_migration_number(path)
13
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
14
+ end
15
+
16
+ desc "Creates an initializer for Splut and copy files to your application."
17
+ def create_splut_migration
18
+ migration_template "create_splut_tables.rb", "db/migrate/create_splut_tables.rb"
19
+ end
20
+
21
+ def migration_version
22
+ "[#{ActiveRecord::Migration.current_version}]" if ActiveRecord::Migration.respond_to?(:current_version)
23
+ end
24
+ end
25
+ end
26
+
27
+
@@ -0,0 +1,56 @@
1
+ class CreateSplutTables < ActiveRecord::Migration<%= migration_version %>
2
+ def self.up
3
+ ActiveRecord::Base.transaction do
4
+
5
+ create_table :experiments do |t|
6
+ t.string :name
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ create_table :variations do |t|
12
+ t.integer :experiment_id
13
+ t.string :name
14
+ t.string :letter_designation
15
+ t.integer :_impression_total, default: 0, null: false
16
+ t.integer :_segmentation_total, default: 0, null: false
17
+ t.integer :_impression_success, default: 0, null: false
18
+ t.integer :_segmentation_success, default: 0, null: false
19
+
20
+ t.timestamps
21
+ end
22
+
23
+ create_table :impressions do |t|
24
+ t.integer :variation_id
25
+ t.boolean :success
26
+ t.datetime :success_at
27
+ t.integer :splutable_id
28
+ t.string :splutable_type
29
+ t.integer :segment_participant_id
30
+
31
+ t.timestamps
32
+ end
33
+
34
+ create_table :segment_participants do |t|
35
+ t.integer :variation_id
36
+ t.boolean :success
37
+ t.datetime :success_at
38
+ t.integer :splutable_id
39
+ t.string :splutable_type
40
+
41
+ t.timestamps
42
+ end
43
+ end
44
+ end
45
+
46
+
47
+ def self.down
48
+ ActiveRecord::Base.transaction do
49
+ drop_table :experiments
50
+ drop_table :impressions
51
+ drop_table :segment_participants
52
+ drop_table :variations
53
+
54
+ end
55
+ end
56
+ end
data/lib/railtie.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Splut
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ require 'generators/splut/install_generator.rb'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+
2
+
3
+ module Splut
4
+ class Experiment < ActiveRecord::Base
5
+ self.table_name = "experiments"
6
+
7
+ has_many :variations
8
+
9
+
10
+ def is_in_group?(splutable_thing)
11
+ # only checks to see if they are already segemented
12
+ # but will not segement them
13
+ end
14
+
15
+ def retrieve_group!(splutable_thing)
16
+ # will return the segment participant if the
17
+ # thing is already in the experiment
18
+ #
19
+ #
20
+ # will put the participant into the experiment if not
21
+ end
22
+
23
+
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ require 'counter_culture'
2
+
3
+
4
+ module Splut
5
+ class Impression < ActiveRecord::Base
6
+ self.table_name = "impressions"
7
+
8
+ belongs_to :variation
9
+
10
+ belongs_to :splutable, polymorphic: true
11
+
12
+
13
+ counter_culture :variation, column_name: '_impression_total'
14
+ counter_culture :variation, column_name: proc {|model| model.success ? '_impression_success' : nil }
15
+
16
+
17
+ def success!
18
+ # set this impression to successful
19
+ # set the segment participant to successufl
20
+ #
21
+ #
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+
2
+ require 'counter_culture'
3
+
4
+ module Splut
5
+ class SegementParticipant < ActiveRecord::Base
6
+ self.table_name = "segment_participants"
7
+
8
+ belongs_to :variation
9
+ belongs_to :splutable, polymorphic: true
10
+
11
+ counter_culture :variation, column_name: :_segment_total
12
+ counter_culture :variation, column_name: proc {|model| model.success ? '_segment_success' : nil }
13
+
14
+ def success!
15
+ # since we don't know the impression, just guess
16
+ # that the last impression was the successful one
17
+ #
18
+ #
19
+ # set this + the last impression to successful
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+
2
+ module Splut
3
+ class Variation < ActiveRecord::Base
4
+ self.table_name = "variations"
5
+ belongs_to :experiment
6
+
7
+
8
+
9
+ has_many :impressions
10
+ has_many :segment_participants
11
+
12
+
13
+ end
14
+ end
data/lib/splut.rb ADDED
@@ -0,0 +1,36 @@
1
+ # note this file must be named identically to the gem's name (using hyphen)
2
+ # for it to be picked up in the Gem build
3
+ #
4
+ # THIS FILE IS NOT in the specs and is for the gem builder
5
+
6
+ $LOAD_PATH.unshift __dir__
7
+
8
+ def require_all(path)
9
+ pattern = File.join(__dir__, path, "*.rb")
10
+ Dir.glob(pattern).sort.each do |f|
11
+ require f
12
+ end
13
+ end
14
+
15
+ # require_all("generators/templates")
16
+ require_all("generators/splut")
17
+ require_all("splut/controllers/concerns")
18
+ require_all("splut/models")
19
+ # primary module for UTM. note this file is included in the specs
20
+
21
+ module Splut
22
+ require "railtie.rb" if defined?(Rails)
23
+
24
+ class Settings
25
+
26
+ end
27
+
28
+ def self.configure(&block)
29
+ @_settings = Settings.new
30
+
31
+ block.call(@_settings)
32
+ end
33
+
34
+ end
35
+
36
+
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Splut
2
+ VERSION = "0.0.1"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: counter_culture
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: simplecov
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -57,7 +71,16 @@ email: code@jasonfb.net
57
71
  executables: []
58
72
  extensions: []
59
73
  extra_rdoc_files: []
60
- files: []
74
+ files:
75
+ - lib/generators/splut/install_generator.rb
76
+ - lib/generators/templates/create_splut_tables.rb
77
+ - lib/railtie.rb
78
+ - lib/splut.rb
79
+ - lib/splut/models/experiment.rb
80
+ - lib/splut/models/impression.rb
81
+ - lib/splut/models/segement_participant.rb
82
+ - lib/splut/models/variation.rb
83
+ - lib/version.rb
61
84
  homepage: https://heliosdev.shop/splut/
62
85
  licenses:
63
86
  - MIT