trs24 0.1.0 → 0.1.1

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: 601c72c60b2f124718d8e95ba5b74d683293f019278bc47c08bbb22d316f949c
4
- data.tar.gz: 890d1b051277d97dfc60e3e128575a73d79780de8b69aae7ad059c22ee7958f1
3
+ metadata.gz: 6d5948de892649fa7cec4503a84462e406d09664093669b9d9d3c014bee8ca40
4
+ data.tar.gz: 8505a7f8889ae87505fc330041fe2310d6d6196f1aae03d4f062e90ab2fbea43
5
5
  SHA512:
6
- metadata.gz: 2d9d3a1894978ded1ae0fa27e5380d3605fc9173d04976b8d9b2159de235e8930f7ed842d900243ddef4f6e269967338e9e9bb3d82c21b2c1a7db6c3fd22b4c4
7
- data.tar.gz: db606adf926bce017cafa905ea3a204237ce1baf63d12d03eebc142e6b12d66f1163ae44e59a1c1a653cd491108761ada02210c8c40a3aa0eb024b36f260f3b9
6
+ metadata.gz: b26f3ef8560d596b4e4a8c8506ab584b31ce0f102ef6f5e93679870a7f638a2f3077ee8bdaba58f1cdde41a93fa1f143b5926cdaa9593c1452bbd3ae01038ee6
7
+ data.tar.gz: 6cdeef99fc37e58dc90c646e3b4b45f99c0b2562d8e32976263ef02c575c6ca05472b6df64ea18eeeeb147fdf139cccf2264c0fa824eb9ce733566098ca2431c
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/trs24.rb CHANGED
@@ -13,21 +13,49 @@ class Trs24
13
13
  def initialize(lookup, activities, debug: false)
14
14
 
15
15
  @debug = debug
16
- @mw = MindWords.new(lookup)
16
+ @lookup, _ = RXFHelper.read(lookup)
17
17
  @activities = activities
18
18
  collect_times()
19
19
 
20
20
  end
21
21
 
22
+ def summary()
23
+
24
+ @h.map do |key,value|
25
+
26
+ seconds = value[:summary][:duration]
27
+ next unless seconds
28
+
29
+ [key, Subunit.seconds(seconds).strfunit("%xi")]
30
+
31
+ end.compact.to_h
32
+
33
+ end
34
+
35
+ def to_h()
36
+ @h
37
+ end
38
+
39
+ private
40
+
22
41
  def collect_times()
23
42
 
43
+ words = @lookup.strip.lines.flat_map {|x| x[/.*(?= #)/].split(/ *\| */)}
44
+ new_words = @activities.map(&:first)
45
+ @lookup += "\n" + (new_words - words).map {|x| x + ' #unknown'}.join("\n")
46
+ @lookup += "\nunknown #other"
47
+ puts '@lookup: ' + @lookup.inspect
48
+
49
+ @mw = MindWords.new(@lookup)
24
50
  rows = @activities.map {|s, t1, t2| [t1, s, ((t2 || Time.now) - t1).round] }
25
51
 
52
+ puts 'xml : ' + @mw.to_xml if @debug
26
53
  doc = Rexle.new(@mw.to_xml)
27
54
  @h = LineTree.new(@mw.to_tree).to_h
28
55
 
29
56
  a = rows.map do |time, activity, duration|
30
57
 
58
+ puts 'activity: ' + activity if @debug
31
59
  e = doc.root.element("//[@title='#{activity}']")
32
60
  path = e.attributes[:breadcrumb].split(' / ')
33
61
  puts 'path: ' + path.inspect if @debug
@@ -59,29 +87,7 @@ class Trs24
59
87
 
60
88
  end
61
89
 
62
- end
63
-
64
-
65
- end
66
-
67
- def summary()
68
-
69
- @h.map do |key,value|
70
-
71
- seconds = value[:summary][:duration]
72
- next unless seconds
73
-
74
- duration = Subunit.new(units={minutes:60, hours:60},
75
- seconds: seconds).strfunit("%xi")
76
-
77
- [key, duration]
78
-
79
- end.compact.to_h
80
-
81
- end
82
-
83
- def to_h()
84
- @h
85
- end
90
+ end
86
91
 
92
+ end
87
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trs24
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Wj3GAiwk+bFGSQGtvqPQ4+tuAzvIyrE9rkJKmponQURHvHWBCtpQm1rt6cjMcsCx
36
36
  uh2XVXDOEd6dpWwbX/O9167g
37
37
  -----END CERTIFICATE-----
38
- date: 2021-04-07 00:00:00.000000000 Z
38
+ date: 2021-04-09 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: subunit
@@ -98,7 +98,7 @@ dependencies:
98
98
  - !ruby/object:Gem::Version
99
99
  version: 0.5.7
100
100
  description:
101
- email: james@jamesrobertson.eu
101
+ email: digital.robertson@gmail.com
102
102
  executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
@@ -127,5 +127,5 @@ rubyforge_project:
127
127
  rubygems_version: 2.7.10
128
128
  signing_key:
129
129
  specification_version: 4
130
- summary: trs24
130
+ summary: Accepts a list of activty times and returns a summary of activity duration.
131
131
  test_files: []
metadata.gz.sig CHANGED
Binary file