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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a0a083bfeeace2a3e2dd0381a746abc06b56e83e6d6a5b220fef7293368abc8
4
- data.tar.gz: fd0702657d1aafe58c4ac30d6024e4ec4b8f33b7ff117b934c073669d12a8c6f
3
+ metadata.gz: 7c46a2159d62b6e856e8dff4c06524f6e34098b556a6fa2db6732c3b90158e9c
4
+ data.tar.gz: c33e3ee54a15c187f95e82a759c428bd5452e6ccf68e967b86d2760015e44a19
5
5
  SHA512:
6
- metadata.gz: 32c0ff797033d7262c604fd4b15b584f7ceb168f71bb6274fe6ca53e8bf7e54c71c9951b1a1e96058fb4bfd37af3f0bc9501bca4719c5e542545997e4518a187
7
- data.tar.gz: ae20c82297b3cdd1a303511b03be055326f27766a78e4286f9605e463aa94ce97fdc294f974b23512e8aea98c847e6819390c3b91610b58700f320382e3bd403
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(text)
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(text)
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 = @api_helper.from_str(@note.entity.content)
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 #{time}") if @note.update
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(text)
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('&#xA0;', ' ')
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evertils
4
- VERSION = '2.2.0'
4
+ VERSION = '2.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evertils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe