doing 2.1.30 → 2.1.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +1 -0
  3. data/CHANGELOG.md +4972 -0
  4. data/Dockerfile-2.6 +3 -1
  5. data/Dockerfile-2.7 +4 -2
  6. data/Dockerfile-3.0 +3 -1
  7. data/Gemfile.lock +1 -67
  8. data/README.md +1 -1
  9. data/bash_profile +13 -0
  10. data/bin/commands/again.rb +1 -1
  11. data/bin/commands/archive.rb +3 -3
  12. data/bin/commands/cancel.rb +1 -1
  13. data/bin/commands/commands.rb +8 -8
  14. data/bin/commands/completion.rb +61 -19
  15. data/bin/commands/config.rb +22 -19
  16. data/bin/commands/done.rb +2 -2
  17. data/bin/commands/flag.rb +1 -1
  18. data/bin/commands/grep.rb +6 -33
  19. data/bin/commands/last.rb +1 -1
  20. data/bin/commands/meanwhile.rb +2 -2
  21. data/bin/commands/now.rb +2 -2
  22. data/bin/commands/on.rb +6 -16
  23. data/bin/commands/open.rb +1 -1
  24. data/bin/commands/recent.rb +5 -17
  25. data/bin/commands/rotate.rb +17 -0
  26. data/bin/commands/sections.rb +82 -7
  27. data/bin/commands/show.rb +8 -28
  28. data/bin/commands/since.rb +5 -16
  29. data/bin/commands/tag_dir.rb +27 -3
  30. data/bin/commands/today.rb +3 -28
  31. data/bin/commands/view.rb +3 -3
  32. data/bin/commands/yesterday.rb +3 -36
  33. data/bin/doing +29 -139
  34. data/docs/doc/Array.html +1 -1
  35. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  36. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  37. data/docs/doc/BooleanTermParser/Query.html +1 -1
  38. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  39. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  40. data/docs/doc/BooleanTermParser.html +1 -1
  41. data/docs/doc/Doing/Color.html +1 -1
  42. data/docs/doc/Doing/Completion.html +324 -4
  43. data/docs/doc/Doing/Configuration.html +3 -3
  44. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  45. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  46. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  47. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  48. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  49. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  50. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  51. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  52. data/docs/doc/Doing/Errors.html +1 -1
  53. data/docs/doc/Doing/Hooks.html +1 -1
  54. data/docs/doc/Doing/Item.html +144 -3
  55. data/docs/doc/Doing/Items.html +209 -1
  56. data/docs/doc/Doing/LogAdapter.html +1 -1
  57. data/docs/doc/Doing/Logger.html +1807 -0
  58. data/docs/doc/Doing/Note.html +109 -3
  59. data/docs/doc/Doing/Pager.html +1 -1
  60. data/docs/doc/Doing/Plugins.html +1 -1
  61. data/docs/doc/Doing/Prompt.html +1 -1
  62. data/docs/doc/Doing/Section.html +1 -1
  63. data/docs/doc/Doing/TemplateString.html +1 -1
  64. data/docs/doc/Doing/Types.html +3 -3
  65. data/docs/doc/Doing/Util/Backup.html +1 -1
  66. data/docs/doc/Doing/Util.html +1 -1
  67. data/docs/doc/Doing/WWID.html +8 -58
  68. data/docs/doc/Doing.html +4 -4
  69. data/docs/doc/FalseClass.html +1 -1
  70. data/docs/doc/GLI/Commands/Help.html +1 -1
  71. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  72. data/docs/doc/GLI/Commands.html +1 -1
  73. data/docs/doc/GLI.html +1 -1
  74. data/docs/doc/Hash.html +1 -1
  75. data/docs/doc/Object.html +1 -1
  76. data/docs/doc/PhraseParser/Operator.html +1 -1
  77. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  78. data/docs/doc/PhraseParser/Query.html +1 -1
  79. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  80. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  81. data/docs/doc/PhraseParser/TermClause.html +1 -1
  82. data/docs/doc/PhraseParser.html +1 -1
  83. data/docs/doc/Status.html +1 -1
  84. data/docs/doc/String.html +1 -1
  85. data/docs/doc/Symbol.html +1 -1
  86. data/docs/doc/Time.html +1 -1
  87. data/docs/doc/TrueClass.html +1 -1
  88. data/docs/doc/_index.html +12 -10
  89. data/docs/doc/class_list.html +1 -1
  90. data/docs/doc/file.README.html +2 -2
  91. data/docs/doc/index.html +2 -2
  92. data/docs/doc/method_list.html +424 -304
  93. data/docs/doc/top-level-namespace.html +105 -1
  94. data/docs/index.md +1 -1
  95. data/doing.gemspec +24 -24
  96. data/doing.rdoc +259 -26
  97. data/example_plugin.rb +7 -5
  98. data/inputrc +57 -0
  99. data/lib/completion/_doing.zsh +48 -52
  100. data/lib/completion/doing.bash +14 -25
  101. data/lib/completion/doing.fish +41 -15
  102. data/lib/doing/add_options.rb +152 -0
  103. data/lib/doing/array/array.rb +16 -0
  104. data/lib/doing/changelog/changes.rb +1 -1
  105. data/lib/doing/chronify/string.rb +1 -1
  106. data/lib/doing/completion/bash_completion.rb +12 -51
  107. data/lib/doing/completion/fish_completion.rb +17 -53
  108. data/lib/doing/completion/zsh_completion.rb +21 -59
  109. data/lib/doing/completion.rb +203 -17
  110. data/lib/doing/configuration.rb +7 -1
  111. data/lib/doing/item.rb +30 -5
  112. data/lib/doing/items.rb +53 -5
  113. data/lib/doing/{log_adapter.rb → logger.rb} +8 -2
  114. data/lib/doing/note.rb +24 -8
  115. data/lib/doing/plugins/export/dayone_export.rb +8 -6
  116. data/lib/doing/plugins/export/html_export.rb +4 -4
  117. data/lib/doing/plugins/export/json_export.rb +19 -20
  118. data/lib/doing/plugins/export/markdown_export.rb +2 -2
  119. data/lib/doing/plugins/export/template_export.rb +4 -4
  120. data/lib/doing/plugins/import/calendar_import.rb +2 -2
  121. data/lib/doing/plugins/import/doing_import.rb +2 -2
  122. data/lib/doing/plugins/import/timing_import.rb +2 -2
  123. data/lib/doing/string/highlight.rb +3 -4
  124. data/lib/doing/string/string.rb +8 -0
  125. data/lib/doing/string/tags.rb +1 -1
  126. data/lib/doing/types.rb +2 -2
  127. data/lib/doing/util.rb +1 -1
  128. data/lib/doing/util_backup.rb +12 -12
  129. data/lib/doing/version.rb +1 -1
  130. data/lib/doing/wwid.rb +119 -120
  131. data/lib/doing.rb +61 -3
  132. data/lib/examples/commands/wiki.rb +27 -19
  133. data/lib/examples/plugins/capture_thing_import.rb +1 -1
  134. data/lib/helpers/threaded_tests.rb +2 -0
  135. data/scripts/setting_replace.rb +11 -0
  136. metadata +109 -124
  137. data/.yardoc/checksums +0 -29
  138. data/.yardoc/complete +0 -0
  139. data/.yardoc/object_types +0 -0
  140. data/.yardoc/objects/root.dat +0 -0
  141. data/.yardoc/proxy_types +0 -0
  142. data/bin/commands/add_section.rb +0 -15
@@ -45,7 +45,9 @@ module Doing
45
45
 
46
46
  def self.render(wwid, items, variables: {})
47
47
 
48
- return if items.nil?
48
+ return unless items.good?
49
+
50
+ config = Doing.settings
49
51
 
50
52
  opt = variables[:options]
51
53
  trigger = opt[:output]
@@ -78,7 +80,7 @@ module Doing
78
80
  title = "#{title} @section(#{i.section})" unless variables[:is_single]
79
81
 
80
82
  tags.concat(i.tag_array).sort!.uniq!
81
- flagged = day_flagged = true if i.tags?(wwid.config['marker_tag'])
83
+ flagged = day_flagged = true if i.tags?(config['marker_tag'])
82
84
 
83
85
  interval = wwid.get_interval(i, record: true) if i.title =~ /@done\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/ && opt[:times]
84
86
  interval ||= false
@@ -123,8 +125,8 @@ module Doing
123
125
  end
124
126
 
125
127
 
126
- template = if wwid.config['export_templates']['dayone'] && File.exist?(File.expand_path(wwid.config['export_templates']['dayone']))
127
- IO.read(File.expand_path(wwid.config['export_templates']['dayone']))
128
+ template = if config['export_templates']['dayone'] && File.exist?(File.expand_path(config['export_templates']['dayone']))
129
+ IO.read(File.expand_path(config['export_templates']['dayone']))
128
130
  else
