mongoid_traffic 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -0
- data/Gemfile.lock +22 -21
- data/lib/mongoid_traffic/logger.rb +6 -6
- data/lib/mongoid_traffic/version.rb +2 -2
- data/mongoid_traffic.gemspec +4 -4
- data/test/test_helper.rb +1 -20
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2c00bbcb80356f2546b251e0f48a2863dd8bfcc
|
4
|
+
data.tar.gz: b8ee6c7cece3700d385118cbb0f3fbd925065047
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2026efe6cee6b0f1e491d914daf4d6c8f32b73edb5da304398148643865b5b193b8c4c97a0a8f33462c74c467c94108be8add4cf6b6aab724f665b105d2c387
|
7
|
+
data.tar.gz: be0c1960d5d52002398e556ff397480dfac95dceb8c64c0a7aae4624208d1c2e67c06c439367fa27538858b6a2ecc48e0c6b77e6b7ee3ee2c64bd7059a831c96
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,41 +1,45 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/DatabaseCleaner/database_cleaner.git
|
3
|
+
revision: b87f00320f8aa0f7e499d183128f05ce29cedc33
|
4
|
+
specs:
|
5
|
+
database_cleaner (1.5.1)
|
6
|
+
|
1
7
|
PATH
|
2
8
|
remote: .
|
3
9
|
specs:
|
4
|
-
mongoid_traffic (0.
|
10
|
+
mongoid_traffic (0.2.0)
|
5
11
|
geoip
|
6
|
-
mongoid (~>
|
12
|
+
mongoid (~> 5.0)
|
7
13
|
nokogiri
|
8
14
|
useragent (~> 0.10.0)
|
9
15
|
|
10
16
|
GEM
|
11
17
|
remote: https://rubygems.org/
|
12
18
|
specs:
|
13
|
-
activemodel (4.2.
|
14
|
-
activesupport (= 4.2.
|
19
|
+
activemodel (4.2.4)
|
20
|
+
activesupport (= 4.2.4)
|
15
21
|
builder (~> 3.1)
|
16
|
-
activesupport (4.2.
|
22
|
+
activesupport (4.2.4)
|
17
23
|
i18n (~> 0.7)
|
18
24
|
json (~> 1.7, >= 1.7.7)
|
19
25
|
minitest (~> 5.1)
|
20
26
|
thread_safe (~> 0.3, >= 0.3.4)
|
21
27
|
tzinfo (~> 1.1)
|
22
|
-
bson (2.
|
28
|
+
bson (3.2.4)
|
23
29
|
builder (3.2.2)
|
24
30
|
celluloid (0.15.2)
|
25
31
|
timers (~> 1.1.0)
|
26
32
|
coderay (1.1.0)
|
27
|
-
connection_pool (2.1.0)
|
28
33
|
coveralls (0.7.0)
|
29
34
|
multi_json (~> 1.3)
|
30
35
|
rest-client
|
31
36
|
simplecov (>= 0.7)
|
32
37
|
term-ansicolor
|
33
38
|
thor
|
34
|
-
database_cleaner (1.3.0)
|
35
39
|
docile (1.1.5)
|
36
40
|
ffi (1.9.3)
|
37
41
|
formatador (0.2.5)
|
38
|
-
geoip (1.
|
42
|
+
geoip (1.6.1)
|
39
43
|
guard (2.6.1)
|
40
44
|
formatador (>= 0.2.4)
|
41
45
|
listen (~> 2.7)
|
@@ -46,7 +50,7 @@ GEM
|
|
46
50
|
guard (~> 2.0)
|
47
51
|
minitest (>= 3.0)
|
48
52
|
i18n (0.7.0)
|
49
|
-
json (1.8.
|
53
|
+
json (1.8.3)
|
50
54
|
listen (2.7.9)
|
51
55
|
celluloid (>= 0.15.2)
|
52
56
|
rb-fsevent (>= 0.9.3)
|
@@ -54,22 +58,19 @@ GEM
|
|
54
58
|
lumberjack (1.0.9)
|
55
59
|
method_source (0.8.2)
|
56
60
|
mime-types (1.25.1)
|
57
|
-
mini_portile (0.6.
|
61
|
+
mini_portile (0.6.2)
|
58
62
|
minitest (5.4.0)
|
59
|
-
|
63
|
+
mongo (2.1.1)
|
64
|
+
bson (~> 3.0)
|
65
|
+
mongoid (5.0.0)
|
60
66
|
activemodel (~> 4.0)
|
61
|
-
|
67
|
+
mongo (~> 2.1)
|
62
68
|
origin (~> 2.1)
|
63
69
|
tzinfo (>= 0.3.37)
|
64
|
-
moped (2.0.2)
|
65
|
-
bson (~> 2.2)
|
66
|
-
connection_pool (~> 2.0)
|
67
|
-
optionable (~> 0.2.0)
|
68
70
|
multi_json (1.10.1)
|
69
71
|
netrc (0.7.7)
|
70
|
-
nokogiri (1.6.
|
72
|
+
nokogiri (1.6.6.2)
|
71
73
|
mini_portile (~> 0.6.0)
|
72
|
-
optionable (0.2.0)
|
73
74
|
origin (2.1.1)
|
74
75
|
pry (0.10.0)
|
75
76
|
coderay (~> 1.1.0)
|
@@ -91,7 +92,7 @@ GEM
|
|
91
92
|
term-ansicolor (1.3.0)
|
92
93
|
tins (~> 1.0)
|
93
94
|
thor (0.19.1)
|
94
|
-
thread_safe (0.3.
|
95
|
+
thread_safe (0.3.5)
|
95
96
|
timers (1.1.0)
|
96
97
|
tins (1.3.1)
|
97
98
|
tzinfo (1.2.2)
|
@@ -104,7 +105,7 @@ PLATFORMS
|
|
104
105
|
DEPENDENCIES
|
105
106
|
bundler (~> 1.3)
|
106
107
|
coveralls
|
107
|
-
database_cleaner
|
108
|
+
database_cleaner!
|
108
109
|
guard
|
109
110
|
guard-minitest
|
110
111
|
minitest
|
@@ -13,14 +13,14 @@ module MongoidTraffic
|
|
13
13
|
TIME_SCOPE_OPTIONS = %i(year month week day)
|
14
14
|
|
15
15
|
# ---------------------------------------------------------------------
|
16
|
-
|
16
|
+
|
17
17
|
def self.log log_cls, *args
|
18
18
|
new(log_cls, *args).log
|
19
19
|
end
|
20
20
|
|
21
21
|
# ---------------------------------------------------------------------
|
22
22
|
|
23
|
-
def initialize log_cls, ip_address: nil, referer: nil, scope: nil, time_scope: %i(month day), unique_id: nil, user_agent: nil
|
23
|
+
def initialize log_cls, ip_address: nil, referer: nil, scope: nil, time_scope: %i(month day), unique_id: nil, user_agent: nil
|
24
24
|
@log_cls = log_cls
|
25
25
|
@ip_address = ip_address
|
26
26
|
@referer_string = referer
|
@@ -35,14 +35,14 @@ module MongoidTraffic
|
|
35
35
|
raise "Invalid time scope definition: #{@time_scope}" unless @time_scope.all?{ |ts| TIME_SCOPE_OPTIONS.include?(ts) }
|
36
36
|
|
37
37
|
@time_scope.each do |ts|
|
38
|
-
@log_cls.collection.find( find_query(ts) ).
|
38
|
+
@log_cls.collection.find( find_query(ts) ).update_many( upsert_query, upsert: true )
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
# ---------------------------------------------------------------------
|
43
43
|
|
44
44
|
def upsert_query
|
45
|
-
{
|
45
|
+
{
|
46
46
|
'$inc' => access_count_query.
|
47
47
|
merge(browser_query).
|
48
48
|
merge(country_query).
|
@@ -84,7 +84,7 @@ module MongoidTraffic
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# ---------------------------------------------------------------------
|
87
|
-
|
87
|
+
|
88
88
|
def escape_key key
|
89
89
|
CGI::escape(key).gsub('.', '%2E')
|
90
90
|
end
|
@@ -110,7 +110,7 @@ module MongoidTraffic
|
|
110
110
|
end
|
111
111
|
|
112
112
|
private # =============================================================
|
113
|
-
|
113
|
+
|
114
114
|
def browser
|
115
115
|
return unless @user_agent_string.present?
|
116
116
|
@browser ||= Browser.new(@user_agent_string)
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module MongoidTraffic
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "0.2.0"
|
3
|
+
end
|
data/mongoid_traffic.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'mongoid_traffic/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "mongoid_traffic"
|
8
8
|
spec.version = MongoidTraffic::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["Tomáš Celizna"]
|
10
10
|
spec.email = ["tomas.celizna@gmail.com"]
|
11
11
|
spec.description = %q{Aggregated traffic logs stored in MongoDB.}
|
12
12
|
spec.summary = %q{Aggregated traffic logs stored in MongoDB.}
|
@@ -19,15 +19,15 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "geoip"
|
22
|
-
spec.add_dependency "mongoid", "~>
|
22
|
+
spec.add_dependency "mongoid", "~> 5.0"
|
23
23
|
spec.add_dependency "nokogiri"
|
24
24
|
spec.add_dependency "useragent", "~> 0.10.0"
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
27
|
spec.add_development_dependency "coveralls"
|
28
|
-
spec.add_development_dependency "database_cleaner"
|
28
|
+
spec.add_development_dependency "database_cleaner", ">= 1.5.1"
|
29
29
|
spec.add_development_dependency "guard"
|
30
30
|
spec.add_development_dependency "guard-minitest"
|
31
31
|
spec.add_development_dependency "minitest"
|
32
32
|
spec.add_development_dependency "rake"
|
33
|
-
end
|
33
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -11,27 +11,8 @@ if ENV["CI"]
|
|
11
11
|
Coveralls.wear!
|
12
12
|
end
|
13
13
|
|
14
|
-
ENV["MONGOID_TEST_HOST"] ||= "localhost"
|
15
|
-
ENV["MONGOID_TEST_PORT"] ||= "27017"
|
16
|
-
|
17
|
-
HOST = ENV["MONGOID_TEST_HOST"]
|
18
|
-
PORT = ENV["MONGOID_TEST_PORT"].to_i
|
19
|
-
|
20
|
-
def database_id
|
21
|
-
"mongoid_traffic_test"
|
22
|
-
end
|
23
|
-
|
24
|
-
CONFIG = {
|
25
|
-
sessions: {
|
26
|
-
default: {
|
27
|
-
database: database_id,
|
28
|
-
hosts: [ "#{HOST}:#{PORT}" ]
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
14
|
Mongoid.configure do |config|
|
34
|
-
config.
|
15
|
+
config.connect_to('mongoid_traffic_test')
|
35
16
|
end
|
36
17
|
|
37
18
|
DatabaseCleaner.orm = :mongoid
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_traffic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Tomáš Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: geoip
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.5.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.5.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: guard
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
224
|
+
rubygems_version: 2.4.8
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Aggregated traffic logs stored in MongoDB.
|