bit_analytics 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 8978bfb9dd2bf699d69081776c673859b7893687
4
- data.tar.gz: 22dce94749ec582804d3fba2de027effa55de4b9
3
+ metadata.gz: 5fce88feba09c13d6a91ed272942b54b2e800eed
4
+ data.tar.gz: cddf8c287cce5180edd39e353da711fdde010cf9
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: a24a71ba813bdb1b5daf2177450a91bd7fb544d322cbb7e10dd58e82006751678cf6a74a79781606b034b61703f5672b16584c7cbd39aae612076bdbe1a4f039
7
- data.tar.gz: c5fdc49e40652c6eb5529f1cb23106ce3bf1f3cf5f0557d0112157da15aaf7f1cc4da956ab09c829ed63d08692c03ff6e534686db5add1e01e25a738fdbef3df
6
+ metadata.gz: ba179695e5699412b98a4c9261a8d2d910accbc7c3466e980f1a0927d5dd5ae4318952670c9d3aa640bd62a1131a110bf908e58c71159f68ce7b6816342cee93
7
+ data.tar.gz: f79c8be49beb2ebf38df68a2d76a6dfe246fc8548d2208ae69321b0b6ed4437a804625d5a6b5f16ff58dc7116c4ef877771a0de16ab813c3b6b81f8509a0e103
data/lib/bit_analytics.rb CHANGED
@@ -12,17 +12,18 @@ class BitAnalytics
12
12
  end
13
13
  end
14
14
 
15
- #--- Events marking and deleting ---
16
15
  # Marks an event for hours, days, weeks and months.
17
- # :param :event_name The name of the event, could be "active" or "new_signups"
18
- # :param :uuid An unique id, typically user id. The id should not be huge, read Redis documentation why (bitmaps)
19
- # :param :now Which date should be used as a reference point, default is `datetime.utcnow`
20
- # :param :track_hourly Should hourly stats be tracked, defaults to bitanalytics.TRACK_HOURLY, but an be changed
21
- # Examples:
16
+ #
17
+ # * +event_name+ - The name of the event, could be "active" or "new_signups"
18
+ # * +uuid+ - An unique id, typically user id. The id should not be huge, read Redis documentation why (bitmaps)
19
+ # * +now+ - Which date should be used as a reference point, default is `Time.now.getutc`
20
+ # * +track_hourly+ - Should hourly stats be tracked
21
+ #
22
+ # ==== Example
22
23
  # Mark id 1 as active
23
- # mark_event('active', 1)
24
+ # @bit_analytics.mark_event('active', 1)
24
25
  # Mark task completed for id 252
25
- # mark_event('tasks:completed', 252)
26
+ # @bit_analytics.mark_event('tasks:completed', 252)
26
27
  def mark_event(event_name, uuid, now: nil, track_hourly: nil)
27
28
  # Has memory applications
28
29
  track_hourly ||= false
@@ -116,11 +117,11 @@ class BitAnalytics
116
117
 
117
118
  #--- Events ---
118
119
 
119
- # Extends with an obj.has_events_marked()
120
- # that returns `True` if there are any events marked,
121
- # otherwise `False` is returned.
120
+ # Extends with an obj.has_events_marked
121
+ # that returns truw if there are any events marked,
122
+ # otherwise false is returned.
122
123
 
123
- # Extens also with a obj.delete()
124
+ # Extends also with a obj.delete
124
125
  # (useful for deleting temporary calculations).
125
126
 
126
127
  module MixinEventsMisc
@@ -132,8 +133,8 @@ class BitAnalytics
132
133
  end
133
134
  end
134
135
 
135
- # Extends with an obj.get_count() that uses BITCOUNT to
136
- # count all the events. Supports also __len__
136
+ # Extends with an obj.get_count that uses BITCOUNT to
137
+ # count all the events. Supports also length.
137
138
 
138
139
  module MixinCounts
139
140
  def get_count
@@ -146,8 +147,8 @@ class BitAnalytics
146
147
  end
