bullit 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dc4e4773d0af202048720a7c8a50182d79acc2f1
4
+ data.tar.gz: d65f57afd736a8684a342005381e754987183dad
5
+ SHA512:
6
+ metadata.gz: 9294e578acf3543ca5a3f393a6a7b0f590d275024fef5a82b5bfae0342ed09501854f94fe0af5287b46c8da2cdf1c53db1c557708edab52f4eda11dc7dc398a7
7
+ data.tar.gz: 198b1aa7cd779b467d3e0b1e01b71a65686abdea6a5747e65feb2cdeed34b6d98cfbd928023f949da54a715f486db90c2cd0a2c2b4bf3b6ca7da7994330079ec
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.2
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bullit.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bullit (0.1.0)
5
+ clamp
6
+ tty-prompt
7
+ tty-table
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ clamp (1.3.0)
13
+ coderay (1.1.2)
14
+ diff-lcs (1.3)
15
+ equatable (0.5.0)
16
+ method_source (0.9.2)
17
+ necromancer (0.4.0)
18
+ pastel (0.7.2)
19
+ equatable (~> 0.5.0)
20
+ tty-color (~> 0.4.0)
21
+ pry (0.12.2)
22
+ coderay (~> 1.1.0)
23
+ method_source (~> 0.9.0)
24
+ rake (10.5.0)
25
+ rspec (3.8.0)
26
+ rspec-core (~> 3.8.0)
27
+ rspec-expectations (~> 3.8.0)
28
+ rspec-mocks (~> 3.8.0)
29
+ rspec-core (3.8.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-expectations (3.8.2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-mocks (3.8.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-support (3.8.0)
38
+ strings (0.1.4)
39
+ strings-ansi (~> 0.1.0)
40
+ unicode-display_width (~> 1.4.0)
41
+ unicode_utils (~> 1.4.0)
42
+ strings-ansi (0.1.0)
43
+ timers (4.3.0)
44
+ tty-color (0.4.3)
45
+ tty-cursor (0.6.0)
46
+ tty-prompt (0.18.1)
47
+ necromancer (~> 0.4.0)
48
+ pastel (~> 0.7.0)
49
+ timers (~> 4.0)
50
+ tty-cursor (~> 0.6.0)
51
+ tty-reader (~> 0.5.0)
52
+ tty-reader (0.5.0)
53
+ tty-cursor (~> 0.6.0)
54
+ tty-screen (~> 0.6.4)
55
+ wisper (~> 2.0.0)
56
+ tty-screen (0.6.5)
57
+ tty-table (0.10.0)
58
+ equatable (~> 0.5.0)
59
+ necromancer (~> 0.4.0)
60
+ pastel (~> 0.7.2)
61
+ strings (~> 0.1.0)
62
+ tty-screen (~> 0.6.4)
63
+ unicode-display_width (1.4.1)
64
+ unicode_utils (1.4.0)
65
+ wisper (2.0.0)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bullit!
72
+ bundler (~> 2.0)
73
+ pry
74
+ rake (~> 10.0)
75
+ rspec (~> 3.0)
76
+
77
+ BUNDLED WITH
78
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Tom Nadolny
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,39 @@
1
+ # BulletJournal
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bullit`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bullit'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bullit
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bullit.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/bullit ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bullit'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bullit"
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
@@ -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
data/bullit.gemspec ADDED
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bullit/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bullit"
8
+ spec.version = BulletJournal::VERSION
9
+ spec.authors = ["Tomek Nadolny"]
10
+ spec.email = ["tomek.nad@gmail.com"]
11
+
12
+ spec.summary = %q{A tool used to manage your daily tasks and memos}
13
+ spec.homepage = "https://github.com/tomekn/bullit"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "bin"
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry"
29
+
30
+ spec.add_dependency "clamp"
31
+ spec.add_dependency "tty-table"
32
+ spec.add_dependency "tty-prompt"
33
+ end
@@ -0,0 +1,88 @@
1
+ require 'pathname'
2
+ require 'yaml'
3
+ require 'pry'
4
+
5
+ require 'bullit/task'
6
+
7
+ module BulletJournal
8
+ class File
9
+ def self.generate_today_file(loud)
10
+ today_file.dirname.mkpath
11
+
12
+ unless today_file.exist?
13
+ t = Time.now
14
+
15
+ title = "Journal for #{t.strftime('%m/%d/%y')}"
16
+
17
+ file_contents = {
18
+ title: title,
19
+ tasks: incomplete_tasks_from_yesterday
20
+ }
21
+
22
+ today_file.write(YAML.dump(file_contents))
23
+
24
+ puts "#{today_file.to_s} created." if loud
25
+ end
26
+ end
27
+
28
+ def self.incomplete_tasks_from_yesterday
29
+ if yesterday_file.exist?
30
+ file = YAML.load(yesterday_file.read)
31
+ return {} if file[:tasks].empty?
32
+ file[:tasks].reject{ |t| t.complete == true }
33
+ end
34
+ end
35
+
36
+ def self.today_tasks
37
+ YAML.load(today_file.read)[:tasks]
38
+ end
39
+
40
+ def self.add_task(text)
41
+ file = YAML.load(today_file.read)
42
+
43
+ if file[:tasks].nil?
44
+ file[:tasks] = [ Task.new(text: text).to_h ]
45
+ else
46
+ file[:tasks] = today_tasks << Task.new(text: text).to_h
47
+ end
48
+
49
+ today_file.write(YAML.dump(file))
50
+ end
51
+
52
+ def self.complete_task(task_number)
53
+ file = YAML.load(today_file.read)
54
+
55
+ unless file[:tasks].nil?
56
+ unless file[:tasks][task_number].nil?
57
+ file[:tasks][task_number] = Task.new(file[:tasks][task_number].to_h).mark_as_complete
58
+ today_file.write(YAML.dump(file))
59
+ end
60
+ end
61
+ end
62
+
63
+ def self.today_file
64
+ t = Time.now
65
+
66
+ year = t.strftime "%Y"
67
+ week = t.strftime "%W"
68
+ weekday = t.strftime "%u"
69
+
70
+ Pathname("tasks/#{year}/#{week}/#{weekday}.yaml")
71
+ end
72
+
73
+ def self.yesterday_file
74
+ t = Time.now
75
+
76
+ year = t.strftime "%Y"
77
+ week = t.strftime "%W"
78
+ weekday = t.strftime("%u").to_i
79
+
80
+ # TODO: the logic here is a bit dodgy... it should look for the latest file in case you don't use your machine for more than one day.
81
+ if weekday > 1
82
+ Pathname("tasks/#{year}/#{week}/#{(weekday - 1).to_s}.md")
83
+ else
84
+ Pathname("tasks/#{year}/#{week-1}/7.md")
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,24 @@
1
+ module BulletJournal
2
+ class Task
3
+ attr_accessor :text, :complete
4
+
5
+ def initialize(text:, complete: false, created_at: Time.now)
6
+ @text = text
7
+ @complete = complete
8
+ @created_at = created_at
9
+ end
10
+
11
+ def to_h
12
+ {
13
+ text: text,
14
+ complete: complete,
15
+ created_at: Time.now.to_s
16
+ }
17
+ end
18
+
19
+ def mark_as_complete
20
+ @complete = true
21
+ to_h
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module BulletJournal
2
+ VERSION = "0.1.0"
3
+ end
data/lib/bullit.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'clamp'
2
+ require 'tty-table'
3
+ require 'tty-prompt'
4
+
5
+ require "bullit/version"
6
+ require "bullit/file"
7
+
8
+ module BulletJournal
9
+ class Error < StandardError; end
10
+
11
+ Clamp do
12
+ option "--loud", :flag, "say it loud"
13
+
14
+ subcommand "generate", "generator functions" do
15
+ subcommand "today", "creates task file for today" do
16
+ def execute
17
+ BulletJournal::File.generate_today_file(loud?)
18
+ end
19
+ end
20
+ end
21
+
22
+ subcommand "tasks", "manage today's tasks" do
23
+ subcommand "list", "list your tasks" do
24
+ def execute
25
+ show_tasks
26
+ end
27
+ end
28
+
29
+ subcommand "add", "add a task" do
30
+ option "--text", "TEXT", "what the task is"
31
+ def execute
32
+ prompt = TTY::Prompt.new
33
+ text = prompt.ask('what do you need to do?') if text.nil?
34
+ BulletJournal::File.add_task(text)
35
+ end
36
+ end
37
+
38
+ subcommand "complete", "complete a task" do
39
+ parameter "TASK_NUMBER", "what the task is", required: true
40
+ def execute
41
+ BulletJournal::File.complete_task(task_number.to_i)
42
+ end
43
+ end
44
+ end
45
+
46
+ def show_tasks
47
+ tasks = BulletJournal::File.today_tasks.each_with_index.map{ |t,i| [i,t[:text], t[:complete] == true ? ' ✅' : ' ❌']}
48
+
49
+ puts TTY::Table.new(['#', 'Task', ''], tasks).render(:ascii)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ ---
2
+ :title: Journal for 02/09/19
3
+ :tasks:
4
+ - :text: Get cat food
5
+ :complete: true
6
+ :created_at: '2019-02-09 16:46:24 +0000'
7
+ - :text: Finish this app
8
+ :complete: true
9
+ :created_at: '2019-02-09 17:03:43 +0000'
10
+ - :text: Add colours to the terminal.
11
+ :complete: true
12
+ :created_at: '2019-02-09 19:20:57 +0000'
13
+ - :text: Make sure the rename worked
14
+ :complete: true
15
+ :created_at: '2019-02-09 20:00:26 +0000'
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bullit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomek Nadolny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-09 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: clamp
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-table
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-prompt
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - tomek.nad@gmail.com
114
+ executables:
115
+ - bullit
116
+ - console
117
+ - setup
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - ".gitignore"
122
+ - ".rspec"
123
+ - ".travis.yml"
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/bullit
130
+ - bin/console
131
+ - bin/setup
132
+ - bullit.gemspec
133
+ - lib/bullit.rb
134
+ - lib/bullit/file.rb
135
+ - lib/bullit/task.rb
136
+ - lib/bullit/version.rb
137
+ - tasks/2019/05/6.yaml
138
+ homepage: https://github.com/tomekn/bullit
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.6.13
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: A tool used to manage your daily tasks and memos
162
+ test_files: []