trs24 0.1.0

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 +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +4 -0
  4. data/lib/trs24.rb +87 -0
  5. metadata +131 -0
  6. metadata.gz.sig +2 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 601c72c60b2f124718d8e95ba5b74d683293f019278bc47c08bbb22d316f949c
4
+ data.tar.gz: 890d1b051277d97dfc60e3e128575a73d79780de8b69aae7ad059c22ee7958f1
5
+ SHA512:
6
+ metadata.gz: 2d9d3a1894978ded1ae0fa27e5380d3605fc9173d04976b8d9b2159de235e8930f7ed842d900243ddef4f6e269967338e9e9bb3d82c21b2c1a7db6c3fd22b4c4
7
+ data.tar.gz: db606adf926bce017cafa905ea3a204237ce1baf63d12d03eebc142e6b12d66f1163ae44e59a1c1a653cd491108761ada02210c8c40a3aa0eb024b36f260f3b9
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ :�-�;w�OLo���1FJ�~ �s�%}�Ҝ9Iɕ�>���G�̯���=�LT�a�Z�t��B8�s�[� ���>B�-�R��3ĩz���}����f
2
+ EE��W���,��������
3
+ 7^�!���IJ�A~��$ 9�Q�6��M5�I6K.��ٿ
4
+ � @oj�5P�xq��J�q[ ��k%_�B;�5ӿ
data/lib/trs24.rb ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: trs24.rb
4
+
5
+ require 'subunit'
6
+ require 'dynarex'
7
+ require 'mindwords'
8
+
9
+
10
+ class Trs24
11
+ using HashDigx
12
+
13
+ def initialize(lookup, activities, debug: false)
14
+
15
+ @debug = debug
16
+ @mw = MindWords.new(lookup)
17
+ @activities = activities
18
+ collect_times()
19
+
20
+ end
21
+
22
+ def collect_times()
23
+
24
+ rows = @activities.map {|s, t1, t2| [t1, s, ((t2 || Time.now) - t1).round] }
25
+
26
+ doc = Rexle.new(@mw.to_xml)
27
+ @h = LineTree.new(@mw.to_tree).to_h
28
+
29
+ a = rows.map do |time, activity, duration|
30
+
31
+ e = doc.root.element("//[@title='#{activity}']")
32
+ path = e.attributes[:breadcrumb].split(' / ')
33
+ puts 'path: ' + path.inspect if @debug
34
+
35
+ h = @h.digx(path)[:summary]
36
+
37
+ h[:duration] ? h[:duration] += duration : h[:duration] = duration
38
+
39
+ path
40
+ end
41
+
42
+ # tally up the duration
43
+
44
+ a2 = a.uniq.group_by {|x| x[0..-2]}.to_a\
45
+ .map {|key, value| [key, value.map(&:last)] }
46
+
47
+ a2.each do |path, list|
48
+
49
+ list.each do |activity|
50
+
51
+ val = @h.digx(path + [activity])[:summary][:duration]
52
+
53
+ path.length.times.each.with_index do |x,i|
54
+ puts 'path[0..-(i+1)]:' + path[0..-(i+1)].inspect if @debug
55
+ r = @h.digx(path[0..-(i+1)])[:summary]
56
+ puts 'r: ' + r.inspect if @debug
57
+ r[:duration] ? r[:duration] += val : r[:duration] = val
58
+ end
59
+
60
+ end
61
+
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
86
+
87
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trs24
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
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uXwn4U08lwoEt/JgIX7AxrKAJbbwldZFERpLRlrD
30
+ 8TevZFaUfx/tF5yJokU2yWqkwZ6NMn04qEMgEpYi6lEAz5NcJ4z0MY+tWdbzXFja
31
+ GnVFKF2dpIFZmifdvbXdjlL0DUve4BBaqDP1HYAzTOQU2lloUOV6SvMcL1qECaMx
32
+ MoUakLYlgRRPQ+yxwJz15bcClrk2xiGdKSEMd6zMgmwpz9+HuWgn+PlT1uKkUFo7
33
+ sqhQfTXjV1z79Sn+e6NUPWxVT9atpw20UK8tlxYLhJlrNgxqLzfKLcBsFTtPCeyw
34
+ qy9NRVMq0YrrZDmY3aQIY5gNmlGPVgBUJr+CwC4/RGzNRGtXbHCePJEvLpe2JsI5
35
+ Wj3GAiwk+bFGSQGtvqPQ4+tuAzvIyrE9rkJKmponQURHvHWBCtpQm1rt6cjMcsCx
36
+ uh2XVXDOEd6dpWwbX/O9167g
37
+ -----END CERTIFICATE-----
38
+ date: 2021-04-07 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: subunit
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.8'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.8.3
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.8'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.8.3
60
+ - !ruby/object:Gem::Dependency
61
+ name: dynarex
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.8'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.27
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.8'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.8.27
80
+ - !ruby/object:Gem::Dependency
81
+ name: mindwords
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.5'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.7
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.5.7
100
+ description:
101
+ email: james@jamesrobertson.eu
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - lib/trs24.rb
107
+ homepage: https://github.com/jrobertson/trs24
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.10
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: trs24
131
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ��™�?g�d���p��<u l��P��XV��`P��{\�y{�ډ�Mݘ�����d5�O��b���S����{ܫ]�q&�lv���w-�4>\��'+''��:��Ft�5L�<qo����*Mq��f�(�u��eNOfʼn;�@ �(A&4��k�t�D)�\��9�w]�.���a���{⌟s:�By%�cg�?�#�֊��?�iކ#^
2
  C)L��#K�Id���i����tE)��u��T�*ܰp��=3'��G��Ia4���b)���V����_�i���������*��N�Kvb�|G�CY��?���ux�*r�M�ӏ�ߝ3b�:�5����<�7!�
3
+ l�_��MF��̾��4�R��`���9�٢��kr�E