129
131
  self.template('dayone')
130
132
  end
@@ -144,8 +146,8 @@ module Doing
144
146
  starred: hsh[:starred])
145
147
  end
146
148
  when :entries
147
- entry_template = if wwid.config['export_templates']['dayone_entry'] && File.exist?(File.expand_path(wwid.config['export_templates']['dayone_entry']))
148
- IO.read(File.expand_path(wwid.config['export_templates']['dayone_entry']))
149
+ entry_template = if config['export_templates']['dayone_entry'] && File.exist?(File.expand_path(config['export_templates']['dayone_entry']))
150
+ IO.read(File.expand_path(config['export_templates']['dayone_entry']))
149
151
  else
150
152
  self.template('dayone-entry')
151
153
  end
@@ -58,14 +58,14 @@ module Doing
58
58
  }
59
59
  end
60
60
 
61
- template = if wwid.config['export_templates']['haml'] && File.exist?(File.expand_path(wwid.config['export_templates']['haml']))
62
- IO.read(File.expand_path(wwid.config['export_templates']['haml']))
61
+ template = if Doing.setting('export_templates.haml') && File.exist?(File.expand_path(Doing.setting('export_templates.haml')))
62
+ IO.read(File.expand_path(Doing.setting('export_templates.haml')))
63
63
  else
64
64
  self.template('html')
65
65
  end
66
66
 
67
- style = if wwid.config['export_templates']['css'] && File.exist?(File.expand_path(wwid.config['export_templates']['css']))
68
- IO.read(File.expand_path(wwid.config['export_templates']['css']))
67
+ style = if Doing.setting('export_templates.css') && File.exist?(File.expand_path(Doing.setting('export_templates.css')))
68
+ IO.read(File.expand_path(Doing.setting('export_templates.css')))
69
69
  else
70
70
  self.template('css')
71
71
  end
@@ -29,16 +29,12 @@ module Doing
29
29
  max = last_date.strftime('%F')
30
30
  min = items[0].date.strftime('%F')
31
31
  items.each_with_index do |i, index|
32
- if String.method_defined? :force_encoding
33
- title = i.title.force_encoding('utf-8')
34
- note = i.note.map { |line| line.force_encoding('utf-8').strip } if i.note
35
- else
36
- title = i.title
37
- note = i.note.map { |line| line.strip } if i.note
38
- end
32
+ title = i.title.utf8
33
+ note = i.note.utf8
39
34
 
40
35
  end_date = i.end_date || ''
41
36
  interval = wwid.get_interval(i, formatted: false) || 0
37
+ duration = i.duration || 0
42
38
  note ||= ''
43
39
 
44
40
  tags = []
@@ -49,14 +45,15 @@ module Doing
49
45
  attributes[tag[0]] = tag[1] if tag[1]
50
46
  end
51
47
 
52
- if opt[:output] == 'json'
53
-
48
+ case opt[:output]
49
+ when 'json'
54
50
  i = {
55
51
  date: i.date,
56
52
  end_date: end_date,
57
53
  title: title.strip, #+ " #{note}"
58
- note: note.instance_of?(Array) ? note.to_s : note,
54
+ note: note.to_s(prefix: ''),
59
55
  time: interval.time_string(format: :clock),
56
+ duration: duration.time_string(format: :clock),
60
57
  tags: tags
61
58
  }
62
59
 
@@ -64,7 +61,7 @@ module Doing
64
61
 
65
62
  items_out << i
66
63
 
67
- elsif opt[:output] == 'timeline'
64
+ when 'timeline'
68
65
  new_item = {
69
66
  'id' => index + 1,
70
67
  'content' => title.strip, #+ " #{note}"
@@ -74,26 +71,28 @@ module Doing
74
71
  'style' => 'color:#4c566b;background-color:#d8dee9;'
75
72
  }
76
73
 
77
-
78
- if interval && interval.to_i > 0
74
+ if interval.to_i&.positive?
79
75
  new_item['end'] = end_date.strftime('%F %T')
80
76
  if interval.to_i > 3600
81
77
  new_item['type'] = 'range'
82
78
  new_item['style'] = 'color:white;background-color:#a2bf8a;'
83
79
  end
84
80
  end
85
- new_item['style'] = 'color:white;background-color:#f7921e;' if i.tags?(wwid.config['marker_tag'])
81
+ new_item['style'] = 'color:white;background-color:#f7921e;' if i.tags?(Doing.setting('marker_tag'))
86
82
  items_out.push(new_item)
87
83
  end
88
84
  end
89
- if opt[:output] == 'json'
85
+ case opt[:output]
86
+ when 'json'
90
87
  Doing.logger.debug('JSON Export:', "#{items_out.count} items output to JSON")
91
88
  JSON.pretty_generate({
92
- 'section' => variables[:page_title],
93
- 'items' => items_out,
94
- 'timers' => wwid.tag_times(format: :json, sort_by: opt[:sort_tags], sort_order: opt[:tag_order])
95
- })
96
- elsif opt[:output] == 'timeline'
89
+ 'section' => variables[:page_title],
90
+ 'items' => items_out,
91
+ 'timers' => wwid.tag_times(format: :json,
92
+ sort_by: opt[:sort_tags],
93
+ sort_order: opt[:tag_order])
94
+ })
95
+ when 'timeline'
97
96
  template = <<~EOTEMPLATE
98
97
  <!doctype html>
99
98
  <html>
@@ -66,8 +66,8 @@ module Doing
66
66
  }
67
67
  end
68
68
 
69
- template = if wwid.config['export_templates']['markdown'] && File.exist?(File.expand_path(wwid.config['export_templates']['markdown']))
70
- IO.read(File.expand_path(wwid.config['export_templates']['markdown']))
69
+ template = if Doing.setting('export_templates.markdown') && File.exist?(File.expand_path(Doing.setting('export_templates.markdown')))
70
+ IO.read(File.expand_path(Doing.setting('export_templates.markdown')))
71
71
  else
72
72
  self.template(nil)
73
73
  end
@@ -24,8 +24,8 @@ module Doing
24
24
 
25
25
  out = ''
26
26
  items.each do |item|
27
- if opt[:highlight] && item.title =~ /@#{wwid.config['marker_tag']}\b/i
28
- flag = Doing::Color.send(wwid.config['marker_color'])
27
+ if opt[:highlight] && item.title =~ /@#{Doing.setting('marker_tag')}\b/i
28
+ flag = Doing::Color.send(Doing.setting('marker_color'))
29
29
  reset = Doing::Color.reset + Doing::Color.default
30
30
  else
31
31
  flag = ''
@@ -34,7 +34,7 @@ module Doing
34
34
 
35
35
  placeholders = {}
36
36
 
37
- if !item.note.empty? && wwid.config['include_notes']
37
+ if !item.note.empty? && Doing.setting('include_notes')
38
38
  note = item.note.map(&:strip).delete_if(&:empty?)
39
39
  note.map! { |line| "#{line.sub(/^\t*/, '')} " }
40
40
 
@@ -133,7 +133,7 @@ module Doing
133
133
 
134
134
  # Doing.logger.debug('Template Export:', "#{items.count} items output to template #{opt[:template]}")
135
135
  if opt[:totals]
136
- out += wwid.tag_times(format: wwid.config['timer_format'].to_sym,
136
+ out += wwid.tag_times(format: Doing.setting('timer_format').to_sym,
137
137
  sort_by: opt[:sort_tags],
138
138
  sort_order: opt[:tag_order])
139
139
  end
@@ -23,9 +23,9 @@ module Doing
23
23
  limit_start = options[:start].to_i
24
24
  limit_end = options[:end].to_i
25
25
 
26
- section = options[:section] || wwid.config['current_section']
26
+ section = options[:section] || Doing.setting('current_section')
27
27
  options[:no_overlap] ||= false
28
- options[:autotag] ||= wwid.auto_tag
28
+ options[:autotag] ||= Doing.auto_tag
29
29
 
30
30
  wwid.content.add_section(section) unless wwid.content.section?(section)
31
31
 
@@ -29,7 +29,7 @@ module Doing
29
29
  exit_now! 'File not found' unless File.exist?(File.expand_path(path))
30
30
 
31
31
  options[:no_overlap] ||= false
32
- options[:autotag] ||= wwid.auto_tag
32
+ options[:autotag] ||= Doing.auto_tag
33
33
 
34
34
  tags = options[:tag] ? options[:tag].split(/[ ,]+/).map { |t| t.sub(/^@?/, '') } : []
35
35
  prefix = options[:prefix] || ''
@@ -63,7 +63,7 @@ module Doing
63
63
  title.gsub!(/ +/, ' ')
64
64
  title.strip!
65
65
  section = options[:section] || item.section
66
- section ||= wwid.config['current_section']
66
+ section ||= Doing.setting('current_section')
67
67
 
68
68
  new_item = Item.new(item.date, title, section)
69
69
  new_item.note = item.note
@@ -24,9 +24,9 @@ module Doing
24
24
  ##
25
25
  def self.import(wwid, path, options: {})
26
26
  exit_now! 'Path to JSON report required' if path.nil?
27
- section = options[:section] || wwid.config['current_section']
27
+ section = options[:section] || Doing.setting('current_section')
28
28
  options[:no_overlap] ||= false
29
- options[:autotag] ||= wwid.auto_tag
29
+ options[:autotag] ||= Doing.auto_tag
30
30
  wwid.content.add_section(section) unless wwid.content.section?(section)
31
31
 
32
32
  add_tags = options[:tag] ? options[:tag].split(/[ ,]+/).map { |t| t.sub(/^@?/, '') } : []
@@ -35,10 +35,9 @@ module Doing
35
35
 
36
36
  def highlight_search(search, distance: nil, negate: false, case_type: nil)
37
37
  out = dup
38
- prefs = Doing.config.settings['search'] || {}
39
- matching = prefs.fetch('matching', 'pattern').normalize_matching
40
- distance ||= prefs.fetch('distance', 3).to_i
41
- case_type ||= prefs.fetch('case', 'smart').normalize_case
38
+ matching = Doing.setting('search.matching', 'pattern').normalize_matching
39
+ distance ||= Doing.setting('search.distance', 3).to_i
40
+ case_type ||= Doing.setting('search.case', 'smart').normalize_case
42
41
 
43
42
  if search.rx? || matching == :fuzzy
44
43
  rx = search.to_rx(distance: distance, case_type: case_type)
@@ -2,6 +2,14 @@
2
2
 
3
3
  class ::String
4
4
  include Doing::Color
5
+
6
+ def utf8
7
+ if String.method_defined? :force_encoding
8
+ dup.force_encoding('utf-8')
9
+ else
10
+ self
11
+ end
12
+ end
5
13
  end
6
14
 
7
15
  require_relative 'highlight'
@@ -144,7 +144,7 @@ module Doing
144
144
  tags = title.scan(/(?<=\A| )(@(\S+?)(\([^)]+\))?)(?= |\Z)/).uniq
145
145
  tags.each do |tag|
146
146
  found = false
147
- title.gsub!(/( |^)#{tag[1]}(\([^)]+\))?(?= |$)/) do |m|
147
+ title.gsub!(/( |^)#{Regexp.escape(tag[1])}(\([^)]+\))?(?= |$)/) do |m|
148
148
  if found
149
149
  ''
150
150
  else
data/lib/doing/types.rb CHANGED
@@ -11,8 +11,8 @@ module Doing
11
11
  REGEX_TIME = /^#{REGEX_CLOCK}$/i.freeze
12
12
  REGEX_DAY = /^(mon|tue|wed|thur?|fri|sat|sun)(\w+(day)?)?$/i.freeze
13
13
  REGEX_RANGE_INDICATOR = ' +(?:to|through|thru|(?:un)?til|-+) +'
14
- REGEX_RANGE = /^\S+#{REGEX_RANGE_INDICATOR}+\S+/i.freeze
15
- REGEX_TIME_RANGE = /^#{REGEX_CLOCK}#{REGEX_RANGE_INDICATOR}#{REGEX_CLOCK}$/i.freeze
14
+ REGEX_RANGE = /^\S+.*?#{REGEX_RANGE_INDICATOR}\S+.*?$/i.freeze
15
+ REGEX_TIME_RANGE = /^#{REGEX_CLOCK}(?:#{REGEX_RANGE_INDICATOR}#{REGEX_CLOCK})?$/i.freeze
16
16
 
17
17
  InvalidExportType = Class.new(RuntimeError)
18
18
  MissingConfigFile = Class.new(RuntimeError)
data/lib/doing/util.rb CHANGED
@@ -159,7 +159,7 @@ module Doing
159
159
 
160
160
  return ENV['EDITOR'] if ENV['DOING_EDITOR_TEST']
161
161
 
162
- editor_config = Doing.config.settings['editors']
162
+ editor_config = Doing.setting('editors')
163
163
 
164
164
  if editor_config.is_a?(String)
165
165
  msg = "Please update your configuration, 'editors' should be a mapping."
@@ -30,7 +30,7 @@ module Doing
30
30
  ## @param limit Maximum number of backups to retain
31
31
  ##
32
32
  def clear_redo(filename)
33
- filename ||= Doing.config.settings['doing_file']
33
+ filename ||= Doing.setting('doing_file')
34
34
  backups = Dir.glob("undone*___#{File.basename(filename)}", base: backup_dir).sort.reverse
35
35
  backups.each do |file|
36
36
  FileUtils.rm(File.join(backup_dir, file))
@@ -44,7 +44,7 @@ module Doing
44
44
  ## @return [String] filename
45
45
  ##
46
46
  def last_backup(filename = nil, count: 1)
47
- filename ||= Doing.config.settings['doing_file']
47
+ filename ||= Doing.setting('doing_file')
48
48
 
49
49
  backup = get_backups(filename).slice(count - 1)
50
50
  backup.nil? ? nil : File.join(backup_dir, backup)
@@ -59,7 +59,7 @@ module Doing
59
59
  ##
60
60
  def restore_last_backup(filename = nil, count: 1)
61
61
  Doing.logger.benchmark(:restore_backup, :start)
62
- filename ||= Doing.config.settings['doing_file']
62
+ filename ||= Doing.setting('doing_file')
63
63
 
64
64
  backup_file = last_backup(filename, count: count)
65
65
  raise DoingRuntimeError, 'End of undo history' if backup_file.nil?
@@ -77,7 +77,7 @@ module Doing
77
77
  ## @param filename The filename
78
78
  ##
79
79
  def redo_backup(filename = nil, count: 1)
80
- filename ||= Doing.config.settings['doing_file']
80
+ filename ||= Doing.setting('doing_file')
81
81
  # redo_file = File.join(backup_dir, "undone___#{File.basename(filename)}")
82
82
  undones = Dir.glob("undone*#{File.basename(filename)}", base: backup_dir).sort.reverse
83
83
  total = undones.count
@@ -101,7 +101,7 @@ module Doing
101
101
  end
102
102
 
103
103
  def clear_undone(filename = nil)
104
- filename ||= Doing.config.settings['doing_file']
104
+ filename ||= Doing.setting('doing_file')
105
105
  # redo_file = File.join(backup_dir, "undone___#{File.basename(filename)}")
106
106
  Dir.glob("undone*#{File.basename(filename)}", base: backup_dir).each do |f|
107
107
  FileUtils.rm(File.join(backup_dir, f))
@@ -115,7 +115,7 @@ module Doing
115
115
  ## @param filename The filename to restore
116
116
  ##
117
117
  def select_redo(filename = nil)
118
- filename ||= Doing.config.settings['doing_file']
118
+ filename ||= Doing.setting('doing_file')
119
119
 
120
120
  undones = Dir.glob("undone*#{File.basename(filename)}", base: backup_dir).sort
121
121
 
@@ -155,7 +155,7 @@ module Doing
155
155
  ## @param filename The filename to restore
156
156
  ##
157
157
  def select_backup(filename = nil)
158
- filename ||= Doing.config.settings['doing_file']
158
+ filename ||= Doing.setting('doing_file')
159
159
 
160
160
  options = get_backups(filename).each_with_object([]) do |file, arr|
161
161
  d, _base = date_of_backup(file)
@@ -219,7 +219,7 @@ module Doing
219
219
  ##
220
220
  def write_backup(filename = nil)
221
221
  Doing.logger.benchmark(:_write_backup, :start)
222
- filename ||= Doing.config.settings['doing_file']
222
+ filename ||= Doing.setting('doing_file')
223
223
 
224
224
  unless File.exist?(filename)
225
225
  Doing.logger.debug('Backup:', "original file doesn't exist (#{filename})")
@@ -234,7 +234,7 @@ module Doing
234
234
 
235
235
  FileUtils.cp(filename, backup_file)
236
236
 
237
- prune_backups(filename, Doing.config.settings['history_size'].to_i)
237
+ prune_backups(filename, Doing.setting('history_size').to_i)
238
238
  clear_undone(filename)
239
239
  Doing.logger.benchmark(:_write_backup, :finish)
240
240
  end
@@ -246,13 +246,13 @@ module Doing
246
246
  end
247
247
 
248
248
  def get_backups(filename = nil, include_forward: false)
249
- filename ||= Doing.config.settings['doing_file']
249
+ filename ||= Doing.setting('doing_file')
250
250
  backups = Dir.glob("*___#{File.basename(filename)}", base: backup_dir).sort.reverse
251
251
  backups.delete_if { |f| f =~ /^undone/ } unless include_forward
252
252
  end
253
253
 
254
254
  def save_undone(filename = nil)
255
- filename ||= Doing.config.settings['doing_file']
255
+ filename ||= Doing.setting('doing_file')
256
256
  undone_file = File.join(backup_dir, "undone#{timestamp_filename}___#{File.basename(filename)}")
257
257
  FileUtils.cp(filename, undone_file)
258
258
  end
@@ -279,7 +279,7 @@ module Doing
279
279
  end
280
280
 
281
281
  def create_backup_dir
282
- dir = File.expand_path(Doing.config.settings['backup_dir']) || File.join(user_home, '.doing_backup')
282
+ dir = File.expand_path(Doing.setting('backup_dir')) || File.join(user_home, '.doing_backup')
283
283
  if File.exist?(dir) && !File.directory?(dir)
284
284
  raise DoingRuntimeError, "Backup error: #{dir} is not a directory"
285
285
 
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '2.1.30'
2
+ VERSION = '2.1.34'
3
3
  end