tddium_status 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/tddium_status CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..' , 'lib'))
4
4
 
5
+ require 'rubygems'
6
+
5
7
  require 'tddium_status'
6
8
  require 'rainbow'
7
9
 
@@ -1,20 +1,21 @@
1
- require 'yaml/store'
1
+ require 'yaml'
2
2
 
3
3
  module TddiumStatus
4
4
  class Configuration
5
5
  def initialize(path = self.class.default_path)
6
- @store = YAML::Store.new(path)
6
+ @path = path
7
+ @lock = Mutex.new
7
8
  end
8
9
 
9
10
  def feeds
10
- @feeds ||= @store.transaction do
11
- @store[:feeds] ||= []
11
+ @feeds ||= transaction do |data|
12
+ data[:feeds] ||= []
12
13
  end
13
14
  end
14
15
 
15
16
  def feeds=(feeds)
16
- @store.transaction do
17
- @store[:feeds] = feeds || []
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
@@ -1,3 +1,3 @@
1
1
  module TddiumStatus
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  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.1
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-26 00:00:00.000000000 Z
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow