fewald-worklog 0.2.13 → 0.2.15
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/configuration.rb +20 -0
- data/lib/storage.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25cba6c16164da66d60c6ea7f00d3f37a32b2e0cb2fdefd8be7ea862346542a5
|
4
|
+
data.tar.gz: c094a3fca2e496c9d70684db1fde141695a8db36d1511c4ab01df7764da33e4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10fdaa8f8ca7ee544d5476c22bac3652eda53548a9d439178cc7b4ab8c7fdd904f8831f779146985d2224f6d6395e310f6d692d45e7fed82c5434a989152d527
|
7
|
+
data.tar.gz: c6a472717293fbe7ba7dc6a79175c5a9b305c8a14e5039e4e260594b388e90355899a9cf10cc4e95198a1a5621dc9a6542292bd2afdcaa16521da4b6803dbf4c
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.15
|
data/lib/configuration.rb
CHANGED
@@ -5,6 +5,14 @@ require 'yaml'
|
|
5
5
|
|
6
6
|
module Worklog
|
7
7
|
# Configuration class for the application.
|
8
|
+
# @!attribute [rw] storage_path
|
9
|
+
# @return [String] The path where the application stores its data.
|
10
|
+
# @!attribute [rw] log_level
|
11
|
+
# @return [Symbol] The logging level for the application.
|
12
|
+
# Possible values: :debug, :info, :warn, :error, :fatal
|
13
|
+
# @!attribute [rw] webserver_port
|
14
|
+
# @return [Integer] The port on which the web server runs.
|
15
|
+
# Default is 3000.
|
8
16
|
class Configuration
|
9
17
|
attr_accessor :storage_path, :log_level, :webserver_port
|
10
18
|
|
@@ -35,5 +43,17 @@ module Worklog
|
|
35
43
|
|
36
44
|
config
|
37
45
|
end
|
46
|
+
|
47
|
+
# Check if the storage path exists.
|
48
|
+
# @return [Boolean] true if the storage path exists, false otherwise
|
49
|
+
def storage_path_exist?
|
50
|
+
File.exist?(@storage_path)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Check if the storage path is the default path.
|
54
|
+
# @return [Boolean] true if the storage path is the default, false otherwise
|
55
|
+
def default_storage_path?
|
56
|
+
@storage_path == File.join(Dir.home, '.worklog')
|
57
|
+
end
|
38
58
|
end
|
39
59
|
end
|
data/lib/storage.rb
CHANGED
@@ -13,6 +13,9 @@ class Storage
|
|
13
13
|
|
14
14
|
FILE_SUFFIX = '.yaml'
|
15
15
|
|
16
|
+
# Regular expression to match daily log file names
|
17
|
+
LOG_PATTERN = /\d{4}-\d{2}-\d{2}#{FILE_SUFFIX}\z/
|
18
|
+
|
16
19
|
def initialize(config)
|
17
20
|
@config = config
|
18
21
|
end
|
@@ -28,7 +31,7 @@ class Storage
|
|
28
31
|
|
29
32
|
logs = []
|
30
33
|
Dir.glob(File.join(@config.storage_path, "*#{FILE_SUFFIX}")).map do |file|
|
31
|
-
next
|
34
|
+
next unless file.match?(LOG_PATTERN)
|
32
35
|
|
33
36
|
logs << load_log(file)
|
34
37
|
end
|