daily_log 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.byebug_history +8 -0
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +49 -0
- data/History.md +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +95 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/daily_log.gemspec +29 -0
- data/exe/dl +7 -0
- data/lib/daily_log.rb +23 -0
- data/lib/daily_log/day.rb +39 -0
- data/lib/daily_log/entry.rb +89 -0
- data/lib/daily_log/latest_date.rb +46 -0
- data/lib/daily_log/options.rb +53 -0
- data/lib/daily_log/pathname.rb +66 -0
- data/lib/daily_log/scm_check.rb +36 -0
- data/lib/daily_log/version.rb +3 -0
- data/lib/tasks/doc.rake +12 -0
- data/lib/templates/daily_log/entry.md.erb +20 -0
- data/lib/zero_padded.rb +13 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c783c694e311e44ea889b3035e718ae46073bec77e1491d90d907e0c4b1552e
|
4
|
+
data.tar.gz: 01c0fabb78e929c5ada6832fcf436f590849000cfbc7d024e4f09385ff961026
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61039bd2ba30f414c70ce8019c6fead05fb3b78aa3d43ecccdd4d6e4975b4d2631bc4e687ce6e0db5bb1409653fb3d6390e48ea4355bf6e7ed3b58b7c23fad48
|
7
|
+
data.tar.gz: 5bc29134cfa37afeb9f664896e0cb9f0c01015747e9e8464100666681d76253c7b6ac808be393ce5ce99a44f518071577813ca2992f2e871c14952ba99b8b0fe
|
data/.byebug_history
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
|
11
|
+
gem "yard-tomdoc"
|
12
|
+
|
13
|
+
gem "rake"
|
14
|
+
|
15
|
+
gem "irb", "~> 1.2"
|
16
|
+
|
17
|
+
gem "rspec", "~> 3.9"
|
18
|
+
|
19
|
+
gem "byebug"
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
daily_log (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
byebug (11.0.1)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
io-console (0.5.4)
|
12
|
+
irb (1.2.1)
|
13
|
+
reline (>= 0.0.1)
|
14
|
+
rake (13.0.1)
|
15
|
+
reline (0.1.2)
|
16
|
+
io-console (~> 0.5)
|
17
|
+
rspec (3.9.0)
|
18
|
+
rspec-core (~> 3.9.0)
|
19
|
+
rspec-expectations (~> 3.9.0)
|
20
|
+
rspec-mocks (~> 3.9.0)
|
21
|
+
rspec-core (3.9.1)
|
22
|
+
rspec-support (~> 3.9.1)
|
23
|
+
rspec-expectations (3.9.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.9.0)
|
26
|
+
rspec-mocks (3.9.1)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.9.0)
|
29
|
+
rspec-support (3.9.2)
|
30
|
+
tomparse (0.4.2)
|
31
|
+
yard (0.9.23)
|
32
|
+
yard-tomdoc (0.7.1)
|
33
|
+
tomparse (>= 0.4.0)
|
34
|
+
yard
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.17)
|
41
|
+
byebug
|
42
|
+
daily_log!
|
43
|
+
irb (~> 1.2)
|
44
|
+
rake
|
45
|
+
rspec (~> 3.9)
|
46
|
+
yard-tomdoc
|
47
|
+
|
48
|
+
BUNDLED WITH
|
49
|
+
1.17.3
|
data/History.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
n.n.n / 2020-01-07
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Bundle as Rubygem
|
6
|
+
* Update README
|
7
|
+
* Remove YARD files from git repo
|
8
|
+
* Added documentation
|
9
|
+
* Remove .daily_logs from gitignore
|
10
|
+
* Basic working version up and running
|
11
|
+
* Basic text-file is opening
|
12
|
+
* Initial commit
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Bodacious
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# DailyLog
|
2
|
+
|
3
|
+
Provides a simple framework for keeping a daily log of the work you do on a project
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Call the binary `daily_log` to open today's log.
|
8
|
+
|
9
|
+
Pass in the option `--help` to see the other options available.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
``` bash
|
14
|
+
cd /usr/local
|
15
|
+
git clone https://github.com/KatanaCode/daily_log.git
|
16
|
+
alias /usr/local/bin/daily_log /usr/local/daily_log/bin/daily_log
|
17
|
+
```
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
At the end of a working day, you run from your console
|
22
|
+
|
23
|
+
``` bash
|
24
|
+
$ daily_log
|
25
|
+
```
|
26
|
+
|
27
|
+
This opens a text file in your editor that looks like this:
|
28
|
+
|
29
|
+
``` text
|
30
|
+
# Daily Entry - Wed 01 January, 2020
|
31
|
+
|
32
|
+
## Today I worked on:
|
33
|
+
|
34
|
+
- Thing one
|
35
|
+
|
36
|
+
## Next time, you should continue with:
|
37
|
+
|
38
|
+
- Thing two
|
39
|
+
|
40
|
+
## Notes:
|
41
|
+
|
42
|
+
Some optional notes here...
|
43
|
+
|
44
|
+
<!--
|
45
|
+
Automatically generated by DailyLog https://github.com/KatanaCode/daily_log
|
46
|
+
Date: 2020-01-01
|
47
|
+
Project: dailylog
|
48
|
+
By: Yourname
|
49
|
+
-->
|
50
|
+
```
|
51
|
+
|
52
|
+
You edit the file to say:
|
53
|
+
|
54
|
+
``` text
|
55
|
+
# Daily Entry - Wed 01 January, 2020
|
56
|
+
|
57
|
+
## Today I worked on:
|
58
|
+
|
59
|
+
- Adding two-factor authentication for admins
|
60
|
+
|
61
|
+
## Next time, you should continue with:
|
62
|
+
|
63
|
+
- Password management for admins
|
64
|
+
|
65
|
+
## Notes:
|
66
|
+
|
67
|
+
We need to rethink how we handle password resets when user has 2FA enabled
|
68
|
+
|
69
|
+
<!--
|
70
|
+
Automatically generated by DailyLog https://github.com/KatanaCode/daily_log
|
71
|
+
Date: 2020-01-01
|
72
|
+
Project: dailylog
|
73
|
+
By: Yourname
|
74
|
+
-->
|
75
|
+
```
|
76
|
+
|
77
|
+
### A few days later
|
78
|
+
|
79
|
+
Some time has passed since you last worked on the project. You aren't quite sure where to pick up from the last time you worked on it.
|
80
|
+
|
81
|
+
You type:
|
82
|
+
|
83
|
+
```
|
84
|
+
$ daily_log -l # short for daily_log --last
|
85
|
+
```
|
86
|
+
|
87
|
+
...to print out your log to the console.
|
88
|
+
|
89
|
+
## Why bother?
|
90
|
+
|
91
|
+
Managing a log file like this can help you keep your train of thought when interrupted on a project for a few days or longer.
|
92
|
+
|
93
|
+
This is a simple, non-invasive way to leave notes to your future self.
|
94
|
+
|
95
|
+
It's also a great way to take full stock of a project once it's complete. Were your time estimates as accurate as you thought they would be?
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "daily_log"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/daily_log.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "daily_log/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "daily_log"
|
8
|
+
spec.version = DailyLog::VERSION
|
9
|
+
spec.authors = ["Bodacious"]
|
10
|
+
spec.email = ["bodacious@katanacode.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Daily code journal on a per project basis}
|
13
|
+
spec.description = %q{Keep a short, daily log of the work you do within a project repo}
|
14
|
+
spec.homepage = "https://github.com/KatanaCode/daily_log"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
data/exe/dl
ADDED
data/lib/daily_log.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DailyLog
|
4
|
+
|
5
|
+
require_relative "daily_log/options"
|
6
|
+
require_relative "daily_log/latest_date"
|
7
|
+
require_relative "daily_log/scm_check"
|
8
|
+
require_relative "daily_log/day"
|
9
|
+
require_relative "daily_log/entry"
|
10
|
+
require_relative "daily_log/pathname"
|
11
|
+
|
12
|
+
module_function
|
13
|
+
|
14
|
+
# Open or print the Entry file, depending on the options
|
15
|
+
def open_or_print(options = {})
|
16
|
+
@day = Day.new(options[:date])
|
17
|
+
@entry = Entry.new(@day)
|
18
|
+
puts @entry.pathname if options[:path]
|
19
|
+
@entry.print if options[:print]
|
20
|
+
@entry.open if options[:edit]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DailyLog
|
4
|
+
|
5
|
+
# Represents one calendar Day
|
6
|
+
class Day
|
7
|
+
|
8
|
+
##
|
9
|
+
# Format for dates when printed as stringss
|
10
|
+
DATE_FORMAT = "%Y-%m-%d"
|
11
|
+
|
12
|
+
##
|
13
|
+
# The Date object for this Day
|
14
|
+
attr_reader :date
|
15
|
+
|
16
|
+
##
|
17
|
+
# Create a new day
|
18
|
+
#
|
19
|
+
# date - A valid Date object
|
20
|
+
def initialize(date)
|
21
|
+
@date = date
|
22
|
+
end
|
23
|
+
|
24
|
+
# Is this Day today's calendar Date?
|
25
|
+
#
|
26
|
+
# Returns Boolean
|
27
|
+
def today?
|
28
|
+
@date == Date.today
|
29
|
+
end
|
30
|
+
|
31
|
+
# Print the date as a formatted string
|
32
|
+
#
|
33
|
+
# Returns String
|
34
|
+
def to_s
|
35
|
+
date.strftime(DATE_FORMAT)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DailyLog
|
4
|
+
# One Daily Log journal Entry
|
5
|
+
#
|
6
|
+
class Entry
|
7
|
+
require 'erb'
|
8
|
+
require "fileutils"
|
9
|
+
|
10
|
+
##
|
11
|
+
# The Day this Entry is for
|
12
|
+
attr_reader :day
|
13
|
+
|
14
|
+
##
|
15
|
+
# The Pathname of the file to the Entry
|
16
|
+
attr_reader :pathname
|
17
|
+
|
18
|
+
|
19
|
+
##
|
20
|
+
# Default path for the daily entry Markdown template
|
21
|
+
TEMPLATE_PATH = File.join(File.dirname(__FILE__), '..', '..',
|
22
|
+
'lib/templates/daily_log/entry.md.erb')
|
23
|
+
|
24
|
+
|
25
|
+
# Create a new Entry
|
26
|
+
#
|
27
|
+
# day - The Day we're creating a new Entry for
|
28
|
+
def initialize(day)
|
29
|
+
@day = day
|
30
|
+
@pathname = Pathname.new(day.date)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Print the contents of this Entry to STDOUT. If no entry exists, print a
|
34
|
+
# warning.
|
35
|
+
def print
|
36
|
+
if exists?
|
37
|
+
puts file.read
|
38
|
+
else
|
39
|
+
puts "No file exists for date: #{@day}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Open the Entry file in the text editor. If one doens't already exist,
|
44
|
+
# create it for this Day
|
45
|
+
def open
|
46
|
+
ensure!
|
47
|
+
open_in_editor
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def open_in_editor
|
53
|
+
exec("$EDITOR -w #{pathname}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def file
|
57
|
+
@file ||= File.open(pathname, 'r')
|
58
|
+
end
|
59
|
+
|
60
|
+
def local_template_path
|
61
|
+
"./#{Pathname.dirname}/templates.md.erb"
|
62
|
+
end
|
63
|
+
|
64
|
+
def template_path
|
65
|
+
if local_template_exists?
|
66
|
+
local_template_path
|
67
|
+
else
|
68
|
+
TEMPLATE_PATH
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def local_template_exists?
|
73
|
+
File.exist?(local_template_path)
|
74
|
+
end
|
75
|
+
|
76
|
+
def exists?
|
77
|
+
File.exist?(pathname)
|
78
|
+
end
|
79
|
+
|
80
|
+
def ensure!
|
81
|
+
return if exists?
|
82
|
+
FileUtils.mkdir_p(pathname.dirname)
|
83
|
+
template = ERB.new File.read(template_path)
|
84
|
+
File.open(pathname.to_s, "wb") do |file|
|
85
|
+
file.write template.result(binding)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module DailyLog
|
2
|
+
|
3
|
+
# Finds the latest past Date that we have an Entry for in the local filesystem
|
4
|
+
class LatestDate
|
5
|
+
|
6
|
+
##
|
7
|
+
# Match a file path to extract a date component
|
8
|
+
DATE_PATH_MATCHER = /(?<year>\d{4})\/(?<month>\d{2})\/(?<day>\d{2})/
|
9
|
+
|
10
|
+
# The latest entry in the local file system
|
11
|
+
#
|
12
|
+
# Returns Date
|
13
|
+
# Returns nil
|
14
|
+
def find
|
15
|
+
return nil unless entry_paths.any?
|
16
|
+
past_entries = entry_paths.map do |path|
|
17
|
+
match = path.match(DATE_PATH_MATCHER)
|
18
|
+
Date.parse(match.to_s)
|
19
|
+
end.select { |date| date < today }
|
20
|
+
|
21
|
+
past_entries.last
|
22
|
+
end
|
23
|
+
|
24
|
+
# Convert the Date to a String
|
25
|
+
# Returns String
|
26
|
+
def to_s
|
27
|
+
find.to_s.strftime(Day::DATE_FORMAT)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return the Date as a Date object
|
31
|
+
def to_date
|
32
|
+
find
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def today
|
38
|
+
@today = Date.today
|
39
|
+
end
|
40
|
+
|
41
|
+
def entry_paths
|
42
|
+
Dir[File.join(Pathname.dirname, "**", "*.md")].sort
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DailyLog
|
4
|
+
class Options
|
5
|
+
require "optparse"
|
6
|
+
require "optparse/date"
|
7
|
+
require "date"
|
8
|
+
|
9
|
+
attr_reader :hash
|
10
|
+
|
11
|
+
alias to_hash hash
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@hash = defaults
|
15
|
+
parse
|
16
|
+
end
|
17
|
+
|
18
|
+
def defaults
|
19
|
+
_defaults = { date: Date.today }
|
20
|
+
_defaults[:print] = _defaults[:date] != Date.today
|
21
|
+
_defaults[:edit] = _defaults[:date] == Date.today
|
22
|
+
_defaults
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse
|
26
|
+
OptionParser.new do |opts|
|
27
|
+
opts.banner = "Usage: dl [options]"
|
28
|
+
opts.on("-e", "--edit", "Open the entry in the editor",
|
29
|
+
"(Even when it's not today's date)") do
|
30
|
+
hash[:edit] = true
|
31
|
+
end
|
32
|
+
opts.on("", "--path", "Show the path for the given entry file") do
|
33
|
+
hash[:path] = true
|
34
|
+
end
|
35
|
+
opts.on("-p", "--print", "Print the entry to STDOUT",
|
36
|
+
"(Even when it's today's date)") do
|
37
|
+
hash[:print] = true
|
38
|
+
end
|
39
|
+
opts.on("-d", "--date=DATE", Date, "Date to show string for") do |date|
|
40
|
+
hash[:date] = date
|
41
|
+
end
|
42
|
+
opts.on("-l", "--last", "Show the last daily log entry") do |dh|
|
43
|
+
last = DailyLog::LatestDate.new.find
|
44
|
+
if last
|
45
|
+
hash[:date] = last
|
46
|
+
else
|
47
|
+
puts "There are no previous entries"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end.parse!
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DailyLog
|
4
|
+
|
5
|
+
# The pathname for an Entry file on a given Day
|
6
|
+
class Pathname
|
7
|
+
require "forwardable"
|
8
|
+
require "zero_padded"
|
9
|
+
|
10
|
+
extend Forwardable
|
11
|
+
using ZeroPadded
|
12
|
+
|
13
|
+
##
|
14
|
+
# The default name for the dir where entries are stored.
|
15
|
+
DEFAULT_DIRNAME = ".daily_logs"
|
16
|
+
|
17
|
+
##
|
18
|
+
# The default format for entries
|
19
|
+
FORMAT = "md"
|
20
|
+
|
21
|
+
##
|
22
|
+
# The Date we're caluclating the Pathname for
|
23
|
+
attr_reader :date
|
24
|
+
|
25
|
+
def_delegators :date, :year, :month, :day
|
26
|
+
|
27
|
+
class << self
|
28
|
+
|
29
|
+
##
|
30
|
+
# Set the dirname where entries are stored
|
31
|
+
attr_writer :dirname
|
32
|
+
|
33
|
+
##
|
34
|
+
# The dirname where entries are stored
|
35
|
+
#
|
36
|
+
# Returns String
|
37
|
+
def dirname
|
38
|
+
@dirname || DEFAULT_DIRNAME
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create a new Pathname
|
44
|
+
#
|
45
|
+
# date - The Date we're creating a Pathname for
|
46
|
+
def initialize(date)
|
47
|
+
@date = date
|
48
|
+
end
|
49
|
+
|
50
|
+
# The Pathname as a path string
|
51
|
+
# Returns String
|
52
|
+
def to_path
|
53
|
+
File.join(dirname, "#{day.zero_pad}.#{FORMAT}")
|
54
|
+
end
|
55
|
+
|
56
|
+
alias to_s to_path
|
57
|
+
|
58
|
+
# The name of the directory where the Entry will live
|
59
|
+
#
|
60
|
+
# Returns String
|
61
|
+
def dirname
|
62
|
+
File.join self.class.dirname, year.zero_pad, month.zero_pad
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DailyLog
|
4
|
+
|
5
|
+
# Source-Code management check. Make sure the entries aren't being checked
|
6
|
+
# into Git.
|
7
|
+
# # TODO: Allow devs to disable this in as an option
|
8
|
+
# # TODO: Allow devs to disable this in a .daily_log file
|
9
|
+
# # TODO: Add support for other SCM
|
10
|
+
class ScmCheck
|
11
|
+
|
12
|
+
# Perform the check. Print to STDOUT if there is a warning
|
13
|
+
def perform!
|
14
|
+
return unless git_project?
|
15
|
+
return if has_gitignore? && has_ignored_daily_logs?
|
16
|
+
warn <<~TEXT
|
17
|
+
You should add .daily_logs to your .gitignore file
|
18
|
+
TEXT
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def git_project?
|
24
|
+
Dir.exists?("./.git")
|
25
|
+
end
|
26
|
+
|
27
|
+
def has_gitignore?
|
28
|
+
File.exists?("./.gitignore")
|
29
|
+
end
|
30
|
+
|
31
|
+
def has_ignored_daily_logs?
|
32
|
+
File.read(".gitignore").include?(DailyLog::Pathname::dirname)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/tasks/doc.rake
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :doc do
|
2
|
+
|
3
|
+
desc "Create the HTML docs for this project"
|
4
|
+
task :create do
|
5
|
+
load("lib/daily_log/version.rb")
|
6
|
+
system("yard doc --plugin tomdoc\
|
7
|
+
--hide-void-return\
|
8
|
+
--title \"Daily Logs - #{DailyLog::VERSION}\"")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
task doc: ["doc:create"]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Daily Entry - <%= @day.date.strftime("%a %d %B, %Y") %>
|
2
|
+
|
3
|
+
## Today I worked on:
|
4
|
+
|
5
|
+
- Thing one
|
6
|
+
|
7
|
+
## Next time, you should continue with:
|
8
|
+
|
9
|
+
- Thing two
|
10
|
+
|
11
|
+
## Notes:
|
12
|
+
|
13
|
+
Some optional notes here...
|
14
|
+
|
15
|
+
<!--
|
16
|
+
Automatically generated by DailyLog https://github.com/KatanaCode/daily_log
|
17
|
+
Date: <%= @day.to_s %>
|
18
|
+
Project: <%= File.basename(Dir.getwd) %>
|
19
|
+
By: <%= Etc.getlogin %>
|
20
|
+
-->
|
data/lib/zero_padded.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Extends the Integer class with zero-padded numbers, so that months are days
|
2
|
+
# all always shown as double-digit numbers
|
3
|
+
module ZeroPadded
|
4
|
+
|
5
|
+
refine Integer do
|
6
|
+
|
7
|
+
# Return the value of an Integer zero-padded to a min of 2 chars
|
8
|
+
def zero_pad
|
9
|
+
to_s.rjust(2, "0")
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: daily_log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bodacious
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Keep a short, daily log of the work you do within a project repo
|
56
|
+
email:
|
57
|
+
- bodacious@katanacode.com
|
58
|
+
executables:
|
59
|
+
- dl
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".byebug_history"
|
64
|
+
- ".daily_logs/2020/01/06.md"
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
68
|
+
- Gemfile
|
69
|
+
- Gemfile.lock
|
70
|
+
- History.md
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- daily_log.gemspec
|
77
|
+
- exe/dl
|
78
|
+
- lib/daily_log.rb
|
79
|
+
- lib/daily_log/day.rb
|
80
|
+
- lib/daily_log/entry.rb
|
81
|
+
- lib/daily_log/latest_date.rb
|
82
|
+
- lib/daily_log/options.rb
|
83
|
+
- lib/daily_log/pathname.rb
|
84
|
+
- lib/daily_log/scm_check.rb
|
85
|
+
- lib/daily_log/version.rb
|
86
|
+
- lib/tasks/doc.rake
|
87
|
+
- lib/templates/daily_log/entry.md.erb
|
88
|
+
- lib/zero_padded.rb
|
89
|
+
homepage: https://github.com/KatanaCode/daily_log
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.0.3
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Daily code journal on a per project basis
|
112
|
+
test_files: []
|