evertils 2.2.0 → 2.2.1
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/lib/evertils/controllers/log.rb +27 -13
- 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: 7c46a2159d62b6e856e8dff4c06524f6e34098b556a6fa2db6732c3b90158e9c
|
4
|
+
data.tar.gz: c33e3ee54a15c187f95e82a759c428bd5452e6ccf68e967b86d2760015e44a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ab525b278952924e836d3c10cacb497ef8a2ded543c0e3e839f559119c42dad49c7959442c728ed976c5bab56561e84d470c65e60d10755f5e135df2440d26d
|
7
|
+
data.tar.gz: 6d7b58fdbfd3827d83820ec6a790a07f1967a161e4e3ffee496157bd13414c1ad5f50c8b236c41789a12dc113bcca8a106177d72e2b23fc5b00deedc00797600
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Evertils
|
2
2
|
module Controller
|
3
3
|
class Log < Controller::Base
|
4
|
+
WORDS_PER_LINE = 20
|
5
|
+
|
4
6
|
def pre_exec
|
5
7
|
super
|
6
8
|
|
@@ -14,10 +16,13 @@ module Evertils
|
|
14
16
|
return Notify.error('A message is required') if text.nil?
|
15
17
|
|
16
18
|
@note = @note_helper.find_note_by_grammar(grammar.to_s)
|
19
|
+
text_groups = text.split(' ').each_slice(WORDS_PER_LINE).map do |w|
|
20
|
+
w.join(' ')
|
21
|
+
end
|
17
22
|
|
18
23
|
return Notify.error('Note not found') if @note.entity.nil?
|
19
24
|
|
20
|
-
modify_with(
|
25
|
+
modify_with(text_groups)
|
21
26
|
end
|
22
27
|
|
23
28
|
#
|
@@ -39,7 +44,7 @@ module Evertils
|
|
39
44
|
|
40
45
|
return Notify.error('Note not found') if @note.entity.nil?
|
41
46
|
|
42
|
-
group_by
|
47
|
+
group_by
|
43
48
|
end
|
44
49
|
|
45
50
|
private
|
@@ -57,15 +62,7 @@ module Evertils
|
|
57
62
|
|
58
63
|
# Update a note with content
|
59
64
|
def modify_with(text)
|
60
|
-
xml =
|
61
|
-
|
62
|
-
time = Time.now.strftime('%I:%M')
|
63
|
-
target = xml.search('en-note').first
|
64
|
-
|
65
|
-
log_message_txt = "<div>* #{time} - #{clean(text)}</div>"
|
66
|
-
|
67
|
-
# append the log message to the target
|
68
|
-
target.add_child(log_message_txt)
|
65
|
+
xml = update_note_content_with(text)
|
69
66
|
|
70
67
|
# remove XML processing definition if it is the second element
|
71
68
|
if xml.children[1].is_a?(Nokogiri::XML::ProcessingInstruction)
|
@@ -74,7 +71,20 @@ module Evertils
|
|
74
71
|
|
75
72
|
@note.entity.content = xml.to_s
|
76
73
|
|
77
|
-
Notify.success("Item logged at #{
|
74
|
+
Notify.success("Item logged at #{current_time}") if @note.update
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# @since 2.2.1
|
79
|
+
def update_note_content_with(text)
|
80
|
+
xml = @api_helper.from_str(@note.entity.content)
|
81
|
+
target = xml.search('en-note').first
|
82
|
+
|
83
|
+
text.each do |line|
|
84
|
+
target.add_child("<div>* #{current_time} - #{clean(line)}</div>")
|
85
|
+
end
|
86
|
+
|
87
|
+
xml
|
78
88
|
end
|
79
89
|
|
80
90
|
#
|
@@ -90,7 +100,7 @@ module Evertils
|
|
90
100
|
|
91
101
|
#
|
92
102
|
# @since 2.2.0
|
93
|
-
def group_by
|
103
|
+
def group_by
|
94
104
|
grouped_results.each_pair do |job_id, rows|
|
95
105
|
Notify.note("#{clean(job_id)} - #{rows.size} occurrences") unless job_id.nil?
|
96
106
|
|
@@ -133,6 +143,10 @@ module Evertils
|
|
133
143
|
def clean(text)
|
134
144
|
text.delete("\n").gsub(' ', ' ')
|
135
145
|
end
|
146
|
+
|
147
|
+
def current_time
|
148
|
+
Time.now.strftime('%I:%M')
|
149
|
+
end
|
136
150
|
end
|
137
151
|
end
|
138
152
|
end
|
data/lib/evertils/version.rb
CHANGED