feed-the-zettelkasten 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2d4ad4b141e03670748ca1827b8fc951d46314026de410d728a20c688e487ff2
4
+ data.tar.gz: e9816de93de56d9c0280933d73096326ea50c01fdaade54e4e444d743e178932
5
+ SHA512:
6
+ metadata.gz: b5c7c976ed6c5c4e2c97481122b9ce59b249e35936286db1d0d978d82182cf6d2710a84e0f619d0f3dfbca768cc273524c6377fc1a1fc40e853611b12664d495
7
+ data.tar.gz: 558811fc1895f9ae8068e6fb11d4159fb03963c9c0b0a01a1396f27abc201416c2bb748d9c5ad9fb8ec1b7ec5c61e7b16b705a35c08b7dc90c5ad93843b0ae9b
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.2
@@ -0,0 +1,3 @@
1
+ # 0.1.0
2
+
3
+ * Initial version
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in feed-the-zettelkasten.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ feed-the-zettelkasten (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.14.2)
10
+ rake (12.3.3)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ feed-the-zettelkasten!
17
+ minitest (~> 5.0)
18
+ rake (~> 12.0)
19
+
20
+ BUNDLED WITH
21
+ 2.1.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Gareth Rees
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # Feed The Zettelkasten
2
+
3
+ Command Line Seinfeld calendar for The Archive Zettelkasten notes.
4
+
5
+ ## Installation
6
+
7
+ $ gem install feed-the-zettelkasten
8
+
9
+ ## Usage
10
+
11
+ ```
12
+ $ feed-the-zettelkasten --from=2020-09-25 --to=2020-10-04 --target=1 ~/notes
13
+ 2020-09-25: ❌
14
+ 2020-09-26: ✅
15
+ 2020-09-27: ❌
16
+ 2020-09-28: ❌
17
+ 2020-09-29: ❌
18
+ 2020-09-30: ❌
19
+ 2020-10-01: ❌
20
+ 2020-10-02: ✅
21
+ 2020-10-03: ✅
22
+ 2020-10-04: ❌
23
+ ```
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/garethrees/feed-the-zettelkasten.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "feed/the/zettelkasten"
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
5
+ require 'feed_the_zettelkasten'
6
+
7
+ exit FeedTheZettelkasten::CLI.run(ARGV)
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/feed_the_zettelkasten/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'feed-the-zettelkasten'
5
+ spec.version = FeedTheZettelkasten::VERSION
6
+ spec.authors = ['Gareth Rees']
7
+ spec.email = ['gareth@garethrees.co.uk']
8
+ spec.license = 'MIT'
9
+
10
+ spec.summary = 'Report on daily note-taking progress'
11
+ spec.homepage = 'https://github.com/garethrees/feed-the-zettelkasten'
12
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
13
+
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata['changelog_uri'] = "#{ spec.homepage }/blob/master/CHANGELOG.md"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ require 'date'
3
+
4
+ require 'feed_the_zettelkasten/format/pretty'
5
+
6
+ require 'feed_the_zettelkasten/cli/options'
7
+ require 'feed_the_zettelkasten/cli'
8
+
9
+ require 'feed_the_zettelkasten/notes_dir'
10
+ require 'feed_the_zettelkasten/notes'
11
+ require 'feed_the_zettelkasten/seinfeld'
12
+ require 'feed_the_zettelkasten/version'
13
+
14
+ module FeedTheZettelkasten
15
+ class Error < StandardError; end
16
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FeedTheZettelkasten
4
+ # Entrypoint for CLI usage
5
+ class CLI
6
+ STATUS_SUCCESS = 0
7
+ STATUS_FAILURE = 1
8
+
9
+ def self.run(argv)
10
+ new(Options.new(argv)).run
11
+ end
12
+
13
+ def initialize(options)
14
+ @options = options
15
+ end
16
+
17
+ def run
18
+ notes = NotesDir.new(options[:path], file_extension: options[:ext])
19
+ range = options[:from]..options[:to]
20
+
21
+ Seinfeld.new(notes, target: options[:target]).each_day(range) do |data|
22
+ puts Format::Pretty.new(data)
23
+ end
24
+
25
+ STATUS_SUCCESS
26
+ rescue StandardError => e
27
+ $stderr.puts e
28
+ STATUS_FAILURE
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :options
34
+ end
35
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+ require 'optparse/date'
5
+
6
+ module FeedTheZettelkasten
7
+ class CLI
8
+ # Parse CLI options
9
+ class Options
10
+ DEFAULTS = {
11
+ from: Date.today - 30,
12
+ to: Date.today,
13
+ target: 3,
14
+ ext: 'md'
15
+ }.freeze
16
+
17
+ def initialize(args)
18
+ @args = args
19
+ end
20
+
21
+ def [](key)
22
+ parse[key]
23
+ end
24
+
25
+ def to_hash
26
+ parse
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :args
32
+
33
+ def parse
34
+ @parse ||= parse!
35
+ end
36
+
37
+ def parse!
38
+ options = DEFAULTS.dup
39
+ option_parser.parse!(args, into: options)
40
+ options[:path] = args.shift
41
+
42
+ unless options[:path]
43
+ raise OptionParser::MissingArgument, 'Missing NOTES_DIR argument'
44
+ end
45
+
46
+ unless File.directory?(options[:path])
47
+ raise OptionParser::InvalidArgument,
48
+ "'#{ options[:path] } is not a directory"
49
+ end
50
+
51
+ options
52
+ end
53
+
54
+ def option_parser
55
+ OptionParser.new do |opts|
56
+ opts.banner = 'Usage: feed-the-zettelkasten [options] NOTES_DIR'
57
+ opts.on('--from[=DATE]', Date, 'Include notes after DATE (default: 30 days ago)')
58
+ opts.on('--to[=DATE]', Date, 'Include notes before DATE (default: today)')
59
+ opts.on('--target[=INTEGER]', Integer, 'Number of notes required to meet daily goal (default: 3)')
60
+ opts.on('--ext[=STRING]', 'Note extension (default: md)')
61
+ opts.on('-v', '--version', 'Print version') { exit 0 }
62
+ opts.on('-h', '--help', 'Prints this help') do
63
+ puts opts
64
+ exit 1
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FeedTheZettelkasten
4
+ module Format
5
+ class Pretty
6
+ SYMBOLS = {
7
+ true => '✅',
8
+ false => '❌'
9
+ }.freeze
10
+
11
+ def initialize(data)
12
+ @data = data
13
+ end
14
+
15
+ def to_s
16
+ data.
17
+ map { |date, success| "#{ date }: #{ SYMBOLS[success] }"}.
18
+ join("\n")
19
+ end
20
+
21
+ protected
22
+
23
+ attr_reader :data
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FeedTheZettelkasten
4
+ class Notes
5
+ include Enumerable
6
+
7
+ def initialize(notes)
8
+ @notes = notes
9
+ end
10
+
11
+ def hit_target?(target)
12
+ to_a.size >= target
13
+ end
14
+
15
+ def each
16
+ notes.each { |note| yield note }
17
+ end
18
+
19
+ protected
20
+
21
+ attr_reader :notes
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ module FeedTheZettelkasten
6
+ class NotesDir
7
+ def initialize(path, file_extension: 'md')
8
+ @path = Pathname.new(path)
9
+ @file_extension = file_extension
10
+ end
11
+
12
+ def created_on(date)
13
+ Notes.new(path.glob("*#{ date.strftime('%Y%m%d') }*.#{ file_extension }"))
14
+ end
15
+
16
+ protected
17
+
18
+ attr_reader :path, :file_extension
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FeedTheZettelkasten
4
+ class Seinfeld
5
+ def initialize(notes, target: 3)
6
+ @notes = notes
7
+ @target = target
8
+ end
9
+
10
+ def each_day(range)
11
+ range.each_with_object(notes) do |day, notes|
12
+ yield day.to_s =>
13
+ Notes.new(notes.created_on(day)).hit_target?(target)
14
+ end
15
+ end
16
+
17
+ protected
18
+
19
+ attr_reader :notes, :range, :target
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FeedTheZettelkasten
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feed-the-zettelkasten
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gareth Rees
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-10-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - gareth@garethrees.co.uk
16
+ executables:
17
+ - feed-the-zettelkasten
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".travis.yml"
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENCE.md
27
+ - README.md
28
+ - Rakefile
29
+ - bin/console
30
+ - bin/setup
31
+ - exe/feed-the-zettelkasten
32
+ - feed-the-zettelkasten.gemspec
33
+ - lib/feed_the_zettelkasten.rb
34
+ - lib/feed_the_zettelkasten/cli.rb
35
+ - lib/feed_the_zettelkasten/cli/options.rb
36
+ - lib/feed_the_zettelkasten/format/pretty.rb
37
+ - lib/feed_the_zettelkasten/notes.rb
38
+ - lib/feed_the_zettelkasten/notes_dir.rb
39
+ - lib/feed_the_zettelkasten/seinfeld.rb
40
+ - lib/feed_the_zettelkasten/version.rb
41
+ homepage: https://github.com/garethrees/feed-the-zettelkasten
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ homepage_uri: https://github.com/garethrees/feed-the-zettelkasten
46
+ source_code_uri: https://github.com/garethrees/feed-the-zettelkasten
47
+ changelog_uri: https://github.com/garethrees/feed-the-zettelkasten/blob/master/CHANGELOG.md
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.3.0
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.1.2
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Report on daily note-taking progress
67
+ test_files: []