log_magic 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rebuild +1 -1
- data/lib/log_magic/explainer_templates/boost.haml +4 -0
- data/lib/log_magic/explainer_templates/dis_max.haml +4 -0
- data/lib/log_magic/explainer_templates/match.haml +4 -0
- data/lib/log_magic/explainer_templates/searchkick.haml +2 -1
- data/lib/log_magic/explainers/explainer_sections/boost_explainer.rb +19 -0
- data/lib/log_magic/explainers/explainer_sections/dis_max_explainer.rb +19 -0
- data/lib/log_magic/explainers/explainer_sections/match_explainer.rb +19 -0
- data/lib/log_magic/explainers/searchkick_explainer.rb +20 -10
- data/lib/log_magic/persistance_layer.rb +1 -1
- data/lib/log_magic/utils/json_utils.rb +4 -0
- data/lib/log_magic/utils/templating_utils.rb +12 -0
- data/lib/log_magic.rb +4 -1
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2995ed8296855e2b64a848d1c6be572f21b4c77d
|
4
|
+
data.tar.gz: bb267b3e7f42148109699f6a17ab9eb11e611823
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab06de5813d616854b69fedc6ffc98c0b138903fb6dfa0b9570ef98c914d2470eb40cc26973e91a56a9ea152f99ab1e532d0adfc8674802c18b1a78b022082a8
|
7
|
+
data.tar.gz: c13f6d63f49e2b393cfa82ed0e08c1772dfc792042cfbf9cab8350dec2f9fc13c330b4710944dc20b3d47a988d57f2d4d03be2e5b2130d3a1b6f81f1c112fd78
|
data/bin/rebuild
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
gem build log_magic.gemspec
|
2
|
-
gem install log_magic-0.0.
|
2
|
+
gem install log_magic-0.0.3.gem
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class LogMagic::SearchkickExplainer::BoostExplainerSection
|
2
|
+
include ::LogMagic::TemplatingUtils
|
3
|
+
|
4
|
+
def initialize(query_json)
|
5
|
+
@query_json = query_json
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?
|
9
|
+
@query_json =~ /[^\w]boost[^\w]/
|
10
|
+
end
|
11
|
+
|
12
|
+
def explanation
|
13
|
+
rendered_template
|
14
|
+
end
|
15
|
+
|
16
|
+
def template_name
|
17
|
+
'boost.haml'
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class LogMagic::SearchkickExplainer::DisMaxExplainerSection
|
2
|
+
include ::LogMagic::TemplatingUtils
|
3
|
+
|
4
|
+
def initialize(query_json)
|
5
|
+
@query_json = query_json
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?
|
9
|
+
@query_json =~ /[^\w]dis_max[^\w]/
|
10
|
+
end
|
11
|
+
|
12
|
+
def explanation
|
13
|
+
rendered_template
|
14
|
+
end
|
15
|
+
|
16
|
+
def template_name
|
17
|
+
'dis_max.haml'
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class LogMagic::SearchkickExplainer::MatchExplainerSection
|
2
|
+
include ::LogMagic::TemplatingUtils
|
3
|
+
|
4
|
+
def initialize(query_json)
|
5
|
+
@query_json = query_json
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?
|
9
|
+
@query_json =~ /[^\w]match[^\w]/
|
10
|
+
end
|
11
|
+
|
12
|
+
def explanation
|
13
|
+
rendered_template
|
14
|
+
end
|
15
|
+
|
16
|
+
def template_name
|
17
|
+
'match.haml'
|
18
|
+
end
|
19
|
+
end
|
@@ -4,6 +4,7 @@ require 'haml'
|
|
4
4
|
|
5
5
|
class LogMagic::SearchkickExplainer
|
6
6
|
include ::LogMagic::JSONUtils
|
7
|
+
include ::LogMagic::TemplatingUtils
|
7
8
|
|
8
9
|
attr_accessor :database_name
|
9
10
|
|
@@ -15,6 +16,22 @@ class LogMagic::SearchkickExplainer
|
|
15
16
|
@persistance_layer.retrieve_value(@uuid)
|
16
17
|
end
|
17
18
|
|
19
|
+
def explainer_section_classes
|
20
|
+
[
|
21
|
+
DisMaxExplainerSection,
|
22
|
+
BoostExplainerSection,
|
23
|
+
MatchExplainerSection
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def explainer_sections
|
28
|
+
explainer_section_classes.map do |explainer_section_class|
|
29
|
+
explainer_section_class.new(query_json)
|
30
|
+
end.select do |explainer_section|
|
31
|
+
explainer_section.matches?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
18
35
|
def start
|
19
36
|
app = Proc.new do |env|
|
20
37
|
@uuid = env['PATH_INFO'][1..-1]
|
@@ -24,17 +41,10 @@ class LogMagic::SearchkickExplainer
|
|
24
41
|
end
|
25
42
|
|
26
43
|
Rack::Handler::WEBrick.run app, Port: 7467,
|
27
|
-
Logger: WEBrick::Log::new('/
|
28
|
-
end
|
29
|
-
|
30
|
-
def rendered_template
|
31
|
-
engine = Haml::Engine.new(File.read(template_path))
|
32
|
-
engine.render(self)
|
44
|
+
Logger: WEBrick::Log::new('/tmp/log_magic.log')
|
33
45
|
end
|
34
46
|
|
35
|
-
def
|
36
|
-
|
37
|
-
File.join(__FILE__, '..', '..', 'explainer_templates', 'searchkick.haml')
|
38
|
-
)
|
47
|
+
def template_name
|
48
|
+
'searchkick.haml'
|
39
49
|
end
|
40
50
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module LogMagic::TemplatingUtils
|
2
|
+
def rendered_template
|
3
|
+
engine = Haml::Engine.new(File.read(template_path))
|
4
|
+
engine.render(self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def template_path
|
8
|
+
File.expand_path(
|
9
|
+
File.join(__FILE__, '..', '..', 'explainer_templates', template_name)
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
data/lib/log_magic.rb
CHANGED
@@ -48,9 +48,12 @@ end
|
|
48
48
|
|
49
49
|
|
50
50
|
require 'log_magic/utils/json_utils'
|
51
|
+
require 'log_magic/utils/templating_utils'
|
51
52
|
require 'log_magic/log_listener'
|
52
53
|
require 'log_magic/refiners/searchkick_refiner'
|
53
54
|
require 'log_magic/printers/searchkick_printer'
|
54
|
-
|
55
55
|
require 'log_magic/explainers/searchkick_explainer'
|
56
|
+
require 'log_magic/explainers/explainer_sections/dis_max_explainer'
|
57
|
+
require 'log_magic/explainers/explainer_sections/match_explainer'
|
58
|
+
require 'log_magic/explainers/explainer_sections/boost_explainer'
|
56
59
|
require 'log_magic/persistance_layer'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Korfmann
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
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'
|
83
97
|
description: "\n By analysing your development.log,\n log_magic gives you insights
|
84
98
|
about your services.\n "
|
85
99
|
email: manu@korfmann.info
|
@@ -91,14 +105,21 @@ files:
|
|
91
105
|
- bin/log_magic
|
92
106
|
- bin/rebuild
|
93
107
|
- lib/log_magic.rb
|
108
|
+
- lib/log_magic/explainer_templates/boost.haml
|
109
|
+
- lib/log_magic/explainer_templates/dis_max.haml
|
110
|
+
- lib/log_magic/explainer_templates/match.haml
|
94
111
|
- lib/log_magic/explainer_templates/searchkick.haml
|
112
|
+
- lib/log_magic/explainers/explainer_sections/boost_explainer.rb
|
113
|
+
- lib/log_magic/explainers/explainer_sections/dis_max_explainer.rb
|
114
|
+
- lib/log_magic/explainers/explainer_sections/match_explainer.rb
|
95
115
|
- lib/log_magic/explainers/searchkick_explainer.rb
|
96
116
|
- lib/log_magic/log_listener.rb
|
97
117
|
- lib/log_magic/persistance_layer.rb
|
98
118
|
- lib/log_magic/printers/searchkick_printer.rb
|
99
119
|
- lib/log_magic/refiners/searchkick_refiner.rb
|
100
120
|
- lib/log_magic/utils/json_utils.rb
|
101
|
-
|
121
|
+
- lib/log_magic/utils/templating_utils.rb
|
122
|
+
homepage: https://github.com/ManuelArno/log_magic
|
102
123
|
licenses:
|
103
124
|
- MIT
|
104
125
|
metadata: {}
|