djanowski-facebooker 1.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.
- data/CHANGELOG.txt +0 -0
- data/COPYING +19 -0
- data/History.txt +16 -0
- data/Manifest.txt +110 -0
- data/README +46 -0
- data/README.txt +81 -0
- data/Rakefile +76 -0
- data/TODO.txt +10 -0
- data/generators/facebook/facebook_generator.rb +14 -0
- data/generators/facebook/templates/config/facebooker.yml +41 -0
- data/generators/facebook/templates/public/javascripts/facebooker.js +106 -0
- data/generators/facebook_controller/USAGE +33 -0
- data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
- data/generators/facebook_controller/templates/controller.rb +7 -0
- data/generators/facebook_controller/templates/functional_test.rb +11 -0
- data/generators/facebook_controller/templates/helper.rb +2 -0
- data/generators/facebook_controller/templates/view.fbml.erb +2 -0
- data/generators/facebook_controller/templates/view.html.erb +2 -0
- data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
- data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
- data/generators/facebook_publisher/templates/publisher.rb +3 -0
- data/generators/facebook_scaffold/USAGE +27 -0
- data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
- data/generators/facebook_scaffold/templates/controller.rb +93 -0
- data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
- data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
- data/generators/facebook_scaffold/templates/helper.rb +2 -0
- data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
- data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
- data/generators/facebook_scaffold/templates/style.css +74 -0
- data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
- data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
- data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
- data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
- data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
- data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
- data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
- data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
- data/generators/publisher/publisher_generator.rb +14 -0
- data/init.rb +54 -0
- data/install.rb +12 -0
- data/lib/facebooker/adapters/adapter_base.rb +87 -0
- data/lib/facebooker/adapters/bebo_adapter.rb +73 -0
- data/lib/facebooker/adapters/facebook_adapter.rb +48 -0
- data/lib/facebooker/admin.rb +28 -0
- data/lib/facebooker/batch_request.rb +44 -0
- data/lib/facebooker/data.rb +57 -0
- data/lib/facebooker/feed.rb +78 -0
- data/lib/facebooker/logging.rb +51 -0
- data/lib/facebooker/model.rb +123 -0
- data/lib/facebooker/models/affiliation.rb +10 -0
- data/lib/facebooker/models/album.rb +11 -0
- data/lib/facebooker/models/applicationproperties.rb +39 -0
- data/lib/facebooker/models/cookie.rb +10 -0
- data/lib/facebooker/models/education_info.rb +11 -0
- data/lib/facebooker/models/event.rb +26 -0
- data/lib/facebooker/models/friend_list.rb +14 -0
- data/lib/facebooker/models/group.rb +35 -0
- data/lib/facebooker/models/info_item.rb +10 -0
- data/lib/facebooker/models/info_section.rb +10 -0
- data/lib/facebooker/models/location.rb +8 -0
- data/lib/facebooker/models/notifications.rb +17 -0
- data/lib/facebooker/models/page.rb +27 -0
- data/lib/facebooker/models/photo.rb +10 -0
- data/lib/facebooker/models/tag.rb +12 -0
- data/lib/facebooker/models/user.rb +352 -0
- data/lib/facebooker/models/work_info.rb +9 -0
- data/lib/facebooker/parser.rb +540 -0
- data/lib/facebooker/rails/controller.rb +246 -0
- data/lib/facebooker/rails/facebook_asset_path.rb +18 -0
- data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
- data/lib/facebooker/rails/facebook_pretty_errors.rb +14 -0
- data/lib/facebooker/rails/facebook_request_fix.rb +24 -0
- data/lib/facebooker/rails/facebook_session_handling.rb +69 -0
- data/lib/facebooker/rails/facebook_url_rewriting.rb +39 -0
- data/lib/facebooker/rails/helpers.rb +615 -0
- data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
- data/lib/facebooker/rails/publisher.rb +492 -0
- data/lib/facebooker/rails/routing.rb +49 -0
- data/lib/facebooker/rails/test_helpers.rb +88 -0
- data/lib/facebooker/rails/utilities.rb +22 -0
- data/lib/facebooker/server_cache.rb +24 -0
- data/lib/facebooker/service.rb +31 -0
- data/lib/facebooker/session.rb +564 -0
- data/lib/facebooker/version.rb +9 -0
- data/lib/facebooker.rb +143 -0
- data/lib/net/http_multipart_post.rb +123 -0
- data/lib/tasks/facebooker.rake +18 -0
- data/lib/tasks/tunnel.rake +46 -0
- data/rails/init.rb +1 -0
- data/setup.rb +1585 -0
- data/templates/layout.erb +24 -0
- data/test/adapters_test.rb +98 -0
- data/test/batch_request_test.rb +82 -0
- data/test/event_test.rb +15 -0
- data/test/facebook_admin_test.rb +75 -0
- data/test/facebook_cache_test.rb +43 -0
- data/test/facebook_data_test.rb +84 -0
- data/test/facebooker_test.rb +855 -0
- data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
- data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
- data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
- data/test/http_multipart_post_test.rb +54 -0
- data/test/logging_test.rb +43 -0
- data/test/model_test.rb +91 -0
- data/test/publisher_test.rb +436 -0
- data/test/rails_integration_test.rb +1126 -0
- data/test/session_test.rb +587 -0
- data/test/test_helper.rb +60 -0
- data/test/user_test.rb +229 -0
- metadata +181 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
2
|
+
Content-Disposition: form-data; name="aid"
|
|
3
|
+
|
|
4
|
+
940915667462717
|
|
5
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
6
|
+
Content-Disposition: form-data; name="api_key"
|
|
7
|
+
|
|
8
|
+
77a52842357422fadd912a2600e6e53c
|
|
9
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
10
|
+
Content-Disposition: form-data; name="call_id"
|
|
11
|
+
|
|
12
|
+
1172623588.023010
|
|
13
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
14
|
+
Content-Disposition: form-data; name="caption"
|
|
15
|
+
|
|
16
|
+
Under the sunset
|
|
17
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
18
|
+
Content-Disposition: form-data; name="method"
|
|
19
|
+
|
|
20
|
+
facebook.photos.upload
|
|
21
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
22
|
+
Content-Disposition: form-data; name="session_key"
|
|
23
|
+
|
|
24
|
+
489727d0ab2efc6e8003018c-i2LLkn8BDb2s.
|
|
25
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
26
|
+
Content-Disposition: form-data; name="sig"
|
|
27
|
+
|
|
28
|
+
dfa724b8a5cd97d9df4baf2b60d3484c
|
|
29
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
30
|
+
Content-Disposition: form-data; name="v"
|
|
31
|
+
|
|
32
|
+
1.0
|
|
33
|
+
--MichaelNiessnerIsSuperDuperAwesome--
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
2
|
+
Content-Disposition: form-data; name="aid"
|
|
3
|
+
|
|
4
|
+
940915667462717
|
|
5
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
6
|
+
Content-Disposition: form-data; name="api_key"
|
|
7
|
+
|
|
8
|
+
77a52842357422fadd912a2600e6e53c
|
|
9
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
10
|
+
Content-Disposition: form-data; name="call_id"
|
|
11
|
+
|
|
12
|
+
1172623588.023010
|
|
13
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
14
|
+
Content-Disposition: form-data; name="caption"
|
|
15
|
+
|
|
16
|
+
Under the sunset
|
|
17
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
18
|
+
Content-Disposition: form-data; name="method"
|
|
19
|
+
|
|
20
|
+
facebook.photos.upload
|
|
21
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
22
|
+
Content-Disposition: form-data; name="session_key"
|
|
23
|
+
|
|
24
|
+
489727d0ab2efc6e8003018c-i2LLkn8BDb2s.
|
|
25
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
26
|
+
Content-Disposition: form-data; name="sig"
|
|
27
|
+
|
|
28
|
+
dfa724b8a5cd97d9df4baf2b60d3484c
|
|
29
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
30
|
+
Content-Disposition: form-data; name="v"
|
|
31
|
+
|
|
32
|
+
1.0
|
|
33
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
34
|
+
Content-Disposition: form-data; name="file"; filename="somefilename.jpg"
|
|
35
|
+
Content-Type: image/jpg
|
|
36
|
+
|
|
37
|
+
[Raw file data here]
|
|
38
|
+
--MichaelNiessnerIsSuperDuperAwesome--
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
2
|
+
Content-Disposition: form-data; name="aid"
|
|
3
|
+
|
|
4
|
+
940915667462717
|
|
5
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
6
|
+
Content-Disposition: form-data; name="api_key"
|
|
7
|
+
|
|
8
|
+
77a52842357422fadd912a2600e6e53c
|
|
9
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
10
|
+
Content-Disposition: form-data; name="call_id"
|
|
11
|
+
|
|
12
|
+
1172623588.023010
|
|
13
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
14
|
+
Content-Disposition: form-data; name="caption"
|
|
15
|
+
|
|
16
|
+
Under the sunset
|
|
17
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
18
|
+
Content-Disposition: form-data; name="method"
|
|
19
|
+
|
|
20
|
+
facebook.photos.upload
|
|
21
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
22
|
+
Content-Disposition: form-data; name="session_key"
|
|
23
|
+
|
|
24
|
+
489727d0ab2efc6e8003018c-i2LLkn8BDb2s.
|
|
25
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
26
|
+
Content-Disposition: form-data; name="sig"
|
|
27
|
+
|
|
28
|
+
dfa724b8a5cd97d9df4baf2b60d3484c
|
|
29
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
30
|
+
Content-Disposition: form-data; name="v"
|
|
31
|
+
|
|
32
|
+
1.0
|
|
33
|
+
--MichaelNiessnerIsSuperDuperAwesome
|
|
34
|
+
Content-Disposition: form-data; filename="somefilename.jpg"
|
|
35
|
+
Content-Type: image/jpg
|
|
36
|
+
|
|
37
|
+
[Raw file data here]
|
|
38
|
+
--MichaelNiessnerIsSuperDuperAwesome--
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'flexmock/test_unit'
|
|
4
|
+
require 'net/http_multipart_post'
|
|
5
|
+
|
|
6
|
+
class HttpMulitpartPostTest < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def fixture(string)
|
|
12
|
+
File.open(File.dirname(__FILE__) + "/fixtures/#{string}.txt").read
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_multipart_post_with_only_parameters
|
|
16
|
+
params = add_sample_facebook_params({})
|
|
17
|
+
post = Net::HTTP::MultipartPost.new("uri", params)
|
|
18
|
+
assert_equal fixture("multipart_post_body_with_only_parameters"), post.send(:body)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_multipart_post_with_a_single_file
|
|
22
|
+
params = add_sample_facebook_params({})
|
|
23
|
+
params[:file] = Net::HTTP::MultipartPostFile.new
|
|
24
|
+
params[:file].filename = "somefilename.jpg"
|
|
25
|
+
params[:file].content_type = "image/jpg"
|
|
26
|
+
params[:file].data = "[Raw file data here]"
|
|
27
|
+
post = Net::HTTP::MultipartPost.new("uri", params)
|
|
28
|
+
assert_equal fixture("multipart_post_body_with_single_file"), post.send(:body)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_multipart_post_with_a_single_file_parameter_that_has_nil_key
|
|
32
|
+
params = add_sample_facebook_params({})
|
|
33
|
+
params[nil] = Net::HTTP::MultipartPostFile.new("somefilename.jpg", "image/jpg", "[Raw file data here]")
|
|
34
|
+
post = Net::HTTP::MultipartPost.new("uri", params)
|
|
35
|
+
assert_equal fixture("multipart_post_body_with_single_file_that_has_nil_key"), post.send(:body)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_multipart_post_should_have_correct_content_type
|
|
39
|
+
post = Net::HTTP::MultipartPost.new("uri", {})
|
|
40
|
+
assert post.send(:content_type) =~ /multipart\/form-data; boundary=/
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def add_sample_facebook_params(hash)
|
|
44
|
+
hash[:method] = "facebook.photos.upload"
|
|
45
|
+
hash[:v] = "1.0"
|
|
46
|
+
hash[:api_key] = "77a52842357422fadd912a2600e6e53c"
|
|
47
|
+
hash[:session_key] = "489727d0ab2efc6e8003018c-i2LLkn8BDb2s."
|
|
48
|
+
hash[:call_id] = "1172623588.023010"
|
|
49
|
+
hash[:caption] = "Under the sunset"
|
|
50
|
+
hash[:aid] = "940915667462717"
|
|
51
|
+
hash[:sig] = "dfa724b8a5cd97d9df4baf2b60d3484c"
|
|
52
|
+
hash
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LoggingTest < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
super
|
|
7
|
+
Facebooker.logger = Logger.new(STDERR)
|
|
8
|
+
Facebooker::Logging.skip_api_logging=false
|
|
9
|
+
end
|
|
10
|
+
def teardown
|
|
11
|
+
Facebooker.logger = nil
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_does_not_crash_with_nil_logger
|
|
16
|
+
Facebooker.logger = nil
|
|
17
|
+
Facebooker::Logging.log_fb_api('sample.api.call',
|
|
18
|
+
{'param1' => true, 'param2' => 'value2'})
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_does_not_crash_outside_rails
|
|
22
|
+
flexmock(Facebooker.logger, :logger).should_receive(:debug).once.with(String)
|
|
23
|
+
Facebooker::Logging.log_fb_api('sample.api.call',
|
|
24
|
+
{'param1' => true, 'param2' => 'value2'})
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_can_disable_logging
|
|
28
|
+
Facebooker::Logging.skip_api_logging = true
|
|
29
|
+
flexmock(Facebooker::Logging).should_receive(:log_info).never
|
|
30
|
+
Facebooker::Logging.log_fb_api('sample.api.call',
|
|
31
|
+
{'param1' => true, 'param2' => 'value2'})
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_plain_format
|
|
35
|
+
flexmock(Facebooker.logger, :logger).should_receive(:debug).once.with(
|
|
36
|
+
'sample.api.call (0) param1 = true')
|
|
37
|
+
Facebooker::Logging.log_fb_api('sample.api.call',
|
|
38
|
+
{'param1' => true})
|
|
39
|
+
ensure
|
|
40
|
+
Facebooker.logger = nil
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
data/test/model_test.rb
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'flexmock/test_unit'
|
|
4
|
+
|
|
5
|
+
class TestFacebooker < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
class ComplexThing
|
|
8
|
+
include Facebooker::Model
|
|
9
|
+
attr_accessor :weight, :height
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Thing
|
|
13
|
+
include Facebooker::Model
|
|
14
|
+
attr_accessor :name, :job
|
|
15
|
+
hash_settable_accessor :complex_thing, ComplexThing
|
|
16
|
+
hash_settable_list_accessor :list_of_complex_things, ComplexThing
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class PopulatingThing
|
|
20
|
+
include Facebooker::Model
|
|
21
|
+
populating_attr_accessor :first_name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_can_instantiate_an_object_with_a_hash
|
|
25
|
+
h = {:name => "Blob", :job => "Monster"}
|
|
26
|
+
assert_equal("Blob", Thing.from_hash(h).name)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_ignores_non_model_keys
|
|
30
|
+
h = {:name => "Blob", :job => "Monster", :not_there=>true}
|
|
31
|
+
assert_equal("Blob", Thing.from_hash(h).name)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_logs_non_model_keys
|
|
35
|
+
flexmock(Facebooker::Logging).should_receive(:log_info)
|
|
36
|
+
h = {:name => "Blob", :job => "Monster", :not_there=>true}
|
|
37
|
+
Thing.from_hash(h)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_if_no_hash_is_given_to_model_constructor_no_attributes_are_set
|
|
42
|
+
assert_nothing_raised {
|
|
43
|
+
t = Thing.new
|
|
44
|
+
assert_nil(t.name)
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_can_declare_hash_settable_attributes
|
|
49
|
+
t = Thing.new({})
|
|
50
|
+
t.complex_thing = {:weight => 123, :height => 5.4}
|
|
51
|
+
assert_equal(123, t.complex_thing.weight)
|
|
52
|
+
t.complex_thing = ComplexThing.new(:weight => 321)
|
|
53
|
+
assert_equal(321, t.complex_thing.weight)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_can_declare_attributes_which_are_settable_via_a_list_of_hashes
|
|
57
|
+
t = Thing.new
|
|
58
|
+
t.list_of_complex_things = [{:weight => 444, :height => 123.0}, {:weight => 222, :height => 321.1}]
|
|
59
|
+
assert_equal("123.0, 321.1", t.list_of_complex_things.map{|ct| ct.height.to_s}.sort.join(', '))
|
|
60
|
+
t.list_of_complex_things = [ComplexThing.new(:weight => 555), ComplexThing.new(:weight => 111)]
|
|
61
|
+
assert_equal("111, 555", t.list_of_complex_things.map{|ct| ct.weight.to_s}.sort.join(', '))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_if_you_try_to_use_a_models_session_without_initializing_it_first_you_get_a_descriptive_error
|
|
65
|
+
t = Thing.new
|
|
66
|
+
assert_raises(Facebooker::Model::UnboundSessionException) {
|
|
67
|
+
t.session
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_populating_reader_will_call_populate_if_model_was_not_previously_populated
|
|
72
|
+
t = PopulatingThing.new
|
|
73
|
+
flexmock(t).should_receive(:populate).once
|
|
74
|
+
t.first_name
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_populating_reader_will_not_call_populate_if_model_was_previously_populated
|
|
78
|
+
t = PopulatingThing.new
|
|
79
|
+
flexmock(t).should_receive(:populated?).and_return(true)
|
|
80
|
+
flexmock(t).should_receive(:populate).never
|
|
81
|
+
t.first_name
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_attempting_to_access_a_populating_reader_will_raise_an_exception_if_populate_was_not_defined
|
|
85
|
+
t = PopulatingThing.new
|
|
86
|
+
assert_raises(NotImplementedError) {
|
|
87
|
+
t.first_name
|
|
88
|
+
}
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|