doing 2.1.30 → 2.1.31pre

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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +1 -0
  3. data/.yardoc/checksums +9 -8
  4. data/.yardoc/object_types +0 -0
  5. data/.yardoc/objects/root.dat +0 -0
  6. data/CHANGELOG.md +4923 -0
  7. data/Gemfile.lock +1 -1
  8. data/README.md +1 -1
  9. data/bin/commands/again.rb +1 -1
  10. data/bin/commands/archive.rb +3 -3
  11. data/bin/commands/cancel.rb +1 -1
  12. data/bin/commands/commands.rb +8 -8
  13. data/bin/commands/completion.rb +61 -19
  14. data/bin/commands/config.rb +9 -9
  15. data/bin/commands/done.rb +1 -1
  16. data/bin/commands/flag.rb +1 -1
  17. data/bin/commands/grep.rb +5 -5
  18. data/bin/commands/last.rb +1 -1
  19. data/bin/commands/meanwhile.rb +1 -1
  20. data/bin/commands/now.rb +1 -1
  21. data/bin/commands/on.rb +1 -1
  22. data/bin/commands/open.rb +1 -1
  23. data/bin/commands/recent.rb +4 -4
  24. data/bin/commands/show.rb +8 -8
  25. data/bin/commands/since.rb +1 -1
  26. data/bin/commands/today.rb +1 -1
  27. data/bin/commands/view.rb +3 -3
  28. data/bin/commands/yesterday.rb +2 -2
  29. data/bin/doing +22 -133
  30. data/docs/doc/Array.html +1 -1
  31. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  32. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  33. data/docs/doc/BooleanTermParser/Query.html +1 -1
  34. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  35. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  36. data/docs/doc/BooleanTermParser.html +1 -1
  37. data/docs/doc/Doing/Color.html +1 -1
  38. data/docs/doc/Doing/Completion.html +324 -4
  39. data/docs/doc/Doing/Configuration.html +1 -1
  40. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  41. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  42. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  43. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  44. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  45. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  46. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  47. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  48. data/docs/doc/Doing/Errors.html +1 -1
  49. data/docs/doc/Doing/Hooks.html +1 -1
  50. data/docs/doc/Doing/Item.html +125 -1
  51. data/docs/doc/Doing/Items.html +1 -1
  52. data/docs/doc/Doing/LogAdapter.html +1 -1
  53. data/docs/doc/Doing/Note.html +109 -3
  54. data/docs/doc/Doing/Pager.html +1 -1
  55. data/docs/doc/Doing/Plugins.html +1 -1
  56. data/docs/doc/Doing/Prompt.html +1 -1
  57. data/docs/doc/Doing/Section.html +1 -1
  58. data/docs/doc/Doing/TemplateString.html +1 -1
  59. data/docs/doc/Doing/Types.html +1 -1
  60. data/docs/doc/Doing/Util/Backup.html +1 -1
  61. data/docs/doc/Doing/Util.html +1 -1
  62. data/docs/doc/Doing/WWID.html +6 -6
  63. data/docs/doc/Doing.html +2 -2
  64. data/docs/doc/FalseClass.html +1 -1
  65. data/docs/doc/GLI/Commands/Help.html +1 -1
  66. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  67. data/docs/doc/GLI/Commands.html +1 -1
  68. data/docs/doc/GLI.html +1 -1
  69. data/docs/doc/Hash.html +1 -1
  70. data/docs/doc/Object.html +1 -1
  71. data/docs/doc/PhraseParser/Operator.html +1 -1
  72. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  73. data/docs/doc/PhraseParser/Query.html +1 -1
  74. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  75. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  76. data/docs/doc/PhraseParser/TermClause.html +1 -1
  77. data/docs/doc/PhraseParser.html +1 -1
  78. data/docs/doc/Status.html +1 -1
  79. data/docs/doc/String.html +1 -1
  80. data/docs/doc/Symbol.html +1 -1
  81. data/docs/doc/Time.html +1 -1
  82. data/docs/doc/TrueClass.html +1 -1
  83. data/docs/doc/_index.html +3 -1
  84. data/docs/doc/file.README.html +2 -2
  85. data/docs/doc/index.html +2 -2
  86. data/docs/doc/method_list.html +337 -241
  87. data/docs/doc/top-level-namespace.html +105 -1
  88. data/doing.rdoc +25 -9
  89. data/example_plugin.rb +7 -5
  90. data/lib/completion/_doing.zsh +2 -2
  91. data/lib/completion/doing.bash +2 -2
  92. data/lib/completion/doing.fish +2 -3
  93. data/lib/doing/add_options.rb +117 -0
  94. data/lib/doing/array/array.rb +16 -0
  95. data/lib/doing/completion/bash_completion.rb +12 -51
  96. data/lib/doing/completion/fish_completion.rb +16 -52
  97. data/lib/doing/completion/zsh_completion.rb +12 -56
  98. data/lib/doing/completion.rb +203 -17
  99. data/lib/doing/item.rb +21 -3
  100. data/lib/doing/items.rb +5 -5
  101. data/lib/doing/note.rb +24 -8
  102. data/lib/doing/plugins/export/dayone_export.rb +8 -6
  103. data/lib/doing/plugins/export/html_export.rb +4 -4
  104. data/lib/doing/plugins/export/json_export.rb +19 -20
  105. data/lib/doing/plugins/export/markdown_export.rb +2 -2
  106. data/lib/doing/plugins/export/template_export.rb +4 -4
  107. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  108. data/lib/doing/plugins/import/doing_import.rb +1 -1
  109. data/lib/doing/plugins/import/timing_import.rb +1 -1
  110. data/lib/doing/string/highlight.rb +3 -4
  111. data/lib/doing/string/string.rb +8 -0
  112. data/lib/doing/util.rb +1 -1
  113. data/lib/doing/util_backup.rb +12 -12
  114. data/lib/doing/version.rb +1 -1
  115. data/lib/doing/wwid.rb +76 -77
  116. data/lib/doing.rb +57 -0
  117. data/lib/examples/commands/wiki.rb +27 -19
  118. data/scripts/setting_replace.rb +11 -0
  119. metadata +6 -4
