kk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f31a081bfd513dbb1e3c76f1b85c38e25797d1eb
4
+ data.tar.gz: 45b6f5b530d9cba626ee3ab0e0619da39203c04d
5
+ SHA512:
6
+ metadata.gz: 4d05a0dc8046d24165b5b643892cb6adf61b064a786e74fbd148b5abe927562668839148344196936fbedeb4ef1597b7a3ea003fed99f36879ba6e8c52e34691
7
+ data.tar.gz: 14dd1d5b266f2d8f954eceaa2736fa4a52a0c988fb829220bfd90c03417fd2dac2d0bd653e7bc5fbe8b9db1c0d82d100f2934ccf1711850d5cdfb43b54ff596a
@@ -0,0 +1 @@
1
+ kk
@@ -0,0 +1 @@
1
+ ruby-2.1.4
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kk (0.0.1)
5
+ sequel (~> 4.16.0)
6
+ sqlite3 (~> 1.3.10)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ celluloid (0.16.0)
12
+ timers (~> 4.0.0)
13
+ coderay (1.1.0)
14
+ diff-lcs (1.2.5)
15
+ ffi (1.9.6)
16
+ formatador (0.2.5)
17
+ guard (2.8.0)
18
+ formatador (>= 0.2.4)
19
+ listen (~> 2.7)
20
+ lumberjack (~> 1.0)
21
+ pry (>= 0.9.12)
22
+ thor (>= 0.18.1)
23
+ guard-rspec (4.3.1)
24
+ guard (~> 2.1)
25
+ rspec (>= 2.14, < 4.0)
26
+ hitimes (1.2.2)
27
+ listen (2.7.11)
28
+ celluloid (>= 0.15.2)
29
+ rb-fsevent (>= 0.9.3)
30
+ rb-inotify (>= 0.9)
31
+ lumberjack (1.0.9)
32
+ method_source (0.8.2)
33
+ pry (0.10.1)
34
+ coderay (~> 1.1.0)
35
+ method_source (~> 0.8.1)
36
+ slop (~> 3.4)
37
+ rb-fsevent (0.9.4)
38
+ rb-inotify (0.9.5)
39
+ ffi (>= 0.5.0)
40
+ rspec (3.1.0)
41
+ rspec-core (~> 3.1.0)
42
+ rspec-expectations (~> 3.1.0)
43
+ rspec-mocks (~> 3.1.0)
44
+ rspec-core (3.1.7)
45
+ rspec-support (~> 3.1.0)
46
+ rspec-expectations (3.1.2)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.1.0)
49
+ rspec-mocks (3.1.3)
50
+ rspec-support (~> 3.1.0)
51
+ rspec-support (3.1.2)
52
+ sequel (4.16.0)
53
+ slop (3.6.0)
54
+ sqlite3 (1.3.10)
55
+ thor (0.19.1)
56
+ timers (4.0.1)
57
+ hitimes
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ guard (~> 2.8.0)
64
+ guard-rspec (~> 4.3.1)
65
+ kk!
66
+ rspec (~> 3.1.0)
@@ -0,0 +1,110 @@
1
+ # kk - Personal diary/journaling/logging tool
2
+
3
+ kk is an ultra-lightweight tool for journaling, logging and
4
+ diarykeeping. It stores the journal in a sqlite3 database, ensuring
5
+ fast updates and searches even when the logging gets fairly
6
+ involved. kk is inspired by the awesome
7
+ [jrnl app](http://maebert.github.io/jrnl/), and my intention is to
8
+ make kk "scratch my own itch" for specialty needs like templates,
9
+ reporting and logging.
10
+
11
+ If all you need is a command-line journal app with tagging and simple
12
+ searching, you probably want to use jrnl.
13
+
14
+ # Feature Comparison with jrnl
15
+
16
+ This is a list of the key features of kk and jrnl so that I can
17
+ implement them using this document as a sort of "README-driven
18
+ development" guide.
19
+
20
+ | Feature | kk | jrnl |
21
+ |------------------------------------------+-----+------|
22
+ | Exists at all, in any way, shape or form | YES | yes |
23
+ | Add entries from the command line | YES | yes |
24
+ | Add journal entry with title and date | NO | yes |
25
+ | Show all journal entries | NO | yes |
26
+ | Convenient dates and times | NO | yes |
27
+ | Export to json | NO | yes |
28
+ | Search by date or date range | NO | yes |
29
+ | List tags | NO | yes |
30
+ | Add tags with @ from CLI | NO | yes |
31
+ | Search by tag | NO | yes |
32
+ | 256-bit AES Encryption | NO | yes |
33
+ | Portable by saving file to dropbox | NO | yes |
34
+ | Init config, db on startup if no db | NO | yes |
35
+ | Web server | NO | NO |
36
+ | CLI->browser capture for longer entries | NO | NO |
37
+ | Template support | NO | NO |
38
+ | Extra document data | NO | NO |
39
+ | Search by document data | NO | NO |
40
+
41
+
42
+ # Simple Usage Examples
43
+
44
+
45
+ kk Lunch. Went to favorite place.
46
+ # title: "Lunch", body: "Went to favorite place.", date: today, time: now
47
+
48
+ kk 3pm: Late lunch
49
+ # title: "Late lunch", body: nil, date: today, time: 3pm
50
+
51
+ kk yesterday: Tracked time for @work.
52
+ # title: "Tracked time for @work", body: nil, time: none, date: yesterday
53
+
54
+
55
+ # Template Support
56
+
57
+ I'm not sure yet how I want to tackle this, even to demonstrate how
58
+ I'd use it (a la "design by wishful thinking"), but in short I want to
59
+ create templates that let me quickly add new entries later. **These
60
+ examples will likely change!**
61
+
62
+ kk --templates
63
+ # -> list templates
64
+
65
+ kk %fbg title: "Fasting Blood Glucose", body: %1, glucose:i: %1, fasting:b: true
66
+ # -> Creates/updates template "fbg" so that it takes one value
67
+ # from the command-line and writes it as the body of the journal
68
+ # entry. It sets the title to "Fasting Blood Glucose", and then
69
+ # adds extra data fields "glucose" (integer, set to .to_i of %1)
70
+ # and "fasting" (bool, set to true). TOTALLY UNSURE if I even want
71
+ # to support special types here or if everything should just be
72
+ # strings. On one hand I could see it all going into a json blob
73
+ # in the database anyway; on the other hand if create objects that
74
+ # the database can understand I can sift and sort by those types
75
+ # rather than by strings, so 10 would come after 9 instead of
76
+ # between 1 and 2, etc.
77
+
78
+ kk %fbg 86
79
+ # -> Records a glucose entry of 86.
80
+
81
+ # Extra Document Data
82
+
83
+ An extension of the extra fields idea raised by the templating
84
+ thought. Ideally I want to all some kind of NoSQL-like data storage
85
+ and searching, like "Show me all the glucose logs that are fasting:
86
+ false" or "Show me the highest glucose entry in this date range". For
87
+ now I'm thinking of either a JSON blob field, or if I move to postgres
88
+ I can consider using an hstore column.
89
+
90
+ TODO: Give some serious thought to rolling the whole thing with PStore
91
+ or, even better, YAML::Store instead of sqlite. This would essentially
92
+ make the whole store a NoSQL-style database. It essentially returns a
93
+ giant hash so its use as a Key/Value store would be obvious. Expanding
94
+ it to a "proper" document database might require more tooling than
95
+ it's worth, dunno. Definitely have to store off my own indices, but I
96
+ might be able to aggregate the values into document objects if the
97
+ YAML store has a clean marshaling mechanism.
98
+
99
+ Do I want to go to the trouble of separating the data access from the
100
+ application? That means rolling a lot of the data access myself, sigh,
101
+ but would it be worth it to be able to switch from sqlite to
102
+ yaml/store?
103
+
104
+ (Another consideration is speed: I know sqlite3 is pretty fast, but
105
+ yaml store could end up implicitly creating objects for the entire
106
+ file every time I loaded it. The result would be a huge performance
107
+ hit once the journal got large. Food for thought. One option would be
108
+ to roll my own store somehow, but right now I think perhaps the best
109
+ option might be to use sqlite3 and roll as much of a key/value store
110
+ on top of it as I need, but only as I need it.)
data/bin/kk ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load kk libs and connect to DB
4
+ require_relative '../lib/kk'
5
+
6
+ # Parse args and execute
7
+ entry = ARGV * ' '
8
+ time, msg = entry.split(/:/, 2)
9
+
10
+ now = DateTime.now
11
+
12
+ if msg.nil?
13
+ msg = time
14
+ time = now
15
+ end
16
+
17
+ title, body = msg.split(/\./, 2)
18
+ body ||= ""
19
+
20
+ Kk::Entry.create(title: title, body: body, entered_at: time, created_at: now, updated_at: now)
@@ -0,0 +1,12 @@
1
+ # before running this, ensure that DB refers to the database we wanna modify...
2
+
3
+ DB.create_table :entries do
4
+ primary_key :id
5
+ String :title
6
+ String :body, text: true
7
+ DateTime :entered_at
8
+ DateTime :created_at
9
+ DateTime :updated_at
10
+
11
+ index :entered_at
12
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'kk'
3
+ gem.version = '0.0.1'
4
+ gem.date = '2014-11-05'
5
+ gem.summary = "Personal CLI/web diary/journaling tool"
6
+ gem.description = "Personal CLI/web diary/journaling tool with tagging, templates, and customizable data fields"
7
+ gem.authors = ["David Brady"]
8
+ gem.email = 'dbrady@shinybit.com'
9
+ gem.files = `git ls-files`.split($/)
10
+ gem.executables = gem.files.grep(%r{^bin/}).map {|f| File.basename(f) }
11
+ gem.test_files = gem.files.grep(%r{^(spec|test|features)/})
12
+ gem.require_paths = ["lib"]
13
+ gem.homepage = 'https://github.com/dbrady/kk'
14
+ gem.license = 'MIT'
15
+
16
+ gem.add_dependency "sqlite3", "~> 1.3"
17
+ gem.add_dependency "sequel", "~> 4.16"
18
+
19
+ gem.add_development_dependency "rspec", "~> 3.1"
20
+ gem.add_development_dependency "guard", "~> 2.8"
21
+ gem.add_development_dependency "guard-rspec", "~> 4.3"
22
+
23
+ end
@@ -0,0 +1,8 @@
1
+ # main include/bootup/loadup file
2
+
3
+ require 'sequel'
4
+ require 'sqlite3'
5
+
6
+ DB = Sequel.connect('sqlite://' + File.expand_path("~/.kk-journal.db"))
7
+
8
+ require_relative './kk/entry'
@@ -0,0 +1,18 @@
1
+ module Kk
2
+
3
+ class Entry < Sequel::Model
4
+
5
+ def before_create
6
+ super
7
+ now = DateTime.now
8
+ self.created_at ||= now
9
+ end
10
+
11
+ def before_update
12
+ super
13
+ now = DateTime.now
14
+ self.updated_at ||= now
15
+ end
16
+ end
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Brady
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqlite3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sequel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.16'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.16'
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.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.3'
83
+ description: Personal CLI/web diary/journaling tool with tagging, templates, and customizable
84
+ data fields
85
+ email: dbrady@shinybit.com
86
+ executables:
87
+ - kk
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".ruby-gemset"
92
+ - ".ruby-version"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - README.md
96
+ - bin/kk
97
+ - db/schema.rb
98
+ - kk.gemspec
99
+ - lib/kk.rb
100
+ - lib/kk/entry.rb
101
+ homepage: https://github.com/dbrady/kk
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Personal CLI/web diary/journaling tool
125
+ test_files: []