myslog 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coverrails.yml +1 -0
- data/.gitignore +31 -15
- data/.travis.yml +4 -0
- data/Gemfile +5 -1
- data/LICENSE +13 -0
- data/README.md +2 -0
- data/Rakefile +4 -1
- data/lib/myslog.rb +1 -18
- data/myslog.gemspec +13 -14
- data/spec/{myslog.rb → myslog_spec.rb} +36 -32
- data/spec/spec_helper.rb +7 -2
- metadata +41 -13
- data/Gemfile.lock +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80788f037295ef11c3170012ebc5b2796190bb71
|
4
|
+
data.tar.gz: c89207a4068ada4490f8973ca7026d398b8bb9ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c6800cf04a879821b1fcab7f2d0d244f2230fff976b599426734893c0f316c3d3c0fbe62bad227f8ede031736b74e99ee775dfa273371bd465f9db06a080dac
|
7
|
+
data.tar.gz: 91ada3731ba6290a078a1768c2127274f700681490030697b335228f2c13bfd83fef58f15206ffe9484052cc3db09205a36b1defa657c483f495fd0f0b31b086
|
data/.coverrails.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
@@ -1,18 +1,34 @@
|
|
1
1
|
*.gem
|
2
2
|
*.rbc
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
test/tmp
|
12
|
-
test/version_tmp
|
13
|
-
tmp
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
14
11
|
|
15
|
-
|
16
|
-
.
|
17
|
-
|
18
|
-
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (C) 2015 Yuku TAKAHASHI
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
myslog
|
2
2
|
======
|
3
3
|
|
4
|
+
[![Build Status](https://travis-ci.org/yuku-t/myslog.svg?branch=master)](https://travis-ci.org/yuku-t/myslog) [![Code Climate](https://codeclimate.com/github/yuku-t/myslog/badges/gpa.svg)](https://codeclimate.com/github/yuku-t/myslog) [![Coverage Status](https://coveralls.io/repos/yuku-t/myslog/badge.svg)](https://coveralls.io/r/yuku-t/myslog)
|
5
|
+
|
4
6
|
MySQL slow query log parser
|
5
7
|
|
6
8
|
Install
|
data/Rakefile
CHANGED
data/lib/myslog.rb
CHANGED
@@ -1,20 +1,3 @@
|
|
1
|
-
#
|
2
|
-
# MySlog
|
3
|
-
#
|
4
|
-
# Copyright (C) 2012 Yuku TAKAHASHI
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
1
|
require "time"
|
19
2
|
|
20
3
|
class MySlog
|
@@ -36,7 +19,7 @@ class MySlog
|
|
36
19
|
end
|
37
20
|
|
38
21
|
sql = []
|
39
|
-
while line != nil && !line.start_with?("#")
|
22
|
+
while line != nil && !line.start_with?("# Time") && !line.start_with?("# User@Host") && !line.start_with?("# Query_time")
|
40
23
|
sql << line.strip
|
41
24
|
line = lines.shift
|
42
25
|
end
|
data/myslog.gemspec
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "myslog"
|
3
|
+
spec.version = "0.0.11"
|
4
|
+
spec.authors = ["taka84u9"]
|
5
|
+
spec.email = ["taka84u9@gmail.com"]
|
6
|
+
spec.summary = "MySQL slow query parser."
|
7
|
+
spec.description = "MySQL slow query parser."
|
8
|
+
spec.homepage = "https://github.com/taka84u9/myslog"
|
2
9
|
|
3
|
-
|
4
|
-
|
5
|
-
gem.email = ["taka84u9@gmail.com"]
|
6
|
-
gem.description = %q{MySQL slow query parser.}
|
7
|
-
gem.summary = %q{MySQL slow query parser.}
|
8
|
-
gem.homepage = "https://github.com/taka84u9/myslog"
|
10
|
+
spec.files = `git ls-files -z`.split("\x0")
|
11
|
+
spec.require_paths = ["lib"]
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
gem.name = "myslog"
|
14
|
-
gem.require_paths = ["lib"]
|
15
|
-
gem.version = "0.0.10"
|
16
|
-
gem.add_development_dependency "rspec"
|
13
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
14
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
15
|
+
spec.add_development_dependency "rspec"
|
17
16
|
end
|
@@ -51,9 +51,9 @@ use webtie;
|
|
51
51
|
describe "#parse" do
|
52
52
|
it "should return Array of Hash" do
|
53
53
|
results = @myslog.parse(@log)
|
54
|
-
results.
|
54
|
+
expect(results).to be_an_instance_of Array
|
55
55
|
results.each do |result|
|
56
|
-
results.
|
56
|
+
expect(results).to be_an_instance_of Array
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -65,9 +65,9 @@ use webtie;
|
|
65
65
|
|
66
66
|
it "should return Array of Array" do
|
67
67
|
results = @myslog.divide(@lines)
|
68
|
-
results.
|
68
|
+
expect(results).to be_an_instance_of Array
|
69
69
|
results.each do |result|
|
70
|
-
results.
|
70
|
+
expect(results).to be_an_instance_of Array
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -75,24 +75,28 @@ use webtie;
|
|
75
75
|
results = @myslog.divide(@lines)
|
76
76
|
|
77
77
|
record = results[0]
|
78
|
-
record.size.
|
79
|
-
record[0].
|
78
|
+
expect(record.size).to eq(3)
|
79
|
+
expect(record[0]).to eq(
|
80
80
|
"# User@Host: gimp[drool] @ algernon.retards.org [10.10.10.7]"
|
81
|
+
)
|
81
82
|
|
82
83
|
record = results[1]
|
83
|
-
record.size.
|
84
|
-
record[0].
|
84
|
+
expect(record.size).to eq(3)
|
85
|
+
expect(record[0]).to eq(
|
85
86
|
"# User@Host: gimp[drool] @ algernon.retards.org [10.10.10.7]"
|
87
|
+
)
|
86
88
|
|
87
89
|
record = results[2]
|
88
|
-
record.size.
|
89
|
-
record[0].
|
90
|
+
expect(record.size).to eq(4)
|
91
|
+
expect(record[0]).to eq(
|
90
92
|
"# Time: 010626 10:44:50"
|
93
|
+
)
|
91
94
|
|
92
95
|
record = results[3]
|
93
|
-
record.size.
|
94
|
-
record[0].
|
96
|
+
expect(record.size).to eq(4)
|
97
|
+
expect(record[0]).to eq(
|
95
98
|
"# Time: 010626 10:44:51"
|
99
|
+
)
|
96
100
|
end
|
97
101
|
end
|
98
102
|
|
@@ -106,10 +110,10 @@ use webtie;
|
|
106
110
|
]
|
107
111
|
response = @myslog.parse_record(lines)
|
108
112
|
|
109
|
-
response.
|
113
|
+
expect(response).to be_an_instance_of Hash
|
110
114
|
%w[
|
111
115
|
date user host host_ip time lock_time rows_sent rows_examined sql
|
112
|
-
].each { |k| response.
|
116
|
+
].each { |k| expect(response).to have_key k.to_sym}
|
113
117
|
end
|
114
118
|
|
115
119
|
context "given full log" do
|
@@ -134,15 +138,15 @@ use webtie;
|
|
134
138
|
end
|
135
139
|
|
136
140
|
it "should have expected values" do
|
137
|
-
@response[:date].to_i.
|
138
|
-
@response[:user].
|
139
|
-
@response[:host].
|
140
|
-
@response[:host_ip].
|
141
|
-
@response[:query_time].
|
142
|
-
@response[:lock_time].
|
143
|
-
@response[:rows_sent].
|
144
|
-
@response[:rows_examined].
|
145
|
-
@response[:sql].
|
141
|
+
expect(@response[:date].to_i).to eq(@date.to_i)
|
142
|
+
expect(@response[:user]).to eq(@user)
|
143
|
+
expect(@response[:host]).to eq(@host)
|
144
|
+
expect(@response[:host_ip]).to eq(@host_ip)
|
145
|
+
expect(@response[:query_time]).to eq(@query_time)
|
146
|
+
expect(@response[:lock_time]).to eq(@lock_time)
|
147
|
+
expect(@response[:rows_sent]).to eq(@rows_sent)
|
148
|
+
expect(@response[:rows_examined]).to eq(@rows_examined)
|
149
|
+
expect(@response[:sql]).to eq(@sql.strip)
|
146
150
|
end
|
147
151
|
end
|
148
152
|
end
|
@@ -167,15 +171,15 @@ use webtie;
|
|
167
171
|
end
|
168
172
|
|
169
173
|
it "should have expected values" do
|
170
|
-
@response[:date].to_s.
|
171
|
-
@response[:user].
|
172
|
-
@response[:host].
|
173
|
-
@response[:host_ip].
|
174
|
-
@response[:query_time].
|
175
|
-
@response[:lock_time].
|
176
|
-
@response[:rows_sent].
|
177
|
-
@response[:rows_examined].
|
178
|
-
@response[:sql].
|
174
|
+
expect(@response[:date].utc.to_s).to eq("2011-10-03 05:17:38 UTC")
|
175
|
+
expect(@response[:user]).to eq(@user)
|
176
|
+
expect(@response[:host]).to eq(@host)
|
177
|
+
expect(@response[:host_ip]).to eq(@host_ip)
|
178
|
+
expect(@response[:query_time]).to eq(@query_time)
|
179
|
+
expect(@response[:lock_time]).to eq(@lock_time)
|
180
|
+
expect(@response[:rows_sent]).to eq(@rows_sent)
|
181
|
+
expect(@response[:rows_examined]).to eq(@rows_examined)
|
182
|
+
expect(@response[:sql]).to eq(@sql.strip)
|
179
183
|
end
|
180
184
|
end
|
181
185
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
3
|
|
4
4
|
require "myslog"
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.color = true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- taka84u9
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rspec
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
|
-
- -
|
45
|
+
- - ">="
|
18
46
|
- !ruby/object:Gem::Version
|
19
47
|
version: '0'
|
20
48
|
type: :development
|
21
49
|
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
|
-
- -
|
52
|
+
- - ">="
|
25
53
|
- !ruby/object:Gem::Version
|
26
54
|
version: '0'
|
27
55
|
description: MySQL slow query parser.
|
@@ -31,14 +59,16 @@ executables: []
|
|
31
59
|
extensions: []
|
32
60
|
extra_rdoc_files: []
|
33
61
|
files:
|
34
|
-
- .
|
62
|
+
- ".coverrails.yml"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
35
65
|
- Gemfile
|
36
|
-
-
|
66
|
+
- LICENSE
|
37
67
|
- README.md
|
38
68
|
- Rakefile
|
39
69
|
- lib/myslog.rb
|
40
70
|
- myslog.gemspec
|
41
|
-
- spec/
|
71
|
+
- spec/myslog_spec.rb
|
42
72
|
- spec/spec_helper.rb
|
43
73
|
homepage: https://github.com/taka84u9/myslog
|
44
74
|
licenses: []
|
@@ -49,21 +79,19 @@ require_paths:
|
|
49
79
|
- lib
|
50
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
81
|
requirements:
|
52
|
-
- -
|
82
|
+
- - ">="
|
53
83
|
- !ruby/object:Gem::Version
|
54
84
|
version: '0'
|
55
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
86
|
requirements:
|
57
|
-
- -
|
87
|
+
- - ">="
|
58
88
|
- !ruby/object:Gem::Version
|
59
89
|
version: '0'
|
60
90
|
requirements: []
|
61
91
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.2.2
|
63
93
|
signing_key:
|
64
94
|
specification_version: 4
|
65
95
|
summary: MySQL slow query parser.
|
66
|
-
test_files:
|
67
|
-
- spec/myslog.rb
|
68
|
-
- spec/spec_helper.rb
|
96
|
+
test_files: []
|
69
97
|
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
myslog (0.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.1.3)
|
10
|
-
rspec (2.10.0)
|
11
|
-
rspec-core (~> 2.10.0)
|
12
|
-
rspec-expectations (~> 2.10.0)
|
13
|
-
rspec-mocks (~> 2.10.0)
|
14
|
-
rspec-core (2.10.1)
|
15
|
-
rspec-expectations (2.10.0)
|
16
|
-
diff-lcs (~> 1.1.3)
|
17
|
-
rspec-mocks (2.10.1)
|
18
|
-
|
19
|
-
PLATFORMS
|
20
|
-
ruby
|
21
|
-
|
22
|
-
DEPENDENCIES
|
23
|
-
myslog!
|
24
|
-
rspec
|