doing 1.0.24 → 1.0.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -216
  3. data/bin/doing +44 -17
  4. data/lib/doing/version.rb +1 -1
  5. data/lib/doing/wwid.rb +125 -78
  6. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8701939f6f7f9ab73bd84b4f5eb12fb11000d4267b8e50bb95a586f3f3c031f
4
- data.tar.gz: befe08c2e78ec8df076041cea7e2b7c114950003ffab85697e2fc934acca5c85
3
+ metadata.gz: 0255bb5d4f5bfeda0dc436ec5d7b39cc0076015b38367ae9a3f69aa377ae29aa
4
+ data.tar.gz: 765dff7df4c68a482a2f18db18afc2605945d0d87503aa2ec46da138f5cadef6
5
5
  SHA512:
6
- metadata.gz: bddd6093eeacb8f29539b67e02d8fd3b47f68c4350d8c8bb5d13c8b33fe02e6e62cbaa12c4a406880716a4bb5560ef4a5d52125e7c83e3168896bfa38d85c771
7
- data.tar.gz: '094ba3ce7917a2e1d596f727a7cbd97b1e4eba0d3d1916810ddcccae1eda42082e0b8f8f818afa34c1dbedbd3ecaa3cbfd0d78beabb6f38f44580de84996f5da'
6
+ metadata.gz: b401382aaea67cea9e1ce6aaf414a8bcc104ef8375f044d674f0728e8110128285c9d0a88ed998537430546175220faaf821dce83779606b8281997aaf7fddd5
7
+ data.tar.gz: 5116d2b3723a1caf501380dfe501600644661a6fd019e214e4c5dc87920a9a9890a93dd8797b0a7cf5a8b0b6cefa0efc5af269a15a035c640847d689bd65a845
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
@@ -600,218 +603,4 @@ Feel free to [poke around](http://github.com/ttscoff/doing/), I'll try to add mo
600
603
 
601
604
  ## Changelog
602
605
 
603
- #### 1.0.24
604
-
605
- - `doing note` operates on whatever is most recent, not just the last note in Currently
606
- - `doing tag` with no count specified operates on most recent entry in any section, not just Currently
607
- - `doing tag` with a count greater than 1 requires a section to be specified
608
- - Improved results reporting for `doing tag`
609
- - When removing tag do a whole-word match to avoid removing part of a longer tag
610
-
611
- #### 1.0.23
612
-
613
- - Apply default_tags after autotagging to avoid tags triggering tags
614
- - Set `doing recent` to default to All sections instead of Currently
615
- - Fix error in time reporting
616
- - improved y/n prompt for TTY
617
-
618
- #### 1.0.22
619
-
620
- - Fix handling of "local" config files, allowing per-project configurations
621
- - Allow cascading of local config files
622
- - Allow `doing today` and `yesterday` to specify a section
623
-
624
- #### 1.0.21
625
-
626
- - Add legitimate regex search capabilities
627
- - Synonyms for grep (search) and now (next)
628
- - CSS fix
629
-
630
- #### 1.0.20
631
-
632
- - Rewrite HTML export templates with responsive layout and typography
633
- - Ability to customize the HTML output using HAML and CSS
634
- - New command `doing templates` to export default templates for HAML and CSS
635
- - New config options under `html_template` for `haml` and `css`
636
-
637
- #### 1.0.19
638
-
639
- - For `doing note -e` include the entry title so you know what you're adding a note to
640
- - For any other command that allows `-e` include a comment noting that anything after the first line creates a note
641
- - Ignore # comments when parsing editor results
642
- - Add a .md extension to the temp file passed to the editor so you can take advantage of any syntax highlighting and other features in your editor
643
-
644
- #### 1.0.18
645
-
646
- - Fix `undefined method [] for nil class` error in `doing view`
647
- - Loosened up the template color resetting a bit more
648
-
649
- #### 1.0.17
650
-
651
- - Add `--stdout` global option to send reporting to STDOUT instead of STDERR (for use with LaunchBar et al)
652
-
653
- #### 1.0.16
654
-
655
- - Fixes overzealous color resetting
656
-
657
- #### 1.0.15
658
-
659
- - CLI/text totals block was outputting when HTML output was selected
660
- - Have all template colors reset bold and background automatically when called
661
-
662
- #### 1.0.14
663
-
664
- Catching up on the changelog. Kind of. A lot has happened, mostly fixes.
665
-
666
- - Fish completion
667
- - views and sections subcommands have -c option to output single column
668
- - Fix html title when tag_bool is NONE
669
- - Fix @from tagging missing closing paren
670
- - Fix tag coloring
671
-
672
- #### 1.0.13
673
-
674
- - Fix gsub error in doing meanwhile
675
-
676
- #### 1.0.8pre
677
-
678
- * JSON output option to view commands
679
- * Added autotagging to tag command
680
- * date filtering, improved date language
681
- * added doing on command
682
- * let view templates define output format (csv, json, html, template)
683
- * add `%chompnote` template variable (item note with newlines and extra whitespace stripped)
684
-
685
- #### 1.0.7pre
686
-
687
- * fix for `-v` option
688
- * Slightly fuzzier searching in the grep command
689
- * cleaner exits, `only_timed` key for view configs
690
- * making the note command append new notes better, and load existing notes in the editor if `-e` is called
691
- * handle multiple tag input in `show` tag filter
692
- * Global tag operations, better reporting
693
-
694
- #### 1.0.4pre
695
-
696
- * Improved HTML output
697
- * `--only_timed` option for view/show commands that only outputs items with elapsed timers (interval between start and done dates)
698
- * add seconds for timed items in CSV output, run `--only_timed` before chopping off `--count #`
699
- * fix for 1.8.7 `Dir.home` issue
700
- * version bump
701
- * don't show tag totals with zero times
702
- * zsh completion for doing
703
- * HTML styling
704
- * `--only_timed` option
705
- * added zsh completion file to `README.md`
706
- * add zsh completion file
707
-
708
- #### 1.0.3pre
709
-
710
- * `done` command: making `--took` modify start time if `--back` isn't specified
711
- * Cleaned up time totals, improved HTML output
712
- * fixes for `--back` and `--took` parsing
713
- * Adding more complete terminal reporting to archive command
714
-
715
- #### 1.0.0pre
716
-
717
- * Skipped ahead in the version numbering. Because I don't care.
718
- * Added a `note` command and `--note` flags for entry creation commands
719
-
720
- #### 0.2.6pre
721
-
722
- * `--totals`, `--[no-]times`, `--output [csv,html]` options for `yesterday` command.
723
- * Add tests for Darwin to hide OS X-only features on other systems
724
- * `-f` flag to `now` command for finishing last task when starting a new one (Looks back for the last unfinished task in the list)
725
- * `--took` option for `done` and `finish` for specifying intervals from the start date for the completion date
726
- * Basic command line reporting
727
- * `--auto` flag for `finish` and `done` that will automatically set the completion time to 1 minute before the next start time in the list. You can use it retroactively to add times to sequential todos.
728
- * `doing grep` for searching by text or regex
729
-
730
- #### 0.2.5
731
-
732
- * Default to showing times #26, show totals even if no tags exist #27, fix indentation #29
733
- * Add section label to archived tasks automatically, excepting `Currently` section
734
- * Today outputs and backdate for finish
735
- * HTML styling and fix for 1.8.7 haml errors
736
- * Look, HTML output! (`--output html`)
737
- * Also, `--output csv`
738
- * let doing `archive` function on all sections
739
- * option to exclude date from _@done_,
740
- * output newlines in sections and views
741
- * Flagging (`doing mark`)
742
- * fix for view/section guess error
743
- * Adding tag filtering to archive command (`doing archive \@done`)
744
- * `doing yesterday`
745
- * `doing done -r` to remove last doing tag (optionally from `-s Section`)
746
- * Add `-f` flag to specify alternate doing file
747
- * `meanwhile` command
748
-
749
- #### 0.2.1
750
-
751
- - CSV output for show command (`--csv`)
752
- - HTML output for show command (`--output html`)
753
- - fuzzy searching for all commands that specify a view.
754
- - In the terminal, you'll see "Assume you meant XXX" to show what match it found, but this is output to STDERR (and won't show up if you're redirecting the output or using it in GeekTool, etc.)
755
- - `tags_color` in view config to highlight tags at the end of the lines. Can be set to any of the `%colors`.
756
- - Basic time tracking.
757
- - `-t` on `show` and `view` will turn on time calculations
758
- - Intervals between timestamps and dated _@done_ tags are calculated for each line, if the tag exists.
759
- - You must include a `%interval` token in the appropriate template for it to show
760
- - _@start(date)_ tags can optionally be used to override the timestamp in the calculation
761
- - Any other tags in the line have that line's total added to them
762
- - Totals for tags can be displayed at the end of output with `--totals`
763
-
764
-
765
- #### 0.2.0
766
-
767
- - `doing done` without argument tags last entry done
768
- - `-a` archives them
769
- - `doing finish` or `doing finish X` marks last X entries done
770
- - `-a` archives them
771
- - `doing tag tag1 [tag2]` tags last entry or `-c X` entries
772
- - `doing tag -r tag1 [tag2]` removes said tag(s)
773
- - custom views additions
774
- - custom views can include `tags` and `tags_bool`
775
- - `tags` is a space-separated list of tags to filter the results by
776
- - `tags_bool` defines `AND` (all tags must exist), `OR` (any tag exists), or `NONE` (none of the tags exist)
777
- - `order` key (`asc` or `desc`) defines output sort order by date
778
- - section key can be set to `All` to combine sections
779
- - `doing show` updates
780
- - accepts `all` as a section
781
- - arguments following section name are tags to filter by
782
- - `-b` sets boolean (`AND`, `OR`, `NONE`) or (`ALL`, `ANY`, `NONE`) (default `OR`/`ANY`)
783
- - use `-c X` to limit results
784
- - use `-s` to set sort order (`asc` or `desc`)
785
- - use `-a` to set age (`newest` or `oldest`)
786
- - fuzzy section guessing when specified section isn't found
787
- - fuzzy view guessing for `doing view` command
788
-
789
- ----
790
-
791
- #### 0.1.9
792
-
793
- - colors in templated output
794
- - `open` command
795
- - opens in the default app for file type
796
- - `-a APPNAME` (`doing open -a TaskPaper`)
797
- - `-b bundle_id` (`doing open -b com.sublimetext.3`)
798
- - `-e` switch for `now`, `later` and `done` commands
799
- - save a tmp file and open it in an editor
800
- - allows multi-line entries, anything after first line is considered a note
801
- - assumed when no input is provided (`doing now`)
802
- - `doing views` shows all available custom views
803
- - `doing view` without a view name will let you choose a view from a menu
804
- - `doing archive` fixed so that `-k X` works to keep `X` number of entries in the section
805
-
806
- #### 0.1.7
807
-
808
- - colors in templated output
809
- - `open` command
810
- - opens in the default app for file type
811
- - `-a APPNAME` (`doing open -a TaskPaper`)
812
- - `-b bundle_id` (`doing open -b com.sublimetext.3`)
813
- - `-e` switch for `now`, `later`, and `done` commands
814
- - save a tmp file and open it in an editor
815
- - allows multi-line entries, anything after first line is considered a note
816
- - assumed when no input is provided (`doing now`)
817
-
606
+ See [CHANGELOG.md](https://github.com/ttscoff/doing/blob/master/CHANGELOG.md)
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)
@@ -21,7 +22,11 @@ include GLI::App
21
22
  version Doing::VERSION
22
23
 
23
24
  wwid = WWID.new
24
- wwid.user_home = %x{echo $HOME}.strip
25
+ if Dir.respond_to?('home')
26
+ wwid.user_home = Dir.home
27
+ else
28
+ wwid.user_home = File.expand_path("~")
29
+ end
25
30
  wwid.configure
26
31
 
27
32
 
@@ -38,6 +43,14 @@ desc 'Send results report to STDOUT instead of STDERR'
38
43
  default_value false
39
44
  switch [:stdout], :default_value => false, :negatable => false
40
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
+
41
54
  # desc 'Wrap notes at X chars (0 for no wrap)'
42
55
  # flag [:w,:wrapwidth], :must_match => /^\d+$/, :type => Integer
43
56
 
@@ -129,7 +142,7 @@ command :note do |c|
129
142
  c.desc "Edit entry with #{ENV['EDITOR']}"
130
143
  c.switch [:e, :editor], :negatable => false, :default_value => false
131
144
 
132
- c.desc "Replace/Remove last entry's note"
145
+ c.desc "Replace/Remove last entry's note (default append)"
133
146
  c.switch [:r, :remove], :negatable => false, :default_value => false
134
147
 
135
148
  c.action do |global_options,options,args|
@@ -314,7 +327,7 @@ end
314
327
 
315
328
  desc 'Add a completed item with @done(date). No argument finishes last entry.'
316
329
  arg_name 'entry'
317
- command :done do |c|
330
+ command [:done,:did] do |c|
318
331
  c.desc 'Remove @done tag'
319
332
  c.default_value false
320
333
  c.switch [:r, :remove], :negatable => false, :default_value => false
@@ -327,9 +340,8 @@ command :done do |c|
327
340
  c.default_value false
328
341
  c.switch [:a, :archive], :negatable => false, :default_value => false
329
342
 
330
- # TODO: Set @done date to specific time, backtracking start date in case of --took option. Should ignore --back option if present.
331
- # c.desc 'Set finish date to specific date/time (natural langauge)'
332
- # c.flag [:at]
343
+ c.desc 'Set finish date to specific date/time (natural langauge parsed, e.g. --at=1:30pm). If used, ignores --back. Used with --took, backdates start date'
344
+ c.flag [:at]
333
345
 
334
346
  c.desc 'Backdate start date by interval [4pm|20m|2h|yesterday noon]'
335
347
  c.flag [:b, :back]
@@ -352,6 +364,7 @@ command :done do |c|
352
364
  c.action do |global_options,options,args|
353
365
  took = 0
354
366
 
367
+
355
368
  if options[:took]
356
369
  took = wwid.chronify_qty(options[:took])
357
370
  raise "Unable to parse date string for --took" if took.nil?
@@ -364,7 +377,11 @@ command :done do |c|
364
377
  date = options[:took] ? Time.now - took : Time.now
365
378
  end
366
379
 
367
- if options[:took]
380
+ if options[:at]
381
+ finish_date = wwid.chronify(options[:at])
382
+ raise "Unable to parse date string for --at" if finish_date.nil?
383
+ date = options[:took] ? finish_date - took : finish_date
384
+ elsif options[:took]
368
385
  finish_date = date + took
369
386
  elsif options[:back]
370
387
  finish_date = date
@@ -475,23 +492,23 @@ desc 'Tag last entry'
475
492
  arg_name 'tag1 [tag2...]'
476
493
  command :tag do |c|
477
494
  c.desc 'Section'
478
- c.flag [:s,:section], :default_value => "All"
495
+ c.flag [:s, :section], :default_value => "All"
479
496
 
480
497
  c.desc 'How many recent entries to tag (0 for all)'
481
498
  c.default_value 1
482
- c.flag [:c,:count], :default_value => 1
499
+ c.flag [:c, :count], :default_value => 1
483
500
 
484
501
  c.desc 'Include current date/time with tag'
485
502
  c.default_value false
486
- c.switch [:d,:date], :negatable => false, :default_value => false
503
+ c.switch [:d, :date], :negatable => false, :default_value => false
487
504
 
488
505
  c.desc 'Remove given tag(s)'
489
506
  c.default_value false
490
- c.switch [:r,:remove], :negatable => false, :default_value => false
507
+ c.switch [:r, :remove], :negatable => false, :default_value => false
491
508
 
492
509
  c.desc 'Autotag entries based on autotag configuration in ~/.doingrc'
493
510
  c.default_value false
494
- c.switch [:a,:autotag], :negatable => false, :default_value => false
511
+ c.switch [:a, :autotag], :negatable => false, :default_value => false
495
512
 
496
513
  c.action do |global_options,options,args|
497
514
  if args.length == 0 && !options[:a]
@@ -1069,22 +1086,22 @@ command :config do |c|
1069
1086
  c.action do |global_options,options,args|
1070
1087
  if `uname` =~ /Darwins/
1071
1088
  if options[:x]
1072
- %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}"}
1073
1090
  elsif options[:a] || options[:b]
1074
1091
  if options[:a]
1075
- %x{open -a "#{options[:a]}" "#{File.join(Dir.home, wwid.default_config_file)}"}
1092
+ %x{open -a "#{options[:a]}" "#{wwid.config_file}"}
1076
1093
  elsif options[:b]
1077
- %x{open -b #{options[:b]} "#{File.join(Dir.home, wwid.default_config_file)}"}
1094
+ %x{open -b #{options[:b]} "#{wwid.config_file}"}
1078
1095
  end
1079
1096
  else
1080
1097
  raise "No EDITOR variable defined in environment" if options[:e].nil? && ENV['EDITOR'].nil?
1081
1098
  editor = options[:e].nil? ? ENV['EDITOR'] : options[:e]
1082
- system %Q{#{editor} "#{File.join(Dir.home, wwid.default_config_file)}"}
1099
+ system %Q{#{editor} "#{wwid.config_file}"}
1083
1100
  end
1084
1101
  else
1085
1102
  raise "No EDITOR variable defined in environment" if options[:e].nil? && ENV['EDITOR'].nil?
1086
1103
  editor = options[:e].nil? ? ENV['EDITOR'] : options[:e]
1087
- system %Q{#{editor} "#{File.join(Dir.home, wwid.default_config_file)}"}
1104
+ system %Q{#{editor} "#{wwid.config_file}"}
1088
1105
  end
1089
1106
  end
1090
1107
  end
@@ -1103,12 +1120,22 @@ end
1103
1120
 
1104
1121
 
1105
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
+
1106
1129
  if global[:doing_file]
1107
1130
  wwid.init_doing_file(global[:doing_file])
1108
1131
  else
1109
1132
  wwid.init_doing_file
1110
1133
  end
1134
+
1135
+ wwid.auto_tag = !global[:noauto]
1136
+
1111
1137
  wwid.config[:include_notes] = false unless global[:notes]
1138
+
1112
1139
  if global[:version]
1113
1140
  $stdout.puts "doing v" + Doing::VERSION
1114
1141
  end
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.24'
2
+ VERSION = '1.0.31'
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'] ||= []
@@ -131,13 +195,22 @@ class WWID
131
195
 
132
196
  @config[:include_notes] ||= true
133
197
 
134
- File.open(@config_file, 'w') { |yf| YAML::dump(@config, yf) } unless @config == user_config
198
+ # if ENV['DOING_DEBUG'].to_i == 3
199
+ # if @config['default_tags'].length > 0
200
+ # raise "DEFAULT CONFIG CHANGED"
201
+ # end
202
+ # end
203
+
204
+ unless File.exists?(@config_file)
205
+ File.open(@config_file, 'w') { |yf| YAML::dump(@config, yf) }
206
+ end
135
207
 
136
208
  @config = @local_config.deep_merge(@config)
137
209
 
138
210
  @current_section = @config['current_section']
139
211
  @default_template = @config['templates']['default']['template']
140
- @default_date_format = @config['templates']['default']['date_format']
212
+ @default_date_format = @config['templates']['default']['date_format'];
213
+
141
214
 
142
215
  end
143
216
 
@@ -237,58 +310,6 @@ class WWID
237
310
  end
238
311
  end
239
312
 
240
- ##
241
- ## @brief Finds a project-specific configuration file
242
- ##
243
- ## @return (String) A file path
244
- ##
245
- def find_local_config
246
-
247
- config = {}
248
- dir = Dir.pwd
249
-
250
- local_config_files = []
251
-
252
- while (dir != '/' && (dir =~ /[A-Z]:\//) == nil)
253
- if File.exists? File.join(dir, @default_config_file)
254
- local_config_files.push(File.join(dir, @default_config_file))
255
- end
256
-
257
- dir = File.dirname(dir)
258
- end
259
-
260
- local_config_files
261
- end
262
-
263
- ##
264
- ## @brief Reads a configuration.
265
- ##
266
- def read_config
267
- if Dir.respond_to?('home')
268
- @config_file = File.join(Dir.home, @default_config_file)
269
- else
270
- @config_file = File.join(File.expand_path("~"), @default_config_file)
271
- end
272
- # @doingrc_needs_update = true if File.exists? @config_file
273
- additional_configs = find_local_config
274
-
275
- begin
276
- @local_config = {}
277
-
278
- @config = YAML.load_file(@config_file) || {} if File.exists?(@config_file)
279
- additional_configs.each { |cfg|
280
- new_config = YAML.load_file(cfg) || {} if cfg
281
- @local_config = @local_config.deep_merge(new_config)
282
- }
283
-
284
- # @config.deep_merge(@local_config)
285
- rescue
286
- @config = {}
287
- @local_config = {}
288
- # raise "error reading config"
289
- end
290
- end
291
-
292
313
  ##
293
314
  ## @brief Create a process for an editor and wait for the file handle to return
294
315
  ##
@@ -393,7 +414,7 @@ class WWID
393
414
  if qty.strip =~ /^(\d+):(\d\d)$/
394
415
  minutes += $1.to_i * 60
395
416
  minutes += $2.to_i
396
- elsif qty.strip =~ /^(\d+)([hmd])?$/
417
+ elsif qty.strip =~ /^(\d+(?:\.\d+)?)([hmd])?$/
397
418
  amt = $1
398
419
  type = $2.nil? ? "m" : $2
399
420
 
@@ -561,21 +582,26 @@ class WWID
561
582
  opt[:timed] ||= false
562
583
 
563
584
  title = [title.strip.cap_first]
564
- title = autotag(title.join(' '))
565
- unless @config['default_tags'].empty?
566
- title += @config['default_tags'].map{|t|
567
- unless t.nil?
568
- dt = t.sub(/^ *@/,'').chomp
569
- if title =~ /@#{dt}/
570
- ""
571
- else
572
- ' @' + 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
573
598
  end
574
- end
575
- }.delete_if {|t| t == "" }.join(" ")
599
+ }.delete_if {|t| t == "" }.join(" ")
600
+ end
576
601
  end
602
+ title.gsub!(/ +/,' ')
577
603
  entry = {'title' => title.strip, 'date' => opt[:back]}
578
- unless opt[:note] =~ /^\s*$/s
604
+ unless opt[:note].join('').strip == ''
579
605
  entry['note'] = opt[:note].map {|n| n.gsub(/ *$/,'')}
580
606
  end
581
607
  items = @content[section]['items']
@@ -615,7 +641,11 @@ class WWID
615
641
  if @content.has_key?(section)
616
642
  last_item = @content[section]['items'].dup.sort_by{|item| item['date'] }.reverse[0]
617
643
  $stderr.puts "Editing note for #{last_item['title']}"
618
- return "#{last_item['title']}\n# EDIT BELOW THIS LINE ------------\n#{last_item['note'].map{|line| line.strip }.join("\n")}"
644
+ note = ''
645
+ unless last_item['note'].nil?
646
+ note = last_item['note'].map{|line| line.strip }.join("\n")
647
+ end
648
+ return "#{last_item['title']}\n# EDIT BELOW THIS LINE ------------\n#{note}"
619
649
  else
620
650
  raise "Section #{section} not found"
621
651
  end
@@ -707,7 +737,13 @@ class WWID
707
737
  }
708
738
  item['title'] = title
709
739
  else
710
- item['title'] = autotag(item['title'])
740
+ new_title = autotag(item['title']) if @auto_tag
741
+ unless new_title == item['title']
742
+ @results.push("Tags updated: #{new_title}")
743
+ item['title'] = new_title
744
+ else
745
+ @results.push(%Q{Autotag: No changes})
746
+ end
711
747
  end
712
748
 
713
749
  index += 1
@@ -772,7 +808,7 @@ class WWID
772
808
  elsif current_note.length > 0 && note.length > 0
773
809
  @results.push(%Q{Replaced note from "#{title}"})
774
810
  elsif note.length > 0
775
- @results.push(%Q{Added note to #{title}})
811
+ @results.push(%Q{Added note to "#{title}"})
776
812
  else
777
813
  @results.push(%Q{Entry "#{title}" has no note})
778
814
  end
@@ -898,7 +934,7 @@ class WWID
898
934
  sections.each_with_index {|section, i|
899
935
  puts "% 3d: %s" % [i+1, section]
900
936
  }
901
- print "> "
937
+ print "#{colors['green']}> #{colors['default']}"
902
938
  num = STDIN.gets
903
939
  return false if num =~ /^[a-z ]*$/i
904
940
  return sections[num.to_i - 1]
@@ -1637,9 +1673,13 @@ EOS
1637
1673
  #
1638
1674
  def autotag(text)
1639
1675
  return unless text
1676
+ return text unless @auto_tag
1677
+ current_tags = text.scan(/@\w+/)
1678
+ whitelisted = []
1640
1679
  @config['autotag']['whitelist'].each {|tag|
1641
1680
  text.sub!(/(?<!@)(#{tag.strip})\b/i) do |m|
1642
1681
  m.downcase! if tag =~ /[a-z]/
1682
+ whitelisted.push("@#{m}")
1643
1683
  "@#{m}"
1644
1684
  end unless text =~ /@#{tag}\b/i
1645
1685
  }
@@ -1647,12 +1687,19 @@ EOS
1647
1687
  @config['autotag']['synonyms'].each {|tag, v|
1648
1688
  v.each {|word|
1649
1689
  if text =~ /\b#{word}\b/i
1650
- tail_tags.push(tag)
1690
+ unless current_tags.include?("@#{tag}") || whitelisted.include?("@#{tag}")
1691
+ tail_tags.push(tag)
1692
+ end
1651
1693
  end
1652
1694
  }
1653
1695
  }
1696
+ if whitelisted.length > 0
1697
+ @results.push("Whitelisted tags: #{whitelisted.join(', ')}")
1698
+ end
1654
1699
  if tail_tags.length > 0
1655
- text + ' ' + tail_tags.uniq.map {|t| '@'+t }.join(' ')
1700
+ tags = tail_tags.uniq.map {|t| '@'+t }.join(' ')
1701
+ @results.push("Synonym tags: #{tags}")
1702
+ text + ' ' + tags
1656
1703
  else
1657
1704
  text
1658
1705
  end
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.24
4
+ version: 1.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-10 00:00:00.000000000 Z
11
+ date: 2020-06-17 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
@@ -216,7 +216,7 @@ 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
219
+ rubygems_version: 3.0.3
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: A command line tool for managing What Was I Doing reminders