notifaction 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26422607a1758ad1afac4574c536061cdfd1a632
4
- data.tar.gz: a532ee4c8396687e15792478f0b52910bbb535b6
3
+ metadata.gz: e5439ba63abc58af06453e917aad30bc194eefdd
4
+ data.tar.gz: a3f1c3e082aa9627b890521b6e9db47fe1f31989
5
5
  SHA512:
6
- metadata.gz: 834361b702195e0924d877c05c8db909a598652cab54d5ed4ce2881170776c61d268472df6639c8fbc9ccda19bdc9295f0aa16dbffe6a97055512bf438d08047
7
- data.tar.gz: 410644b1a8feae8626712bdd1064d7314cf5bb9510e278777b272f78a563b4d99f927c2483db37e44568d7ee34aa551efba23cf3007eb47aa70e1664f0d33436
6
+ metadata.gz: 53d8f23d81ee7681ec932e7fe3ed6527dc7123b39a95a917a4032abb0ec1b66683ca7fff1ceaaf7b69907adedf5190d50d71184c733117c3a162a378778d2727
7
+ data.tar.gz: 8309bd266ae92874eefa6b949b47bce806d3c7f675550e5a959b16c9c3e92c4044b4be171ecf5426e30e688a97c2af1b0e63c71993b5192043e07be8bbbfbcbf
@@ -2,18 +2,38 @@ require "yaml"
2
2
 
3
3
  module Notifaction
4
4
  class Cfg
5
- attr_reader :hooks, :conf
6
-
7
5
  #
8
6
  # @since 0.4.0
9
7
  def initialize
10
8
  local_conf = Dir.home + "/.notifaction.yml"
9
+
10
+ conf = {}
11
11
  conf = YAML.load(File.open(local_conf)) if File.exists? local_conf
12
12
 
13
- @hooks = conf["hooks"] || []
14
- @conf = conf["config"] || {}
13
+ @hooks = conf["hooks"] ||= []
14
+ @config = conf["config"] ||= {}
15
15
 
16
16
  nil
17
17
  end
18
+
19
+ #
20
+ # @since 0.4.3
21
+ def hook(item)
22
+ return if @hooks.empty? || item.nil?
23
+ @hooks[item.to_sym]
24
+ end
25
+
26
+ #
27
+ # @since 0.4.3
28
+ def hooks
29
+ @hooks
30
+ end
31
+
32
+ #
33
+ # @since 0.4.3
34
+ def config(item)
35
+ return if @config.empty? || item.nil?
36
+ @config[item.to_sym]
37
+ end
18
38
  end
19
39
  end
@@ -14,7 +14,7 @@ module Notifaction
14
14
  # Should method exit with Type::QUIT? Mainly used in tests
15
15
  # @since 0.4.1
16
16
  def auto_quit_enabled?(config, user_conf)
17
- config[:auto_quit] == false || user_conf.conf["auto_quit"] == false
17
+ config[:auto_quit] == false || user_conf.config("auto_quit") == false
18
18
  end
19
19
  end
20
20
  end
@@ -84,19 +84,19 @@ module Notifaction
84
84
  #
85
85
  # @since 0.4.0
86
86
  def show_symbol(config)
87
- config[:symbol] || config[:fancy] || @user_conf.conf["fancy"] == true
87
+ config[:symbol] || config[:fancy] || @user_conf.config("fancy") == true
88
88
  end
89
89
 
90
90
  #
91
91
  # @since 0.4.0
92
92
  def show_time(config)
93
- config[:show_time] || @user_conf.conf["show_time"]
93
+ config[:show_time] || @user_conf.config("show_time")
94
94
  end
95
95
 
96
96
  #
97
97
  # @since 0.4.0
98
98
  def show_message(config)
99
- config[:print] == false || @user_conf.conf["print"] == false
99
+ config[:print] == false || @user_conf.config("print") == false
100
100
  end
101
101
  end
102
102
  end
@@ -1,3 +1,3 @@
1
1
  module Notifaction
2
- VERSION = "0.4.2".freeze
2
+ VERSION = "0.4.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Яyan Priebe