evertils 1.0.5 → 1.0.6

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: 21f9ae214abe0e8d21339577b29d4124aa63e93bbefe880ea41ce03da30939c5
4
- data.tar.gz: 66a3be8684974c9a61ca55afa04989a720f812c7cd8d44a1388c3c6132803c1a
3
+ metadata.gz: b6cab6f39c8177d185542b7023e206d291c150998564c93734f18eca39df014b
4
+ data.tar.gz: 135ec4a854180bd71fe248c6da3a70690b7be4b9227485ac095b192d564da1c1
5
5
  SHA512:
6
- metadata.gz: 85aafab727acae80a39a31211222bb3fefca6020ccc734ea1136883e59bd2398cef1f364aabe4ff8deb832638e27ec15e9afc4b0eccc8e71048932778d832097
7
- data.tar.gz: c76b7cf310f5af6e15c0c73fa33f5c2ebb61cb7eee8dd195a77d37274cf79ca3a4ecd587fe4329463a60f244a96a616ed13340824b56238fcbde88df5704503f
6
+ metadata.gz: 7fa1b85a44096a98953e2070161b84e2fb87e70ed667a7b55bea4f9639f759308785bcaf09ff58026f114267da175e202e933a827d8d4042f1cc8c2fd5536bf9
7
+ data.tar.gz: 0f82ec9c16f6aad968c4e0fb4e59120290d1e2063646d0868016898a2b7d53badb581f4a565becbf7151fa96947bf27ba11af3e44f2484761f8f87efae6b1c9b
@@ -27,7 +27,7 @@ module Evertils
27
27
  # always skip weekends, even if there is a note for those days
28
28
  next if %i[Sat Sun].include?(dow)
29
29
 
30
- note_title = @args[:title]
30
+ note_title = previous_note_title(@args[:title_format], day)
31
31
  note = @note_helper.model.find_note_contents(note_title).entity
32
32
 
33
33
  Notify.info(" (#{iter}) #{note_title}")
@@ -37,6 +37,26 @@ module Evertils
37
37
 
38
38
  @api.convert_to_xml(note.content).prepare
39
39
  end
40
+
41
+ def previous_note_title(fmt, date)
42
+ # not a good solution but it works
43
+ # TODO: fix this
44
+ replacements = {
45
+ '%DOY%': date.yday,
46
+ '%MONTH_NAME%': date.strftime('%B'),
47
+ '%MONTH%': date.month,
48
+ '%DAY%': date.day,
49
+ '%DOW%': date.wday,
50
+ '%DOW_NAME%': date.strftime('%a'),
51
+ '%YEAR%': date.year,
52
+ '%WEEK%': date.cweek,
53
+ '%WEEK_START%': Date.commercial(date.year, date.cweek, 1),
54
+ '%WEEK_END%': Date.commercial(date.year, date.cweek, 5)
55
+ }
56
+
57
+ replacements.each_pair { |k, v| fmt.gsub!(k.to_s, v.to_s) }
58
+ fmt
59
+ end
40
60
  end
41
61
  end
42
62
  end
@@ -90,6 +90,8 @@ module Evertils
90
90
  end
91
91
 
92
92
  def translate_placeholders
93
+ title_format = @yml[:title].dup
94
+
93
95
  @yml.map do |item|
94
96
  REPLACEMENTS.each_pair do |k, v|
95
97
  item.last.gsub!(k.to_s, v.to_s) if item.last.is_a? String
@@ -97,6 +99,8 @@ module Evertils
97
99
  end
98
100
  end
99
101
 
102
+ @yml[:title_format] = title_format unless @yml.key? :title_format
103
+
100
104
  symbolize_keys(@yml)
101
105
  self
102
106
  end
@@ -4,7 +4,13 @@ module Evertils
4
4
  module Controller
5
5
  class Render < Controller::Base
6
6
  def from_file(config)
7
- @config = config.translate_placeholders.pluck(:title, :notebook, :path, :action)
7
+ @config = config.translate_placeholders.pluck(
8
+ :title,
9
+ :title_format,
10
+ :notebook,
11
+ :path,
12
+ :action
13
+ )
8
14
 
9
15
  return Notify.warning("Note already exists\n- #{@link}") if note_exists?
10
16
 
@@ -34,7 +34,7 @@ module Evertils
34
34
 
35
35
  # Wait for a note to exist
36
36
  def wait_for_by_title(title, notebook, iterations = Evertils::Type::Base::MAX_SEARCH_SIZE)
37
- Notify.info("Waiting for #{notebook}...")
37
+ Notify.info("Waiting for #{title}...")
38
38
  note = find_note_by_title(title)
39
39
 
40
40
  begin
@@ -1,3 +1,3 @@
1
1
  module Evertils
2
- VERSION = '1.0.5'.freeze
2
+ VERSION = '1.0.6'.freeze
3
3
  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: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe