tddium_status 0.0.1 → 0.0.2
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.
- data/bin/tddium_status +2 -0
- data/lib/tddium_status/configuration.rb +18 -6
- data/lib/tddium_status/version.rb +1 -1
- metadata +2 -2
data/bin/tddium_status
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
require 'yaml
|
1
|
+
require 'yaml'
|
2
2
|
|
3
3
|
module TddiumStatus
|
4
4
|
class Configuration
|
5
5
|
def initialize(path = self.class.default_path)
|
6
|
-
@
|
6
|
+
@path = path
|
7
|
+
@lock = Mutex.new
|
7
8
|
end
|
8
9
|
|
9
10
|
def feeds
|
10
|
-
@feeds ||=
|
11
|
-
|
11
|
+
@feeds ||= transaction do |data|
|
12
|
+
data[:feeds] ||= []
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
def feeds=(feeds)
|
16
|
-
|
17
|
-
|
17
|
+
transaction do |data|
|
18
|
+
data[:feeds] = feeds || []
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -24,6 +25,17 @@ module TddiumStatus
|
|
24
25
|
self.feeds = feeds
|
25
26
|
end
|
26
27
|
|
28
|
+
def transaction(&block)
|
29
|
+
@lock.synchronize do
|
30
|
+
data = YAML.load(File.read(@path)) rescue {}
|
31
|
+
result = block.call(data)
|
32
|
+
File.open(@path, "w") do |f|
|
33
|
+
f.write(YAML.dump(data))
|
34
|
+
end
|
35
|
+
result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
27
39
|
def self.default_path
|
28
40
|
File.join(Dir.home, '.tddium_status.yml')
|
29
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tddium_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|