evertils 1.0.3 → 1.0.4

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: 729ea1155bb91b28107d159632c23b56982bea2289cf3b0168b2096ece56bece
4
- data.tar.gz: 5bd294f95c2a4f0cceec90ed896cf35db9d0b2cf4e16b5f508e7ff20d6d404e9
3
+ metadata.gz: 40f5e46e19024a064b17efcb49eb6f405422632c6128be5995530da0bdf8e867
4
+ data.tar.gz: b67fbc4dc7595ec219e80f5d252adbd5c4ccb25d99e3d579930936e61b3378a4
5
5
  SHA512:
6
- metadata.gz: e567a59ae3f1bf91cd8fc092a3911bf83021ba627cdcb9bc4e6075c1631d0cc3ca43094abbb2dcd40f2677f5ef2136cc586b35db6d04bb5de8f86f35f05ba75b
7
- data.tar.gz: 82f8443eb52b10133ca6d8fab20364a0ac9ac4c06fe4c83dd4b6bbeacbdbfb95d64ab744bedb3c50671cabd5611f5bfc1e350cda832d2c9531163657f854907a
6
+ metadata.gz: a38b8cb932b499dcc003704f94e992c2b0db83150f6a83c8cc21652db53c4d2489fb0e2705f526ba17ed8b46bf8b0a8833bbea1539429db619ed31896bb33c8d
7
+ data.tar.gz: 3de009e90382e2f1098d3e0d1f57f02f5f5c96cf5245268e80b2c4ab427b4f557e659e7cb38f376d50ed8a8440ed15e62010eed0175e9dbea8c16408d829e147
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Evertils
4
+ module Action
5
+ class Default < Action::Base
6
+ def initialize(args)
7
+ Notify.error "Unknown action '#{args[:action]}'"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -13,39 +13,35 @@ module Evertils
13
13
  return Notify.error('A message is required', {}) if text.nil?
14
14
 
15
15
  note = @note_helper.wait_for_by_notebook(:Daily)
16
- edit_conf = {
17
- search: 'Triage',
18
- append: text
19
- }
20
16
 
21
17
  return Notify.error('Note not found') if note.entity.nil?
22
18
 
23
- modify(note, edit_conf)
19
+ modify(note, text)
24
20
  end
25
21
 
26
22
  private
27
23
 
28
24
  # Update a note with content
29
- def modify(note, conf)
25
+ def modify(note, text)
30
26
  xml = @api_helper.from_str(note.entity.content)
31
- xml_helper = Evertils::Helper.load('Xml', xml)
32
27
 
33
28
  time = Time.now.strftime('%I:%M')
34
- target = xml.search("h2:contains('#{conf[:search]}')").first
29
+ target = xml.search('en-note>div').first
35
30
 
36
31
  return Notify.error('Unable to log message, triage section not found') if target.nil?
37
32
 
38
- log_message_txt = xml_helper.span("#{time} - #{conf[:append]}")
39
- log_message_el = xml_helper.li(log_message_txt)
33
+ log_message_txt = "* #{time} - #{text}<br clear='none'/>"
40
34
 
41
35
  # append the log message to the target
42
- target.add_child(log_message_el)
36
+ target.add_child(log_message_txt)
37
+
43
38
  # remove XML processing definition if it is the second element
44
39
  if xml.children[1].is_a?(Nokogiri::XML::ProcessingInstruction)
45
40
  xml.children[1].remove
46
41
  end
47
42
 
48
43
  note.entity.content = xml.to_s
44
+
49
45
  Notify.success("Item logged at #{time}") if note.update
50
46
  end
51
47
  end
@@ -10,7 +10,7 @@ module Evertils
10
10
 
11
11
  Notify.info 'Note not found, creating a new one'
12
12
 
13
- execute_action(@config[:action] || :create)
13
+ execute_action(@config[:action])
14
14
  end
15
15
 
16
16
  def note_exists?
@@ -22,11 +22,16 @@ module Evertils
22
22
  end
23
23
 
24
24
  def execute_action(action)
25
- case action.to_sym
26
- when :duplicate_previous
25
+ case action
26
+ when nil
27
+ Notify.info 'Action not provided, creation new note...'
28
+ Action::Create.new(@config)
29
+ when 'create'
30
+ Action::Create.new(@config)
31
+ when 'duplicate_previous'
27
32
  Action::DuplicatePrevious.new(@config)
28
33
  else
29
- Action::Create.new(@config)
34
+ Action::Default.new(action: action)
30
35
  end
31
36
  end
32
37
  end
@@ -1,3 +1,3 @@
1
1
  module Evertils
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
data/lib/evertils.rb CHANGED
@@ -22,6 +22,7 @@ require 'evertils/version'
22
22
  require 'evertils/base'
23
23
  require 'evertils/type'
24
24
  require 'evertils/action'
25
+ require 'evertils/actions/default'
25
26
  require 'evertils/actions/create'
26
27
  require 'evertils/actions/duplicate_previous'
27
28
  require 'evertils/helpers/time'
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: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe
@@ -112,6 +112,7 @@ files:
112
112
  - lib/evertils.rb
113
113
  - lib/evertils/action.rb
114
114
  - lib/evertils/actions/create.rb
115
+ - lib/evertils/actions/default.rb
115
116
  - lib/evertils/actions/duplicate_previous.rb
116
117
  - lib/evertils/base.rb
117
118
  - lib/evertils/config.rb