evertils 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/evertils/controllers/log.rb +88 -10
- data/lib/evertils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a0a083bfeeace2a3e2dd0381a746abc06b56e83e6d6a5b220fef7293368abc8
|
4
|
+
data.tar.gz: fd0702657d1aafe58c4ac30d6024e4ec4b8f33b7ff117b934c073669d12a8c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c0ff797033d7262c604fd4b15b584f7ceb168f71bb6274fe6ca53e8bf7e54c71c9951b1a1e96058fb4bfd37af3f0bc9501bca4719c5e542545997e4518a187
|
7
|
+
data.tar.gz: ae20c82297b3cdd1a303511b03be055326f27766a78e4286f9605e463aa94ce97fdc294f974b23512e8aea98c847e6819390c3b91610b58700f320382e3bd403
|
@@ -4,6 +4,7 @@ module Evertils
|
|
4
4
|
def pre_exec
|
5
5
|
super
|
6
6
|
|
7
|
+
@note = nil
|
7
8
|
@note_helper = Evertils::Helper::Note.instance
|
8
9
|
@api_helper = Evertils::Helper::ApiEnmlHandler.new(@config)
|
9
10
|
end
|
@@ -12,11 +13,33 @@ module Evertils
|
|
12
13
|
def message(text = nil)
|
13
14
|
return Notify.error('A message is required') if text.nil?
|
14
15
|
|
15
|
-
note = @note_helper.find_note_by_grammar(grammar.to_s)
|
16
|
+
@note = @note_helper.find_note_by_grammar(grammar.to_s)
|
16
17
|
|
17
|
-
return Notify.error('Note not found') if note.entity.nil?
|
18
|
+
return Notify.error('Note not found') if @note.entity.nil?
|
18
19
|
|
19
|
-
|
20
|
+
modify_with(text)
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# @since 2.2.0
|
25
|
+
def grep(text = nil)
|
26
|
+
return Notify.error('A search term is required') if text.nil?
|
27
|
+
|
28
|
+
@note = @note_helper.find_note_by_grammar(grammar.to_s)
|
29
|
+
|
30
|
+
return Notify.error('Note not found') if @note.entity.nil?
|
31
|
+
|
32
|
+
search_for(text)
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# @since 2.2.0
|
37
|
+
def group(text = nil)
|
38
|
+
@note = @note_helper.find_note_by_grammar(grammar.to_s)
|
39
|
+
|
40
|
+
return Notify.error('Note not found') if @note.entity.nil?
|
41
|
+
|
42
|
+
group_by(text)
|
20
43
|
end
|
21
44
|
|
22
45
|
private
|
@@ -33,15 +56,13 @@ module Evertils
|
|
33
56
|
end
|
34
57
|
|
35
58
|
# Update a note with content
|
36
|
-
def
|
37
|
-
xml = @api_helper.from_str(note.entity.content)
|
59
|
+
def modify_with(text)
|
60
|
+
xml = @api_helper.from_str(@note.entity.content)
|
38
61
|
|
39
62
|
time = Time.now.strftime('%I:%M')
|
40
63
|
target = xml.search('en-note').first
|
41
64
|
|
42
|
-
|
43
|
-
|
44
|
-
log_message_txt = "<div>* #{time} - #{text}</div>"
|
65
|
+
log_message_txt = "<div>* #{time} - #{clean(text)}</div>"
|
45
66
|
|
46
67
|
# append the log message to the target
|
47
68
|
target.add_child(log_message_txt)
|
@@ -51,9 +72,66 @@ module Evertils
|
|
51
72
|
xml.children[1].remove
|
52
73
|
end
|
53
74
|
|
54
|
-
note.entity.content = xml.to_s
|
75
|
+
@note.entity.content = xml.to_s
|
76
|
+
|
77
|
+
Notify.success("Item logged at #{time}") if @note.update
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# @since 2.2.0
|
82
|
+
def search_for(text)
|
83
|
+
results = grep_results_for(text)
|
84
|
+
|
85
|
+
return Notify.error("No rows matched search query {#{text}}") if results.empty?
|
86
|
+
|
87
|
+
Notify.success("#{results.size} rows matched query {#{text}}")
|
88
|
+
results.each { |res| Notify.info(clean(res)) }
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# @since 2.2.0
|
93
|
+
def group_by(text)
|
94
|
+
grouped_results.each_pair do |job_id, rows|
|
95
|
+
Notify.note("#{clean(job_id)} - #{rows.size} occurrences") unless job_id.nil?
|
96
|
+
|
97
|
+
rows.each { |row| Notify.info(clean(row)) }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# @since 2.2.0
|
103
|
+
def search_nodes
|
104
|
+
xml = @api_helper.from_str(@note.entity.content)
|
105
|
+
target = xml.search('en-note').first
|
106
|
+
nodes = []
|
107
|
+
|
108
|
+
target.children.each do |child|
|
109
|
+
node = child.children.first.to_s
|
110
|
+
nodes.push(clean(node)) unless node.empty? || node == '<br/>'
|
111
|
+
end
|
112
|
+
|
113
|
+
nodes
|
114
|
+
end
|
115
|
+
|
116
|
+
#
|
117
|
+
# @since 2.2.0
|
118
|
+
def grouped_results
|
119
|
+
search_nodes.group_by do |node|
|
120
|
+
match = /- (.*)? -/.match(node)
|
121
|
+
match[1] unless match.nil?
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# @since 2.2.0
|
127
|
+
def grep_results_for(text)
|
128
|
+
search_nodes.select { |line| line.include? text }
|
129
|
+
end
|
55
130
|
|
56
|
-
|
131
|
+
#
|
132
|
+
# @since 2.2.0
|
133
|
+
def clean(text)
|
134
|
+
text.delete("\n").gsub(' ', ' ')
|
57
135
|
end
|
58
136
|
end
|
59
137
|
end
|
data/lib/evertils/version.rb
CHANGED