popular_stream 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/popular_stream.rb +3 -2
- data/lib/popular_stream/version.rb +1 -1
- data/popular_stream.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97072d1f27665b49962a92e4cefc4b731b496e0e
|
4
|
+
data.tar.gz: 30a8a8bbea632490d4b1daaf63e5f58abdf45e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72af93548be40f24ee19b10d95e501799aa477eea71adfd4db45de21d9b763eddaf3ea44b153508c9aa40c21076573a37d1b13aa4fb11ee0c7a294d73d507806
|
7
|
+
data.tar.gz: 8192bb84cfe9a18992775968daab7bc5fd2cd9b69069a9081d5c50cbe66659eb145b2688cdbf7829948c033e9a8c9371a1c818b5f32707387c9fc6e118d4c87b
|
data/README.md
CHANGED
@@ -18,6 +18,10 @@ The way this works is that "old" votes will count less than newer votes, that wa
|
|
18
18
|
a tag that was used 20 times today will be more popular than a tag used 30 times
|
19
19
|
last week.
|
20
20
|
|
21
|
+
[Here are more details about how this gem works.](http://blog.nhocki.com/2014/12/02/trending-content-with-ruby-and-redis/)
|
22
|
+
|
23
|
+
This gem was extracted from the [We Heart It](http://weheartit.com) codebase.
|
24
|
+
|
21
25
|
Once again, thanks to Micah Fivecoate for his post.
|
22
26
|
|
23
27
|
## Installation
|
data/lib/popular_stream.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
require 'time'
|
1
2
|
require "popular_stream/version"
|
2
3
|
|
3
4
|
# Most of this was taken from:
|
4
|
-
# http://
|
5
|
+
# http://qwerjk.com/posts/surfacing-interesting-content
|
5
6
|
class PopularStream
|
6
7
|
attr_reader :name, :epoch, :max_items
|
7
8
|
|
@@ -27,7 +28,7 @@ class PopularStream
|
|
27
28
|
def vote(field:, time: Time.now.to_i, weight: 1)
|
28
29
|
time = time.to_i if time.respond_to?(:to_i)
|
29
30
|
|
30
|
-
delta = 2 ** ((time - epoch) / HALF_LIFE)
|
31
|
+
delta = 2 ** ((time - epoch).to_f / HALF_LIFE)
|
31
32
|
redis.zincrby(name, weight * delta.to_f, field)
|
32
33
|
trim
|
33
34
|
end
|
data/popular_stream.gemspec
CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.required_ruby_version = '~> 2.1'
|
22
|
-
spec.add_dependency "redis", "~> 3.1
|
22
|
+
spec.add_dependency "redis", "~> 3.1"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.1
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
27
27
|
spec.add_development_dependency "timecop", "~> 0.7.1"
|
28
28
|
spec.add_development_dependency "fakeredis", "~> 0.5.0"
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: popular_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolás Hock Isaza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.1
|
19
|
+
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.1
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.1
|
61
|
+
version: '3.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.1
|
68
|
+
version: '3.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: timecop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.4.5
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Ruby gem to track popular streams with a redis backend.
|