doing 1.0.63 → 1.0.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/doing +35 -0
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +50 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6ebff7b78368227b7642297b5b88c8f018f0a9049f42478fc070f545421b1c
|
4
|
+
data.tar.gz: bff5c3852e60db87cacaba489f30fcf93fbdb01a8b7e4cba5fd06b6fc23db936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c987d7c4a54bb331a3d9db464c5e35b86b1bcc777418547067b8f3bf609756663990c42b53b12d0f36a536f86b3041943eacd539d4d0cf8d1610ff7f3333801
|
7
|
+
data.tar.gz: 514fa3c1e8acefc9ebfde3e71e517918648b57c6b52c6d2c86bc9fe79d555d158edae4a9a2dc54c91bbfc32962280e328d97e26875114d4e1b0c98f693923b04
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s
|
|
29
29
|
|
30
30
|
## Installation
|
31
31
|
|
32
|
-
The current version of `doing` is <!--VER-->1.0.
|
32
|
+
The current version of `doing` is <!--VER-->1.0.63<!--END VER-->.
|
33
33
|
|
34
34
|
$ [sudo] gem install doing
|
35
35
|
|
data/bin/doing
CHANGED
@@ -1391,6 +1391,41 @@ command :undo do |c|
|
|
1391
1391
|
end
|
1392
1392
|
end
|
1393
1393
|
|
1394
|
+
desc 'Import entries from an external source'
|
1395
|
+
long_desc 'Imports entries from other sources. Currently only handles JSON reports exported from Timing.app.'
|
1396
|
+
arg_name 'PATH'
|
1397
|
+
command [:import] do |c|
|
1398
|
+
c.desc 'Import type'
|
1399
|
+
c.arg_name 'TYPE'
|
1400
|
+
c.flag [:type], default_value: 'timing'
|
1401
|
+
|
1402
|
+
c.desc 'Target section'
|
1403
|
+
c.arg_name 'NAME'
|
1404
|
+
c.flag %i[s section], default_value: wwid.current_section
|
1405
|
+
|
1406
|
+
c.desc 'Tag all imported entries'
|
1407
|
+
c.arg_name 'TAGS'
|
1408
|
+
c.flag [:tag]
|
1409
|
+
|
1410
|
+
c.desc 'Prefix entries with'
|
1411
|
+
c.arg_name 'PREFIX'
|
1412
|
+
c.flag [:prefix]
|
1413
|
+
|
1414
|
+
c.action do |_global_options, options, args|
|
1415
|
+
|
1416
|
+
section = wwid.guess_section(options[:s]) || options[:s].cap_first
|
1417
|
+
|
1418
|
+
if options[:type] =~ /^tim/i
|
1419
|
+
args.each do |path|
|
1420
|
+
wwid.import_timing(path, { section: section, tag: options[:tag], prefix: options[:prefix] })
|
1421
|
+
wwid.write(wwid.doing_file)
|
1422
|
+
end
|
1423
|
+
else
|
1424
|
+
raise 'Invalid import type'
|
1425
|
+
end
|
1426
|
+
end
|
1427
|
+
end
|
1428
|
+
|
1394
1429
|
pre do |global, _command, _options, _args|
|
1395
1430
|
if global[:config_file] && global[:config_file] != wwid.config_file
|
1396
1431
|
wwid.config_file = global[:config_file]
|
data/lib/doing/version.rb
CHANGED
data/lib/doing/wwid.rb
CHANGED
@@ -310,7 +310,7 @@ class WWID
|
|
310
310
|
else
|
311
311
|
@content[section]['items'][current - 1]['note'] = [] unless @content[section]['items'][current - 1].key? 'note'
|
312
312
|
|
313
|
-
@content[section]['items'][current - 1]['note'].push(line.
|
313
|
+
@content[section]['items'][current - 1]['note'].push(line.chomp)
|
314
314
|
# end
|
315
315
|
end
|
316
316
|
end
|
@@ -667,6 +667,55 @@ class WWID
|
|
667
667
|
@results.push(%(Added "#{entry['title']}" to #{section}))
|
668
668
|
end
|
669
669
|
|
670
|
+
##
|
671
|
+
## @brief Imports a Timing report
|
672
|
+
##
|
673
|
+
## @param path (String) Path to JSON report file
|
674
|
+
## @param section (String) The section to add to
|
675
|
+
## @param opt (Hash) Additional Options
|
676
|
+
##
|
677
|
+
def import_timing(path, opt = {})
|
678
|
+
section = opt[:section] || @current_section
|
679
|
+
add_section(section) unless @content.has_key?(section)
|
680
|
+
|
681
|
+
add_tags = opt[:tag] ? opt[:tag].split(/[ ,]+/).map { |t| t.sub(/^@?/, '@') }.join(' ') : ''
|
682
|
+
prefix = opt[:prefix] ? opt[:prefix] : '[Timing.app]'
|
683
|
+
raise "File not found" unless File.exist?(File.expand_path(path))
|
684
|
+
|
685
|
+
data = JSON.parse(IO.read(File.expand_path(path)))
|
686
|
+
new_items = []
|
687
|
+
data.each do |entry|
|
688
|
+
# Only process task entries
|
689
|
+
next if entry.key?('activityType') && entry['activityType'] != 'Task'
|
690
|
+
# Only process entries with a start and end date
|
691
|
+
next unless entry.key?('startDate') && entry.key?('endDate')
|
692
|
+
|
693
|
+
start_time = Time.parse(entry['startDate'])
|
694
|
+
end_time = Time.parse(entry['endDate'])
|
695
|
+
next unless start_time && end_time
|
696
|
+
tags = entry['project'].split(/ ▸ /).map {|proj| proj.gsub(/ +/, '').downcase }
|
697
|
+
title = "#{prefix} "
|
698
|
+
title += entry.key?('activityTitle') && entry['activityTitle'] != '(Untitled Task)' ? entry['activityTitle'] : 'Working on'
|
699
|
+
tags.each do |tag|
|
700
|
+
if title =~ /\b#{tag}\b/i
|
701
|
+
title.sub!(/\b#{tag}\b/i, "@#{tag}")
|
702
|
+
else
|
703
|
+
title += " @#{tag}"
|
704
|
+
end
|
705
|
+
end
|
706
|
+
title = autotag(title) if @auto_tag
|
707
|
+
title += " @done(#{end_time.strftime('%Y-%m-%d %H:%M')})"
|
708
|
+
title.gsub!(/ +/, ' ')
|
709
|
+
title.strip!
|
710
|
+
new_entry = { 'title' => title, 'date' => start_time, 'section' => section }
|
711
|
+
new_entry['note'] = entry['notes'].split(/\n/).map(&:chomp) if entry.key?('notes')
|
712
|
+
new_items.push(new_entry)
|
713
|
+
end
|
714
|
+
|
715
|
+
@content[section]['items'].concat(new_items)
|
716
|
+
@results.push(%(Imported #{new_items.count} items to #{section}))
|
717
|
+
end
|
718
|
+
|
670
719
|
##
|
671
720
|
## @brief Return the content of the last note for a given section
|
672
721
|
##
|
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: 1.0.
|
4
|
+
version: 1.0.64
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|