Top Level Namespace
Defined Under Namespace
Modules: DateParser, Editor, Hashify, StringHelper, Summary Classes: Configuration, DailyLog, DefaultHeaderMiddleware, Hash, LogEntry, Person, Printer, Statistics, Storage, WorkLogApp, WorkLogResponse, WorkLogServer, WorkLogger, Worklog, WorklogCLI
Constant Summary collapse
- STATS =
Data.define(:total_days, :total_entries, :total_epics, :avg_entries, :first_entry, :last_entry)
Instance Method Summary collapse
-
#current_version ⇒ String
Returns the current version of the gem from ‘.version`.
-
#increment_version(version, part = 'patch') ⇒ String
Increment version number according to SemVer.
- #load_configuration ⇒ Object
Instance Method Details
#current_version ⇒ String
Returns the current version of the gem from ‘.version`. Versioning follows SemVer.
8 9 10 11 |
# File 'worklog/version.rb', line 8 def current_version version_file_path = File.join(Pathname.new(__dir__).parent, '.version') File.read(version_file_path).strip end |
#increment_version(version, part = 'patch') ⇒ String
Increment version number according to SemVer.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'worklog/version.rb', line 17 def increment_version(version, part = 'patch') major, minor, patch = version.split('.').map(&:to_i) case part when 'major' major += 1 minor = 0 patch = 0 when 'minor' minor += 1 patch = 0 when 'patch' patch += 1 end [major, minor, patch].join('.') end |
#load_configuration ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'worklog/configuration.rb', line 19 def load_configuration # TODO: Implement loading configuration from a file file_path = File.join(Dir.home, '.worklog.yaml') if File.exist?(file_path) file_cfg = YAML.load_file(file_path) Configuration.new do |cfg| cfg.storage_path = file_cfg['storage_path'] if file_cfg['storage_path'] cfg.log_level = file_cfg['log_level'].to_sym if file_cfg['log_level'] cfg.webserver_port = file_cfg['webserver_port'] if file_cfg['webserver_port'] end else puts "Configuration file does not exist in #{file_path}" end end |