doing 1.0.26 → 1.0.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3631ac831d0c67d8082a02f66bf733e49bfc759091f235b87464af7ddb163eec
4
- data.tar.gz: 9366ddb434383df32e204d409e588915d5e959f5b9c77f6411fb6781f24c6c4a
3
+ metadata.gz: fe6fb41048c3152bcb7368e8c0c1443a750f2f4c35dcf6b961854d1535ff6d7f
4
+ data.tar.gz: 77dce944d05f9de577f4fecf1fc4ea95ea408f6cd6d1aef34f2b03f6d64e303c
5
5
  SHA512:
6
- metadata.gz: 716adc40f91a6b4a637e66fc310bbb70904112a67bd1a28a744bde5f19dbeb21c5040d66e3662fc9a33d5122307fc768a5859858786077ff48b5b5f9a649d3e1
7
- data.tar.gz: 42f564a64a07e81b29879f8364df85ae75644875cd752b2274f1481c24791baa97be354de39f1a1b521f82b2e652d6fe11294329d32ad6d314ad8e079c9c8db7
6
+ metadata.gz: cf4553553485d02e7ebe4bbe8bb538d0fab8172e3d5eb44671d252659ecba2d804c1ff8631eb4eec0c0cdd5867d4108901b36ccd7006ec4dfca7ea49e2a515e5
7
+ data.tar.gz: ea0efd6dbc79ca4c018e2a252261f727f37d8525c09382ae386a9d90f840faafa9a4b2f409938735317f486879febde14c75e3c0a41cdf583c7b2cd23bf25936
data/README.md CHANGED
@@ -54,6 +54,8 @@ When using the `now` and `later` commands on the command line, you can start the
54
54
 
55
55
  Notes can be prevented from ever appearing in output with the global option `--no-notes`: `doing --no-notes show all`.
56
56
 
57
+ Auto tagging (adding tags listed in .doingrc under `autotag` and `default_tags`) can be skipped for an entry with the `-x` global option: `doing -x done skipping some automatic tagging`.
58
+
57
59
  ## Configuration
58
60
 
59
61
  A basic configuration looks like this:
@@ -382,6 +384,7 @@ Note that you can include a tag with synonyms in the whitelist as well to tag it
382
384
  --[no-]notes - Output notes if included in the template (default: enabled)
383
385
  --stdout - Send results report to STDOUT instead of STDERR
384
386
  --version - Display the program version
387
+ -x, --[no-]noauto - Exclude auto tags and default tags
385
388
 
386
389
  ### Commands:
387
390
 
@@ -390,7 +393,7 @@ Note that you can include a tag with synonyms in the whitelist as well to tag it
390
393
 
391
394
  #### Adding entries:
392
395
 
393
- now - Add an entry
396
+ now, did - Add an entry
394
397
  later - Add an item to the Later section
395
398
  done - Add a completed item with @done(date). No argument finishes last entry.
396
399
  meanwhile - Finish any @meanwhile tasks and optionally create a new one
data/bin/doing CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift File.join(__dir__, '..', 'lib')
3
3
  require 'gli'
4
4
  require 'doing'
5
5
  require 'tempfile'
6
+ require 'pp'
6
7
 
7
8
  def class_exists?(class_name)
8
9
  klass = Module.const_get(class_name)
@@ -42,6 +43,14 @@ desc 'Send results report to STDOUT instead of STDERR'
42
43
  default_value false
43
44
  switch [:stdout], :default_value => false, :negatable => false
44
45
 
46
+ desc 'Exclude auto tags and default tags'
47
+ switch [:x,:noauto], :default_value => false
48
+
49
+ desc 'Use a specific configuration file'
50
+ default_value false
51
+ flag [:config_file]
52
+
53
+
45
54
  # desc 'Wrap notes at X chars (0 for no wrap)'
46
55
  # flag [:w,:wrapwidth], :must_match => /^\d+$/, :type => Integer
47
56
 
@@ -483,23 +492,23 @@ desc 'Tag last entry'
483
492
  arg_name 'tag1 [tag2...]'
484
493
  command :tag do |c|
485
494
  c.desc 'Section'
486
- c.flag [:s,:section], :default_value => "All"
495
+ c.flag [:s, :section], :default_value => "All"
487
496
 
488
497
  c.desc 'How many recent entries to tag (0 for all)'
489
498
  c.default_value 1
490
- c.flag [:c,:count], :default_value => 1
499
+ c.flag [:c, :count], :default_value => 1
491
500
 
492
501
  c.desc 'Include current date/time with tag'
493
502
  c.default_value false
494
- c.switch [:d,:date], :negatable => false, :default_value => false
503
+ c.switch [:d, :date], :negatable => false, :default_value => false
495
504
 
496
505
  c.desc 'Remove given tag(s)'
497
506
  c.default_value false
498
- c.switch [:r,:remove], :negatable => false, :default_value => false
507
+ c.switch [:r, :remove], :negatable => false, :default_value => false
499
508
 
500
509
  c.desc 'Autotag entries based on autotag configuration in ~/.doingrc'
501
510
  c.default_value false
502
- c.switch [:a,:autotag], :negatable => false, :default_value => false
511
+ c.switch [:a, :autotag], :negatable => false, :default_value => false
503
512
 
504
513
  c.action do |global_options,options,args|
505
514
  if args.length == 0 && !options[:a]
@@ -1077,22 +1086,22 @@ command :config do |c|
1077
1086
  c.action do |global_options,options,args|
1078
1087
  if `uname` =~ /Darwins/
1079
1088
  if options[:x]
1080
- %x{open -a "#{wwid.config['editor_app']}" "#{File.join(Dir.home, wwid.default_config_file)}"}
1089
+ %x{open -a "#{wwid.config['editor_app']}" "#{wwid.config_file}"}
1081
1090
  elsif options[:a] || options[:b]
1082
1091
  if options[:a]
1083
- %x{open -a "#{options[:a]}" "#{File.join(Dir.home, wwid.default_config_file)}"}
1092
+ %x{open -a "#{options[:a]}" "#{wwid.config_file}"}
1084
1093
  elsif options[:b]
1085
- %x{open -b #{options[:b]} "#{File.join(Dir.home, wwid.default_config_file)}"}
1094
+ %x{open -b #{options[:b]} "#{wwid.config_file}"}
1086
1095
  end
1087
1096
  else
1088
1097
  raise "No EDITOR variable defined in environment" if options[:e].nil? && ENV['EDITOR'].nil?
1089
1098
  editor = options[:e].nil? ? ENV['EDITOR'] : options[:e]
1090
- system %Q{#{editor} "#{File.join(Dir.home, wwid.default_config_file)}"}
1099
+ system %Q{#{editor} "#{wwid.config_file}"}
1091
1100
  end
1092
1101
  else
1093
1102
  raise "No EDITOR variable defined in environment" if options[:e].nil? && ENV['EDITOR'].nil?
1094
1103
  editor = options[:e].nil? ? ENV['EDITOR'] : options[:e]
1095
- system %Q{#{editor} "#{File.join(Dir.home, wwid.default_config_file)}"}
1104
+ system %Q{#{editor} "#{wwid.config_file}"}
1096
1105
  end
1097
1106
  end
1098
1107
  end
@@ -1111,12 +1120,22 @@ end
1111
1120
 
1112
1121
 
1113
1122
  pre do |global,command,options,args|
1123
+ if global[:config_file]
1124
+ wwid.config_file = global[:config_file]
1125
+ wwid.configure({:ignore_local => true})
1126
+ # wwid.results.push("Override config file #{wwid.config_file}")
1127
+ end
1128
+
1114
1129
  if global[:doing_file]
1115
1130
  wwid.init_doing_file(global[:doing_file])
1116
1131
  else
1117
1132
  wwid.init_doing_file
1118
1133
  end
1134
+
1135
+ wwid.auto_tag = !global[:noauto]
1136
+
1119
1137
  wwid.config[:include_notes] = false unless global[:notes]
1138
+
1120
1139
  if global[:version]
1121
1140
  $stdout.puts "doing v" + Doing::VERSION
1122
1141
  end
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.26'
2
+ VERSION = '1.0.32'
3
3
  end
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'deep_merge'
4
- require 'pp'
5
4
 
6
5
  ##
7
6
  ## @brief String helpers
@@ -43,7 +42,7 @@ end
43
42
  ## @brief Main "What Was I Doing" methods
44
43
  ##
45
44
  class WWID
46
- attr_accessor :content, :sections, :current_section, :doing_file, :config, :user_home, :default_config_file, :results
45
+ attr_accessor :content, :sections, :current_section, :doing_file, :config, :user_home, :default_config_file, :config_file, :results, :auto_tag
47
46
 
48
47
  ##
49
48
  ## @brief Initializes the object.
@@ -53,6 +52,66 @@ class WWID
53
52
  @doingrc_needs_update = false
54
53
  @default_config_file = '.doingrc'
55
54
  @interval_cache = {}
55
+ @results = []
56
+ @auto_tag = true
57
+ end
58
+
59
+ ##
60
+ ## @brief Finds a project-specific configuration file
61
+ ##
62
+ ## @return (String) A file path
63
+ ##
64
+ def find_local_config
65
+
66
+ config = {}
67
+ dir = Dir.pwd
68
+
69
+ local_config_files = []
70
+
71
+ while (dir != '/' && (dir =~ /[A-Z]:\//) == nil)
72
+ if File.exists? File.join(dir, @default_config_file)
73
+ local_config_files.push(File.join(dir, @default_config_file))
74
+ end
75
+
76
+ dir = File.dirname(dir)
77
+ end
78
+
79
+ local_config_files
80
+ end
81
+
82
+ ##
83
+ ## @brief Reads a configuration.
84
+ ##
85
+ def read_config(opt={})
86
+ unless @config_file
87
+ if Dir.respond_to?('home')
88
+ @config_file = File.join(Dir.home, @default_config_file)
89
+ else
90
+ @config_file = File.join(File.expand_path("~"), @default_config_file)
91
+ end
92
+ end
93
+
94
+ if opt[:ignore_local]
95
+ additional_configs = []
96
+ else
97
+ additional_configs = find_local_config
98
+ end
99
+
100
+ begin
101
+ @local_config = {}
102
+
103
+ @config = YAML.load_file(@config_file) || {} if File.exists?(@config_file)
104
+ additional_configs.each { |cfg|
105
+ new_config = YAML.load_file(cfg) || {} if cfg
106
+ @local_config = @local_config.deep_merge(new_config)
107
+ }
108
+
109
+ # @config.deep_merge(@local_config)
110
+ rescue
111
+ @config = {}
112
+ @local_config = {}
113
+ # raise "error reading config"
114
+ end
56
115
  end
57
116
 
58
117
  ##
@@ -62,12 +121,17 @@ class WWID
62
121
  ##
63
122
  def configure(opt={})
64
123
  @timers = {}
65
- @config_file == File.join(@user_home, @default_config_file)
124
+ opt[:ignore_local] ||= false
66
125
 
67
- read_config
126
+ unless @config_file
127
+ @config_file = File.join(@user_home, @default_config_file)
128
+ end
129
+
130
+ read_config({:ignore_local => opt[:ignore_local]})
68
131
 
69
132
  user_config = @config.dup
70
- @results = []
133
+
134
+ @config = {} if @config.nil?
71
135
 
72
136
  @config['autotag'] ||= {}
73
137
  @config['autotag']['whitelist'] ||= []
@@ -137,13 +201,16 @@ class WWID
137
201
  # end
138
202
  # end
139
203
 
140
- File.open(@config_file, 'w') { |yf| YAML::dump(@config, yf) } unless @config == user_config
204
+ unless File.exists?(@config_file)
205
+ File.open(@config_file, 'w') { |yf| YAML::dump(@config, yf) }
206
+ end
141
207
 
142
208
  @config = @local_config.deep_merge(@config)
143
209
 
144
210
  @current_section = @config['current_section']
145
211
  @default_template = @config['templates']['default']['template']
146
- @default_date_format = @config['templates']['default']['date_format']
212
+ @default_date_format = @config['templates']['default']['date_format'];
213
+
147
214
 
148
215
  end
149
216
 
@@ -243,58 +310,6 @@ class WWID
243
310
  end
244
311
  end
245
312
 
246
- ##
247
- ## @brief Finds a project-specific configuration file
248
- ##
249
- ## @return (String) A file path
250
- ##
251
- def find_local_config
252
-
253
- config = {}
254
- dir = Dir.pwd
255
-
256
- local_config_files = []
257
-
258
- while (dir != '/' && (dir =~ /[A-Z]:\//) == nil)
259
- if File.exists? File.join(dir, @default_config_file)
260
- local_config_files.push(File.join(dir, @default_config_file))
261
- end
262
-
263
- dir = File.dirname(dir)
264
- end
265
-
266
- local_config_files
267
- end
268
-
269
- ##
270
- ## @brief Reads a configuration.
271
- ##
272
- def read_config
273
- if Dir.respond_to?('home')
274
- @config_file = File.join(Dir.home, @default_config_file)
275
- else
276
- @config_file = File.join(File.expand_path("~"), @default_config_file)
277
- end
278
- # @doingrc_needs_update = true if File.exists? @config_file
279
- additional_configs = find_local_config
280
-
281
- begin
282
- @local_config = {}
283
-
284
- @config = YAML.load_file(@config_file) || {} if File.exists?(@config_file)
285
- additional_configs.each { |cfg|
286
- new_config = YAML.load_file(cfg) || {} if cfg
287
- @local_config = @local_config.deep_merge(new_config)
288
- }
289
-
290
- # @config.deep_merge(@local_config)
291
- rescue
292
- @config = {}
293
- @local_config = {}
294
- # raise "error reading config"
295
- end
296
- end
297
-
298
313
  ##
299
314
  ## @brief Create a process for an editor and wait for the file handle to return
300
315
  ##
@@ -567,21 +582,26 @@ class WWID
567
582
  opt[:timed] ||= false
568
583
 
569
584
  title = [title.strip.cap_first]
570
- title = autotag(title.join(' '))
571
- unless @config['default_tags'].empty?
572
- title += @config['default_tags'].map{|t|
573
- unless t.nil?
574
- dt = t.sub(/^ *@/,'').chomp
575
- if title =~ /@#{dt}/
576
- ""
577
- else
578
- ' @' + dt
585
+ title = title.join(' ')
586
+
587
+ if @auto_tag
588
+ title = autotag(title)
589
+ unless @config['default_tags'].empty?
590
+ title += @config['default_tags'].map{|t|
591
+ unless t.nil?
592
+ dt = t.sub(/^ *@/,'').chomp
593
+ if title =~ /@#{dt}/
594
+ ""
595
+ else
596
+ ' @' + dt
597
+ end
579
598
  end
580
- end
581
- }.delete_if {|t| t == "" }.join(" ")
599
+ }.delete_if {|t| t == "" }.join(" ")
600
+ end
582
601
  end
602
+ title.gsub!(/ +/,' ')
583
603
  entry = {'title' => title.strip, 'date' => opt[:back]}
584
- unless opt[:note] =~ /^\s*$/s
604
+ unless opt[:note].join('').strip == ''
585
605
  entry['note'] = opt[:note].map {|n| n.gsub(/ *$/,'')}
586
606
  end
587
607
  items = @content[section]['items']
@@ -717,7 +737,7 @@ class WWID
717
737
  }
718
738
  item['title'] = title
719
739
  else
720
- new_title = autotag(item['title'])
740
+ new_title = autotag(item['title']) if @auto_tag
721
741
  unless new_title == item['title']
722
742
  @results.push("Tags updated: #{new_title}")
723
743
  item['title'] = new_title
@@ -1653,6 +1673,7 @@ EOS
1653
1673
  #
1654
1674
  def autotag(text)
1655
1675
  return unless text
1676
+ return text unless @auto_tag
1656
1677
  current_tags = text.scan(/@\w+/)
1657
1678
  whitelisted = []
1658
1679
  @config['autotag']['whitelist'].each {|tag|
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.26
4
+ version: 1.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-16 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 12.3.3
20
20
  type: :development
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: 12.3.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +193,7 @@ homepage: http://brettterpstra.com/project/doing/
193
193
  licenses:
194
194
  - MIT
195
195
  metadata: {}
196
- post_install_message:
196
+ post_install_message:
197
197
  rdoc_options:
198
198
  - "--title"
199
199
  - doing
@@ -216,8 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 3.0.6
220
- signing_key:
219
+ rubygems_version: 3.0.8
220
+ signing_key:
221
221
  specification_version: 4
222
222
  summary: A command line tool for managing What Was I Doing reminders
223
223
  test_files: []