facebooked 0.1.0 → 0.1.1
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 +1 -0
- data/Rakefile +30 -0
- data/VERSION +1 -1
- data/facebooked.gemspec +14 -3
- data/lib/facebooked.rb +4 -2
- data/spec/facebooked_spec.rb +76 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- metadata +27 -7
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/*
|
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
1
4
|
begin
|
2
5
|
require 'jeweler'
|
3
6
|
Jeweler::Tasks.new do |gemspec|
|
@@ -7,8 +10,35 @@ begin
|
|
7
10
|
gemspec.email = "l33byrd@gmail.com"
|
8
11
|
gemspec.homepage = "http://github.com/leebyrd/facebooked"
|
9
12
|
gemspec.authors = ["Lee Byrd"]
|
13
|
+
gemspec.add_development_dependency "rspec", ">= 1.2.9"
|
10
14
|
end
|
11
15
|
Jeweler::GemcutterTasks.new
|
12
16
|
rescue LoadError
|
13
17
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
14
18
|
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
task :spec => :check_dependencies
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "temp_gem #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/facebooked.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{facebooked}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Lee Byrd"]
|
@@ -16,26 +16,37 @@ Gem::Specification.new do |s|
|
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
19
|
+
".gitignore",
|
20
|
+
"README.rdoc",
|
20
21
|
"Rakefile",
|
21
22
|
"VERSION",
|
22
23
|
"facebooked.gemspec",
|
23
|
-
"lib/facebooked.rb"
|
24
|
+
"lib/facebooked.rb",
|
25
|
+
"spec/facebooked_spec.rb",
|
26
|
+
"spec/spec.opts",
|
27
|
+
"spec/spec_helper.rb"
|
24
28
|
]
|
25
29
|
s.homepage = %q{http://github.com/leebyrd/facebooked}
|
26
30
|
s.rdoc_options = ["--charset=UTF-8"]
|
27
31
|
s.require_paths = ["lib"]
|
28
32
|
s.rubygems_version = %q{1.3.7}
|
29
33
|
s.summary = %q{Facebook api wrapper for server side authentication}
|
34
|
+
s.test_files = [
|
35
|
+
"spec/facebooked_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
30
38
|
|
31
39
|
if s.respond_to? :specification_version then
|
32
40
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
33
41
|
s.specification_version = 3
|
34
42
|
|
35
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
36
45
|
else
|
46
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
37
47
|
end
|
38
48
|
else
|
49
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
39
50
|
end
|
40
51
|
end
|
41
52
|
|
data/lib/facebooked.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
1
3
|
module Facebooked
|
2
4
|
def facebook_session
|
3
|
-
return unless cookie = cookies["fbs_#{APP_ID}"]
|
5
|
+
return unless cookie = cookies["fbs_#{self.class::APP_ID}"]
|
4
6
|
|
5
7
|
fs = {}
|
6
8
|
cookie.gsub(/"/, '').split('&').map{|str| str.split('=')}.each do |pair|
|
@@ -21,6 +23,6 @@ protected
|
|
21
23
|
[:access_token, :expires, :secret, :session_key, :uid] .each do |key|
|
22
24
|
digest += "#{key.to_s}=#{facebook_session[key]}"
|
23
25
|
end
|
24
|
-
Digest::MD5.hexdigest(digest + SECRET) == facebook_session[:sig]
|
26
|
+
Digest::MD5.hexdigest(digest + self.class::SECRET) == facebook_session[:sig]
|
25
27
|
end
|
26
28
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
class FacebookedController
|
4
|
+
include Facebooked
|
5
|
+
|
6
|
+
APP_ID = "1Z5148396205221"
|
7
|
+
SECRET = "ad6f9c32ed9b0e929fa501d0f17bd0z0"
|
8
|
+
|
9
|
+
def cookies
|
10
|
+
@cookies ||= {}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class User
|
15
|
+
attr_accessor :fb_id
|
16
|
+
|
17
|
+
def self.find_or_create_by_fb_id(params={}); end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Facebooked do
|
21
|
+
before do
|
22
|
+
@controller = FacebookedController.new
|
23
|
+
|
24
|
+
@user_id = '932554485'
|
25
|
+
@valid_cookie = "access_token=1Z5148396205221|2.CwTndyUul10gGU7RbqsV_A__.3600.1280012400-732554485|OysLlVCa0fleQgd2BryTofvumUA.&expires=1280012400&secret=sDyOuEWLl6tOcS2CQPhw4z__&session_key=2.CwTndyUul10gGU7RbqsV_A__.3600.1280012400-732554485&sig=4bee0f5d75676e806ec259f7765a78de&uid=932554485"
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_cookie(content)
|
29
|
+
@controller.cookies["fbs_#{FacebookedController::APP_ID}"] = content
|
30
|
+
end
|
31
|
+
|
32
|
+
context "#facebook_session" do
|
33
|
+
it "parses facebook_session from valid cookie" do
|
34
|
+
set_cookie(@valid_cookie)
|
35
|
+
session = @controller.facebook_session
|
36
|
+
session[:access_token].should == "1Z5148396205221|2.CwTndyUul10gGU7RbqsV_A__.3600.1280012400-732554485|OysLlVCa0fleQgd2BryTofvumUA."
|
37
|
+
session[:expires].should == "1280012400"
|
38
|
+
session[:secret].should == "sDyOuEWLl6tOcS2CQPhw4z__"
|
39
|
+
session[:session_key].should == "2.CwTndyUul10gGU7RbqsV_A__.3600.1280012400-732554485"
|
40
|
+
session[:sig].should == "4bee0f5d75676e806ec259f7765a78de"
|
41
|
+
session[:uid].should == "932554485"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns nil if cookie is nil" do
|
45
|
+
@controller.facebook_session.should be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "#current_user" do
|
50
|
+
before do
|
51
|
+
@user = User.new
|
52
|
+
User.stub!(:find_or_create_by_fb_id).with(:fb_id => @user_id).and_return(@user)
|
53
|
+
end
|
54
|
+
|
55
|
+
def current_user
|
56
|
+
@controller.send(:current_user)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns user with valid cookie" do
|
60
|
+
set_cookie(@valid_cookie)
|
61
|
+
|
62
|
+
current_user.should == @user
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns nil with invalid cookie" do
|
66
|
+
invalid_cookie = "access_token=905148396205221|2.CwTndyUul10gGU7RbqsV_A__.3600.1280012400-732554485|OysLlVCa0fleQgd2BryTofvumUA.&expires=1280012400&secret=sDyOuEWLl6tOcS2CQPhw4g__&session_key=2.CwTndyUul10gGU7RbqsV_A__.3600.1280012400-732554485&sig=36f769492d5e94aef5a580c36d47a480&uid=732554485"
|
67
|
+
set_cookie(invalid_cookie)
|
68
|
+
|
69
|
+
current_user.should be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns nil with no cookie" do
|
73
|
+
current_user.should be_nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebooked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lee Byrd
|
@@ -17,8 +17,23 @@ cert_chain: []
|
|
17
17
|
|
18
18
|
date: 2010-08-02 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
22
37
|
description: Facebooked is complimentary to connect-js
|
23
38
|
email: l33byrd@gmail.com
|
24
39
|
executables: []
|
@@ -28,11 +43,15 @@ extensions: []
|
|
28
43
|
extra_rdoc_files:
|
29
44
|
- README.rdoc
|
30
45
|
files:
|
46
|
+
- .gitignore
|
31
47
|
- README.rdoc
|
32
48
|
- Rakefile
|
33
49
|
- VERSION
|
34
50
|
- facebooked.gemspec
|
35
51
|
- lib/facebooked.rb
|
52
|
+
- spec/facebooked_spec.rb
|
53
|
+
- spec/spec.opts
|
54
|
+
- spec/spec_helper.rb
|
36
55
|
has_rdoc: true
|
37
56
|
homepage: http://github.com/leebyrd/facebooked
|
38
57
|
licenses: []
|
@@ -67,5 +86,6 @@ rubygems_version: 1.3.7
|
|
67
86
|
signing_key:
|
68
87
|
specification_version: 3
|
69
88
|
summary: Facebook api wrapper for server side authentication
|
70
|
-
test_files:
|
71
|
-
|
89
|
+
test_files:
|
90
|
+
- spec/facebooked_spec.rb
|
91
|
+
- spec/spec_helper.rb
|