evertils 1.0.12 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -3
  3. data/evertils.gemspec +3 -3
  4. data/lib/evertils/action.rb +2 -2
  5. data/lib/evertils/actions/duplicate_previous.rb +1 -1
  6. data/lib/evertils/base.rb +3 -3
  7. data/lib/evertils/config.rb +1 -3
  8. data/lib/evertils/controller.rb +0 -1
  9. data/lib/evertils/controllers/log.rb +2 -2
  10. data/lib/evertils/controllers/render.rb +15 -3
  11. data/lib/evertils/{gpg_exception.rb → exceptions/gpg_exception.rb} +0 -0
  12. data/lib/evertils/{required_check_exception.rb → exceptions/required_check_exception.rb} +0 -0
  13. data/lib/evertils/{yubikey_exception.rb → exceptions/yubikey_exception.rb} +0 -0
  14. data/lib/evertils/grammar.rb +4 -2
  15. data/lib/evertils/helpers/api-enml-handler.rb +2 -2
  16. data/lib/evertils/helpers/formatting.rb +1 -76
  17. data/lib/evertils/helpers/note.rb +12 -8
  18. data/lib/evertils/router.rb +3 -7
  19. data/lib/evertils/version.rb +1 -1
  20. data/lib/evertils.rb +3 -6
  21. metadata +14 -31
  22. data/lib/evertils/configs/templates/daily.enml +0 -14
  23. data/lib/evertils/configs/templates/monthly-task-summaries.enml +0 -9
  24. data/lib/evertils/configs/templates/monthly.enml +0 -13
  25. data/lib/evertils/configs/templates/pq.enml +0 -3
  26. data/lib/evertils/configs/templates/weekly.enml +0 -13
  27. data/lib/evertils/controllers/convert.rb +0 -48
  28. data/lib/evertils/controllers/generate.rb +0 -57
  29. data/lib/evertils/controllers/get.rb +0 -55
  30. data/lib/evertils/controllers/new.rb +0 -88
  31. data/lib/evertils/helper.rb +0 -19
  32. data/lib/evertils/helpers/time.rb +0 -28
  33. data/lib/evertils/type.rb +0 -58
  34. data/lib/evertils/types/daily.rb +0 -54
  35. data/lib/evertils/types/monthly-task-summary.rb +0 -24
  36. data/lib/evertils/types/monthly.rb +0 -58
  37. data/lib/evertils/types/priority-queue.rb +0 -55
  38. data/lib/evertils/types/weekly.rb +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99e8ad314c474633e6107fb99dd66364cab9d8a2f38ae36e461c07cae6a2a842
4
- data.tar.gz: 94cff8759a0cac2568fc06f59205870225d7b9f9e76c8f5c37ad3bccfa299f62
3
+ metadata.gz: 04b57db19e88587c1b226d8b457f2366be8abaa9d9ac11167d08c704d828a008
4
+ data.tar.gz: 2dc9c21a462bdd8404f116bdd45a3ffd32e91e4191133e4ee0d1bc363936a721
5
5
  SHA512:
6
- metadata.gz: d0a4d0c5ccb9461475e0c975515c0cdaddd13250ba10631504ac861f3729acf218361a86e5d6daeb037f779cd53a3bf8bd6d131a41a6dec4bc9ce503f882dcd0
7
- data.tar.gz: 29e50ce9b59a4be5a41fe9288b4d465d13abb20422094487e7df9bdecccbd6f25fb22a8dda22cef551ec1c40239b53177b464ec3104d4b134ad184aacedd08ee
6
+ metadata.gz: be6ea98ad31e762358da2188e145f987367e1c2e1e976470e1ec575c2c9ec687c639bf838a90c090a0c426dbff9a4d4783fe9b248bf75ede31bb9ef0619a183f
7
+ data.tar.gz: 3d7d6aeae4d8676cee6f5619407719ef364bc426f398c4c39fc29178106290daeea7b746c11e4a2b69cd5b3797c973f0a2b9fa3e241efc7f02b9402ba805de2f
data/README.md CHANGED
@@ -17,9 +17,7 @@ See [this document](https://github.com/aapis/evertils/wiki/Logging-Specification
17
17
  |Command|Description|Usage|
18
18
  |:--------------|:-----------|:-------------|
19
19
  |generate|Create notes from templates|`evertils generate daily`, `evertils generate morning`, `evertils generate monthly`|
20
- |new|Manually create notes|`evertils new note "STUFF"`, `evertils new share_note "STUFF"`, `other task $PIPE_CHAR$ evertils new share_note --title="Piped data note"`|
21
- |get|Get data from Evernote|`evertils get notebook` (coming soon)|
22
- |convert|Convert your notes to Markdown, then back to ENML|(coming soon)|
20
+ |log|Write a line to a note|`evertils log message "I am a message"`|
23
21
 
24
22
  ## Automation
25
23
 
data/evertils.gemspec CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.executables = 'evertils'
18
18
  s.required_ruby_version = '>= 2.4.0'
19
19
 
20
- s.add_runtime_dependency 'notifaction'
21
- s.add_runtime_dependency 'mime-types'
20
+ s.add_runtime_dependency 'notifaction', '~> 0.4.4'
21
+ s.add_runtime_dependency 'mime-types', '~> 3.3.1'
22
22
  s.add_runtime_dependency 'evertils-common', '~> 0.3.7'
23
23
  s.add_runtime_dependency 'nokogiri'
24
24
 
25
25
  s.add_development_dependency "bundler", "~> 1.10"
26
- s.add_development_dependency "rake", "~> 10.0"
26
+ s.add_development_dependency "rake", "~> 12.3.3"
27
27
  end
@@ -5,8 +5,8 @@ module Evertils
5
5
  class Base
6
6
  def initialize(args)
7
7
  @args = args
8
- @note_helper = Evertils::Helper.load('Note')
9
- @api = Evertils::Helper.load('ApiEnmlHandler', {})
8
+ @note_helper = Evertils::Helper::Note.instance
9
+ @api = Evertils::Helper::ApiEnmlHandler.new
10
10
  end
11
11
  end
12
12
  end
@@ -20,7 +20,7 @@ module Evertils
20
20
 
21
21
  Notify.info("Searching for last #{@args[:notebook]}...")
22
22
 
23
- (1..Evertils::Type::Base::MAX_SEARCH_SIZE).each do |iter|
23
+ (1..Evertils::Base::MAX_SEARCH_SIZE).each do |iter|
24
24
  day -= 1
25
25
  dow = day.strftime('%a')
26
26
 
data/lib/evertils/base.rb CHANGED
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Evertils
2
4
  class Base
3
- def initialize
4
- @format = Evertils::Helper.load('Formatting')
5
- end
5
+ MAX_SEARCH_SIZE = 11
6
6
  end
7
7
  end
@@ -47,9 +47,7 @@ module Evertils
47
47
  # Populates the internal hash which stores any values set in the config file
48
48
  def populate_config
49
49
  file = File.expand_path("~/.evertils/config.yml")
50
- fmt = Evertils::Helper.load('Formatting')
51
-
52
- @yml = fmt.symbolize(::YAML.load_file(file))
50
+ @yml = symbolize_keys(::YAML.load_file(file))
53
51
 
54
52
  set_evertils_token
55
53
 
@@ -31,7 +31,6 @@ module Evertils
31
31
 
32
32
  # Perform pre-run tasks
33
33
  def pre_exec
34
- @format = Evertils::Helper.load('Formatting')
35
34
  end
36
35
 
37
36
  # Handle the request
@@ -4,8 +4,8 @@ module Evertils
4
4
  def pre_exec
5
5
  super
6
6
 
7
- @note_helper = Evertils::Helper.load('Note')
8
- @api_helper = Evertils::Helper.load('ApiEnmlHandler', @config)
7
+ @note_helper = Evertils::Helper::Note.instance
8
+ @api_helper = Evertils::Helper::ApiEnmlHandler.new(@config)
9
9
  end
10
10
 
11
11
  # Send arbitrary text to the daily log
@@ -14,8 +14,9 @@ module Evertils
14
14
  end
15
15
 
16
16
  def note_exists?
17
- helper = Evertils::Helper.load('Note')
18
- note = helper.wait_for_by_title(@allowed_fields[:title], @allowed_fields[:notebook], 3)
17
+ helper = Evertils::Helper::Note.instance
18
+ note = helper.wait_for_with_grammar(grammar)
19
+
19
20
  @link = helper.external_url_for(note.entity) unless note.entity.nil?
20
21
 
21
22
  note.exists?
@@ -24,7 +25,7 @@ module Evertils
24
25
  def execute_action(action)
25
26
  case action
26
27
  when nil
27
- Notify.info 'Action not provided, creation new note...'
28
+ Notify.info 'Action not provided, creating new note...'
28
29
  Action::Create.new(@allowed_fields)
29
30
  when 'create'
30
31
  Action::Create.new(@allowed_fields)
@@ -47,6 +48,17 @@ module Evertils
47
48
  :tags
48
49
  )
49
50
  end
51
+
52
+ def grammar
53
+ terms = Grammar.new
54
+ terms.notebook = @allowed_fields[:notebook]
55
+ terms.tags = {
56
+ day: Date.today.yday,
57
+ week: Date.today.cweek
58
+ }
59
+ terms.created = Date.new(Date.today.year, 1, 1).strftime('%Y%m%d')
60
+ terms
61
+ end
50
62
  end
51
63
  end
52
64
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Evertils
4
4
  class Grammar
5
- attr_accessor :tags, :notebook, :created
5
+ attr_accessor :tags, :notebook, :created, :intitle
6
6
 
7
7
  # Available grammars
8
8
  # https://dev.evernote.com/doc/articles/search_grammar.php
@@ -11,6 +11,7 @@ module Evertils
11
11
  @tags = []
12
12
  @grammar = []
13
13
  @notebook = nil
14
+ @intitle = nil
14
15
  @created = Date.today.strftime('%Y%m%d')
15
16
  end
16
17
 
@@ -42,7 +43,8 @@ module Evertils
42
43
  grammars_used.reject! { |k, _| k.to_s.end_with?('=') || k == :tags }
43
44
 
44
45
  grammars_used.each do |grammar|
45
- @grammar.push("#{grammar}:#{send(grammar)}")
46
+ value = send(grammar)
47
+ @grammar.push("#{grammar}:#{value}") unless value.nil?
46
48
  end
47
49
  end
48
50
  end
@@ -5,8 +5,8 @@ module Evertils
5
5
 
6
6
  #
7
7
  # @since 0.3.7
8
- def initialize(args = [])
9
- @config = args.first
8
+ def initialize(conf)
9
+ @config = conf
10
10
  self
11
11
  end
12
12
 
@@ -3,42 +3,8 @@
3
3
  module Evertils
4
4
  module Helper
5
5
  class Formatting
6
- # Legacy notes will have single/double character denotations for day of
7
- # week, this maps them.
8
- def day_of_week(arg_date = Date.today.strftime('%a'))
9
- case arg_date
10
- when 'Mon'
11
- :M
12
- when 'Tue'
13
- :Tu
14
- when 'Wed'
15
- :W
16
- when 'Thu'
17
- :Th
18
- when 'Fri'
19
- :F
20
- when 'Sat'
21
- :Sa
22
- when 'Sun'
23
- :Su
24
- end
25
- end
26
-
27
- # Template file for note body
28
- def template_contents(type = nil)
29
- begin
30
- raise ArgumentError, "Type is required" if type.nil?
31
-
32
- IO.readlines(load_template(type), :encoding => 'UTF-8').join("").delete!("\n")
33
- rescue Errno::ENOENT => e
34
- Notify.error("#{e}\n#{e.backtrace.join("\n")}", show_time: false)
35
- rescue ArgumentError => e
36
- Notify.error("#{e}\n#{e.backtrace.join("\n")}", show_time: false)
37
- end
38
- end
39
-
40
6
  # Template string for note title
41
- def date_templates
7
+ def self.date_templates
42
8
  current_date = Date.today
43
9
  week_stub = current_date.strftime('%a')
44
10
  start_of_week = Date.commercial(current_date.year, current_date.cweek, 1)
@@ -52,47 +18,6 @@ module Evertils
52
18
  :'Priority Queue' => "Queue For [#{current_date.strftime('%B %-d')} - #{week_stub}]"
53
19
  }
54
20
  end
55
-
56
- # Recursively symbolize keys in a hash
57
- # Params:
58
- # +h+:: The hash you want to symbolize
59
- def symbolize(h)
60
- case h
61
- when Hash
62
- Hash[
63
- h.map do |k, v|
64
- [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize(v)]
65
- end
66
- ]
67
- when Enumerable
68
- h.map { |v| symbolize(v) }
69
- else
70
- h
71
- end
72
- end
73
-
74
- private
75
-
76
- #
77
- # @since 0.3.1
78
- def load_template(type)
79
- file_name = type.to_s.downcase.gsub(/\s/, '-')
80
- installed_dir = Gem::Specification.find_by_name('evertils').gem_dir
81
- local_installed_dir = "#{Dir.home}/.evertils/templates/"
82
- template_file = "#{installed_dir}/lib/evertils/configs/templates/#{file_name}.enml"
83
-
84
- if Dir.exist? local_installed_dir
85
- template_file = "#{local_installed_dir}#{file_name}.enml"
86
-
87
- # local config dir exists but the requested template does not, use
88
- # the default template for this type
89
- unless File.exist? template_file
90
- template_file = "#{installed_dir}/lib/evertils/configs/templates/#{file_name}.enml"
91
- end
92
- end
93
-
94
- template_file
95
- end
96
21
  end
97
22
  end
98
23
  end
@@ -1,17 +1,21 @@
1
1
  module Evertils
2
2
  module Helper
3
3
  class Note
4
+ include Singleton
5
+
4
6
  attr_reader :model
5
7
 
6
8
  # Create the Note object
7
9
  def initialize
8
10
  @model = Evertils::Common::Query::Simple.new
9
- @format = Evertils::Helper.load('Formatting')
11
+ @format = Formatting.new
10
12
  @user = @model.user_info[:user]
11
13
  @shard = @model.user_info[:shard]
12
14
  end
13
15
 
14
- def wait_for_with_grammar(grammar, iterations = Evertils::Type::Base::MAX_SEARCH_SIZE)
16
+ #
17
+ # @since 1.0.12
18
+ def wait_for_with_grammar(grammar, iterations = Evertils::Base::MAX_SEARCH_SIZE)
15
19
  Notify.info("Searching with grammar #{grammar}")
16
20
  note = find_note_by_grammar(grammar.to_s)
17
21
 
@@ -22,7 +26,7 @@ module Evertils
22
26
  Notify.info(" (#{iter}) Looking for #{grammar}")
23
27
  note = find_note_by_grammar(grammar.to_s, true)
24
28
 
25
- break unless note.entity.nil? || iter == Evertils::Type::Base::MAX_SEARCH_SIZE
29
+ break unless note.entity.nil? || iter == Evertils::Base::MAX_SEARCH_SIZE
26
30
  end
27
31
  end
28
32
  rescue Interrupt
@@ -33,7 +37,7 @@ module Evertils
33
37
  end
34
38
 
35
39
  # Wait for a note to exist
36
- def wait_for_by_notebook(notebook, iterations = Evertils::Type::Base::MAX_SEARCH_SIZE)
40
+ def wait_for_by_notebook(notebook, iterations = Evertils::Base::MAX_SEARCH_SIZE)
37
41
  Notify.info("Waiting for #{notebook}...")
38
42
  note = find_note_by_notebook(notebook)
39
43
 
@@ -43,7 +47,7 @@ module Evertils
43
47
  (1..iterations).each do |iter|
44
48
  Notify.info(" (#{iter}) Looking for #{notebook.downcase}")
45
49
  note = find_note_by_notebook(notebook, true)
46
- break unless note.entity.nil? || iter == Evertils::Type::Base::MAX_SEARCH_SIZE
50
+ break unless note.entity.nil? || iter == Evertils::Base::MAX_SEARCH_SIZE
47
51
  end
48
52
  end
49
53
  rescue Interrupt
@@ -54,7 +58,7 @@ module Evertils
54
58
  end
55
59
 
56
60
  # Wait for a note to exist