147
148
 
148
149
  # Makes it possible to see if an uuid has been marked.
149
- # Example:
150
- # user_active_today = 123 in DayEvents('active', 2012, 10, 23)
150
+ # ==== Example
151
+ # user_active_today = @bit_analytics.day_events('active', 2012, 10, 23).includes?(123)
151
152
  module MixinContains
152
153
  def includes?(uuid)
153
154
  if @redis.getbit(self.redis_key, uuid) == 1
@@ -166,8 +167,8 @@ end
166
167
 
167
168
 
168
169
  # Events for a month.
169
- # Example:
170
- # MonthEvents('active', 2012, 10)
170
+ # ==== Example
171
+ # @bit_analytics.month_events('active', 2012, 10)
171
172
  class MonthEvents < BitAnalytics
172
173
  include RedisConnection
173
174
  include MixinCounts
@@ -182,8 +183,8 @@ class MonthEvents < BitAnalytics
182
183
  end
183
184
 
184
185
  # Events for a week.
185
- # Example:
186
- # WeekEvents('active', 2012, 48)
186
+ # ==== Example
187
+ # @bit_analytics.week_events('active', 2012, 48)
187
188
  class WeekEvents < BitAnalytics
188
189
  include RedisConnection
189
190
  include MixinCounts
@@ -196,8 +197,8 @@ class WeekEvents < BitAnalytics
196
197
  end
197
198
 
198
199
  # Events for a day.
199
- # Example:
200
- # DayEvents('active', 2012, 10, 23)
200
+ # ==== Example
201
+ # @bit_analytics.day_events('active', 2012, 10, 23)
201
202
  class DayEvents < BitAnalytics
202
203
  include RedisConnection
203
204
  include MixinCounts
@@ -210,8 +211,8 @@ class DayEvents < BitAnalytics
210
211
  end
211
212
 
212
213
  # Events for a hour.
213
- # Example:
214
- # HourEvents('active', 2012, 10, 23, 13)
214
+ # ==== Example
215
+ # @bit_analytics.hour_events('active', 2012, 10, 23, 13)
215
216
  class HourEvents < BitAnalytics
216
217
  include RedisConnection
217
218
  include MixinCounts
@@ -224,22 +225,22 @@ class HourEvents < BitAnalytics
224
225
  end
225
226
 
226
227
  #--- Bit operations ---
228
+
227
229
  # Base class for bit operations (AND, OR, XOR).
228
230
  # Please note that each bit operation creates a new key prefixed with `bitanalytics_bitop_`.
229
231
  # These temporary keys can be deleted with `delete_temporary_bitop_keys`.
230
-
231
232
  # You can even nest bit operations.
232
- # Example:
233
- # active_2_months = BitOpAnd(
234
- # MonthEvents('active', last_month.year, last_month.month),
235
- # MonthEvents('active', now.year, now.month)
233
+ # ==== Example
234
+ # active_2_months = @bit_analytics.bit_op_and(
235
+ # @bit_analytics.month_events('active', last_month.year, last_month.month),
236
+ # @bit_analytics.month_events('active', now.year, now.month)
236
237
  # )
237
- # active_2_months = BitOpAnd(
238
- # BitOpAnd(
239
- # MonthEvents('active', last_month.year, last_month.month),
240
- # MonthEvents('active', now.year, now.month)
238
+ # active_2_months = @bit_analytics.bit_op_and(
239
+ # @bit_analytics.bit_op_and(
240
+ # @bit_analytics.month_events('active', last_month.year, last_month.month),
241
+ # @bit_analytics.month_events('active', now.year, now.month)
241
242
  # ),
242
- # MonthEvents('active', now.year, now.month)
243
+ # @bit_analytics.month_events('active', now.year, now.month)
243
244
  # )
244
245
  class BitOperation < BitAnalytics
245
246
  include MixinContains
@@ -1,3 +1,3 @@
1
1
  class BitAnalytics
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bit_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jure Triglav