ptimelog 0.8.0 → 0.9.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ef3bd0d847dd1a258f83f7e1a41123352f4831270d89f550560d0ae802c3f72
4
- data.tar.gz: 4a407b654336ca4e37272dffa964e7abeceb478ffb46d1f54926fa2fec0700a8
3
+ metadata.gz: efde9baef775527079705c4a87dfa656a8df4f186381a88c6ebd51e0cfdfd4c8
4
+ data.tar.gz: d68a4f17937165e47fe381dedade07ab625ae98c426a30c6cf09d806a2b77466
5
5
  SHA512:
6
- metadata.gz: 4441aa2504527e658d29c83903e94a8e939f5f2bfbb529cb2f3cb4dabc57b0766ae0674784888f1696a9a85a5137285064b71edb089218d9bdf38170daf88b47
7
- data.tar.gz: 44265b7b8be6540b726e61919f912c1cbd460636b88b3da2296dc4114f940644b72124fa89f893e67bb7823c104a5948d6227ef6f251ee4e1a1ef4179dc64bf1
6
+ metadata.gz: 439357c8e138db02f373cdefedbcd3abd79e16aa5997a8140449327352e0efbdb436b293989b0a19086fcbe41a07c09e7743a3e68b9945cd885080e31b06f056
7
+ data.tar.gz: 2ca4a1333cd8f21fc07deb995f2ab31b62ada7a8b95286f050bb3f481adbddf85471df28be2c80b5a838c0a91d0e770dbf144830f1349298157161284d545a6f
data/README.md CHANGED
@@ -17,10 +17,10 @@ small tooling to transfer timelog-entries from gtimelog's timelog.txt to the Puz
17
17
  - [x] infer time-account from ticket-format
18
18
  - [x] support user-supplied ticket-parsers
19
19
  - [x] get ticket-parser from tags
20
- - [ ] merge equal adjacent entries into one
20
+ - [x] merge equal adjacent entries into one
21
21
  - [ ] complete login/entry automation
22
22
  - [ ] handle authentication
23
- - [ ] login and store cookie
23
+ - [ ] login and store cookie (https://stackoverflow.com/questions/12399087/curl-to-access-a-page-that-requires-a-login-from-a-different-page#12399176)
24
24
  - [ ] send user and pwd with every request
25
25
  - [ ] make entries
26
26
  - [ ] open day in browser for review
@@ -22,5 +22,6 @@ module Ptimelog
22
22
  autoload :Edit, 'ptimelog/command/edit'
23
23
  autoload :Show, 'ptimelog/command/show'
24
24
  autoload :Upload, 'ptimelog/command/upload'
25
+ autoload :Version, 'ptimelog/command/version'
25
26
  end
26
27
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ptimelog
4
+ module Command
5
+ # Output the Version-Number
6
+ class Version < Base
7
+ def initialize(_arg)
8
+ super(nil)
9
+ end
10
+
11
+ def run
12
+ puts Ptimelog::VERSION
13
+ end
14
+ end
15
+ end
16
+ end
@@ -12,26 +12,60 @@ module Ptimelog
12
12
  next unless date # guard against the machine
13
13
  next unless @date == :all || @date == date # limit to one day if passed
14
14
 
15
- entries[date] = []
16
- start = nil # at the start of the day, we have no previous end
15
+ entries[date] = join_similar(entries_of_day(lines)) # lines |> entries_of_day |> join_similar"
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def timelog
22
+ Timelog.load
23
+ end
17
24
 
18
- lines.each do |line|
19
- entry = Entry.from_timelog(line)
20
- entry.start_time = start
25
+ def entries_of_day(lines)
26
+ entries = []
27
+ start = nil # at the start of the day, we have no previous end
21
28
 
22
- entries[date] << entry if entry.valid?
29
+ lines.each do |line|
30
+ entry = Entry.from_timelog(line)
31
+ entry.start_time = start
23
32
 
24
- start = entry.finish_time # store previous ending for nice display of next entry
25
- end
33
+ entries << entry if entry.valid?
26
34
 
27
- entries
35
+ start = entry.finish_time # store previous ending for nice display of next entry
28
36
  end
37
+
38
+ entries
29
39
  end
30
40
 
31
- private
41
+ def join_similar(list)
42
+ return [] if list.empty?
43
+ return list if list.one?
32
44
 
33
- def timelog
34
- Timelog.load
45
+ one, *tail = list
46
+ two, *rest = tail
47
+
48
+ joined = maybe_join(one, two)
49
+
50
+ if joined.one?
51
+ join_similar(joined + rest)
52
+ else
53
+ [one] + join_similar(tail)
54
+ end
55
+ end
56
+
57
+ def maybe_join(one, two)
58
+ if one.ticket == two.ticket &&
59
+ one.description == two.description &&
60
+ one.finish_time == two.start_time
61
+
62
+ joined = one.dup
63
+ joined.finish_time = two.finish_time
64
+
65
+ [joined]
66
+ else
67
+ [one, two]
68
+ end
35
69
  end
36
70
  end
37
71
  end
@@ -16,5 +16,5 @@
16
16
  # with an improvement. Keep in mind that this is also covered by rspec so I
17
17
  # expect (pun intended) 100% test-coverage for any additional code.
18
18
  module Ptimelog
19
- VERSION = '0.8.0'
19
+ VERSION = '0.9.0'
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ptimelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Viehweger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: naught
@@ -153,6 +153,7 @@ files:
153
153
  - lib/ptimelog/command/edit.rb
154
154
  - lib/ptimelog/command/show.rb
155
155
  - lib/ptimelog/command/upload.rb
156
+ - lib/ptimelog/command/version.rb
156
157
  - lib/ptimelog/configuration.rb
157
158
  - lib/ptimelog/day.rb
158
159
  - lib/ptimelog/deprecation_warning.rb