evertils 2.0.0 → 2.0.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: 04b57db19e88587c1b226d8b457f2366be8abaa9d9ac11167d08c704d828a008
4
- data.tar.gz: 2dc9c21a462bdd8404f116bdd45a3ffd32e91e4191133e4ee0d1bc363936a721
3
+ metadata.gz: a73b52e4baf5b8c14bb0927c7f34ad5d6379c32403a5aa73dd3e4aa6720695fc
4
+ data.tar.gz: eabd9cd23471a321759a41586f1551561b8508058fddc60069acb452c0e04580
5
5
  SHA512:
6
- metadata.gz: be6ea98ad31e762358da2188e145f987367e1c2e1e976470e1ec575c2c9ec687c639bf838a90c090a0c426dbff9a4d4783fe9b248bf75ede31bb9ef0619a183f
7
- data.tar.gz: 3d7d6aeae4d8676cee6f5619407719ef364bc426f398c4c39fc29178106290daeea7b746c11e4a2b69cd5b3797c973f0a2b9fa3e241efc7f02b9402ba805de2f
6
+ metadata.gz: 90f8309a45345fa461078aeda4bc4a0b2c58698a958c84101291a3e14950d221ec7ee1425ff07809875f5bff724ea8097b03763e68adcc9e8690c83e03fe0495
7
+ data.tar.gz: 2f983ff37691cd9969de44a240e1b594216dc52c8397c3266e1c7684569fbe053f451d1d96ae2a22dc4a5105cf9abb05c65a616e46dbc0549719b1b92be61a4c
@@ -6,7 +6,7 @@ module Evertils
6
6
  def initialize(args)
7
7
  @args = args
8
8
  @note_helper = Evertils::Helper::Note.instance
9
- @api = Evertils::Helper::ApiEnmlHandler.new
9
+ @api = Evertils::Helper::ApiEnmlHandler.new(@args)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Evertils
6
6
  def initialize(args)
7
7
  super(args)
8
8
 
9
- @args[:content] = find_previous(args)
9
+ @args[:content] = find_previous
10
10
 
11
11
  query = Evertils::Common::Query::Simple.new
12
12
  query.create_note_from_hash(@args)
@@ -14,50 +14,22 @@ module Evertils
14
14
 
15
15
  private
16
16
 
17
- def find_previous(args)
18
- day = Date.today
19
- note = nil
17
+ def find_previous
18
+ helper = Evertils::Helper::Note.instance
19
+ note = helper.wait_for_with_grammar(grammar)
20
20
 
21
- Notify.info("Searching for last #{@args[:notebook]}...")
22
-
23
- (1..Evertils::Base::MAX_SEARCH_SIZE).each do |iter|
24
- day -= 1
25
- dow = day.strftime('%a')
26
-
27
- # always skip weekends, even if there is a note for those days
28
- next if %i[Sat Sun].include?(dow)
29
-
30
- note_title = previous_note_title(@args[:title_format], day)
31
- note = @note_helper.model.find_note_contents(note_title).entity
32
-
33
- Notify.info(" (#{iter}) #{note_title}")
34
-
35
- break unless note.nil?
36
- end
37
-
38
- @api.convert_to_xml(note.content).prepare
21
+ @api.convert_to_xml(note.entity.content).prepare
39
22
  end
40
23
 
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)
24
+ def grammar
25
+ terms = Grammar.new
26
+ terms.notebook = @args[:notebook]
27
+ terms.tags = {
28
+ day: Date.today.yday,
29
+ week: Date.today.cweek
55
30
  }
56
-
57
- title_format = fmt.dup
58
-
59
- replacements.each_pair { |k, v| title_format.gsub!(k.to_s, v.to_s) }
60
- title_format
31
+ terms.created = Date.new(Date.today.year, 1, 1).strftime('%Y%m%d')
32
+ terms
61
33
  end
62
34
  end
63
35
  end
@@ -6,9 +6,11 @@ module Evertils
6
6
  def from_file
7
7
  set_allowed_fields
8
8
 
9
- return Notify.warning("Note already exists\n- #{@link}") if note_exists?
9
+ if @allowed_fields[:action] == 'create'
10
+ return Notify.warning("Note already exists\n- #{@link}") if note_exists?
10
11
 
11
- Notify.info 'Note not found, creating a new one'
12
+ Notify.info 'Note not found, creating a new one'
13
+ end
12
14
 
13
15
  execute_action(@allowed_fields[:action])
14
16
  end
@@ -18,6 +18,7 @@ module Evertils
18
18
  #
19
19
  # @since 1.0.12
20
20
  def to_s
21
+ @grammar = []
21
22
  stringify_properties
22
23
  stringify_tags unless @tags.empty?
23
24
 
@@ -1,3 +1,3 @@
1
1
  module Evertils
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.0.1'.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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe