purzelrakete-boomloop 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +1,39 @@
1
+ =begin
2
+ stores oauth credentials.
3
+ =end
1
4
  module Boomloop
2
5
  module Authentication
3
6
  module Store
4
7
  class YAMLStore < Base
5
- @@ymlfile = File.dirname(__FILE__) + '/../../../config/credentials.yml'
6
8
 
7
- class << self
8
- attr_accessor :config
9
- end
10
-
11
- def initialize
12
- self.class.load_config
9
+ # pass in where the yml should be stored.
10
+ def initialize(filename = "#{ ENV["HOME"] }/.boomloop_credentials.yml")
11
+ @config_filename = filename
12
+ self.load_config
13
13
  end
14
14
 
15
- def self.load_config
16
- File.open(@@ymlfile) do |file|
17
- self.config = YAML.load(file) || {}
18
- end
15
+ def load_config
16
+ file = File.new(@config_filename, "a+")
17
+ file.rewind
18
+ @config = YAML.load(file) || {}
19
+ file.close
19
20
  end
20
21
 
21
- def self.save_config
22
- if self.config
23
- File.open(@@ymlfile, "w") do |f|
24
- f.write self.config.to_yaml
22
+ def save_config
23
+ if @config
24
+ File.open(@config_filename, "w") do |f|
25
+ f.write @config.to_yaml
25
26
  end
26
27
  end
27
28
  end
28
29
 
29
30
  def update(credentials)
30
- self.class.config[credentials.username] = credentials.options
31
- self.class.save_config
31
+ @config[credentials.username] = credentials.options
32
+ self.save_config
32
33
  end
33
34
 
34
35
  def find(user)
35
- ::Boomloop::Authentication::Credentials.new(user, self, self.class.config[user])
36
+ ::Boomloop::Authentication::Credentials.new(user, self, @config[user])
36
37
  end
37
38
  end
38
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purzelrakete-boomloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rany Keddo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-26 00:00:00 -07:00
12
+ date: 2008-05-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -49,7 +49,6 @@ files:
49
49
  - test/mocks
50
50
  - test/mocks/monster.rb
51
51
  - test/test_helper.rb
52
- - config/credentials.yml
53
52
  has_rdoc: true
54
53
  homepage: http://github.com/purzelrakete/boomloop
55
54
  post_install_message:
@@ -1,6 +0,0 @@
1
- ---
2
- api:
3
- :consumer_key: j2Nl3hhU09Eo4tSstzbJQ
4
- :access_secret: SweZHltNo4LF4mvG2vqp1nbMRNw7ZZLraP65TvrLic
5
- :consumer_secret: Uzwy52l8lSVQYZWMVYNv6nphINN0pGrwKmsXiGSUzg
6
- :access_key: m4qOECcRym7aW4mtGOw9Fw