omnikiq 0.1.0
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 +7 -0
- data/lib/capistrano/templates/puma.rb +21 -0
- data/lib/omnikiq.rb +42 -0
- data/lib/omnikiq/configuration.rb +59 -0
- data/lib/omnikiq/trackers/base.rb +13 -0
- data/lib/omnikiq/trackers/mixpanel_alias.rb +9 -0
- data/lib/omnikiq/trackers/mixpanel_events.rb +12 -0
- data/lib/omnikiq/trackers/mixpanel_people.rb +12 -0
- data/spec/configuration_spec.rb +11 -0
- data/spec/omnikiq_spec.rb +23 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/rspec.rb +4 -0
- data/spec/trackers/mixpanel_alias_spec.rb +19 -0
- data/spec/trackers/mixpanel_events_spec.rb +19 -0
- data/spec/trackers/mixpanel_people_spec.rb +21 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c4121b6ebf9f51bd0e9020663ac39cff9cfe1864
|
4
|
+
data.tar.gz: 3a989e94a75d2dc74a511500536569fc91fb4093
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c52418f0c0e1de3d7d46c4baa08838a7cc27a4551798cb28ac8abe7b4234d46bd8a9eed80f0a309cfcc3e108caccafc9947d22b00e47128e02132f8a6e11e920
|
7
|
+
data.tar.gz: eebf1bab2bcfd1716b2e12fdfdea88242e8ba33a0de175775f032bfc6a0e505a474a9042d9b2c4549d6f523dee8b9a3484a6e51f17c7e56acb9043e6ede375b4
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env puma
|
2
|
+
|
3
|
+
directory '/var/www/omnikiq/current'
|
4
|
+
rackup '/var/www/omnikiq/current/config.ru'
|
5
|
+
environment ENV['RACK_ENV']
|
6
|
+
|
7
|
+
pidfile '/var/www/omnikiq/shared/tmp/pids/puma.pid'
|
8
|
+
state_path '/var/www/omnikiq/shared/tmp/pids/puma.state'
|
9
|
+
stdout_redirect '/var/www/omnikiq/shared/log/puma_access.log', '/var/www/omnikiq/shared/log/puma_error.log', true
|
10
|
+
|
11
|
+
threads 0, 2
|
12
|
+
|
13
|
+
bind 'unix:/var/www/omnikiq/shared/tmp/sockets/puma.sock'
|
14
|
+
workers 2
|
15
|
+
|
16
|
+
preload_app!
|
17
|
+
|
18
|
+
on_restart do
|
19
|
+
puts 'Refreshing Gemfile'
|
20
|
+
ENV['BUNDLE_GEMFILE'] = '/var/www/omnikiq/current/Gemfile'
|
21
|
+
end
|
data/lib/omnikiq.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
require 'mixpanel-ruby'
|
3
|
+
|
4
|
+
require 'omnikiq/configuration'
|
5
|
+
require 'omnikiq/trackers/base'
|
6
|
+
|
7
|
+
module OmniKiq
|
8
|
+
class << self
|
9
|
+
attr_writer :configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
module Trackers
|
13
|
+
autoload :MixpanelAlias, 'omnikiq/trackers/mixpanel_alias'
|
14
|
+
autoload :MixpanelEvents, 'omnikiq/trackers/mixpanel_events'
|
15
|
+
autoload :MixpanelPeople, 'omnikiq/trackers/mixpanel_people'
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= begin
|
20
|
+
config = OmniKiq::Configuration.new
|
21
|
+
config
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configure
|
26
|
+
yield configuration if block_given?
|
27
|
+
configure_client
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure_client
|
31
|
+
Sidekiq.configure_client do |config|
|
32
|
+
config.redis = {
|
33
|
+
url: OmniKiq.configuration.redis_url,
|
34
|
+
namespace: OmniKiq.configuration.redis_namespace,
|
35
|
+
size: 10
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# default config for the client
|
41
|
+
configure_client
|
42
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module OmniKiq
|
2
|
+
class Configuration
|
3
|
+
# Module that holds `attr_reader` declarations. It's in a separate
|
4
|
+
# module to allow us to override those methods and use `super`.
|
5
|
+
# @private
|
6
|
+
READERS = Module.new
|
7
|
+
include READERS
|
8
|
+
|
9
|
+
# @private
|
10
|
+
def self.define_reader(name)
|
11
|
+
READERS.class_eval do
|
12
|
+
remove_method name if method_defined?(name)
|
13
|
+
attr_reader name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# @private
|
18
|
+
def self.define_aliases(name, alias_name)
|
19
|
+
alias_method alias_name, name
|
20
|
+
alias_method "#{alias_name}=", "#{name}="
|
21
|
+
define_predicate_for alias_name
|
22
|
+
end
|
23
|
+
|
24
|
+
# @private
|
25
|
+
def self.define_predicate_for(*names)
|
26
|
+
names.each { |name| alias_method "#{name}?", name }
|
27
|
+
end
|
28
|
+
# @private
|
29
|
+
#
|
30
|
+
# Invoked by the `add_setting` instance method. Use that method on a
|
31
|
+
# `Configuration` instance rather than this class method.
|
32
|
+
def self.add_setting(name, opts = {})
|
33
|
+
attr_writer name
|
34
|
+
add_read_only_setting name
|
35
|
+
Array(opts[:alias_with]).each do |alias_name|
|
36
|
+
define_aliases(name, alias_name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
# @private
|
40
|
+
#
|
41
|
+
# As `add_setting` but only add the reader.
|
42
|
+
def self.add_read_only_setting(name, _opts = {})
|
43
|
+
define_reader name
|
44
|
+
define_predicate_for name
|
45
|
+
end
|
46
|
+
|
47
|
+
add_setting :mixpanel_api_key
|
48
|
+
add_setting :redis_url
|
49
|
+
add_setting :redis_namespace
|
50
|
+
add_setting :test_mode
|
51
|
+
|
52
|
+
def initialize
|
53
|
+
@mixpanel_api_key = ''
|
54
|
+
@redis_url = 'redis://localhost:6379'
|
55
|
+
@redis_namespace = ENV['RACK_ENV'] || 'default'
|
56
|
+
@test_mode = false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniKiq::Configuration do
|
4
|
+
subject { OmniKiq::Configuration.new }
|
5
|
+
|
6
|
+
describe 'sensible defaults' do
|
7
|
+
its(:mixpanel_api_key) { is_expected.to eq '' }
|
8
|
+
its(:redis_url) { is_expected.to eq 'redis://localhost:6379' }
|
9
|
+
its(:redis_namespace) { 'default' }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniKiq do
|
4
|
+
describe :configure do
|
5
|
+
subject { OmniKiq.configuration }
|
6
|
+
|
7
|
+
before do
|
8
|
+
OmniKiq.configure do |c|
|
9
|
+
c.mixpanel_api_key = 'mixpanel id'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:mixpanel_api_key) { is_expected.to eq 'mixpanel id' }
|
14
|
+
|
15
|
+
it 'sets to new config settings to the sidekiq client' do
|
16
|
+
expect(OmniKiq).to receive(:configure_client)
|
17
|
+
|
18
|
+
OmniKiq.configure do |c|
|
19
|
+
c.mixpanel_api_key = 'mixpanel id'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
ENV['RACK_ENV'] ||= 'test'
|
4
|
+
|
5
|
+
require 'omnikiq'
|
6
|
+
require 'rspec/its'
|
7
|
+
|
8
|
+
# Require all of the RSpec Support libraries
|
9
|
+
Dir[File.expand_path(File.join('../support/**/*.rb'), __FILE__)].each { |f| require f }
|
10
|
+
|
11
|
+
require 'simplecov'
|
12
|
+
require 'simplecov-teamcity-summary'
|
13
|
+
SimpleCov.start 'teamcity'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniKiq::Trackers::MixpanelAlias do
|
4
|
+
describe :perform do
|
5
|
+
let(:mixpanel_alias) { OmniKiq::Trackers::MixpanelAlias.new }
|
6
|
+
let(:mixpanel_tracker) { double(Mixpanel::Tracker) }
|
7
|
+
|
8
|
+
subject { mixpanel_alias.perform('oh@yeah.com', '42') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
mixpanel_alias.mixpanel_tracker = mixpanel_tracker
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'will call alias with the correct params' do
|
15
|
+
expect(mixpanel_tracker).to receive(:alias).with('oh@yeah.com', '42')
|
16
|
+
subject
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniKiq::Trackers::MixpanelEvents do
|
4
|
+
describe :perform do
|
5
|
+
let(:mixpanel_events) { OmniKiq::Trackers::MixpanelEvents.new }
|
6
|
+
let(:mixpanel_tracker) { double(Mixpanel::Tracker) }
|
7
|
+
|
8
|
+
subject { mixpanel_events.perform('devil@feel.i', 'find love', {}) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
mixpanel_events.mixpanel_tracker = mixpanel_tracker
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'will call track with correct params' do
|
15
|
+
expect(mixpanel_tracker).to receive(:track).with('devil@feel.i', 'find love', {}, 0)
|
16
|
+
subject
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniKiq::Trackers::MixpanelPeople do
|
4
|
+
describe :perform do
|
5
|
+
let(:mixpanel_people) { OmniKiq::Trackers::MixpanelPeople.new }
|
6
|
+
let(:mixpanel_tracker) { double(Mixpanel::Tracker) }
|
7
|
+
|
8
|
+
subject { mixpanel_people.perform('42', {}) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
mixpanel_people.mixpanel_tracker = mixpanel_tracker
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'will call set with correct params' do
|
15
|
+
people = double(:people)
|
16
|
+
expect(mixpanel_tracker).to receive(:people).and_return(people)
|
17
|
+
expect(people).to receive(:set).with('42', {}, 0)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omnikiq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Nistor
|
8
|
+
- Alexandru Calinoiu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mixpanel-ruby
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: sidekiq
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec-its
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1'
|
84
|
+
description: A gem used to defer posts to mixpanel in a background worker.
|
85
|
+
email: nistor.adrian@agilefreaks.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/capistrano/templates/puma.rb
|
91
|
+
- lib/omnikiq.rb
|
92
|
+
- lib/omnikiq/configuration.rb
|
93
|
+
- lib/omnikiq/trackers/base.rb
|
94
|
+
- lib/omnikiq/trackers/mixpanel_alias.rb
|
95
|
+
- lib/omnikiq/trackers/mixpanel_events.rb
|
96
|
+
- lib/omnikiq/trackers/mixpanel_people.rb
|
97
|
+
- spec/configuration_spec.rb
|
98
|
+
- spec/omnikiq_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/support/rspec.rb
|
101
|
+
- spec/trackers/mixpanel_alias_spec.rb
|
102
|
+
- spec/trackers/mixpanel_events_spec.rb
|
103
|
+
- spec/trackers/mixpanel_people_spec.rb
|
104
|
+
homepage: https://github.com/Agilefreaks/OmniKiq
|
105
|
+
licenses:
|
106
|
+
- "© 2015 Omnipaste"
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 2.1.5
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.5
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Integrate mixpanel and sidekiq in your ruby app
|
128
|
+
test_files:
|
129
|
+
- spec/configuration_spec.rb
|
130
|
+
- spec/omnikiq_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
- spec/support/rspec.rb
|
133
|
+
- spec/trackers/mixpanel_alias_spec.rb
|
134
|
+
- spec/trackers/mixpanel_events_spec.rb
|
135
|
+
- spec/trackers/mixpanel_people_spec.rb
|