data/lib/doing.rb CHANGED
@@ -66,10 +66,67 @@ module Doing
66
66
  @logger ||= LogAdapter.new((ENV['DOING_LOG_LEVEL'] || :info).to_sym)
67
67
  end
68
68
 
69
+ ##
70
+ ## Holds a Configuration object with methods and a @settings hash
71
+ ##
72
+ ## @return [Configuration] Configuration object
73
+ ##
69
74
  def config
70
75
  @config ||= Configuration.new
71
76
  end
72
77
 
78
+ ##
79
+ ## Shortcut for Doing.config.settings
80
+ ##
81
+ ## @return [Hash] Settings hash
82
+ ##
83
+ def settings
84
+ config.settings
85
+ end
86
+
87
+ ##
88
+ ## Fetch a config setting using a dot-separated keypath
89
+ ## or array of keys
90
+ ##
91
+ ## @param keypath [String|Array] Either a
92
+ ## dot-separated key path
93
+ ## (search.case) or array of keys
94
+ ## (['search', 'case'])
95
+ ## @param default A default value to return if the
96
+ ## provided path returns nil result
97
+ ##
98
+ def setting(keypath, default = nil)
99
+ cfg = config.settings
100
+ case keypath
101
+ when Array
102
+ cfg.dig(*keypath) || default
103
+ when String
104
+ unless keypath =~ /^[.*]?$/
105
+ real_path = config.resolve_key_path(keypath, create: false)
106
+ return default unless real_path&.count&.positive?
107
+
108
+ cfg = cfg.dig(*real_path)
109
+ end
110
+
111
+ cfg.nil? ? default : cfg
112
+ end
113
+ end
114
+
115
+ def set(keypath, value)
116
+ real_path = config.resolve_key_path(keypath, create: false)
117
+ return nil unless real_path&.count&.positive?
118
+
119
+ config.settings.deep_set(real_path, value)
120
+ end
121
+
122
+ ##
123
+ ## Update configuration from specified file
124
+ ##
125
+ ## @param file [String] Path to new config file
126
+ ## @param options [Hash] options
127
+ ##
128
+ ## @option options :ignore_local Ignore local configuration files
129
+ ##
73
130
  def config_with(file, options = {})
74
131
  @config = Configuration.new(file, options: options)
75
132
  end
@@ -35,7 +35,7 @@ command :wiki do |c|
35
35
  c.desc 'Only show items with recorded time intervals'
36
36
  c.switch [:only_timed], default_value: false, negatable: false
37
37
 
38
- c.action do |global, options, args|
38
+ c.action do |_global, options, _args|
39
39
  tags = @wwid.tag_groups([], opt: options)
40
40
 
41
41
  wiki = Doing::Plugins.plugins.dig(:export, 'wiki', :class)
@@ -43,38 +43,46 @@ command :wiki do |c|
43
43
  tags.each do |tag, items|
44
44
  export_options = { page_title: tag, is_single: false, options: options }
45
45
 