57
- def wait_for_by_title(title, notebook, iterations = Evertils::Type::Base::MAX_SEARCH_SIZE)
61
+ def wait_for_by_title(title, notebook, iterations = Evertils::Base::MAX_SEARCH_SIZE)
58
62
  Notify.info("Waiting for #{title}...")
59
63
  note = find_note_by_title(title)
60
64
 
@@ -64,7 +68,7 @@ module Evertils
64
68
  (1..iterations).each do |iter|
65
69
  Notify.info(" (#{iter}) Looking for #{notebook.downcase}")
66
70
  note = find_note_by_title(notebook, true)
67
- break unless note.entity.nil? || iter == Evertils::Type::Base::MAX_SEARCH_SIZE
71
+ break unless note.entity.nil? || iter == Evertils::Base::MAX_SEARCH_SIZE
68
72
  end
69
73
  end
70
74
  rescue Interrupt
@@ -83,7 +87,7 @@ module Evertils
83
87
  # Find a note by notebook
84
88
  def find_note_by_notebook(notebook, sleep = false)
85
89
  sleep(5) if sleep
86
- title = @format.date_templates[notebook]
90
+ title = Formatting.date_templates[notebook]
87
91
 
88
92
  @model.find_note_contents(title)
89
93
  end
@@ -12,12 +12,9 @@ module Evertils
12
12
  @request = Request.new
13
13
 
14
14
  begin
15
- # include the controller
16
- require "evertils/controllers/#{@request.controller}"
17
- # include helpers
18
- require "evertils/helpers/#{@request.controller}" if File.exist? "evertils/helpers/#{@request.controller}"
15
+ update_config if uses_local_configuration?
19
16
 
20
- update_config if uses_config_file?
17
+ require "evertils/controllers/#{@request.controller}" unless uses_local_configuration?
21
18
 
22
19
  # perform all required checks
23
20
  must_pass = Helper::Results.new
@@ -45,7 +42,6 @@ module Evertils
45
42
  begin
46
43
  unless @request.controller.nil?
47
44
  controller = Evertils::Controller.const_get @request.controller.capitalize
48
- controller = Evertils::Controller::Render if @config.exist?(:path)
49
45
 
50
46
  # create an instance of the requested controller
51
47
  context = controller.new(@config, @request)
@@ -70,7 +66,7 @@ module Evertils
70
66
  end
71
67
  end
72
68
 
73
- def uses_config_file?
69
+ def uses_local_configuration?
74
70
  @config_file_path = File.expand_path("~/.evertils/templates/type/#{@request.command}.yml")
75
71
  File.exist? @config_file_path
76
72
  end
@@ -1,3 +1,3 @@
1
1
  module Evertils
2
- VERSION = '1.0.12'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
data/lib/evertils.rb CHANGED
@@ -20,23 +20,20 @@ require 'nokogiri'
20
20
  require 'evertils/kernel'
21
21
  require 'evertils/version'
22
22
  require 'evertils/base'
23
- require 'evertils/type'
24
23
  require 'evertils/action'
25
24
  require 'evertils/actions/default'
26
25
  require 'evertils/actions/create'
27
26
  require 'evertils/actions/duplicate_previous'
28
- require 'evertils/helpers/time'
29
27
  require 'evertils/helpers/results'
30
28
  require 'evertils/helpers/api-enml-handler'
31
- require 'evertils/gpg_exception'
32
- require 'evertils/yubikey_exception'
33
- require 'evertils/required_check_exception'
29
+ require 'evertils/exceptions/gpg_exception'
30
+ require 'evertils/exceptions/yubikey_exception'
31
+ require 'evertils/exceptions/required_check_exception'
34
32
  require 'evertils/config'
35
33
  require 'evertils/request'
36
34
  require 'evertils/controller'
37
35
  require 'evertils/controllers/render'
38
36
  require 'evertils/router'
39
- require 'evertils/helper'
40
37
  require 'evertils/helpers/formatting'
41
38
  require 'evertils/helpers/evernote-enml'
42
39
  require 'evertils/helpers/note'
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.12
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe
@@ -14,30 +14,30 @@ dependencies:
14
14
  name: notifaction
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.4.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.4.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mime-types
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 3.3.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 3.3.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: evertils-common
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: 12.3.3
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: 12.3.3
97
97
  description: Evernote utilities for your CLI workflow
98
98
  email: hello@ryanpriebe.com
99
99
  executables:
@@ -116,44 +116,27 @@ files:
116
116
  - lib/evertils/actions/duplicate_previous.rb
117
117
  - lib/evertils/base.rb
118
118
  - lib/evertils/config.rb
119
- - lib/evertils/configs/templates/daily.enml
120
- - lib/evertils/configs/templates/monthly-task-summaries.enml
121
- - lib/evertils/configs/templates/monthly.enml
122
- - lib/evertils/configs/templates/pq.enml
123
- - lib/evertils/configs/templates/weekly.enml
124
119
  - lib/evertils/controller.rb
125
120
  - lib/evertils/controllers/change.rb
126
- - lib/evertils/controllers/convert.rb
127
121
  - lib/evertils/controllers/firstrun.rb
128
- - lib/evertils/controllers/generate.rb
129
- - lib/evertils/controllers/get.rb
130
122
  - lib/evertils/controllers/log.rb
131
- - lib/evertils/controllers/new.rb
132
123
  - lib/evertils/controllers/render.rb
133
- - lib/evertils/gpg_exception.rb
124
+ - lib/evertils/exceptions/gpg_exception.rb
125
+ - lib/evertils/exceptions/required_check_exception.rb
126
+ - lib/evertils/exceptions/yubikey_exception.rb
134
127
  - lib/evertils/grammar.rb
