sticky 0.1.0 → 0.1.1
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/lib/sticky/note.rb +30 -21
- data/lib/sticky/version.rb +1 -1
- data/lib/sticky.rb +12 -5
- data/sticky.gemspec +1 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d45a99eb2153d0b4f7a8fdd6da7432569e4e2a8c
|
|
4
|
+
data.tar.gz: 44f6045de94576ebfd4f56815195fb5782ead787
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7021521a56250acc3dd8725a6cd2bf1a0902cc56f3e635b07111a438e8042c266fad4f909962515d0544593e9d163a75c7a72096eab622009d7562362361234e
|
|
7
|
+
data.tar.gz: 66e31074d2762c90572d6defde600338ff28101a47d8d5d313cc96fe84cc425a112a2a846023f52a6943c4ec8a99ba181983f6df36b505c864ce461f2e2767d1
|
data/lib/sticky/note.rb
CHANGED
|
@@ -2,33 +2,42 @@ require "yaml/store"
|
|
|
2
2
|
|
|
3
3
|
module Sticky
|
|
4
4
|
class Note
|
|
5
|
-
attr_accessor :message, :tag, :timestamp
|
|
5
|
+
attr_accessor :message, :tag, :timestamp, :db
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class << self
|
|
8
|
+
def build(message, tag = nil, db = YAML::Store.new("#{Dir.home}/.sticky.yml"))
|
|
9
|
+
new(message, tag, db)
|
|
10
|
+
end
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
def show(tag, db = YAML::Store.new("#{Dir.home}/.sticky.yml"))
|
|
13
|
+
db.transaction do
|
|
14
|
+
db[:sticky_notes] ||= []
|
|
15
|
+
db[:sticky_notes].each do |sticky|
|
|
16
|
+
puts sticky.message if tag.nil? || sticky.tag == tag
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
tag: @tag
|
|
20
|
-
}
|
|
21
|
+
def delete!(tag, db = YAML::Store.new("#{Dir.home}/.sticky.yml"))
|
|
22
|
+
db.transaction do
|
|
23
|
+
db[:sticky_notes] ||= []
|
|
24
|
+
db[:sticky_notes] = \
|
|
25
|
+
db[:sticky_notes].select { |sticky| sticky.tag != tag }
|
|
26
|
+
end
|
|
21
27
|
end
|
|
22
28
|
end
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
def initialize(message, tag, db, timestamp = Time.now)
|
|
31
|
+
@message = message
|
|
32
|
+
@db = db
|
|
33
|
+
@tag = tag
|
|
34
|
+
@timestamp = timestamp
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def save!
|
|
38
|
+
db.transaction do
|
|
39
|
+
db[:sticky_notes] ||= []
|
|
40
|
+
db[:sticky_notes] << self
|
|
32
41
|
end
|
|
33
42
|
end
|
|
34
43
|
end
|
data/lib/sticky/version.rb
CHANGED
data/lib/sticky.rb
CHANGED
|
@@ -6,18 +6,25 @@ require "thor"
|
|
|
6
6
|
module Sticky
|
|
7
7
|
class CLI < Thor
|
|
8
8
|
|
|
9
|
-
desc "new MESSAGE", "Creates a new sticky note"
|
|
9
|
+
desc "new MESSAGE", "Creates a new sticky note."
|
|
10
10
|
option :tag, type: :string, aliases: :t
|
|
11
11
|
def new(message)
|
|
12
|
-
Sticky::Note.
|
|
12
|
+
Sticky::Note.build(message, options[:tag]).save!
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
desc "show [TAG]", "Displays all sticky notes. If TAG is given, displays only the matching sticky notes."
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
option :tag, type: :string, aliases: :t
|
|
17
|
+
def show
|
|
18
|
+
Sticky::Note.show(options[:tag])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "delete TAG", "Deletes sticky notes tagged with TAG."
|
|
22
|
+
option :tag, type: :string, aliases: :t, required: true
|
|
23
|
+
def delete
|
|
24
|
+
Sticky::Note.delete!(options[:tag])
|
|
18
25
|
end
|
|
19
26
|
|
|
20
|
-
desc "help", "Shows help text
|
|
27
|
+
desc "help", "Shows help text"
|
|
21
28
|
def help
|
|
22
29
|
puts "help"
|
|
23
30
|
end
|
data/sticky.gemspec
CHANGED
|
@@ -10,8 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ["artur.o.tsuda@gmail.com"]
|
|
11
11
|
|
|
12
12
|
spec.summary = "Sticky / Postit notes from your terminal"
|
|
13
|
-
|
|
14
|
-
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
|
13
|
+
spec.homepage = "https://github.com/arturts/sticky"
|
|
15
14
|
spec.license = "MIT"
|
|
16
15
|
|
|
17
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
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.1.
|
|
4
|
+
version: 0.1.1
|
|
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-
|
|
11
|
+
date: 2016-08-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -90,7 +90,7 @@ files:
|
|
|
90
90
|
- lib/sticky/note.rb
|
|
91
91
|
- lib/sticky/version.rb
|
|
92
92
|
- sticky.gemspec
|
|
93
|
-
homepage:
|
|
93
|
+
homepage: https://github.com/arturts/sticky
|
|
94
94
|
licenses:
|
|
95
95
|
- MIT
|
|
96
96
|
metadata: {}
|