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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17894314764e236a44242117890473cd1452ecf4
4
- data.tar.gz: 1d5b9e32287bab8745d858352674b614c24dfea0
3
+ metadata.gz: d45a99eb2153d0b4f7a8fdd6da7432569e4e2a8c
4
+ data.tar.gz: 44f6045de94576ebfd4f56815195fb5782ead787
5
5
  SHA512:
6
- metadata.gz: acab7da0e5a13d939a7cb3024be5c9f781d7479870de6fb1f21685cd7bc7072cbf6ba436c42ba1951ea074a619126f641326236774c85fee58a2b459e799ab43
7
- data.tar.gz: e41d89c4b3bbb72d29febfbd98c131295e7c17ac6e8f3b84b9408fe6b56546bae5ea7e4e299ef230daa99a06ca75c348cfb8164be550ef663a5c829b31eae456
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
- DB = YAML::Store.new("#{Dir.home}/.sticky.yml")
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
- def initialize(message, tag = nil)
10
- @message, @tag, @timestamp = message, tag, Time.now
11
- end
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
- def save!
14
- DB.transaction do
15
- DB[:sticky_notes] ||= []
16
- DB[:sticky_notes] << {
17
- timestamp: @timestamp,
18
- message: @message,
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
- class << self
25
- def show(tag)
26
- DB.transaction do
27
- DB[:sticky_notes] ||= []
28
- DB[:sticky_notes].each do |sticky|
29
- puts sticky[:message] unless tag || sticky[:tag] == tag
30
- end
31
- end
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
@@ -1,3 +1,3 @@
1
1
  module Sticky
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.new(message, options[:tag]).save!
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
- def show(tag = nil)
17
- Sticky::Note.show(tag)
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
- # spec.description = %q{TODO: Write a longer description or delete this line.}
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.0
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-07-30 00:00:00.000000000 Z
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: {}