upstream-simple_facebook_connect 0.0.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.
Files changed (34) hide show
  1. data/.gitignore +1 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +90 -0
  4. data/Rakefile +27 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/simple_facebook_connect/connect_controller.rb +59 -0
  7. data/app/views/shared/_facebook_connect_button.html.erb +15 -0
  8. data/config/simple_facebook_connect_routes.rb +4 -0
  9. data/generators/simple_facebook_connect_features/simple_facebook_connect_features_generator.rb +14 -0
  10. data/generators/simple_facebook_connect_features/templates/facebook_auth_getsession.xml +9 -0
  11. data/generators/simple_facebook_connect_features/templates/facebook_connect.feature +27 -0
  12. data/generators/simple_facebook_connect_features/templates/facebook_connect_steps.rb +19 -0
  13. data/generators/simple_facebook_connect_features/templates/facebook_connect_stubs.rb +44 -0
  14. data/generators/simple_facebook_connect_features/templates/facebook_users_getinfo.xml +119 -0
  15. data/generators/simple_facebook_connect_migration/simple_facebook_connect_migration_generator.rb +13 -0
  16. data/generators/simple_facebook_connect_migration/templates/migration.rb +17 -0
  17. data/init.rb +35 -0
  18. data/lib/simple_facebook_connect.rb +14 -0
  19. data/lib/simple_facebook_connect/controller_extension.rb +11 -0
  20. data/lib/simple_facebook_connect/extensions/routes.rb +13 -0
  21. data/lib/simple_facebook_connect/parser.rb +161 -0
  22. data/lib/simple_facebook_connect/service.rb +34 -0
  23. data/lib/simple_facebook_connect/session.rb +73 -0
  24. data/lib/simple_facebook_connect/user.rb +26 -0
  25. data/lib/simple_facebook_connect/user_extension.rb +21 -0
  26. data/rails/init.rb +1 -0
  27. data/simple_facebook_connect.gemspec +71 -0
  28. data/spec/fixtures/facebook.auth.getSession/default.xml +9 -0
  29. data/spec/fixtures/facebook.users.getInfo/default.xml +119 -0
  30. data/spec/lib/simple_facebook_connect/parser_spec.rb +12 -0
  31. data/spec/lib/simple_facebook_connect/user_extension_spec.rb +16 -0
  32. data/spec/lib/simple_facebook_connect/user_spec.rb +30 -0
  33. data/spec/spec_helper.rb +31 -0
  34. metadata +89 -0
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <auth_getSession_response
3
+ xmlns="http://api.facebook.com/1.0/"
4
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
6
+ <session_key>5f34e11bfb97c762e439e6a5-8055</session_key>
7
+ <uid>8055</uid>
8
+ <expires>1173309298</expires>
9
+ </auth_getSession_response>
@@ -0,0 +1,119 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <users_getInfo_response xmlns="http://api.facebook.com/1.0/"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
5
+ <user>
6
+ <uid>8055</uid>
7
+ <about_me>This field perpetuates the glorification of the ego. Also, it has a character limit.</about_me>
8
+ <activities>Here: facebook, etc. There: Glee Club, a capella, teaching.</activities>
9
+ <affiliations list="true">
10
+ <affiliation>
11
+ <nid>50453093</nid>
12
+ <name>Facebook Developers</name>
13
+ <type>work</type>
14
+ <status/>
15
+ <year/>
16
+ </affiliation>
17
+ </affiliations>
18
+ <birthday>November 3</birthday>
19
+ <books>The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar</books>
20
+ <current_location>
21
+ <city>Palo Alto</city>
22
+ <state>California</state>
23
+ <country>United States</country>
24
+ <zip>94303</zip>
25
+ </current_location>
26
+ <education_history list="true">
27
+ <education_info>
28
+ <name>Harvard</name>
29
+ <year>2003</year>
30
+ <concentrations list="true">
31
+ <concentration>Applied Mathematics</concentration>
32
+ <concentration>Computer Science</concentration>
33
+ </concentrations>
34
+ </education_info>
35
+ </education_history>
36
+ <email_hashes list="true">
37
+ <email_hash_elt>2781152470_9f9c29692798573d8c76eaaf053a1911</email_hash_elt>
38
+ </email_hashes>
39
+ <family list="true">
40
+ <family_elt list="true">
41
+ <family_elt_elt>mother</family_elt_elt>
42
+ <family_elt_elt>1394244902</family_elt_elt>
43
+ </family_elt>
44
+ <family_elt list="true">
45
+ <family_elt_elt>sister</family_elt_elt>
46
+ <family_elt_elt>48703107</family_elt_elt>
47
+ </family_elt>
48
+ <family_elt list="true">
49
+ <family_elt_elt>brother</family_elt_elt>
50
+ <family_elt_elt>1078767258</family_elt_elt>
51
+ </family_elt>
52
+ <family_elt list="true">
53
+ <family_elt_elt>brother</family_elt_elt>
54
+ <family_elt_elt>John Doe</family_elt_elt>
55
+ <family_elt_elt/>
56
+ </family_elt>
57
+ </family>
58
+ <first_name>Dave</first_name>
59
+ <hometown_location>
60
+ <city>York</city>
61
+ <state>Pennsylvania</state>
62
+ <country>United States</country>
63
+ </hometown_location>
64
+ <hs_info>
65
+ <hs1_name>Central York High School</hs1_name>
66
+ <hs2_name/>
67
+ <grad_year>1999</grad_year>
68
+ <hs1_id>21846</hs1_id>
69
+ <hs2_id>0</hs2_id>
70
+ </hs_info>
71
+ <is_app_user>1</is_app_user>
72
+ <has_added_app>1</has_added_app>
73
+ <interests>coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers</interests>
74
+ <last_name>Fetterman</last_name>
75
+ <locale>en_US</locale>
76
+ <meeting_for list="true">
77
+ <seeking>Friendship</seeking>
78
+ </meeting_for>
79
+ <meeting_sex list="true">
80
+ <sex>female</sex>
81
+ </meeting_sex>
82
+ <movies>Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space </movies>
83
+ <music>New Found Glory, Daft Punk, Weezer, The Crystal Method, Rage, the KLF, Green Day, Live, Coldplay, Panic at the Disco, Family Force 5</music>
84
+ <name>Dave Fetterman</name>
85
+ <notes_count>0</notes_count>
86
+ <pic>http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg</pic>
87
+ <pic_big>http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg</pic_big>
88
+ <pic_small>http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg</pic_small>
89
+ <pic_square>http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg</pic_square>
90
+ <political>Moderate</political>
91
+ <profile_update_time>1170414620</profile_update_time>
92
+ <quotes/>
93
+ <relationship_status>In a Relationship</relationship_status>
94
+ <religion/>
95
+ <sex>male</sex>
96
+ <significant_other_id xsi:nil="true"/>
97
+ <status>
98
+ <message>Fast Company, November issue, page 84</message>
99
+ <time>1193075616</time>
100
+ </status>
101
+ <timezone>-8</timezone>
102
+ <tv>cf. Bob Trahan</tv>
103
+ <wall_count>121</wall_count>
104
+ <work_history list="true">
105
+ <work_info>
106
+ <location>
107
+ <city>Palo Alto</city>
108
+ <state>CA</state>
109
+ <country>United States</country>
110
+ </location>
111
+ <company_name>Facebook</company_name>
112
+ <position>Software Engineer</position>
113
+ <description>Tech Lead, Facebook Platform</description>
114
+ <start_date>2006-01</start_date>
115
+ <end_date/>
116
+ </work_info>
117
+ </work_history>
118
+ </user>
119
+ </users_getInfo_response>
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe SimpleFacebookConnect::Parser, 'parse' do
4
+ it "should parse getInfo xml response" do
5
+ result = SimpleFacebookConnect::Parser.parse('facebook.users.getInfo', File.read(File.dirname(__FILE__) + '/../../fixtures/facebook.users.getInfo/default.xml'))
6
+ result.should == parsed_array
7
+ end
8
+
9
+ def parsed_array
10
+ [{"uid"=>"8055", "about_me"=>"This field perpetuates the glorification of the ego. Also, it has a character limit.", "activities"=>"Here: facebook, etc. There: Glee Club, a capella, teaching.", "affiliations"=>[{"nid"=>"50453093", "name"=>"Facebook Developers", "type"=>"work", "status"=>"", "year"=>""}], "birthday"=>"November 3", "books"=>"The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar", "current_location"=>{"city"=>"Palo Alto", "state"=>"California", "country"=>"United States", "zip"=>"94303"}, "education_history"=>[{"name"=>"Harvard", "year"=>"2003", "concentrations"=>["Applied Mathematics", "Computer Science"]}], "email_hashes"=>["2781152470_9f9c29692798573d8c76eaaf053a1911"], "family"=>[{"family_elt_elt"=>"1394244902"}, {"family_elt_elt"=>"48703107"}, {"family_elt_elt"=>"1078767258"}, {"family_elt_elt"=>""}], "first_name"=>"Dave", "hometown_location"=>{"city"=>"York", "state"=>"Pennsylvania", "country"=>"United States"}, "hs_info"=>{"hs1_name"=>"Central York High School", "hs2_name"=>{}, "grad_year"=>"1999", "hs1_id"=>"21846", "hs2_id"=>"0"}, "is_app_user"=>"1", "has_added_app"=>"1", "interests"=>"coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers", "last_name"=>"Fetterman", "locale"=>"en_US", "meeting_for"=>["Friendship"], "meeting_sex"=>["female"], "movies"=>"Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space", "music"=>"New Found Glory, Daft Punk, Weezer, The Crystal Method, Rage, the KLF, Green Day, Live, Coldplay, Panic at the Disco, Family Force 5", "name"=>"Dave Fetterman", "notes_count"=>"0", "pic"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg", "pic_big"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg", "pic_small"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg", "pic_square"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg", "political"=>"Moderate", "profile_update_time"=>"1170414620", "quotes"=>"", "relationship_status"=>"In a Relationship", "religion"=>"", "sex"=>"male", "significant_other_id"=>nil, "status"=>{"message"=>"Fast Company, November issue, page 84", "time"=>"1193075616"}, "timezone"=>"-8", "tv"=>"cf. Bob Trahan", "wall_count"=>"121", "work_history"=>[{"location"=>{"city"=>"Palo Alto", "state"=>"CA", "country"=>"United States"}, "company_name"=>"Facebook", "position"=>"Software Engineer", "description"=>"Tech Lead, Facebook Platform", "start_date"=>"2006-01", "end_date"=>""}]}]
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe SimpleFacebookConnect::UserExtension, 'email=' do
4
+ class User < ActiveRecord::Base
5
+ include SimpleFacebookConnect::UserExtension
6
+
7
+ end
8
+
9
+ it "should set the email hash" do
10
+ user = User.new
11
+ user.email = 'joe@doe.com'
12
+ user.save!
13
+ user.email_hash.should == '3404385302_68ef883c573edb5d26365e8f20156eec'
14
+
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe SimpleFacebookConnect::User, 'initialize' do
4
+ before(:each) do
5
+ @session = stub 'session', :post => nil
6
+ end
7
+
8
+ it "should send a remote call to facebook" do
9
+ @session.should_receive(:post).with('facebook.users.getInfo', :fields => 'uid,hometown_location,first_name,last_name,current_location,pic,locale,email_hashes', :uids => 8055)
10
+ SimpleFacebookConnect::User.new(8055, @session)
11
+ end
12
+
13
+ it "should populate the user attributes" do
14
+ @session.stub!(:post).and_yield(user_info_response)
15
+ user = SimpleFacebookConnect::User.new(8055, @session)
16
+ user.email_hashes.should == ["2781152470_9f9c29692798573d8c76eaaf053a1911"]
17
+ user.uid.should == '8055'
18
+ user.hometown_location.should == {"city"=>"York", "state"=>"Pennsylvania", "country"=>"United States"}
19
+ user.first_name.should == 'Dave'
20
+ user.last_name.should == 'Fetterman'
21
+ user.current_location.should == {"city"=>"Palo Alto", "state"=>"California", "country"=>"United States", "zip"=>"94303"}
22
+ user.pic.should == 'http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg'
23
+ user.locale.should == 'en_US'
24
+ end
25
+
26
+
27
+ def user_info_response
28
+ [{"uid"=>"8055", "about_me"=>"This field perpetuates the glorification of the ego. Also, it has a character limit.", "activities"=>"Here: facebook, etc. There: Glee Club, a capella, teaching.", "affiliations"=>[{"nid"=>"50453093", "name"=>"Facebook Developers", "type"=>"work", "status"=>"", "year"=>""}], "birthday"=>"November 3", "books"=>"The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar", "current_location"=>{"city"=>"Palo Alto", "state"=>"California", "country"=>"United States", "zip"=>"94303"}, "education_history"=>[{"name"=>"Harvard", "year"=>"2003", "concentrations"=>["Applied Mathematics", "Computer Science"]}], "email_hashes"=>["2781152470_9f9c29692798573d8c76eaaf053a1911"], "family"=>[{"family_elt_elt"=>"1394244902"}, {"family_elt_elt"=>"48703107"}, {"family_elt_elt"=>"1078767258"}, {"family_elt_elt"=>""}], "first_name"=>"Dave", "hometown_location"=>{"city"=>"York", "state"=>"Pennsylvania", "country"=>"United States"}, "hs_info"=>{"hs1_name"=>"Central York High School", "hs2_name"=>{}, "grad_year"=>"1999", "hs1_id"=>"21846", "hs2_id"=>"0"}, "is_app_user"=>"1", "has_added_app"=>"1", "interests"=>"coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers", "last_name"=>"Fetterman", "locale"=>"en_US", "meeting_for"=>["Friendship"], "meeting_sex"=>["female"], "movies"=>"Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space", "music"=>"New Found Glory, Daft Punk, Weezer, The Crystal Method, Rage, the KLF, Green Day, Live, Coldplay, Panic at the Disco, Family Force 5", "name"=>"Dave Fetterman", "notes_count"=>"0", "pic"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg", "pic_big"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg", "pic_small"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg", "pic_square"=>"http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg", "political"=>"Moderate", "profile_update_time"=>"1170414620", "quotes"=>"", "relationship_status"=>"In a Relationship", "religion"=>"", "sex"=>"male", "significant_other_id"=>nil, "status"=>{"message"=>"Fast Company, November issue, page 84", "time"=>"1193075616"}, "timezone"=>"-8", "tv"=>"cf. Bob Trahan", "wall_count"=>"121", "work_history"=>[{"location"=>{"city"=>"Palo Alto", "state"=>"CA", "country"=>"United States"}, "company_name"=>"Facebook", "position"=>"Software Engineer", "description"=>"Tech Lead, Facebook Platform", "start_date"=>"2006-01", "end_date"=>""}]}]
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ __DIR__ = File.dirname __FILE__
2
+ $LOAD_PATH << __DIR__ + '/../lib'
3
+
4
+ require 'simple_facebook_connect'
5
+
6
+ require 'fileutils'
7
+ require 'rubygems'
8
+ Gem::RubyGemsVersion.inspect # without this the activerecord gem doesn't load on ruby 1.9 #WTF
9
+ require 'sqlite3'
10
+ gem 'activerecord'
11
+ require 'activerecord'
12
+
13
+
14
+
15
+ FileUtils.rm_rf __DIR__ + '/../test.sqlite3'
16
+ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => File.join(__DIR__, '..', 'test.sqlite3')
17
+
18
+ # migrate
19
+
20
+ class CreateUsers < ActiveRecord::Migration
21
+ def self.up
22
+ create_table :users do |t|
23
+ t.string :email
24
+ end
25
+ end
26
+ end
27
+
28
+ require __DIR__ + '/../generators/simple_facebook_connect_migration/templates/migration'
29
+
30
+ CreateUsers.up
31
+ AddFacebookConnect.up
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: upstream-simple_facebook_connect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Lang
8
+ - "Frank Pr\xC3\xB6\xC3\x9Fdorf"
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-07-15 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email: alex@upstream-berlin.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README.md
25
+ files:
26
+ - .gitignore
27
+ - MIT-LICENSE
28
+ - README.md
29
+ - Rakefile
30
+ - VERSION
31
+ - app/controllers/simple_facebook_connect/connect_controller.rb
32
+ - app/views/shared/_facebook_connect_button.html.erb
33
+ - config/simple_facebook_connect_routes.rb
34
+ - generators/simple_facebook_connect_features/simple_facebook_connect_features_generator.rb
35
+ - generators/simple_facebook_connect_features/templates/facebook_auth_getsession.xml
36
+ - generators/simple_facebook_connect_features/templates/facebook_connect.feature
37
+ - generators/simple_facebook_connect_features/templates/facebook_connect_steps.rb
38
+ - generators/simple_facebook_connect_features/templates/facebook_connect_stubs.rb
39
+ - generators/simple_facebook_connect_features/templates/facebook_users_getinfo.xml
40
+ - generators/simple_facebook_connect_migration/simple_facebook_connect_migration_generator.rb
41
+ - generators/simple_facebook_connect_migration/templates/migration.rb
42
+ - init.rb
43
+ - lib/simple_facebook_connect.rb
44
+ - lib/simple_facebook_connect/controller_extension.rb
45
+ - lib/simple_facebook_connect/extensions/routes.rb
46
+ - lib/simple_facebook_connect/parser.rb
47
+ - lib/simple_facebook_connect/service.rb
48
+ - lib/simple_facebook_connect/session.rb
49
+ - lib/simple_facebook_connect/user.rb
50
+ - lib/simple_facebook_connect/user_extension.rb
51
+ - rails/init.rb
52
+ - simple_facebook_connect.gemspec
53
+ - spec/fixtures/facebook.auth.getSession/default.xml
54
+ - spec/fixtures/facebook.users.getInfo/default.xml
55
+ - spec/lib/simple_facebook_connect/parser_spec.rb
56
+ - spec/lib/simple_facebook_connect/user_extension_spec.rb
57
+ - spec/lib/simple_facebook_connect/user_spec.rb
58
+ - spec/spec_helper.rb
59
+ has_rdoc: true
60
+ homepage: http://github.com/upstream/simple_facebook_connect
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --charset=UTF-8
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.2.0
82
+ signing_key:
83
+ specification_version: 2
84
+ summary: This plugin adds the ability to sign in/sign up using facebook connect to your Rails application.
85
+ test_files:
86
+ - spec/lib/simple_facebook_connect/parser_spec.rb
87
+ - spec/lib/simple_facebook_connect/user_extension_spec.rb
88
+ - spec/lib/simple_facebook_connect/user_spec.rb
89
+ - spec/spec_helper.rb