active_redis_stats 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fasterer.yml +19 -0
- data/.gitattributes +2 -0
- data/.gitignore +13 -0
- data/.irbrc +44 -0
- data/.reek.yml +16 -0
- data/.rspec +4 -0
- data/.rubocop.yml +21 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +6 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/active_redis_stats.gemspec +35 -0
- data/bin/console +15 -0
- data/bin/rake +15 -0
- data/bin/setup +7 -0
- data/lib/active_redis_stats/base.rb +106 -0
- data/lib/active_redis_stats/count/base.rb +13 -0
- data/lib/active_redis_stats/count/get.rb +20 -0
- data/lib/active_redis_stats/count/set.rb +27 -0
- data/lib/active_redis_stats/rank/base.rb +13 -0
- data/lib/active_redis_stats/rank/get.rb +57 -0
- data/lib/active_redis_stats/rank/set.rb +27 -0
- data/lib/active_redis_stats/version.rb +5 -0
- data/lib/active_redis_stats.rb +21 -0
- metadata +223 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3d45f723d18b29a6e875ecc5583c18c6d1ee0ba0d59c0ba67bc8eb2381a5a14a
|
4
|
+
data.tar.gz: 42d832e0aed98ef66e2f761556d045234eca8dded75c8740871d62f46e440107
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f40f595689a0105b033a16588b08d53d10e7de7cbb6d7f6b845bf92e969bde6495b9465f2211e2170af154af9d2f1c0a8097cdc4c9485b9677c508185508700
|
7
|
+
data.tar.gz: ec2def78c6cd40f15b17a905f3fe51efb5ebc18d3555d969bc15423f0e635ac830f412a491cae8ab11b1e781a69a513f1699472ca8190776fef37e1670d8475e
|
data/.fasterer.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
speedups:
|
2
|
+
rescue_vs_respond_to: true
|
3
|
+
module_eval: true
|
4
|
+
shuffle_first_vs_sample: true
|
5
|
+
for_loop_vs_each: true
|
6
|
+
each_with_index_vs_while: false
|
7
|
+
map_flatten_vs_flat_map: true
|
8
|
+
reverse_each_vs_reverse_each: true
|
9
|
+
select_first_vs_detect: true
|
10
|
+
sort_vs_sort_by: true
|
11
|
+
fetch_with_argument_vs_block: true
|
12
|
+
keys_each_vs_each_key: true
|
13
|
+
hash_merge_bang_vs_hash_brackets: true
|
14
|
+
block_vs_symbol_to_proc: true
|
15
|
+
proc_call_vs_yield: true
|
16
|
+
gsub_vs_tr: true
|
17
|
+
select_last_vs_reverse_detect: true
|
18
|
+
getter_vs_attr_reader: true
|
19
|
+
setter_vs_attr_writer: true
|
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/.irbrc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Awesome print
|
4
|
+
begin
|
5
|
+
require 'awesome_print'
|
6
|
+
|
7
|
+
AwesomePrint.irb!
|
8
|
+
rescue LoadError => err
|
9
|
+
warn "Couldn't load awesome_print: #{err}"
|
10
|
+
end
|
11
|
+
|
12
|
+
# IRB
|
13
|
+
require 'irb/completion'
|
14
|
+
|
15
|
+
ARGV.concat %w[--readline --prompt-mode simple]
|
16
|
+
|
17
|
+
IRB.conf[:PROMPT_MODE] = :SIMPLE
|
18
|
+
IRB.conf[:EVAL_HISTORY] = 1000
|
19
|
+
IRB.conf[:SAVE_HISTORY] = 1000
|
20
|
+
IRB.conf[:HISTORY_FILE] = File.expand_path('.irbrc_history')
|
21
|
+
|
22
|
+
# Rails
|
23
|
+
railsrc_path = File.expand_path('.irbrc_rails')
|
24
|
+
|
25
|
+
if (ENV['RAILS_ENV'] || defined?(Rails)) && File.exist?(railsrc_path)
|
26
|
+
begin
|
27
|
+
load railsrc_path
|
28
|
+
rescue Exception => err
|
29
|
+
warn "Could not load: #{railsrc_path} because of #{err}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Object
|
34
|
+
class Object
|
35
|
+
|
36
|
+
def interesting_methods
|
37
|
+
case self.class
|
38
|
+
when Class then public_methods.sort - Object.public_methods
|
39
|
+
when Module then public_methods.sort - Module.public_methods
|
40
|
+
else public_methods.sort - Object.new.public_methods
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/.reek.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
detectors:
|
3
|
+
BooleanParameter:
|
4
|
+
enabled: false
|
5
|
+
DuplicateMethodCall:
|
6
|
+
enabled: false
|
7
|
+
IrresponsibleModule:
|
8
|
+
enabled: false
|
9
|
+
LongParameterList:
|
10
|
+
enabled: false
|
11
|
+
NilCheck:
|
12
|
+
enabled: false
|
13
|
+
UncommunicativeVariableName:
|
14
|
+
enabled: false
|
15
|
+
UnusedParameters:
|
16
|
+
enabled: false
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
Layout/EmptyLinesAroundBlockBody:
|
6
|
+
Enabled: false
|
7
|
+
Layout/EmptyLinesAroundClassBody:
|
8
|
+
Enabled: false
|
9
|
+
LineLength:
|
10
|
+
Max: 100
|
11
|
+
Lint/RescueException:
|
12
|
+
Enabled: false
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Enabled: false
|
15
|
+
Naming/FileName:
|
16
|
+
Exclude:
|
17
|
+
- '.irbrc'
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
20
|
+
Style/ExpandPathArguments:
|
21
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# ActiveRedisStats
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/active_redis_stats`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'active_redis_stats'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install active_redis_stats
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_redis_stats. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the ActiveRedisStats project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_redis_stats/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'active_redis_stats/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'active_redis_stats'
|
9
|
+
spec.version = ActiveRedisStats::VERSION
|
10
|
+
spec.authors = ['Juan Gomez']
|
11
|
+
spec.email = ['j.gomez@drexed.com']
|
12
|
+
|
13
|
+
spec.summary = 'Gem for Redis based analytics.'
|
14
|
+
spec.description = 'Redis based analytics.'
|
15
|
+
spec.homepage = 'http://drexed.github.io/active_redis_stats'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = %w[lib]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'active_object'
|
24
|
+
spec.add_runtime_dependency 'active_redis_db'
|
25
|
+
spec.add_runtime_dependency 'activesupport'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'coveralls'
|
29
|
+
spec.add_development_dependency 'fakeredis'
|
30
|
+
spec.add_development_dependency 'generator_spec'
|
31
|
+
spec.add_development_dependency 'rake'
|
32
|
+
spec.add_development_dependency 'reek'
|
33
|
+
spec.add_development_dependency 'rspec'
|
34
|
+
spec.add_development_dependency 'rubocop'
|
35
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'active_redis_stats'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start
|
data/bin/rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'bundler/setup'
|
14
|
+
|
15
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRedisStats
|
4
|
+
class Base
|
5
|
+
|
6
|
+
TIME ||= Time.current.freeze
|
7
|
+
FORMATS ||= {
|
8
|
+
hour: 'year-month-day-hour-minute',
|
9
|
+
day: 'year-month-day-hour',
|
10
|
+
month: 'year-month-day',
|
11
|
+
year: 'year-month',
|
12
|
+
all: 'year',
|
13
|
+
inf: 'inf'
|
14
|
+
}.freeze
|
15
|
+
EXPIRES ||= {
|
16
|
+
hour: 25_200, # 7 hours
|
17
|
+
day: 691_200, # 8 days
|
18
|
+
month: 31_708_800, # 367 days
|
19
|
+
year: 317_174_400, # 3671 days
|
20
|
+
all: 317_174_400, # 3671 days
|
21
|
+
inf: nil # never
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
def self.interval_key(format, time: TIME)
|
25
|
+
format = format.to_sym
|
26
|
+
return "#{format}:#{format}" if format == :inf
|
27
|
+
|
28
|
+
interval = time.format(FORMATS[format])
|
29
|
+
"#{format}:#{interval}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.hour_key(offset: 0)
|
33
|
+
interval_key(:day, time: offset.minutes.ago(TIME))
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.hour_keys(offset: 0)
|
37
|
+
adj = (30 * offset)
|
38
|
+
max = 29 + adj
|
39
|
+
min = 0 + adj
|
40
|
+
|
41
|
+
max.downto(min).collect do |num|
|
42
|
+
interval_key(:hour, time: num.minutes.ago(TIME))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.day_key(offset: 0)
|
47
|
+
interval_key(:month, time: offset.days.ago(TIME))
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.day_keys(offset: 0)
|
51
|
+
boy = offset.days.ago(TIME).beginning_of_day
|
52
|
+
|
53
|
+
0.upto(23).collect do |num|
|
54
|
+
interval_key(:day, time: num.hours.from_now(boy))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.month_key(offset: 0)
|
59
|
+
interval_key(:year, time: offset.months.ago(TIME))
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.month_keys(offset: 0)
|
63
|
+
boy = offset.months.ago(TIME).beginning_of_month
|
64
|
+
max = boy.end_of_month.day - 1
|
65
|
+
|
66
|
+
0.upto(max).collect do |num|
|
67
|
+
interval_key(:month, time: num.days.from_now(boy))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.year_key(offset: 0)
|
72
|
+
interval_key(:all, time: offset.years.ago(TIME))
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.year_keys(offset: 0)
|
76
|
+
boy = offset.years.ago(TIME).beginning_of_year
|
77
|
+
|
78
|
+
0.upto(11).collect do |num|
|
79
|
+
interval_key(:year, time: num.months.from_now(boy))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
84
|
+
def self.all_key(offset: 0)
|
85
|
+
interval_key(:inf)
|
86
|
+
end
|
87
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
88
|
+
|
89
|
+
def self.all_keys(offset: 0)
|
90
|
+
max = 9 + offset
|
91
|
+
min = 0 + offset
|
92
|
+
|
93
|
+
max.downto(min).collect do |num|
|
94
|
+
interval_key(:all, time: num.years.ago(TIME))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.expiration(key, seconds)
|
99
|
+
return if seconds.nil?
|
100
|
+
|
101
|
+
ActiveRedisDB::Key
|
102
|
+
.expire(primary_key(key), seconds)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRedisStats
|
4
|
+
module Count
|
5
|
+
class Get < ActiveRedisStats::Count::Base
|
6
|
+
|
7
|
+
def self.total(key)
|
8
|
+
ActiveRedisDB::String
|
9
|
+
.evaluate
|
10
|
+
.find(primary_key(key)) || 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.total_intervals(key, format: :month, offset: 0)
|
14
|
+
keys = send("#{format}_keys", offset: offset)
|
15
|
+
keys.collect { |k| total("#{key}:#{k}") }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRedisStats
|
4
|
+
module Count
|
5
|
+
class Set < ActiveRedisStats::Count::Base
|
6
|
+
class << self
|
7
|
+
|
8
|
+
%i[decrement increment].each do |meth|
|
9
|
+
define_method(meth) do |key, by: 1|
|
10
|
+
ActiveRedisDB::String
|
11
|
+
.send(meth, primary_key(key), by)
|
12
|
+
end
|
13
|
+
|
14
|
+
define_method("#{meth}_intervals") do |key, by: 1|
|
15
|
+
ActiveRedisStats::Base::EXPIRES.each do |frmt, secs|
|
16
|
+
ikey = "#{key}:#{interval_key(frmt)}"
|
17
|
+
|
18
|
+
send(meth, ikey, by: by)
|
19
|
+
expiration(ikey, secs)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRedisStats
|
4
|
+
module Rank
|
5
|
+
class Get < ActiveRedisStats::Rank::Base
|
6
|
+
|
7
|
+
LIMIT ||= 100
|
8
|
+
|
9
|
+
def self.all(key, with_scores: false)
|
10
|
+
ActiveRedisDB::SortedSet
|
11
|
+
.evaluate
|
12
|
+
.all_reverse(primary_key(key), with_scores: with_scores) || []
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.all_intervals(key, with_scores: false, format: :month, offset: 0)
|
16
|
+
ikey = send("#{format}_key", offset: offset)
|
17
|
+
all("#{key}:#{ikey}", with_scores: with_scores)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.between(key, with_scores: false, from:, to:)
|
21
|
+
ActiveRedisDB::SortedSet
|
22
|
+
.evaluate
|
23
|
+
.between_reverse(primary_key(key), from, to, with_scores: with_scores) || []
|
24
|
+
end
|
25
|
+
|
26
|
+
# rubocop:disable Metrics/ParameterLists
|
27
|
+
def self.between_intervals(key, with_scores: false, from:, to:, format: :month, offset: 0)
|
28
|
+
ikey = send("#{format}_key", offset: offset)
|
29
|
+
between("#{key}:#{ikey}", with_scores: with_scores, from: from, to: to)
|
30
|
+
end
|
31
|
+
# rubocop:enable Metrics/ParameterLists
|
32
|
+
|
33
|
+
def self.bottom(key, with_scores: false, limit: LIMIT)
|
34
|
+
ActiveRedisDB::SortedSet
|
35
|
+
.evaluate
|
36
|
+
.between(primary_key(key), 1, limit, with_scores: with_scores) || []
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.bottom_intervals(key, with_scores: false, limit: LIMIT, format: :month, offset: 0)
|
40
|
+
ikey = send("#{format}_key", offset: offset)
|
41
|
+
bottom("#{key}:#{ikey}", with_scores: with_scores, limit: limit)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.top(key, with_scores: false, limit: LIMIT)
|
45
|
+
ActiveRedisDB::SortedSet
|
46
|
+
.evaluate
|
47
|
+
.between_reverse(primary_key(key), 1, limit, with_scores: with_scores) || []
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.top_intervals(key, with_scores: false, limit: LIMIT, format: :month, offset: 0)
|
51
|
+
ikey = send("#{format}_key", offset: offset)
|
52
|
+
top("#{key}:#{ikey}", with_scores: with_scores, limit: limit)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRedisStats
|
4
|
+
module Rank
|
5
|
+
class Set < ActiveRedisStats::Rank::Base
|
6
|
+
class << self
|
7
|
+
|
8
|
+
%i[decrement increment].each do |meth|
|
9
|
+
define_method(meth) do |key, val, by: 1|
|
10
|
+
ActiveRedisDB::SortedSet
|
11
|
+
.send(meth, primary_key(key), val.to_s, by)
|
12
|
+
end
|
13
|
+
|
14
|
+
define_method("#{meth}_intervals") do |key, val, by: 1|
|
15
|
+
ActiveRedisStats::Base::EXPIRES.each do |frmt, secs|
|
16
|
+
ikey = "#{key}:#{interval_key(frmt)}"
|
17
|
+
|
18
|
+
send(meth, ikey, val, by: by)
|
19
|
+
expiration(ikey, secs)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'fakeredis'
|
5
|
+
rescue LoadError
|
6
|
+
require 'redis'
|
7
|
+
end
|
8
|
+
|
9
|
+
%w[active_object active_redis_db active_support/core_ext/time].each do |file_name|
|
10
|
+
require file_name
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[version base].each do |file_name|
|
14
|
+
require "active_redis_stats/#{file_name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
%w[base set get].each do |file_name|
|
18
|
+
%w[count rank].each do |dir_name|
|
19
|
+
require "active_redis_stats/#{dir_name}/#{file_name}"
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_redis_stats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Gomez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: active_object
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: active_redis_db
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakeredis
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: generator_spec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: reek
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: Redis based analytics.
|
168
|
+
email:
|
169
|
+
- j.gomez@drexed.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".fasterer.yml"
|
175
|
+
- ".gitattributes"
|
176
|
+
- ".gitignore"
|
177
|
+
- ".irbrc"
|
178
|
+
- ".reek.yml"
|
179
|
+
- ".rspec"
|
180
|
+
- ".rubocop.yml"
|
181
|
+
- ".travis.yml"
|
182
|
+
- CODE_OF_CONDUCT.md
|
183
|
+
- Gemfile
|
184
|
+
- README.md
|
185
|
+
- Rakefile
|
186
|
+
- active_redis_stats.gemspec
|
187
|
+
- bin/console
|
188
|
+
- bin/rake
|
189
|
+
- bin/setup
|
190
|
+
- lib/active_redis_stats.rb
|
191
|
+
- lib/active_redis_stats/base.rb
|
192
|
+
- lib/active_redis_stats/count/base.rb
|
193
|
+
- lib/active_redis_stats/count/get.rb
|
194
|
+
- lib/active_redis_stats/count/set.rb
|
195
|
+
- lib/active_redis_stats/rank/base.rb
|
196
|
+
- lib/active_redis_stats/rank/get.rb
|
197
|
+
- lib/active_redis_stats/rank/set.rb
|
198
|
+
- lib/active_redis_stats/version.rb
|
199
|
+
homepage: http://drexed.github.io/active_redis_stats
|
200
|
+
licenses:
|
201
|
+
- MIT
|
202
|
+
metadata: {}
|
203
|
+
post_install_message:
|
204
|
+
rdoc_options: []
|
205
|
+
require_paths:
|
206
|
+
- lib
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - ">="
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '0'
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
requirements: []
|
218
|
+
rubyforge_project:
|
219
|
+
rubygems_version: 2.7.7
|
220
|
+
signing_key:
|
221
|
+
specification_version: 4
|
222
|
+
summary: Gem for Redis based analytics.
|
223
|
+
test_files: []
|