fewald-worklog 0.2.29 → 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 +9 -0
- data/lib/takeout.rb +57 -0
- data/lib/worklog.rb +18 -1
- metadata +2 -1
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
|
@@ -136,6 +136,15 @@ class WorklogCLI < Thor
|
|
|
136
136
|
worklog.tags(tag, options)
|
|
137
137
|
end
|
|
138
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
|
+
|
|
139
148
|
desc 'server', 'Start the work log server'
|
|
140
149
|
def server
|
|
141
150
|
worklog = Worklog::Worklog.new
|
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.
|
|
@@ -284,6 +285,22 @@ module Worklog
|
|
|
284
285
|
end
|
|
285
286
|
end
|
|
286
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
|
+
|
|
287
304
|
# Show overview of all tags used in the work log including their count.
|
|
288
305
|
def tag_overview
|
|
289
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
|