minuteman 2.0.0.pre → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/minuteman.rb +4 -0
- data/lib/minuteman/analyzable.rb +2 -2
- data/lib/minuteman/analyzer.rb +0 -4
- data/lib/minuteman/model.rb +2 -0
- data/lib/minuteman/user.rb +9 -0
- data/minuteman.gemspec +1 -1
- data/test/minuteman_test.rb +23 -0
- metadata +5 -5
- data/lib/minuteman/trigger.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d96820b756c302030f2a5758b0da28c5180158e0
|
4
|
+
data.tar.gz: 202b4c5ad523ea3a95826b398ebb53ba11b7480c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d673fb5af390e80cb753487785e3d63e2f5c9029761092079266e39aff090a14c21cbd935e7e6b13d98144dd15607dab22f805212757846bbbfbd214cd8778f
|
7
|
+
data.tar.gz: ee9a2b9a6dee683c9798bbe097ffe113d0c5ecb47fa3a62997860a069cc896225c6f7faf55d54fea0941bbba721a8273defda5b0c7c77fd4adcd73b2b3c3b720
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/lib/minuteman.rb
CHANGED
data/lib/minuteman/analyzable.rb
CHANGED
@@ -63,7 +63,8 @@ module Minuteman
|
|
63
63
|
Minuteman::Result.new(destination_key)
|
64
64
|
end
|
65
65
|
|
66
|
-
#
|
66
|
+
# Code taken from Ohm. Just small changes to adapt to the current Minuteman
|
67
|
+
# stuff. elcuervo <3 (soveran + djanowski)
|
67
68
|
def script(file, *args)
|
68
69
|
begin
|
69
70
|
cache = Minuteman::LUA_CACHE[Minuteman.config.redis.url]
|
@@ -91,6 +92,5 @@ module Minuteman
|
|
91
92
|
end
|
92
93
|
end
|
93
94
|
end
|
94
|
-
|
95
95
|
end
|
96
96
|
end
|
data/lib/minuteman/analyzer.rb
CHANGED
@@ -5,10 +5,6 @@ module Minuteman
|
|
5
5
|
def initialize(action, klass = Minuteman::Event, user = nil)
|
6
6
|
Minuteman.patterns.keys.each do |method|
|
7
7
|
define_singleton_method(method) do |time = Time.now.utc|
|
8
|
-
if !Minuteman.patterns.include?(method)
|
9
|
-
raise MissingPattern.new(method)
|
10
|
-
end
|
11
|
-
|
12
8
|
key = Minuteman.patterns[method].call(time)
|
13
9
|
search = { type: action, time: key }
|
14
10
|
search[:user_id] = user.id if !user.nil?
|
data/lib/minuteman/model.rb
CHANGED
data/lib/minuteman/user.rb
CHANGED
@@ -5,12 +5,16 @@ module Minuteman
|
|
5
5
|
class User < ::Ohm::Model
|
6
6
|
attribute :uid
|
7
7
|
attribute :identifier
|
8
|
+
attribute :anonymous
|
8
9
|
|
9
10
|
unique :uid
|
10
11
|
unique :identifier
|
11
12
|
|
13
|
+
index :anonymous
|
14
|
+
|
12
15
|
def save
|
13
16
|
self.uid ||= SecureRandom.uuid
|
17
|
+
self.anonymous ||= !identifier
|
14
18
|
super
|
15
19
|
end
|
16
20
|
|
@@ -26,8 +30,13 @@ module Minuteman
|
|
26
30
|
Minuteman::Analyzer.new(action, Minuteman::Counter::User, self)
|
27
31
|
end
|
28
32
|
|
33
|
+
def anonymous?
|
34
|
+
self.anonymous == true
|
35
|
+
end
|
36
|
+
|
29
37
|
def promote(identifier)
|
30
38
|
self.identifier = identifier
|
39
|
+
self.anonymous = false
|
31
40
|
save
|
32
41
|
end
|
33
42
|
|
data/minuteman.gemspec
CHANGED
data/test/minuteman_test.rb
CHANGED
@@ -202,3 +202,26 @@ scope "do actions through a user" do
|
|
202
202
|
assert user.count("login:attempts").day.count == 3
|
203
203
|
end
|
204
204
|
end
|
205
|
+
|
206
|
+
test "get all the created events" do
|
207
|
+
Minuteman.config.redis.call("FLUSHDB")
|
208
|
+
|
209
|
+
assert Minuteman.events.count == 0
|
210
|
+
|
211
|
+
10.times { |i|
|
212
|
+
Minuteman.track("test:#{i}")
|
213
|
+
}
|
214
|
+
|
215
|
+
assert Minuteman.events.count == 10
|
216
|
+
assert Minuteman.events.include?("test:5")
|
217
|
+
end
|
218
|
+
|
219
|
+
test "users are anonymous if they don't have an identifier" do
|
220
|
+
user = Minuteman.track("some_event")
|
221
|
+
|
222
|
+
assert user.anonymous? == true
|
223
|
+
|
224
|
+
user.promote 123
|
225
|
+
|
226
|
+
assert user.anonymous? == false
|
227
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minuteman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- elcuervo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redic
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gems"
|
63
|
+
- ".gitignore"
|
63
64
|
- ".travis.yml"
|
64
65
|
- HUGS
|
65
66
|
- LICENSE
|
@@ -76,7 +77,6 @@ files:
|
|
76
77
|
- lib/minuteman/lua/operations.lua
|
77
78
|
- lib/minuteman/model.rb
|
78
79
|
- lib/minuteman/result.rb
|
79
|
-
- lib/minuteman/trigger.rb
|
80
80
|
- lib/minuteman/user.rb
|
81
81
|
- minuteman.gemspec
|
82
82
|
- test/helper.rb
|
@@ -98,9 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
106
|
rubygems_version: 2.2.2
|
data/lib/minuteman/trigger.rb
DELETED