135
- - lib/evertils/helper.rb
136
128
  - lib/evertils/helpers/api-enml-handler.rb
137
129
  - lib/evertils/helpers/evernote-enml.rb
138
130
  - lib/evertils/helpers/evernote-markdown.rb
139
131
  - lib/evertils/helpers/formatting.rb
140
132
  - lib/evertils/helpers/note.rb
141
133
  - lib/evertils/helpers/results.rb
142
- - lib/evertils/helpers/time.rb
143
134
  - lib/evertils/helpers/xml.rb
144
135
  - lib/evertils/kernel.rb
145
136
  - lib/evertils/request.rb
146
- - lib/evertils/required_check_exception.rb
147
137
  - lib/evertils/router.rb
148
- - lib/evertils/type.rb
149
- - lib/evertils/types/daily.rb
150
- - lib/evertils/types/monthly-task-summary.rb
151
- - lib/evertils/types/monthly.rb
152
- - lib/evertils/types/priority-queue.rb
153
- - lib/evertils/types/weekly.rb
154
138
  - lib/evertils/vendor/enml.dtd
155
139
  - lib/evertils/version.rb
156
- - lib/evertils/yubikey_exception.rb
157
140
  homepage: http://rubygems.org/gems/evertils
158
141
  licenses:
159
142
  - MIT
