sticky 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3681912cc1c498a1a74590a32f732c6988db5ae5
4
- data.tar.gz: 2f8522aff60f130d6da3228a3db583deb8b4494c
3
+ metadata.gz: 89ac0b828a1379f1a6706805471bae993ad5860a
4
+ data.tar.gz: 2fc23dbea0c0db6aac5a6ed09046700982363823
5
5
  SHA512:
6
- metadata.gz: 1775620797ae8dd6b468d42ade1b5c01127ac495d18b2146ea012b7c7d123a3b85b3a2914c3486a914496d7b37a3635aeef36e6d49b260489295ec67c6334c22
7
- data.tar.gz: 2224ea6554bd2a2d1b2fccdfefc158dbf45429a02ec232f821176351702b3e862884f8bbd5c34c2387d96d579fa44f232666a477a511e91d0acdc6d90e2b0944
6
+ metadata.gz: b1151b1d54cd20343c95dd04126699d22cb5b5094fa3b84a836f95ef901168dff14dbca7d12373f81e6f4aac40d44a1d757440805527f901a3991e625d9442d0
7
+ data.tar.gz: 8e72822acc1b2206cafc93acf26532d59939953b14d2596f0c1e8e3cf18aa2eb3633035005229151062b8512cc88e77efd741afac487c420c8693f5926093411
data/README.md CHANGED
@@ -26,11 +26,12 @@ Delete tagged entries with:
26
26
 
27
27
  $ sticky delete -t my-tag
28
28
 
29
+ You can also specify a config file, `$HOME/.sticky.config`. It is a simple YAML file (currently only supports the path to the sticky notes `sticky_path: path/to/file`).
30
+
29
31
  ## TODO
30
32
 
31
33
  * Display last N sticky notes
32
34
  * Multiple tags
33
- * Move some dependencies out of Sticky::Note
34
35
  * Implement specs
35
36
 
36
37
  ## Development
@@ -43,7 +44,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
43
44
 
44
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/arturts/sticky.
45
46
 
46
-
47
47
  ## License
48
48
 
49
49
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,33 @@
1
+ module Sticky
2
+ class Config
3
+
4
+ def initialize
5
+ @config = {
6
+ store: "YAML::Store",
7
+ sticky_path: File.join(Dir.home, ".sticky.yml")
8
+ }.merge(config_overrides)
9
+ end
10
+
11
+ def fetch(key)
12
+ @config[key]
13
+ end
14
+
15
+ private
16
+
17
+ def config_overrides
18
+ YAML.load(config_file).tap do |yaml|
19
+ yaml.keys.each do |key|
20
+ yaml[key.to_sym] = yaml.delete(key)
21
+ end
22
+ end
23
+ end
24
+
25
+ def config_file
26
+ File.exists?(config_path) ? File.open(config_path) : "{}"
27
+ end
28
+
29
+ def config_path
30
+ File.join(Dir.home, ".sticky.config")
31
+ end
32
+ end
33
+ end
data/lib/sticky/note.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'sticky/store'
1
+ require "sticky/store"
2
2
 
3
3
  module Sticky
4
4
  class Note
data/lib/sticky/store.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  require "yaml/store"
2
+ require "sticky/config"
2
3
 
3
4
  module Sticky
4
5
  class Store
5
6
  attr_reader :store
6
7
 
7
- def initialize(store_path = "#{Dir.home}/.sticky.yml")
8
- @store = YAML::Store.new(store_path)
8
+ def initialize(config = Sticky::Config.new)
9
+ klass = Object.const_get(config.fetch(:store))
10
+ @store = klass.new(config.fetch(:sticky_path))
9
11
  end
10
12
 
11
13
  def fetch(tag = nil, date = nil)
@@ -1,3 +1,3 @@
1
1
  module Sticky
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.0
4
+ version: 0.4.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-22 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -102,6 +102,7 @@ files:
102
102
  - bin/setup
103
103
  - bin/sticky
104
104
  - lib/sticky.rb
105
+ - lib/sticky/config.rb
105
106
  - lib/sticky/note.rb
106
107
  - lib/sticky/store.rb
107
108
  - lib/sticky/version.rb