fewald-worklog 0.2.28 → 0.2.30
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 +4 -4
- data/.version +1 -1
- data/lib/cli.rb +10 -0
- data/lib/project.rb +2 -2
- data/lib/storage.rb +1 -1
- data/lib/takeout.rb +57 -0
- data/lib/worklog.rb +19 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e916debca7f984d8594502f3b859bde2a737ffa6b150eab5727c0fb421f355fa
|
|
4
|
+
data.tar.gz: 03d737038fdb12ff54161114b1ede537ff2f371a3499aee287cda71b3425ecff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 145e2873f416d9a6da8210f863697f8b757b7afbafead62619ba76156cf21e8b2fb87ff1f171a75d98dd853d68205b34aa4913bb1c07eb2a9b49bf32d4fa0500
|
|
7
|
+
data.tar.gz: 91e513051b1fc158fe152703f43671b3a2f13b6428d74a29611fe2d24beeb63924182f0e1f0472b653e894c093fcb1907dc605dfa2f930bab46c4019f03f79cb
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.30
|
data/lib/cli.rb
CHANGED
|
@@ -24,6 +24,7 @@ class WorklogCLI < Thor
|
|
|
24
24
|
attr_accessor :config, :storage
|
|
25
25
|
|
|
26
26
|
include StringHelper
|
|
27
|
+
|
|
27
28
|
class_option :verbose, type: :boolean, aliases: '-v', desc: 'Enable verbose output'
|
|
28
29
|
|
|
29
30
|
package_name 'Worklog'
|
|
@@ -135,6 +136,15 @@ class WorklogCLI < Thor
|
|
|
135
136
|
worklog.tags(tag, options)
|
|
136
137
|
end
|
|
137
138
|
|
|
139
|
+
desc 'takeout', <<~EOF
|
|
140
|
+
Export all work log data as a tar.gz archive. The archive contains all log files and settings.
|
|
141
|
+
The filename will be in the format worklog_takeout_YYYYMMDD_HHMMSS.tar.gz
|
|
142
|
+
EOF
|
|
143
|
+
def takeout
|
|
144
|
+
worklog = Worklog::Worklog.new
|
|
145
|
+
worklog.takeout
|
|
146
|
+
end
|
|
147
|
+
|
|
138
148
|
desc 'server', 'Start the work log server'
|
|
139
149
|
def server
|
|
140
150
|
worklog = Worklog::Worklog.new
|
data/lib/project.rb
CHANGED
data/lib/storage.rb
CHANGED
|
@@ -80,7 +80,7 @@ module Worklog
|
|
|
80
80
|
|
|
81
81
|
if tags_filter
|
|
82
82
|
# Safeguard against entries without any tags, not just empty array
|
|
83
|
-
tmp_logs.entries.keep_if { |entry| entry.tags
|
|
83
|
+
tmp_logs.entries.keep_if { |entry| entry.tags&.intersect?(tags_filter) }
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
logs << tmp_logs if tmp_logs.entries.length > 0
|
data/lib/takeout.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'zlib'
|
|
4
|
+
require 'rubygems/package'
|
|
5
|
+
require 'stringio'
|
|
6
|
+
|
|
7
|
+
module Worklog
|
|
8
|
+
# Exporter for worklog entries to a compressed tarball.
|
|
9
|
+
class Takeout
|
|
10
|
+
# Constructor
|
|
11
|
+
# @param configuration [Configuration] The application configuration
|
|
12
|
+
def initialize(configuration)
|
|
13
|
+
@configuration = configuration
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Retrieves all files from the storage path.
|
|
17
|
+
# @return [Array<String>] List of file paths
|
|
18
|
+
def all_files
|
|
19
|
+
Dir.glob(File.join(@configuration.storage_path, '*')).select { |file| File.file?(file) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Creates a tar.gz archive of all worklog files, including settings.
|
|
23
|
+
# @return [String] The tar.gz data as a binary string
|
|
24
|
+
def to_tar_gz
|
|
25
|
+
tar_io = StringIO.new
|
|
26
|
+
|
|
27
|
+
# Build a mapping of file names to their stats for timestamp preservation
|
|
28
|
+
file_stats = {}
|
|
29
|
+
all_files.each do |file_path|
|
|
30
|
+
file_name = File.basename(file_path)
|
|
31
|
+
file_stats[file_name] = File.stat(file_path)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Gem::Package::TarWriter.new(tar_io) do |tar|
|
|
35
|
+
all_files.each do |file_path|
|
|
36
|
+
file_name = File.basename(file_path)
|
|
37
|
+
File.open(file_path, 'rb') do |file|
|
|
38
|
+
stat = file.stat
|
|
39
|
+
tar.add_file(file_name, stat.mode, stat.mtime) do |tar_file|
|
|
40
|
+
IO.copy_stream(file, tar_file)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Compress the tar data with gzip
|
|
47
|
+
gz_io = StringIO.new
|
|
48
|
+
Zlib::GzipWriter.wrap(gz_io) do |gzip|
|
|
49
|
+
tar_io.rewind
|
|
50
|
+
IO.copy_stream(tar_io, gzip)
|
|
51
|
+
end
|
|
52
|
+
gz_io.rewind
|
|
53
|
+
|
|
54
|
+
gz_io.string
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/worklog.rb
CHANGED
|
@@ -14,9 +14,10 @@ require 'storage'
|
|
|
14
14
|
require 'worklogger'
|
|
15
15
|
require 'string_helper'
|
|
16
16
|
require 'printer'
|
|
17
|
+
require 'project_storage'
|
|
17
18
|
require 'statistics'
|
|
18
19
|
require 'summary'
|
|
19
|
-
require '
|
|
20
|
+
require 'takeout'
|
|
20
21
|
|
|
21
22
|
module Worklog
|
|
22
23
|
# Main class providing all worklog functionality.
|
|
@@ -40,6 +41,7 @@ module Worklog
|
|
|
40
41
|
# ticket: 'TICKET-123')
|
|
41
42
|
class Worklog
|
|
42
43
|
include StringHelper
|
|
44
|
+
|
|
43
45
|
attr_reader :config, :storage
|
|
44
46
|
|
|
45
47
|
def initialize(config = nil)
|
|
@@ -283,6 +285,22 @@ module Worklog
|
|
|
283
285
|
end
|
|
284
286
|
end
|
|
285
287
|
|
|
288
|
+
# Export all work log data as a tar.gz archive.
|
|
289
|
+
# The archive contains all log files and settings.
|
|
290
|
+
# The filename will be in the format worklog_takeout_YYYYMMDD_HHMMSS.tar.gz
|
|
291
|
+
def takeout
|
|
292
|
+
takeout = Takeout.new(@config)
|
|
293
|
+
tar_gz_data = takeout.to_tar_gz
|
|
294
|
+
|
|
295
|
+
filename = "worklog_takeout_#{Time.now.strftime('%Y%m%d_%H%M%S')}.tar.gz"
|
|
296
|
+
File.binwrite(filename, tar_gz_data)
|
|
297
|
+
|
|
298
|
+
WorkLogger.info Rainbow("Created takeout archive: #{filename}").green
|
|
299
|
+
|
|
300
|
+
# Return filename for further processing if needed
|
|
301
|
+
filename
|
|
302
|
+
end
|
|
303
|
+
|
|
286
304
|
# Show overview of all tags used in the work log including their count.
|
|
287
305
|
def tag_overview
|
|
288
306
|
all_logs = @storage.all_days
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fewald-worklog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.30
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Friedrich Ewald
|
|
@@ -137,6 +137,7 @@ files:
|
|
|
137
137
|
- lib/storage.rb
|
|
138
138
|
- lib/string_helper.rb
|
|
139
139
|
- lib/summary.rb
|
|
140
|
+
- lib/takeout.rb
|
|
140
141
|
- lib/templates/favicon.svg.erb
|
|
141
142
|
- lib/templates/index.html.erb
|
|
142
143
|
- lib/version.rb
|
|
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
169
|
- !ruby/object:Gem::Version
|
|
169
170
|
version: '0'
|
|
170
171
|
requirements: []
|
|
171
|
-
rubygems_version: 3.6.
|
|
172
|
+
rubygems_version: 3.6.9
|
|
172
173
|
specification_version: 4
|
|
173
174
|
summary: Command line tool for tracking achievments, tasks and interactions.
|
|
174
175
|
test_files: []
|