46
- raise RuntimeError, 'Missing plugin "wiki"' unless wiki
46
+ raise 'Missing plugin "wiki"' unless wiki
47
47
 
48
48
  out = wiki.render(@wwid, items, variables: export_options)
49
49
 
50
50
  if out
51
51
  FileUtils.mkdir_p('doing_wiki')
52
- File.open(File.join('doing_wiki', tag + '.html'), 'w') do |f|
53
- f.puts out
54
- end
52
+ File.open(File.join('doing_wiki', "#{tag}.html"), 'w') { |f| f.puts out }
55
53
  end
56
54
  end
57
55
 
58
- template = if @settings['export_templates']['wiki_index'] && File.exist?(File.expand_path(@settings['export_templates']['wiki_index']))
59
- IO.read(File.expand_path(@settings['export_templates']['wiki_index']))
60
- else
61
- wiki.template('wiki_index')
62
- end
63
- style = if @settings['export_templates']['wiki_css'] && File.exist?(File.expand_path(@settings['export_templates']['wiki_css']))
64
- IO.read(File.expand_path(@settings['export_templates']['wiki_css']))
65
- else
66
- wiki.template('wiki_css')
67
- end
68
- tags_out = tags.map { |t| {url: "#{t}.html"} }
69
- engine = Haml::Engine.new(template)
56
+ engine = Haml::Engine.new(wiki_template(wiki))
57
+ tag_arr = tags.each_with_object([]) { |(tag, items), arr| arr << { name: tag, count: items.count } }
70
58
  index_out = engine.render(Object.new,
71
- { :@tags => tags.each_with_object([]) { |(tag, items), arr| arr << { name: tag, count: items.count } }, :@page_title => "Tags wiki", :@style => style })
59
+ { :@tags => tag_arr,
60
+ :@page_title => 'Tags wiki',
61
+ :@style => wiki_style(wiki) })
72
62
 
73
63
  if index_out
74
64
  File.open(File.join('doing_wiki', 'index.html'), 'w') do |f|
75
65
  f.puts index_out
76
66
  end
77
- Doing.logger.warn("Wiki written to doing_wiki directory")
67
+ Doing.logger.warn('Wiki written to doing_wiki directory')
68
+ end
69
+ end
70
+
71
+ def wiki_template(wiki)
72
+ if Doing.setting('export_templates.wiki_index') &&
73
+ File.exist?(File.expand_path(Doing.setting('export_templates.wiki_index')))
74
+ IO.read(File.expand_path(Doing.setting('export_templates.wiki_index')))
75
+ else
76
+ wiki.template('wiki_index')
77
+ end
78
+ end
79
+
80
+ def wiki_style(wiki)
81
+ if Doing.setting('export_templates.wiki_css') &&
82
+ File.exist?(File.expand_path(Doing.setting('export_templates.wiki_css')))
83
+ IO.read(File.expand_path(Doing.setting('export_templates.wiki_css')))
84
+ else
85
+ wiki.template('wiki_css')
78
86
  end
79
87
  end
80
88
  end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ content = IO.read(ARGV[0])
4
+
5
+ content.gsub!(/Doing.settings((\[.*?\])+)/) do
6
+ m = Regexp.last_match
7
+ keypath = m[0].scan(/\['([^\]]+)'\]/).map { |e| e[0] }.join('.')
8
+ "Doing.setting('#{keypath}')"
9
+ end
10
+
11
+ puts content
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.30
4
+ version: 2.1.31pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -602,6 +602,7 @@ files:
602
602
  - lib/completion/doing.bash
603
603
  - lib/completion/doing.fish
604
604
  - lib/doing.rb
605
+ - lib/doing/add_options.rb
605
606
  - lib/doing/array/array.rb
606
607
  - lib/doing/array/nested_hash.rb
607
608
  - lib/doing/array/tags.rb
@@ -778,6 +779,7 @@ files:
778
779
  - scripts/generate_fish_completions.rb
779
780
  - scripts/generate_zsh_completions.rb
780
781
  - scripts/runtests.sh
782
+ - scripts/setting_replace.rb
781
783
  - scripts/sort_commands.rb
782
784
  - yard_templates/default/method_details/setup.rb
783
785
  homepage: http://brettterpstra.com/project/doing/
@@ -802,9 +804,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
802
804
  version: '0'
803
805
  required_rubygems_version: !ruby/object:Gem::Requirement
804
806
  requirements:
805
- - - ">="
807
+ - - ">"
806
808
  - !ruby/object:Gem::Version
807
- version: '0'
809
+ version: 1.3.1
808
810
  requirements: []
809
811
  rubygems_version: 3.2.16
810
812
  signing_key: