alphred 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/alphred/config.rb +12 -9
- data/lib/alphred/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9ca94ec4f544e985a798830efd2d8a73109a192
|
4
|
+
data.tar.gz: 23e9fd55bed763edc8bc426c3e19886c5de2870d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fabb2a27430690c52d02edabd521f7dac94aa7238dde140efad5f5e561db3be8b1f6546f88d5659f54dbc7ee471062851d772368a11e5606c7b5fde82802c222
|
7
|
+
data.tar.gz: 70e6f5596436d6afab34f9b52e67b6ece3c13db4630e6add630649c77a4a71f1ee1c0397e18dbe8e96304d5ba7ac27075d7309093f85c62dbc08a6e4a64d1f17
|
data/CHANGELOG.md
CHANGED
data/lib/alphred/config.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'json'
|
2
2
|
|
3
3
|
module Alphred
|
4
4
|
class Config
|
5
5
|
def self.load(**defaults)
|
6
|
-
config =
|
6
|
+
config = new(**defaults)
|
7
7
|
config.load!
|
8
8
|
config
|
9
9
|
end
|
@@ -15,23 +15,24 @@ module Alphred
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def load!
|
18
|
-
return unless File.exist?(
|
19
|
-
|
18
|
+
return unless File.exist?(path)
|
19
|
+
data.merge!(JSON.load(File.open(path)))
|
20
20
|
end
|
21
21
|
|
22
22
|
def update!(json)
|
23
23
|
data = self.data.merge(JSON.load(json))
|
24
|
-
File.
|
24
|
+
FileUtils.mkdir_p(File.dirname(path))
|
25
|
+
File.write(path, JSON.dump(data), mode: ?w)
|
25
26
|
end
|
26
27
|
|
27
28
|
def [](key)
|
28
|
-
|
29
|
+
data[key.to_s]
|
29
30
|
end
|
30
31
|
|
31
32
|
def filter_xml(filter=nil)
|
32
|
-
filter ||=
|
33
|
+
filter ||= ''
|
33
34
|
|
34
|
-
items =
|
35
|
+
items = data.map do |key, value|
|
35
36
|
title = if filter.empty?
|
36
37
|
"Unset #{key}"
|
37
38
|
else
|
@@ -48,8 +49,10 @@ module Alphred
|
|
48
49
|
Items.new(*items).to_xml
|
49
50
|
end
|
50
51
|
|
52
|
+
private
|
53
|
+
|
51
54
|
def path
|
52
|
-
File.join(ENV[
|
55
|
+
File.join(ENV['alfred_workflow_data'], 'config.json')
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
data/lib/alphred/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphred
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alpha Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|