twiauth 0.0.2 → 0.1.0
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/.gitignore +2 -1
- data/VERSION +1 -1
- data/lib/twiauth.rb +1 -0
- data/lib/twiauth/oauth.rb +6 -10
- data/lib/twiauth/store.rb +35 -0
- data/spec/spec_helper.rb +0 -8
- data/spec/store_spec.rb +22 -0
- data/twiauth.gemspec +6 -4
- metadata +6 -4
- data/lib/twiauth/handler.rb +0 -6
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/twiauth.rb
CHANGED
data/lib/twiauth/oauth.rb
CHANGED
@@ -8,10 +8,12 @@ module TwiAuth
|
|
8
8
|
:authorize_path => '/oauth/authorize'
|
9
9
|
}
|
10
10
|
|
11
|
-
|
11
|
+
# key for access token
|
12
|
+
ACCESS_TOKEN = 'ACCESS_TOKEN'
|
12
13
|
|
13
14
|
public
|
14
15
|
def initialize(key, secret)
|
16
|
+
@store = TwiAuth::Store.new
|
15
17
|
@oauth_consumer = ::OAuth::Consumer.new(key, secret, TWITTER_OAUTH_SPEC)
|
16
18
|
get_access_token
|
17
19
|
end
|
@@ -25,9 +27,7 @@ module TwiAuth
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def drop_access_token
|
28
|
-
|
29
|
-
::File.delete(ACCESS_TOKEN)
|
30
|
-
end
|
30
|
+
@store.delete(ACCESS_TOKEN)
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -56,15 +56,11 @@ module TwiAuth
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def pull_access_token
|
59
|
-
|
60
|
-
@access_token = ::YAML.load_file(ACCESS_TOKEN)
|
61
|
-
end
|
59
|
+
@access_token = @store.get(ACCESS_TOKEN)
|
62
60
|
end
|
63
61
|
|
64
62
|
def persist_access_token
|
65
|
-
|
66
|
-
YAML.dump(@access_token, out)
|
67
|
-
end
|
63
|
+
@store.put(ACCESS_TOKEN,@access_token)
|
68
64
|
end
|
69
65
|
|
70
66
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'pstore'
|
2
|
+
|
3
|
+
module TwiAuth
|
4
|
+
# A simple key value store using PStore, provided by ruby
|
5
|
+
class Store
|
6
|
+
# Filename for pstore data file
|
7
|
+
DATA_FILE = "data.pstore"
|
8
|
+
# :nodoc:
|
9
|
+
def initialize
|
10
|
+
@store = PStore.new("#{PATH}#{DATA_FILE}")
|
11
|
+
end
|
12
|
+
|
13
|
+
# put a key with value
|
14
|
+
def put(key, value)
|
15
|
+
@store.transaction do
|
16
|
+
@store[key] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# get the value of the key
|
21
|
+
def get(key)
|
22
|
+
@store.transaction do
|
23
|
+
@value = @store[key]
|
24
|
+
end
|
25
|
+
@value
|
26
|
+
end
|
27
|
+
|
28
|
+
# delete a key
|
29
|
+
def delete(key)
|
30
|
+
@store.transaction do
|
31
|
+
@store.delete(key)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/store_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TwiAuth::Store do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@store = TwiAuth::Store.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should store some data" do
|
10
|
+
@store.put("test", "test-value")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return some data" do
|
14
|
+
@store.get("test").should.eql?("test-value")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should delete some data" do
|
18
|
+
@store.delete("test")
|
19
|
+
@store.get("test").should be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/twiauth.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{twiauth}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sascha Wessel"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-12}
|
13
13
|
s.description = %q{simple twitter authentication wrapper}
|
14
14
|
s.email = %q{swessel@gr4yweb.de}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,11 +23,12 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
25
|
"lib/twiauth.rb",
|
26
|
-
"lib/twiauth/handler.rb",
|
27
26
|
"lib/twiauth/oauth.rb",
|
27
|
+
"lib/twiauth/store.rb",
|
28
28
|
"spec/config.yml.sample",
|
29
29
|
"spec/oauth_spec.rb",
|
30
30
|
"spec/spec_helper.rb",
|
31
|
+
"spec/store_spec.rb",
|
31
32
|
"twiauth.gemspec"
|
32
33
|
]
|
33
34
|
s.homepage = %q{http://github.com/gr4y/twiauth}
|
@@ -37,7 +38,8 @@ Gem::Specification.new do |s|
|
|
37
38
|
s.summary = %q{a very simple twitter authentication wrapper}
|
38
39
|
s.test_files = [
|
39
40
|
"spec/spec_helper.rb",
|
40
|
-
"spec/oauth_spec.rb"
|
41
|
+
"spec/oauth_spec.rb",
|
42
|
+
"spec/store_spec.rb"
|
41
43
|
]
|
42
44
|
|
43
45
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.2
|
9
|
+
version: 0.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sascha Wessel
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-12 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -63,11 +63,12 @@ files:
|
|
63
63
|
- Rakefile
|
64
64
|
- VERSION
|
65
65
|
- lib/twiauth.rb
|
66
|
-
- lib/twiauth/handler.rb
|
67
66
|
- lib/twiauth/oauth.rb
|
67
|
+
- lib/twiauth/store.rb
|
68
68
|
- spec/config.yml.sample
|
69
69
|
- spec/oauth_spec.rb
|
70
70
|
- spec/spec_helper.rb
|
71
|
+
- spec/store_spec.rb
|
71
72
|
- twiauth.gemspec
|
72
73
|
has_rdoc: true
|
73
74
|
homepage: http://github.com/gr4y/twiauth
|
@@ -104,3 +105,4 @@ summary: a very simple twitter authentication wrapper
|
|
104
105
|
test_files:
|
105
106
|
- spec/spec_helper.rb
|
106
107
|
- spec/oauth_spec.rb
|
108
|
+
- spec/store_spec.rb
|