sticky 0.1.3 → 0.2.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 +4 -4
- data/README.md +8 -1
- data/lib/sticky/note.rb +6 -3
- data/lib/sticky/store.rb +41 -0
- data/lib/sticky/version.rb +1 -1
- data/lib/sticky.rb +7 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a0194125951114b92e085fa2e1f36ebf99d391e
|
|
4
|
+
data.tar.gz: 8a3b2d860202d2db8ff01e007354d3214e782426
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc6c0d4528f49d069fa211f78f6b919136ed3e8d2215f570c50b498d4006fbe4d15cf9cabcb639f4050dc615293ebd4e4f6f9ab25343ff779e3aa1c787d84327
|
|
7
|
+
data.tar.gz: 693e1e6f8c8887369888e9794b7d4ad0e700d4cb8cfd294b85e8de8382febd236894a3a438f3411a2fbc2f3f4821392bad34ba41045049345086328779e1440a
|
data/README.md
CHANGED
|
@@ -15,10 +15,17 @@ Create a new entry with:
|
|
|
15
15
|
Display all entries with:
|
|
16
16
|
|
|
17
17
|
$ sticky show
|
|
18
|
+
Or...
|
|
19
|
+
|
|
20
|
+
$ sticky show -t my-tag
|
|
21
|
+
$ sticky show -d 2016-08-16
|
|
22
|
+
|
|
23
|
+
Delete tagged entries with:
|
|
24
|
+
|
|
25
|
+
$ sticky delete -t my-tag
|
|
18
26
|
|
|
19
27
|
## TODO
|
|
20
28
|
|
|
21
|
-
* Search and display by tag/date
|
|
22
29
|
* Display last N sticky notes
|
|
23
30
|
* Multiple tags
|
|
24
31
|
* Help text
|
data/lib/sticky/note.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'sticky/store'
|
|
2
|
+
|
|
1
3
|
module Sticky
|
|
2
4
|
class Note
|
|
3
5
|
attr_accessor :message, :tag, :timestamp, :db
|
|
@@ -7,9 +9,10 @@ module Sticky
|
|
|
7
9
|
new(message, tag, db)
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
def show(tag, db = Sticky::Store.new)
|
|
11
|
-
db.fetch(tag) do |note|
|
|
12
|
-
|
|
12
|
+
def show(tag, date, db = Sticky::Store.new)
|
|
13
|
+
db.fetch(tag, date) do |note|
|
|
14
|
+
# TODO use a formatter
|
|
15
|
+
puts note.message
|
|
13
16
|
end
|
|
14
17
|
end
|
|
15
18
|
|
data/lib/sticky/store.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "yaml/store"
|
|
2
|
+
|
|
3
|
+
module Sticky
|
|
4
|
+
class Store
|
|
5
|
+
attr_reader :store
|
|
6
|
+
|
|
7
|
+
def initialize(store_path = "#{Dir.home}/.sticky.yml")
|
|
8
|
+
@store = YAML::Store.new(store_path)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def fetch(tag = nil, date = nil)
|
|
12
|
+
# FIXME: this is ugly, refactor this
|
|
13
|
+
store.transaction do
|
|
14
|
+
store[:sticky_notes] || []
|
|
15
|
+
store[:sticky_notes].each do |sticky|
|
|
16
|
+
if block_given? && ((tag.nil? && date.nil?)\
|
|
17
|
+
|| tag == sticky.tag \
|
|
18
|
+
|| date.to_date == sticky.timestamp.to_date)
|
|
19
|
+
yield sticky
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete!(tag)
|
|
26
|
+
if tag
|
|
27
|
+
store.transaction do
|
|
28
|
+
store[:sticky_notes] || []
|
|
29
|
+
store[:sticky_notes].reject! { |sticky| sticky.tag == tag }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def save!(sticky)
|
|
35
|
+
store.transaction do
|
|
36
|
+
store[:sticky_notes] ||= []
|
|
37
|
+
store[:sticky_notes] << sticky
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/sticky/version.rb
CHANGED
data/lib/sticky.rb
CHANGED
|
@@ -12,10 +12,15 @@ module Sticky
|
|
|
12
12
|
Sticky::Note.build(message, options[:tag]).save!
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
desc "show [
|
|
15
|
+
desc "show [-t my-tag]", "Displays sticky notes."
|
|
16
|
+
long_desc <<-LONGDESC
|
|
17
|
+
Use `-t my-tag` or `-d YYYY-MM-DD`` to display matching tags.
|
|
18
|
+
LONGDESC
|
|
16
19
|
option :tag, type: :string, aliases: :t
|
|
20
|
+
option :date, type: :string, aliases: :d
|
|
17
21
|
def show
|
|
18
|
-
|
|
22
|
+
date = options[:date] ? Time.parse(options[:date]) : nil
|
|
23
|
+
Sticky::Note.show(options[:tag], date)
|
|
19
24
|
end
|
|
20
25
|
|
|
21
26
|
desc "delete TAG", "Deletes sticky notes tagged with TAG."
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sticky
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Artur de Oliveira Tsuda
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-08-
|
|
11
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -88,6 +88,7 @@ files:
|
|
|
88
88
|
- bin/sticky
|
|
89
89
|
- lib/sticky.rb
|
|
90
90
|
- lib/sticky/note.rb
|
|
91
|
+
- lib/sticky/store.rb
|
|
91
92
|
- lib/sticky/version.rb
|
|
92
93
|
- sticky.gemspec
|
|
93
94
|
homepage: https://github.com/arturts/sticky
|