@@ -1,14 +0,0 @@
1
- <div><span style="font-size: 18px;">Logs</span></div>
2
- <ul>
3
- <li>...</li>
4
- </ul>
5
- <br />
6
- <div><span style="font-size: 18px;">Tasks completed</span></div>
7
- <ul>
8
- <li>...</li>
9
- </ul>
10
- <br />
11
- <div><span style="font-size: 18px;">EOD</span></div>
12
- <ul>
13
- <li><en-todo checked="false"/>Timecard is up to date</li>
14
- </ul>
@@ -1,9 +0,0 @@
1
- <div><span style="font-size: 18px;">Completed</span></div>
2
- <ul>
3
- <li>...</li>
4
- </ul>
5
- <br />
6
- <div><span style="font-size: 18px;">Logs</span></div>
7
- <ul>
8
- <li>...</li>
9
- </ul>
@@ -1,13 +0,0 @@
1
- <ul>
2
- <li>...</li>
3
- </ul>
4
- <br />
5
- <div><span style="font-size: 18px;">Highlights</span></div>
6
- <ul>
7
- <li>...</li>
8
- </ul>
9
- <br />
10
- <div><span style="font-size: 18px;">Summaries</span></div>
11
- <ul>
12
- <li>...</li>
13
- </ul>
@@ -1,3 +0,0 @@
1
- <ul>
2
- <ol>...</ol>
3
- </ul>
@@ -1,13 +0,0 @@
1
- <div>
2
- <div><span style="font-size: 18px;">Logs</span></div>
3
- <ul>
4
- <li>...</li>
5
- </ul>
6
- </div>
7
- <div>
8
- <br />
9
- <div><span style="font-size: 18px;">Highlights</span></div>
10
- <ul>
11
- <li>...</li>
12
- </ul>
13
- </div>
@@ -1,48 +0,0 @@
1
- module Evertils
2
- module Controller
3
- class Convert < Controller::Base
4
- attr_accessor :title, :file, :notebook
5
-
6
- def pre_exec
7
- # command flag parser
8
- OptionParser.new do |opt|
9
- opt.banner = "#{Evertils::PACKAGE_NAME} new note [...-flags]"
10
-
11
- opt.on("-m", "--to-markdown", "Convert to MD format") do |b|
12
- @markdown = b
13
- end
14
-
15
- opt.on("-e", "--to-enml", "Convert to ENML") do |b|
16
- @file = b
17
- end
18
-
19
- opt.on("-n", "--notebook=PBOOK", "Attach a file to your custom note") do |notebook|
20
- @notebook = notebook.capitalize
21
- end
22
- end.parse!
23
-
24
- super
25
- end
26
-
27
- def notes_in
28
- unless @notebook
29
- Notify.error("Notebook (--notebook=) is a required argument")
30
- end
31
-
32
- metadata = @model.notes_by_notebook(@notebook)
33
-
34
- if metadata.is_a? Hash
35
- Notify.info("#{metadata.size} notes in #{@notebook}")
36
- Notify.info("Printing list of notes")
37
-
38
- metadata.each_pair do |note_guid, note_content|
39
- # convert it here!
40
- Notify.spit(note_content)
41
- end
42
- else
43
- Notify.error("Could not pull data for notebook #{@notebook}")
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,57 +0,0 @@
1
- require_relative '../types/priority-queue'
2
- require_relative '../types/monthly-task-summary'
3
- require_relative '../types/daily'
4
- require_relative '../types/weekly'
5
- require_relative '../types/monthly'
6
-
7
- module Evertils
8
- module Controller
9
- class Generate < Controller::Base
10
- # generate daily notes
11
- def daily
12
- note = Type::Daily.new(@config)
13
- note.create if note.should_create?
14
- end
15
-
16
- # generate weekly notes
17
- def weekly
18
- note = Type::Weekly.new(@config)
19
- note.create if note.should_create?
20
- note.add_daily_note_link
21
- end
22
-
23
- # generate monthly notes
24
- def monthly
25
- note = Type::Monthly.new(@config)
26
- note.create if note.should_create?
27
- note.add_weekly_note_link
28
- end
29
-
30
- # generate monthly task summary templates
31
- def mts(arg)
32
- Notify.error('Name argument is required', {}) if arg.nil?
33
-
34
- note = Type::MonthlyTaskSummary.new(@config, arg[1])
35
- note.create if note.should_create?
36
- end
37
-
38
- # generate priority queue notes
39
- def pq
40
- note = Type::PriorityQueue.new(@config)
41
- note.create if note.should_create?
42
- end
43
-
44
- # creates the notes required to start the day
45
- # - priority queue
46
- # - daily
47
- # - weekly (if today is Monday and there isn't a weekly log already)
48
- # - monthly (if today is the 1st and there isn't a monthly log already)
49
- def morning
50
- pq
51
- daily
52
- weekly
53
- monthly
54
- end
55
- end
56
- end
57
- end
@@ -1,55 +0,0 @@
1
- module Evertils
2
- module Controller
3
- class Get < Controller::Base
4
- attr_accessor :title, :file, :notebook
5
-
6
- def pre_exec
7
- # command flag parser
8
- OptionParser.new do |opt|
9
- opt.banner = "evertils new note [...-flags]"
10
-
11
- opt.on("-t", "--title=TITLE", "Set a custom title") do |title|
12
- @title = title
13
- end
14
-
15
- opt.on("-f", "--file=PATH", "Attach a file to your custom note") do |file|
16
- @file = file
17
- end
18
-
19
- opt.on("-n", "--notebook=PBOOK", "Attach a file to your custom note") do |notebook|
20
- @notebook = notebook
21
- end
22
- end.parse!
23
-
24
- super
25
- end
26
-
27
- # Get data about a notebook, prints titles of each child note
28
- def notebook
29
- if !$request.custom.nil?
30
- book = $request.custom[0]
31
- metadata = @model.notes_by_notebook(book)
32
-
33
- if metadata.is_a? ::Evernote::EDAM::NoteStore::NotesMetadataList
34
- Notify.info("#{metadata.totalNotes} notes in #{book}")
35
- Notify.info("Printing list of notes")
36
-
37
- metadata.notes.each do |note|
38
- Notify.spit note.title
39
- end
40
- else
41
- Notify.error("Could not pull data for notebook #{$request.custom[0]}", {})
42
- end
43
- else
44
- Notify.error("Notebook name is a required argument, i.e.\n#{Evertils::PACKAGE_NAME} get notebook agendas", {})
45
- end
46
- end
47
-
48
- def info
49
- @config.options.each_pair do |key, value|
50
- Notify.spit("#{key}: #{value}")
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,88 +0,0 @@
1
- module Evertils
2
- module Controller
3
- class New < Controller::Base
4
- attr_accessor :title, :file, :notebook
5
-
6
- def pre_exec
7
- # all methods require internet to make API calls
8
- @methods_require_internet.push(:daily, :weekly, :monthly)
9
-
10
- @title = "Evertils - Custom Note"
11
-
12
- # command flag parser
13
- OptionParser.new do |opt|
14
- opt.banner = "#{Evertils::PACKAGE_NAME} new note [...-flags]"
15
-
16
- opt.on("-t", "--title=TITLE", "Set a custom title") do |title|
17
- @title = title
18
- end
19
-
20
- opt.on("-f", "--file=PATH", "Attach a file to your custom note") do |file|
21
- @file = file
22
- end
23
-
24
- opt.on("-n", "--notebook=PBOOK", "Choose the notebook to add your note to") do |notebook|
25
- @notebook = notebook
26
- end
27
-
28
- opt.on("-b", "--body=BODY", "Note body") do |body|
29
- @body = body
30
- end
31
-
32
- opt.on("-t", "--tags=list", "Assign tags to the new note") do |tags|
33
- @tags = tags
34
- end
35
-
36
- opt.on("-c", "--created_on=DATE", "Set note created date") do |created_on|
37
- # Evernote cuts the last 3 values off of your timestamp because
38
- # it "accurate to milliseconds", so we have to add them back or
39
- # else the date is all messed up
40
- parsed = Date.parse(created_on)
41
- @created_on = (parsed.to_time.to_i.to_s + "000").to_i
42
- end
43
- end.parse!
44
-
45
- super
46
- end
47
-
48
- # Create a new Evernote note from data or terminal output
49
- def note
50
- if @body.nil?
51
- message = JSON.parse(STDIN.gets.to_s).join
52
- message = message.gsub!("\n", '<br />')
53
- else
54
- message = @body
55
- end
56
-
57
- note = @model.create_note(title: @title, body: message, parent_notebook: @notebook, files: @file, shareable: false, created_on: @created_on)
58
-
59
- if note[:note]
60
- Notify.success("Note created")
61
- else
62
- Notify.error("Unable to create note, are you authenticated?")
63
- end
64
- end
65
-
66
- # Create a new note and automatically share it
67
- def share_note
68
- if @body.nil?
69
- message = JSON.parse(STDIN.gets).join
70
- message = message.gsub!("\n", '<br />')
71
- else
72
- message = @body
73
- end
74
-
75
- # Prefix title to indicate it's shared status
76
- @title = "[SHARED] #{@title}"
77
-
78
- note = @model.create_note(title: @title, body: message, parent_notebook: @notebook, files: @file, shareable: true, created_on: @created_on)
79
-
80
- if note[:share_url]
81
- Notify.success("Note created and shared:\n#{note[:share_url]}")
82
- else
83
- Notify.error("Something dreadful happened!")
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,19 +0,0 @@
1
- module Evertils
2
- module Helper
3
- def self.load(klass, *args)
4
- begin
5
- klass_instance = Evertils::Helper.const_get(klass)
6
-
7
- if klass_instance
8
- if args.empty?
9
- klass_instance.new
10
- else
11
- klass_instance.new(args)
12
- end
13
- end
14
- rescue => e
15
- Notify.error("#{e}\n#{e.backtrace.join("\n")}", show_time: false)
16
- end
17
- end
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- module Evertils
2
- module Helper
3
- class Time
4
- def self.human_readable(start, finish)
5
- seconds = finish.to_f - start.to_f
6
-
7
- if seconds < 60
8
- "No time at all!"
9
- else
10
- minutes = (seconds / 60).round(1)
11
- if minutes < 1
12
- "#{minutes} minute"
13
- else
14
- "#{minutes} minutes"
15
- end
16
- end
17
- end
18
-
19
- def self.formatted(time = nil)
20
- if time.nil?
21
- time = ::Time.now
22
- end
23
-
24
- time.strftime("%e/%-m/%Y @ %I:%M:%S%P")
25
- end
26
- end
27
- end
28
- end
data/lib/evertils/type.rb DELETED
@@ -1,58 +0,0 @@
1
- module Evertils
2
- module Type
3
- class Base
4
- attr_reader :title, :content, :notebook
5
-
6
- COLOUR = 0xffffff
7
- MAX_SEARCH_SIZE = 11
8
-
9
- #
10
- # @since 0.3.7
11
- def initialize(config, *args)
12
- # helpers
13
- @note_helper = Evertils::Helper.load('Note')
14
- @format = Evertils::Helper.load('Formatting')
15
-
16
- @config = config
17
- @api = Evertils::Helper.load('ApiEnmlHandler', @config)
18
- @args = args unless args.size.zero?
19
- end
20
-
21
- #
22
- # @since 0.3.7
23
- def create
24
- data = {
25
- title: @title,
26
- body: @content.to_s.delete("\n"),
27
- parent_notebook: self.class::NOTEBOOK,
28
- tags: tags || [],
29
- colour: self.class::COLOUR
30
- }
31
-
32
- raise 'Invalid title' if @title.nil?
33
- raise 'Invalid note content' if @content.nil?
34
- raise 'Invalid notebook' if self.class::NOTEBOOK.nil?
35
-
36
- @note_helper.create_note(data)
37
- end
38
-
39
- #
40
- # @since 0.3.7
41
- def should_create?
42
- @note = @note_helper.find_note(self.class::NOTEBOOK)
43
- @entity = @note.entity
44
- result = @entity.nil?
45
-
46
- Notify.warning "#{self.class.name} skipped, note already exists" unless result
47
-
48
- result
49
- end
50
-
51
- #
52
- # @since 0.3.15
53
- def morning_note?
54
- !caller.grep(/morning/).empty?
55
- end
56
- end
57
- end
58
- end
@@ -1,54 +0,0 @@
1
- module Evertils
2
- module Type
3
- class Daily < Type::Base
4
- NOTEBOOK = :Daily
5
- COLOUR = 0xffe8b7
6
-
7
- #
8
- # @since 0.3.7
9
- def initialize(config, *args)
10
- super(config, *args)
11
-
12
- @title = @format.date_templates[NOTEBOOK]
13
- @content = @format.template_contents(NOTEBOOK)
14
-
15
- attach_pq_note if morning_note?
16
- end
17
-
18
- #
19
- # @since 0.3.9
20
- def tags
21
- [
22
- "day-#{Date.today.yday}",
23
- "week-#{Date.today.cweek}",
24
- "month-#{Date.today.month}"
25
- ]
26
- end
27
-
28
- private
29
-
30
- #
31
- # TODO: refactor
32
- # @since 0.3.13
33
- def attach_pq_note
34
- enml = @api.from_str(@format.template_contents(NOTEBOOK))
35
- pq = @note_helper.wait_for_by_notebook(:'Priority Queue')
36
- xml_conf = {
37
- href: @note_helper.internal_url_for(pq.entity),
38
- content: @format.date_templates[:'Priority Queue']
39
- }
40
- xml = Evertils::Helper.load('Xml', enml)
41
- a = xml.create(:a, xml_conf)
42
-
43
- enml.at('li:contains("Queue") ul li').children.first.replace(a)
44
-
45
- # remove dtd if it is the first element
46
- if enml.children.first.is_a?(Evertils::Helper::DTD)
47
- enml.children.first.remove
48
- end
49
-
50
- @content = enml
51
- end
52
- end
53
- end
54
- end
@@ -1,24 +0,0 @@
1
- module Evertils
2
- module Type
3
- class MonthlyTaskSummary < Type::Base
4
- NOTEBOOK = :'Monthly Task Summaries'
5
- COLOUR = 0xffe8b7
6
-
7
- #
8
- # @since 0.3.7
9
- def initialize(config, *args)
10
- super(config, *args)
11
-
12
- @name = @args.first
13
- @title = "#{@name} #{DateTime.now.strftime('%m-%Y')}"
14
- @content = @format.template_contents(NOTEBOOK)
15
- end
16
-
17
- #
18
- # @since 0.3.9
19
- def tags
20
- ["day-#{Date.today.yday}", @args.first]
21
- end
22
- end
23
- end
24
- end
@@ -1,58 +0,0 @@
1
- module Evertils
2
- module Type
3
- class Monthly < Type::Base
4
- NOTEBOOK = :Monthly
5
- COLOUR = 0xffe8b7
6
-
7
- #
8
- # @since 0.3.7
9
- def initialize(config, *args)
10
- super(config, *args)
11
-
12
- @title = @format.date_templates[NOTEBOOK]
13
- @content = @format.template_contents(NOTEBOOK)
14
- end
15
-
16
- #
17
- # @since 0.3.9
18
- def tags
19
- ["month-#{Date.today.month}"]
20
- end
21
-
22
- #
23
- # @since 0.3.15
24
- def add_weekly_note_link
25
- wk_entity = @note_helper.wait_for_by_notebook(:Weekly).entity
26
- # parse the ENML note data into something we can work with
27
- xml = @api.from_str(@entity.content)
28
- # include the XML element builder
29
- xml_helper = Evertils::Helper.load('Xml', xml)
30
- # internal URL for the linked note
31
- note_url = @note_helper.internal_url_for(wk_entity)
32
-
33
- # don't add the note link if it is already there
34
- unless xml.search("a[href='#{note_url}']").size.zero?
35
- return Notify.warning('Weekly note link already exists here, exiting to avoid duplicate content')
36
- end
37
-
38
- a = xml_helper.a(
39
- note_url,
40
- @format.date_templates[:Weekly]
41
- )
42
- li = xml_helper.li(a)
43
- br = xml_helper.br
44
-
45
- xml.search('ul:first-child li').after(li)
46
-
47
- # add a line break after the UL if one is not there yet
48
- if xml.search('ul:first-child').first.next_element.name != 'br'
49
- xml.search('ul:first-child').after(br)
50
- end
51
-
52
- @entity.content = xml.to_s
53
-
54
- Notify.success("#{self.class.name} updated, added weekly note link") if @note.update
55
- end
56
- end
57
- end
58
- end
@@ -1,55 +0,0 @@
1
- module Evertils
2
- module Type
3
- class PriorityQueue < Type::Base
4
- NOTEBOOK = :'Priority Queue'
5
- COLOUR = 0xffe8b7
6
-
7
- #
8
- # @since 0.3.7
9
- def initialize(config, *args)
10
- super(config, *args)
11
-
12
- @title = @format.date_templates[NOTEBOOK]
13
- @content = find_previous
14
- end
15
-
16
- #
17
- # @since 0.3.9
18
- def tags
19
- [
20
- "day-#{Date.today.yday}",
21
- "week-#{Date.today.cweek}",
22
- "month-#{Date.today.month}"
23
- ]
24
- end
25
-
26
- private
27
-
28
- # Find a previous note
29
- # @since 0.3.7
30
- def find_previous
31
- day = Date.today
32
- note = nil
33
-
34
- Notify.info('Searching for last PQ...')
35
-
36
- (1..MAX_SEARCH_SIZE).each do |iter|
37
- day -= 1
38
- dow = @format.day_of_week(day.strftime('%a'))
39
-
40
- # always skip weekends, even if there is a note for those days
41
- next if %i[Sa Su].include?(dow)
42
-
43
- note_title = "Queue For [#{day.strftime('%B %-d')} - #{dow}]"
44
- note = @note_helper.model.find_note_contents(note_title).entity
45
-
46
- Notify.info(" (#{iter}) #{note_title}")
47
-
48
- break unless note.nil?
49
- end
50
-
51
- @api.convert_to_xml(note.content).prepare
52
- end
53
- end
54
- end
55
- end
@@ -1,66 +0,0 @@
1
- module Evertils
2
- module Type
3
- class Weekly < Type::Base
4
- NOTEBOOK = :Weekly
5
- COLOUR = 0xffe8b7
6
-
7
- #
8
- # @since 0.3.7
9
- def initialize(config, *args)
10
- super(config, *args)
11
-
12
- @title = @format.date_templates[NOTEBOOK]
13
- @content = @format.template_contents(NOTEBOOK)
14
- end
15
-
16
- #
17
- # @since 0.3.9
18
- def tags
19
- [
20
- "week-#{Date.today.cweek}",
21
- "month-#{Date.today.month}"
22
- ]
23
- end
24
-
25
- #
26
- # @since 0.3.15
27
- def add_daily_note_link
28
- da_entity = @note_helper.wait_for_by_notebook(:Daily).entity
29
- # parse the ENML note data into something we can work with
30
- xml = @api.from_str(@entity.content)
31
- # include the XML element builder
32
- xml_helper = Evertils::Helper.load('Xml', xml)
33
- # internal URL for the linked note
34
- note_url = @note_helper.internal_url_for(da_entity)
35
-
36
- # don't add the note link if it is already there
37
- unless xml.search("a[href='#{note_url}']").size.zero?
38
- return Notify.warning('Daily note link already exists here, exiting to avoid duplicate content')
39
- end
40
-
41
- a = xml_helper.a(
42
- note_url,
43
- @format.date_templates[:Daily]
44
- )
45
- li = xml_helper.li(a)
46
- br = xml_helper.br
47
-
48
- xml.search('en-note>div:first-child>ul li:last-child').after(li)
49
-
50
- # add a line break after the UL if one is not there yet
51
- if xml.search('en-note>div:first-child').first.next_element.name != 'br'
52
- xml.search('en-note>div:first-child').after(br)
53
- end
54
-
55
- # remove XML processing definition if it is the second element
56
- if xml.children[1].is_a?(Nokogiri::XML::ProcessingInstruction)
57
- xml.children[1].remove
58
- end
59
-
60
- @entity.content = xml.to_s
61
-
62
- Notify.success("#{self.class.name} updated, added daily note link") if @note.update
63
- end
64
- end
65
- end
66
- end