log_magic 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/log_magic.rb +2 -0
- data/lib/log_magic/explainer_templates/searchkick.haml +31 -4
- data/lib/log_magic/explainers/explainer_sections/custom_analyzer_hover.rb +26 -0
- data/lib/log_magic/explainers/explainer_sections/settings_explainer.rb +9 -2
- data/lib/log_magic/explainers/searchkick_explainer.rb +4 -2
- data/lib/log_magic/renderers/hover_renderer.rb +17 -0
- data/lib/log_magic/util_templates/hovering.haml +3 -0
- data/lib/log_magic/utils/templating_utils.rb +5 -1
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffd3dcd36465ea32aadfa639ac2960c801c416fd
|
4
|
+
data.tar.gz: c8fed639991e0d91b4e56ebb1880942dc2cedb12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f373d8933c051d153128ef6cd1249ba818d5539f1b0f741c251139eae5ea88038f6454caedf125679c79df1a8531dbc776870d8596bf4bf075c9296c87aaf5e
|
7
|
+
data.tar.gz: 31a927edee1cdd9bc631c04ce2a006400ecd73a9cd46907a5a622189ffe0714f787da5f8bd0fa0039d8e15bb275ecd8cdad266edd1a06fca31593da889228edf
|
data/lib/log_magic.rb
CHANGED
@@ -53,6 +53,8 @@ require 'log_magic/log_listener'
|
|
53
53
|
require 'log_magic/refiners/searchkick_refiner'
|
54
54
|
require 'log_magic/printers/searchkick_printer'
|
55
55
|
|
56
|
+
require 'log_magic/renderers/hover_renderer'
|
57
|
+
|
56
58
|
require 'log_magic/explainers/searchkick_explainer'
|
57
59
|
|
58
60
|
Dir.glob("lib/log_magic/explainers/**/*.rb").each do |explainer|
|
@@ -1,5 +1,32 @@
|
|
1
|
-
%
|
2
|
-
%
|
3
|
-
= explained_query.explanation
|
1
|
+
%head
|
2
|
+
%script{ src:"https://code.jquery.com/jquery-3.1.1.min.js", integrity:"sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=", crossorigin:"anonymous" }
|
4
3
|
|
5
|
-
|
4
|
+
:javascript
|
5
|
+
$(document).ready(function() {
|
6
|
+
$('span.hover-key').mouseover(function(e) {
|
7
|
+
$(this).find('.hover-value').css('top', e.pageY);
|
8
|
+
$(this).find('.hover-value').css('left', e.pageX);
|
9
|
+
$(this).find('.hover-value').show();
|
10
|
+
});
|
11
|
+
|
12
|
+
$('span.hover-key').mouseout(function(e) {
|
13
|
+
$(this).find('span.hover-value').hide();
|
14
|
+
});
|
15
|
+
});
|
16
|
+
|
17
|
+
:css
|
18
|
+
.hover-value {
|
19
|
+
display: none;
|
20
|
+
position: absolute;
|
21
|
+
top: 20px;
|
22
|
+
left: 20px;
|
23
|
+
background-color: lightyellow;
|
24
|
+
color: purple;
|
25
|
+
padding: 20px;
|
26
|
+
border: purple 1px solid;
|
27
|
+
}
|
28
|
+
|
29
|
+
%body
|
30
|
+
%h2 Query
|
31
|
+
%p
|
32
|
+
= explained_query.explanation
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'hash_deep_search'
|
2
|
+
|
3
|
+
class LogMagic::SearchkickExplainer::CustomAnalyzerHover
|
4
|
+
def initialize(query_explainer, index_settings)
|
5
|
+
@query_explainer = query_explainer
|
6
|
+
@index_settings = JSON.parse(index_settings)
|
7
|
+
end
|
8
|
+
|
9
|
+
def enriche
|
10
|
+
@query_explainer.query_json.clone.scan(custom_analyzer_matcher) do |match|
|
11
|
+
inject_hover(match[0])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def inject_hover(match)
|
16
|
+
@query_explainer.query_json.sub!(/[^w]#{match}[^w]/, hover_template(match).rendered_template)
|
17
|
+
end
|
18
|
+
|
19
|
+
def hover_template(match)
|
20
|
+
::LogMagic::HoverRenderer.new(match, HashDeepSearch.new(@index_settings).search(match))
|
21
|
+
end
|
22
|
+
|
23
|
+
def custom_analyzer_matcher
|
24
|
+
/[^w]analyzer[^w]\n[^<]*<\/a>\n: "([^"]*)"/
|
25
|
+
end
|
26
|
+
end
|
@@ -3,12 +3,14 @@ class LogMagic::SearchkickExplainer::SettingsExplainerSection
|
|
3
3
|
include ::LogMagic::JSONUtils
|
4
4
|
attr_reader :elasticsearch_url
|
5
5
|
|
6
|
-
def initialize(elasticsearch_url)
|
6
|
+
def initialize(elasticsearch_url, query_explainer)
|
7
|
+
@query_explainer = query_explainer
|
7
8
|
@elasticsearch_url = elasticsearch_url
|
9
|
+
enriche_query_json
|
8
10
|
end
|
9
11
|
|
10
12
|
def index_settings
|
11
|
-
`curl #{elasticsearch_url}/_settings`
|
13
|
+
@index_settings ||= `curl #{elasticsearch_url}/_settings`
|
12
14
|
end
|
13
15
|
|
14
16
|
def explanation
|
@@ -18,4 +20,9 @@ class LogMagic::SearchkickExplainer::SettingsExplainerSection
|
|
18
20
|
def template_name
|
19
21
|
'settings.haml'
|
20
22
|
end
|
23
|
+
|
24
|
+
def enriche_query_json
|
25
|
+
explainer = ::LogMagic::SearchkickExplainer::CustomAnalyzerHover.new(@query_explainer, index_settings)
|
26
|
+
explainer.enriche
|
27
|
+
end
|
21
28
|
end
|
@@ -19,11 +19,13 @@ class LogMagic::SearchkickExplainer
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def settings_explainer_section
|
22
|
-
SettingsExplainerSection.new(elasticsearch_url)
|
22
|
+
SettingsExplainerSection.new(elasticsearch_url, @query_explainer)
|
23
23
|
end
|
24
24
|
|
25
25
|
def explained_query
|
26
|
-
QueryExplainerSection.new(query_json)
|
26
|
+
@query_explainer = QueryExplainerSection.new(query_json)
|
27
|
+
settings_explainer_section.enriche_query_json
|
28
|
+
@query_explainer
|
27
29
|
end
|
28
30
|
|
29
31
|
def start
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class LogMagic::HoverRenderer
|
2
|
+
attr_reader :key, :value
|
3
|
+
include ::LogMagic::TemplatingUtils
|
4
|
+
|
5
|
+
def initialize(key, value)
|
6
|
+
@key = key
|
7
|
+
@value = value
|
8
|
+
end
|
9
|
+
|
10
|
+
def template_name
|
11
|
+
'hovering.haml'
|
12
|
+
end
|
13
|
+
|
14
|
+
def template_dir
|
15
|
+
'util_templates'
|
16
|
+
end
|
17
|
+
end
|
@@ -10,7 +10,7 @@ module LogMagic::TemplatingUtils
|
|
10
10
|
|
11
11
|
def template_path
|
12
12
|
File.expand_path(
|
13
|
-
File.join(__FILE__, '..', '..',
|
13
|
+
File.join(__FILE__, '..', '..', template_dir, template_name)
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
@@ -25,4 +25,8 @@ module LogMagic::TemplatingUtils
|
|
25
25
|
def template_name
|
26
26
|
"#{term_name}.haml"
|
27
27
|
end
|
28
|
+
|
29
|
+
def template_dir
|
30
|
+
'explainer_templates'
|
31
|
+
end
|
28
32
|
end
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Korfmann
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: hash_deep_search
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: byebug
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +132,7 @@ files:
|
|
118
132
|
- lib/log_magic/explainers/explainer_sections/_all_explainer.rb
|
119
133
|
- lib/log_magic/explainers/explainer_sections/analyzer_explainer.rb
|
120
134
|
- lib/log_magic/explainers/explainer_sections/boost_explainer.rb
|
135
|
+
- lib/log_magic/explainers/explainer_sections/custom_analyzer_hover.rb
|
121
136
|
- lib/log_magic/explainers/explainer_sections/dis_max_explainer.rb
|
122
137
|
- lib/log_magic/explainers/explainer_sections/fuzzy_transpositions_explainer.rb
|
123
138
|
- lib/log_magic/explainers/explainer_sections/match_explainer.rb
|
@@ -129,6 +144,8 @@ files:
|
|
129
144
|
- lib/log_magic/persistance_layer.rb
|
130
145
|
- lib/log_magic/printers/searchkick_printer.rb
|
131
146
|
- lib/log_magic/refiners/searchkick_refiner.rb
|
147
|
+
- lib/log_magic/renderers/hover_renderer.rb
|
148
|
+
- lib/log_magic/util_templates/hovering.haml
|
132
149
|
- lib/log_magic/utils/json_utils.rb
|
133
150
|
- lib/log_magic/utils/templating_utils.rb
|
134
151
|
homepage: https://github.com/ManuelArno/log_magic
|