fewald-worklog 0.2.11 → 0.2.13

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: d1bb6e2ee81700ee384981acfa68bfde33ba9d2e5e7d0af30b0c08c392bde042
4
- data.tar.gz: ac0fa2e1c558f97bc11cdcb145e5a1b8eb12fd0ca661dd932f545108b0386732
3
+ metadata.gz: 190a52d7236e8befad053e79f9fbba8f32f149e354695148a73b732b21172e6b
4
+ data.tar.gz: 5bbd3f3a1200119a20288eb59889bd7498c8d08a01e6ebbc1506b95dd8233e38
5
5
  SHA512:
6
- metadata.gz: 5dcae260eadbe46143a35b2dab7a6c3e780104d5b95dbeef0b439f52613e2dcc4ffa014d2963947715700feca90a88ec9c814fa5a7b90bea56068262b8bd8891
7
- data.tar.gz: a4eedd1a9d6e7395fdfd7a758c90548e1eccc62195c80fb6475433500c4a376b67b3ba1e6ab857f9048234b643670f9b814908941093f9881be3d8d4aedb31b3
6
+ metadata.gz: a2a075eeda5349c0190ce4a6420c5bd6b34759ffdf11845227f9c4fc89d2b522ba095c5059abb19b8c4508c7eaf0a2faf72ac6a980844bd89e6d5dde7d982052
7
+ data.tar.gz: 8af5b16a3b3288f5c124d59442d76e83a0d6743ad5a34de5d4c930d3217c0277809082c8fe9c4b2045bf77311c03617b4fb9d5c4b9f495045b737d9a21345efc
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.11
1
+ 0.2.13
data/bin/wl CHANGED
@@ -6,12 +6,13 @@
6
6
  if ENV['WL_PATH']
7
7
  # Import the worklog CLI from the path specified in the WL_PATH environment variable
8
8
  # This is used during development to avoid having to rely on the order of the $PATH.
9
- puts "Loading worklog from #{ENV['WL_PATH']}. This should only be used during development."
10
- puts 'To use the installed worklog, unset the WL_PATH environment variable.'
9
+ warn "Loading worklog from #{ENV['WL_PATH']}. This should only be used during development."
10
+ warn 'To use the installed worklog, unset the WL_PATH environment variable.'
11
11
  $LOAD_PATH.unshift File.join(ENV['WL_PATH'], 'lib')
12
12
  require 'cli'
13
13
  else
14
14
  require_relative '../lib/cli'
15
15
  end
16
16
 
17
+ # Start the Worklog CLI application (Thor application)
17
18
  WorklogCLI.start
data/lib/cli.rb CHANGED
@@ -30,7 +30,7 @@ class WorklogCLI < Thor
30
30
 
31
31
  # Initialize the CLI with the given arguments, options, and configuration
32
32
  def initialize(args = [], options = {}, config = {})
33
- @config = load_configuration
33
+ @config = Worklog::Configuration.load
34
34
  @storage = Storage.new(@config)
35
35
  super
36
36
  end
data/lib/configuration.rb CHANGED
@@ -3,32 +3,37 @@
3
3
  require 'worklogger'
4
4
  require 'yaml'
5
5
 
6
- # Configuration class for the application.
7
- class Configuration
8
- attr_accessor :storage_path, :log_level, :webserver_port
6
+ module Worklog
7
+ # Configuration class for the application.
8
+ class Configuration
9
+ attr_accessor :storage_path, :log_level, :webserver_port
9
10
 
10
- def initialize(&block)
11
- block.call(self) if block_given?
11
+ def initialize(&block)
12
+ block.call(self) if block_given?
12
13
 
13
- # Set default values if not set
14
- @storage_path ||= File.join(Dir.home, '.worklog')
15
- @log_level ||= :info
16
- @webserver_port ||= 3000
17
- end
18
- end
14
+ # Set default values if not set
15
+ @storage_path ||= File.join(Dir.home, '.worklog')
16
+ @log_level = log_level || :info
17
+ @log_level = @log_level.to_sym if @log_level.is_a?(String)
18
+ @webserver_port ||= 3000
19
+ end
20
+
21
+ # Load configuration from a YAML file in the user's home directory.
22
+ # If the file does not exist, it will use default values.
23
+ # @return [Configuration] the loaded configuration
24
+ def self.load
25
+ file_path = File.join(Dir.home, '.worklog.yaml')
26
+ config = Configuration.new
27
+ if File.exist?(file_path)
28
+ file_cfg = YAML.load_file(file_path)
29
+ config.storage_path = file_cfg['storage_path'] if file_cfg['storage_path']
30
+ config.log_level = file_cfg['log_level'].to_sym if file_cfg['log_level']
31
+ config.webserver_port = file_cfg['webserver_port'] if file_cfg['webserver_port']
32
+ else
33
+ WorkLogger.debug "Configuration file does not exist in #{file_path}, using defaults."
34
+ end
19
35
 
20
- # Load configuration from a YAML file.
21
- # The file should be located at ~/.worklog.yaml.
22
- def load_configuration
23
- file_path = File.join(Dir.home, '.worklog.yaml')
24
- if File.exist?(file_path)
25
- file_cfg = YAML.load_file(file_path)
26
- Configuration.new do |cfg|
27
- cfg.storage_path = file_cfg['storage_path'] if file_cfg['storage_path']
28
- cfg.log_level = file_cfg['log_level'].to_sym if file_cfg['log_level']
29
- cfg.webserver_port = file_cfg['webserver_port'] if file_cfg['webserver_port']
36
+ config
30
37
  end
31
- else
32
- WorkLogger.debug "Configuration file does not exist in #{file_path}"
33
38
  end
34
39
  end
data/lib/editor.rb CHANGED
@@ -7,7 +7,7 @@ require 'tempfile'
7
7
  module Editor
8
8
  EDITOR_PREAMBLE = ERB.new <<~README
9
9
  # Edit the content below, then save the file and quit the editor.
10
- # The update content will be saved. The content MUST be valid YAML
10
+ # The updated content will be saved. The content MUST be valid YAML
11
11
  # in order for the application to be able to update the records.
12
12
 
13
13
  <%= content %>
data/lib/worklog.rb CHANGED
@@ -5,6 +5,7 @@ require 'optparse'
5
5
  require 'rainbow'
6
6
  require 'yaml'
7
7
 
8
+ require 'configuration'
8
9
  require 'hash'
9
10
  require 'daily_log'
10
11
  require 'date_parser'
@@ -332,6 +333,7 @@ module Worklog
332
333
  rescue Errno::ENOENT
333
334
  raise ProjectNotFoundError, 'No projects found. Please create a project first.'
334
335
  end
336
+ WorkLogger.debug "Project with key '#{project_key}' exists."
335
337
  return if projects.key?(project_key)
336
338
 
337
339
  raise ProjectNotFoundError, "Project with key '#{project_key}' does not exist."
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.11
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald