dayrb 2.0.4 → 2.0.6

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
- SHA1:
3
- metadata.gz: 9bd54d621f2ea27a6da4f10359e31ff7a365c9d1
4
- data.tar.gz: 15e902f847d739d4d13fac1a05ec6e5ebe473e74
2
+ SHA256:
3
+ metadata.gz: 9b6f1afc79261b757970a6e47e2da8bffc713f9821aac8e4a8a02510abb81a47
4
+ data.tar.gz: 7ef06747b200c3a5c8f3ac4689a08d9f4cc4a4568345160d3fa8653baf9c5fb8
5
5
  SHA512:
6
- metadata.gz: 89b92e1d09a1501b9a12816f5661c299eebce95948cc1b838d6a212f54e1b60409c81a5bdc676b1c43116e0bcd996c9b758756223aa0d4c9952632cbe9c00b59
7
- data.tar.gz: 4097d69eeb3ea33c1806db806c61dc92e3d271b1bf179eea1fc33c56dc675d0cb1bd60134c7fb9d39e5868dc8ade11f3c69aadc44f7b17e6dd4d5a68c80c880a
6
+ metadata.gz: b314afd5732ab2a55b7df56c2fc0ce54cc03a503ee8d9b171c19ba7a14d47c82a6fdf363687c51f243020272afcfacc0436e7c5e6ff0440088e782db909e7c5e
7
+ data.tar.gz: 5cc0177bfe74c6df42b5545dc7ea426ed9c1a0d4f5a38075adb7f25057a8af7ca2c67848d27ed25b81cc882f0873749fb86ee937e39f54fd1aee2a4aae013ce6
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  The MIT License (MIT)
2
- Copyright © 2014 Cameron Carroll, http://ckcarroll.herokuapp.com
2
+ Copyright © 2024 Cam Carroll, http://ieve.me
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
5
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.4
1
+ 2.0.6
data/bin/day.rb CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  # DayRB Main File
4
4
  # Day.rb is a minimalistic command-line to-do and time-tracking application.
5
- # Created in July 2013
5
+ # Created in July 2013, last updated September 2024
6
6
  # See 'day.rb help' for usage.
7
7
  #
8
- # MIT License; See LICENSE file; Cameron Carroll 2015
8
+ # MIT License; See LICENSE file; Cam Carroll 2024
9
9
 
10
10
  require_relative '../lib/day/configuration'
11
11
  require_relative '../lib/day/tasklist'
@@ -14,14 +14,14 @@ require_relative '../lib/day/presenter'
14
14
 
15
15
  require 'fileutils'
16
16
 
17
- VERSION = '2.0.4'
17
+ VERSION = '2.0.6'
18
18
 
19
19
  #-------------- User Configuration:
20
20
  #-------------- Please DO edit the following to your liking:
21
21
 
22
22
  # Configuration File: Stores tasks and their data
23
- CONFIG_DIR = ENV['HOME'] + '/.config/dayrb/'
24
- CONFIG_FILE = CONFIG_DIR + 'daytodo'
23
+ CONFIG_DIR = ENV['HOME'] + '/.config/'
24
+ CONFIG_FILE = CONFIG_DIR + 'dayrb_config_file'
25
25
 
26
26
  # Colorization:
27
27
  # Use ANSI color codes...
@@ -41,6 +41,8 @@ EDITOR = 'vim'
41
41
  #--------------
42
42
 
43
43
  #[CUT HERE] Used in build script. Please don't remove.
44
+ # Note as of September 2024 - I don't remember what the build script was even supposed to do? Or where it is?
45
+ # ?? I published the new version to Rubygems and it seemed to work, so I have no idea.
44
46
 
45
47
  #-------------- Monkey-Patch Definitions:
46
48
 
@@ -87,11 +89,9 @@ class String
87
89
  end
88
90
 
89
91
  #-------------- Application Logic:
92
+ FileUtils.mkdir_p(CONFIG_DIR) unless Dir.exist? CONFIG_DIR
90
93
 
91
- FileUtils.mkdir_p(CONFIG_DIR) unless Dir.exists? CONFIG_DIR
92
-
93
- db = YAML::DBM.new(CONFIG_FILE)
94
- config = Configuration.new(db)
94
+ config = Configuration.new(CONFIG_FILE)
95
95
  opts = Parser.parse_options(config)
96
96
 
97
97
  # TODO: Simplify following logic, we don't need so many variables.
@@ -109,10 +109,10 @@ end
109
109
 
110
110
  # Easier (named) access to config and opts:
111
111
  new_context = opts[:task]
112
- current_context = config.data['context']
112
+ current_context = config.context
113
113
  # If we were already tracking a task when program was called,
114
114
  # this refers to the time spent in that task:
115
- old_time = Time.now - config.data['entry_time'] if config.data['entry_time']
115
+ old_time = Time.now - config.entry_time if config.entry_time
116
116
 
117
117
  # Take action based on operation:
118
118
  case opts[:operation]
@@ -137,7 +137,7 @@ when :leave
137
137
  Presenter.announce_leave_context(current_context, old_time)
138
138
  config.clear_context
139
139
  when :delete
140
- confirmation = Presenter.confirm_deletion(new_context, config.data['tasks'][new_context]['description'])
140
+ confirmation = Presenter.confirm_deletion(new_context, config.tasks[new_context]['description'])
141
141
  if confirmation
142
142
  config.delete(new_context)
143
143
  end
@@ -145,5 +145,4 @@ else
145
145
  Presenter.print_error_unknown
146
146
  end
147
147
 
148
- config.save
149
- db.close
148
+ config.save(CONFIG_FILE)
data/changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ 2.0.5 (aka 2.0.6 because I'm dumb) -- 09/18/2024
2
+ -------------------
3
+ * Bug fix: Replaced deprecated File.exists? method with .exist?
4
+ * Bug fix: Replaced (seemingly) deprecated yaml/dbm library - using psych directly instead to load config yaml file.
5
+ * Bug fix: Reorganized YAML file bootstrapping code to ensure we always load config data (previously a bootstrap run would not initialize config data class variables)
6
+
1
7
  2.0.4 -- 03/20/14
2
8
  -------------------
3
9
 
@@ -22,7 +28,7 @@
22
28
 
23
29
  ### Bug Fixes:
24
30
 
25
- * Changed shebang to user /usr/bin/env ruby instead of /usr/bin/ruby.
31
+ * Changed shebang to use /usr/bin/env ruby instead of /usr/bin/ruby.
26
32
  * Fixed some spec regressions.
27
33
 
28
34
  2.0.1 -- 08/12/14
data/dayrb.gemspec CHANGED
@@ -1,14 +1,15 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dayrb'
3
- s.version = '2.0.4'
3
+ s.version = '2.0.6'
4
+ s.required_ruby_version = '>= 3.0'
4
5
  s.summary = "To-do & Time-Tracking CLI App"
5
6
  s.description = "Create and track time on tasks via command-line."
6
- s.authors = ["Cameron Carroll"]
7
+ s.authors = ["Cam Carroll"]
7
8
  s.email = 'ckcarroll4@gmail.com'
8
9
  s.files = `git ls-files`.split($/)
9
10
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
10
11
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
11
12
  s.homepage =
12
- 'http://github.com/sanarothe/day'
13
+ 'http://github.com/CameronCarroll/day'
13
14
  s.license = 'MIT'
14
15
  end
@@ -1,10 +1,10 @@
1
1
  # DayRB Configuration (Data-Access Layer) Module
2
2
  #
3
- # Provides convenience methods for database access and holds db data.
3
+ # Provides convenience methods for database access and holds config data.
4
4
  #
5
- # MIT License; See LICENSE file; Cameron Carroll 2014
5
+ # MIT License; See LICENSE file; Cameron Carroll 2024
6
6
 
7
- require 'yaml/dbm'
7
+ require 'psych'
8
8
 
9
9
  # Config class handles access to our config file, which mostly just provides a data-access layer.
10
10
  # Schema:
@@ -22,15 +22,26 @@ require 'yaml/dbm'
22
22
  # }
23
23
 
24
24
  class Configuration
25
- attr_reader :data, :context, :entry_time
25
+ attr_reader :tasks, :context, :entry_time
26
26
 
27
- # Load DB data and bootstrap it if empty.
27
+ # Load config data from file -- bootstrap it if empty.
28
28
  #
29
- # @param db [PSYCH::DBM] database (hash-like) initialized and closed by caller.
30
- def initialize(db)
31
- @db = db
32
- @data = @db.to_hash
33
- bootstrap_db if @data.empty?
29
+ # @param data_file Location of task data file on local drive.
30
+ def initialize(data_file)
31
+
32
+ unless File.exist? data_file
33
+ bootstrap_db(data_file)
34
+ puts "day.rb created new config file " + CONFIG_FILE
35
+ end
36
+
37
+ if File.exist? data_file
38
+ loaded_data = Psych.safe_load_file(data_file, permitted_classes: [Time, Symbol])
39
+ @context = loaded_data[:context]
40
+ @entry_time = loaded_data[:entry_time]
41
+ @tasks = loaded_data[:tasks]
42
+ else
43
+ puts "Error creating / loading config file"
44
+ end
34
45
  end
35
46
 
36
47
  # Interface to save_task which decomposes opts hash.
@@ -45,15 +56,15 @@ class Configuration
45
56
  #
46
57
  # @param next_key [String] the name of the task to switch to.
47
58
  def switch_to(next_key)
48
- cap_current_fulfillment if @data['context']
49
- @data['context'] = next_key if @data['tasks'].has_key?(next_key)
50
- @data['entry_time'] = Time.now.getutc
59
+ cap_current_fulfillment if @context
60
+ @context = next_key if @tasks.has_key?(next_key)
61
+ @entry_time = Time.now.getutc
51
62
  end
52
63
 
53
64
  # Exit context without switching to a new one.
54
65
  def clear_context()
55
66
  cap_current_fulfillment
56
- @data['context'], @data['entry_time'] = nil, nil
67
+ @context, @entry_time = nil, nil
57
68
  end
58
69
 
59
70
  # Clear fulfillment for one or all tasks.
@@ -63,7 +74,7 @@ class Configuration
63
74
  if task
64
75
  clear_fulfillment_for task
65
76
  else
66
- @data['tasks'].each do |task, task_data|
77
+ @tasks.each do |task, task_data|
67
78
  clear_fulfillment_for task
68
79
  end
69
80
  end
@@ -76,20 +87,26 @@ class Configuration
76
87
  #
77
88
  # @param task_key [String] Valid task name to delete.
78
89
  def delete(task_key)
79
- @data['tasks'].delete task_key
90
+ @tasks.delete task_key
80
91
  end
81
92
 
82
93
  # Reload class objects from config data.
83
94
  # (Used during testing.)
84
95
  def reload()
85
- @context = @data['context']
86
- @entry_time = @data['entry_time']
96
+ @context = @context
97
+ @entry_time = @entry_time
87
98
 
88
99
  end
89
100
 
90
- # To be called at the very end of the script to write data back into YAML::DBM
91
- def save()
92
- @db.replace(@data)
101
+ # To be called at the very end of the script to write data back into YAML
102
+ def save(data_file)
103
+ data = {
104
+ context: @context,
105
+ entry_time: @entry_time,
106
+ tasks: @tasks }
107
+ File.open(data_file, 'w') do |file|
108
+ file.write(Psych.dump(data))
109
+ end
93
110
  end
94
111
 
95
112
  # Used to verify that a task actually exists and to cross-reference indices to names
@@ -97,9 +114,9 @@ class Configuration
97
114
  # @param task [String] name or index reference to task
98
115
  def lookup_task(task)
99
116
  if task.number?
100
- @data['tasks'].keys[task.to_i]
117
+ @tasks.keys[task.to_i]
101
118
  else
102
- task if @data['tasks'].has_key? task
119
+ task if @tasks.has_key? task
103
120
  end
104
121
  end
105
122
 
@@ -113,28 +130,33 @@ class Configuration
113
130
  # @param estimate [String] a time estimate in integer minutes.
114
131
  def save_task(task, description, valid_days, estimate)
115
132
  if task
116
- @data['tasks'][task] = {'description' => description, 'valid_days' => valid_days,
133
+ @tasks[task] = {'description' => description, 'valid_days' => valid_days,
117
134
  'estimate' => estimate, 'fulfillment' => nil}
118
135
  end
119
136
  end
120
137
 
121
138
  # Builds initial structure for the database file.
122
- def bootstrap_db
123
- @data['context'] = nil
124
- @data['entry_time'] = nil
125
- @data['tasks'] = {}
139
+ def bootstrap_db(data_file)
140
+ data = {
141
+ context: nil,
142
+ entry_time: nil,
143
+ tasks: {} }
144
+
145
+ File.open(data_file, 'w') do |file|
146
+ file.write(Psych.dump(data))
147
+ end
126
148
  end
127
149
 
128
150
  # Add the elapsed time since entering a context. (Used when exiting that context.)
129
151
  def cap_current_fulfillment
130
- @data['tasks'][@data['context']]['fulfillment'] ||= 0
131
- @data['tasks'][@data['context']]['fulfillment'] += Time.now - @data['entry_time']
152
+ @tasks[@context]['fulfillment'] ||= 0
153
+ @tasks[@context]['fulfillment'] += Time.now - @entry_time
132
154
  end
133
155
 
134
156
  # Actually modify fulfillment data for a task.
135
157
  #
136
158
  # @param task [String] Valid task name to verify data for.
137
159
  def clear_fulfillment_for(task)
138
- @data['tasks'][task]['fulfillment'] = nil
160
+ @tasks[task]['fulfillment'] = nil
139
161
  end
140
162
  end
data/lib/day/parser.rb CHANGED
@@ -51,7 +51,7 @@ module Parser
51
51
  demand_second_argument
52
52
  when :switch
53
53
  task = lookup_task(ARGV.first)
54
- if task && @config.data['context'] == task
54
+ if task && @config.context == task
55
55
  opts[:operation] = :leave
56
56
  nil
57
57
  elsif task
data/lib/day/tasklist.rb CHANGED
@@ -14,7 +14,7 @@ class Tasklist
14
14
 
15
15
  def initialize(config)
16
16
  @config = config
17
- @all_tasks = load_tasks(config.data['tasks'])
17
+ @all_tasks = load_tasks(config.tasks)
18
18
  today = Time.new.strftime("%A").downcase.to_sym
19
19
  @valid_tasks = @all_tasks.select do |task_name, task_object|
20
20
  if task_object.valid_days
data/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  day.rb
2
2
  ======
3
- (Version 2.0.4 -- March 2015)
3
+ (Version 2.0.6 -- March 2024)
4
4
 
5
5
  A command-line to-do & time-tracking application.
6
6
 
@@ -9,7 +9,7 @@ A command-line to-do & time-tracking application.
9
9
 
10
10
  Requirements:
11
11
  -------------
12
- * Ruby (Tested with 2.1.2)
12
+ * Ruby (Tested with 3.2.5 in Sept 2024 -- I set minimum ruby version arbitrarily at 3.0 because a lot of stuff needed fixing since the last version from ~2015, I'm not sure what the real minimum version is.)
13
13
 
14
14
  Installation:
15
15
  -------------
@@ -20,7 +20,7 @@ Installation:
20
20
 
21
21
  ### Method 2: Clone the Repository (Entire Folder)
22
22
 
23
- * Clone the repository to your favorite apps folder. (git clone https://github.com/sanarothe/day.git ~/apps)
23
+ * Clone the repository to your favorite apps folder. (git clone https://github.com/CameronCarroll/day.git ~/apps)
24
24
  * Symlink day.rb into your favorite bin folder. (ln -s ~/apps/day/bin/day.rb ~/bin/day)
25
25
  * Chmod it to be executable (chmod +x ~/bin/day)
26
26
 
@@ -66,6 +66,8 @@ Examples
66
66
  # Note 'vim' can be changed to any editor atop day.rb file.
67
67
  day.rb my_new_task vim
68
68
 
69
- Copyright 2015 - Cameron Carroll
69
+
70
+
71
+ Copyright 2024 - Cam Carroll
70
72
 
71
73
  License: MIT
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dayrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
- - Cameron Carroll
8
- autorequire:
7
+ - Cam Carroll
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-22 00:00:00.000000000 Z
11
+ date: 2024-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Create and track time on tasks via command-line.
14
14
  email: ckcarroll4@gmail.com
@@ -32,11 +32,11 @@ files:
32
32
  - spec/configuration_spec.rb
33
33
  - spec/parser_spec.rb
34
34
  - spec/spec_helper.rb
35
- homepage: http://github.com/sanarothe/day
35
+ homepage: http://github.com/CameronCarroll/day
36
36
  licenses:
37
37
  - MIT
38
38
  metadata: {}
39
- post_install_message:
39
+ post_install_message:
40
40
  rdoc_options: []
41
41
  require_paths:
42
42
  - lib
@@ -44,16 +44,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.0'
48
48
  required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
- rubyforge_project:
55
- rubygems_version: 2.4.5
56
- signing_key:
54
+ rubygems_version: 3.5.19
55
+ signing_key:
57
56
  specification_version: 4
58
57
  summary: To-do & Time-Tracking CLI App
59
58
  test_files: