koala 0.9.0 → 1.0.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 +3 -0
- data/CHANGELOG +47 -7
- data/Gemfile +3 -0
- data/LICENSE +1 -1
- data/Manifest +10 -15
- data/Rakefile +13 -13
- data/koala.gemspec +36 -16
- data/lib/koala/graph_api.rb +188 -123
- data/lib/koala/http_services.rb +93 -18
- data/lib/koala/rest_api.rb +73 -6
- data/lib/koala/test_users.rb +85 -0
- data/lib/koala/uploadable_io.rb +115 -0
- data/lib/koala.rb +114 -116
- data/readme.md +32 -18
- data/spec/cases/api_base_spec.rb +101 -0
- data/spec/cases/graph_and_rest_api_spec.rb +31 -0
- data/spec/cases/graph_api_spec.rb +25 -0
- data/spec/cases/http_services/http_service_spec.rb +54 -0
- data/spec/cases/http_services/net_http_service_spec.rb +350 -0
- data/spec/cases/http_services/typhoeus_service_spec.rb +144 -0
- data/spec/cases/oauth_spec.rb +409 -0
- data/spec/cases/realtime_updates_spec.rb +184 -0
- data/spec/cases/rest_api_spec.rb +25 -0
- data/spec/cases/test_users_spec.rb +221 -0
- data/spec/cases/uploadable_io_spec.rb +151 -0
- data/spec/fixtures/beach.jpg +0 -0
- data/spec/{facebook_data.yml → fixtures/facebook_data.yml} +18 -14
- data/spec/{mock_facebook_responses.yml → fixtures/mock_facebook_responses.yml} +314 -241
- data/spec/spec_helper.rb +18 -0
- data/spec/support/graph_api_shared_examples.rb +424 -0
- data/spec/support/live_testing_data_helper.rb +40 -0
- data/spec/{mock_http_service.rb → support/mock_http_service.rb} +94 -80
- data/spec/support/rest_api_shared_examples.rb +161 -0
- data/spec/support/setup_mocks_or_live.rb +52 -0
- data/spec/support/uploadable_io_shared_examples.rb +76 -0
- metadata +140 -55
- data/examples/oauth_playground/Capfile +0 -2
- data/examples/oauth_playground/LICENSE +0 -22
- data/examples/oauth_playground/Rakefile +0 -4
- data/examples/oauth_playground/config/deploy.rb +0 -39
- data/examples/oauth_playground/config/facebook.yml +0 -13
- data/examples/oauth_playground/config.ru +0 -27
- data/examples/oauth_playground/lib/load_facebook.rb +0 -3
- data/examples/oauth_playground/lib/oauth_playground.rb +0 -187
- data/examples/oauth_playground/readme.md +0 -8
- data/examples/oauth_playground/spec/oauth_playground_spec.rb +0 -35
- data/examples/oauth_playground/spec/spec_helper.rb +0 -36
- data/examples/oauth_playground/tmp/restart.txt +0 -0
- data/examples/oauth_playground/views/index.erb +0 -206
- data/examples/oauth_playground/views/layout.erb +0 -39
- data/init.rb +0 -2
- data/spec/koala/api_base_tests.rb +0 -95
- data/spec/koala/graph_and_rest_api/graph_and_rest_api_no_token_tests.rb +0 -10
- data/spec/koala/graph_and_rest_api/graph_and_rest_api_with_token_tests.rb +0 -11
- data/spec/koala/graph_api/graph_api_no_access_token_tests.rb +0 -114
- data/spec/koala/graph_api/graph_api_with_access_token_tests.rb +0 -150
- data/spec/koala/graph_api/graph_collection_tests.rb +0 -104
- data/spec/koala/live_testing_data_helper.rb +0 -15
- data/spec/koala/net_http_service_tests.rb +0 -181
- data/spec/koala/oauth/oauth_tests.rb +0 -440
- data/spec/koala/realtime_updates/realtime_updates_tests.rb +0 -187
- data/spec/koala/rest_api/rest_api_no_access_token_tests.rb +0 -94
- data/spec/koala/rest_api/rest_api_with_access_token_tests.rb +0 -36
- data/spec/koala_spec.rb +0 -18
- data/spec/koala_spec_helper.rb +0 -31
- data/spec/koala_spec_without_mocks.rb +0 -19
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
shared_examples_for "Koala RestAPI" do
|
|
2
|
+
# REST_CALL
|
|
3
|
+
describe "when making a rest request" do
|
|
4
|
+
it "should use the proper path" do
|
|
5
|
+
method = stub('methodName')
|
|
6
|
+
@api.should_receive(:api).with(
|
|
7
|
+
"method/#{method}",
|
|
8
|
+
anything,
|
|
9
|
+
anything,
|
|
10
|
+
anything
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@api.rest_call(method)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should always use the rest api" do
|
|
17
|
+
@api.should_receive(:api).with(
|
|
18
|
+
anything,
|
|
19
|
+
anything,
|
|
20
|
+
anything,
|
|
21
|
+
hash_including(:rest_api => true)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
@api.rest_call('anything')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should set the read_only option to true if the method is listed in the read-only list" do
|
|
28
|
+
method = Koala::Facebook::RestAPI::READ_ONLY_METHODS.first
|
|
29
|
+
|
|
30
|
+
@api.should_receive(:api).with(
|
|
31
|
+
anything,
|
|
32
|
+
anything,
|
|
33
|
+
anything,
|
|
34
|
+
hash_including(:read_only => true)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
@api.rest_call(method)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should set the read_only option to false if the method is not inthe read-only list" do
|
|
41
|
+
method = "I'm not a read-only method"
|
|
42
|
+
|
|
43
|
+
@api.should_receive(:api).with(
|
|
44
|
+
anything,
|
|
45
|
+
anything,
|
|
46
|
+
anything,
|
|
47
|
+
hash_including(:read_only => false)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
@api.rest_call(method)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
it "should take an optional hash of arguments" do
|
|
55
|
+
args = {:arg1 => 'arg1'}
|
|
56
|
+
|
|
57
|
+
@api.should_receive(:api).with(
|
|
58
|
+
anything,
|
|
59
|
+
hash_including(args),
|
|
60
|
+
anything,
|
|
61
|
+
anything
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
@api.rest_call('anything', args)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should always ask for JSON" do
|
|
68
|
+
@api.should_receive(:api).with(
|
|
69
|
+
anything,
|
|
70
|
+
hash_including('format' => 'json'),
|
|
71
|
+
anything,
|
|
72
|
+
anything
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
@api.rest_call('anything')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should pass any options provided to the API" do
|
|
79
|
+
options = {:a => 2}
|
|
80
|
+
|
|
81
|
+
@api.should_receive(:api).with(
|
|
82
|
+
anything,
|
|
83
|
+
hash_including('format' => 'json'),
|
|
84
|
+
anything,
|
|
85
|
+
hash_including(options)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
@api.rest_call('anything', {}, options)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should throw an APIError if the result hash has an error key" do
|
|
92
|
+
Koala.stub(:make_request).and_return(Koala::Response.new(500, {"error_code" => "An error occurred!"}, {}))
|
|
93
|
+
lambda { @api.rest_call("koppel", {}) }.should raise_exception(Koala::Facebook::APIError)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe "when making a FQL request" do
|
|
97
|
+
it "should call fql.query method" do
|
|
98
|
+
@api.should_receive(:rest_call).with(
|
|
99
|
+
"fql.query",
|
|
100
|
+
anything
|
|
101
|
+
).and_return(Koala::Response.new(200, "2", {}))
|
|
102
|
+
|
|
103
|
+
@api.fql_query stub('query string')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should pass a query argument" do
|
|
107
|
+
query = stub('query string')
|
|
108
|
+
|
|
109
|
+
@api.should_receive(:rest_call).with(
|
|
110
|
+
anything,
|
|
111
|
+
hash_including("query" => query)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
@api.fql_query(query)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
shared_examples_for "Koala RestAPI with an access token" do
|
|
122
|
+
# FQL
|
|
123
|
+
it "should be able to access public information via FQL" do
|
|
124
|
+
result = @api.fql_query('select first_name from user where uid = 216743')
|
|
125
|
+
result.size.should == 1
|
|
126
|
+
result.first['first_name'].should == 'Chris'
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should be able to access protected information via FQL" do
|
|
130
|
+
# Tests agains the permissions fql table
|
|
131
|
+
|
|
132
|
+
# get the current user's ID
|
|
133
|
+
# we're sneakily using the Graph API, which should be okay since it has its own tests
|
|
134
|
+
g = Koala::Facebook::GraphAPI.new(@token)
|
|
135
|
+
id = g.get_object("me", :fields => "id")["id"]
|
|
136
|
+
|
|
137
|
+
# now send a query about your permissions
|
|
138
|
+
result = @api.fql_query("select read_stream from permissions where uid = #{id}")
|
|
139
|
+
|
|
140
|
+
result.size.should == 1
|
|
141
|
+
# we assume that you have read_stream permissions, so we can test against that
|
|
142
|
+
# (should we keep this?)
|
|
143
|
+
result.first["read_stream"].should == 1
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
shared_examples_for "Koala RestAPI without an access token" do
|
|
149
|
+
# FQL_QUERY
|
|
150
|
+
describe "when making a FQL request" do
|
|
151
|
+
it "should be able to access public information via FQL" do
|
|
152
|
+
@result = @api.fql_query("select first_name from user where uid = 216743")
|
|
153
|
+
@result.size.should == 1
|
|
154
|
+
@result.first["first_name"].should == "Chris"
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "should not be able to access protected information via FQL" do
|
|
158
|
+
lambda { @api.fql_query("select read_stream from permissions where uid = 216743") }.should raise_error(Koala::Facebook::APIError)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# small helper method for live testing
|
|
2
|
+
module KoalaTest
|
|
3
|
+
def self.validate_user_info(token)
|
|
4
|
+
print "Validating permissions for live testing..."
|
|
5
|
+
# make sure we have the necessary permissions
|
|
6
|
+
api = Koala::Facebook::GraphAndRestAPI.new(token)
|
|
7
|
+
uid = api.get_object("me")["id"]
|
|
8
|
+
perms = api.fql_query("select read_stream, publish_stream, user_photos from permissions where uid = #{uid}")[0]
|
|
9
|
+
perms.each_pair do |perm, value|
|
|
10
|
+
unless value == 1
|
|
11
|
+
puts "failed!\n" # put a new line after the print above
|
|
12
|
+
raise ArgumentError, "Your access token must have the read_stream, publish_stream, and user_photos permissions. You have: #{perms.inspect}"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
puts "done!"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
unless ENV['LIVE']
|
|
21
|
+
# By default the Koala specs are run using stubs for HTTP requests
|
|
22
|
+
#
|
|
23
|
+
# Valid OAuth token and code are not necessary to run these
|
|
24
|
+
# specs. Because of this, specs do not fail due to Facebook
|
|
25
|
+
# imposed rate-limits or server timeouts.
|
|
26
|
+
#
|
|
27
|
+
# However as a result they are more brittle since
|
|
28
|
+
# we are not testing the latest responses from the Facebook servers.
|
|
29
|
+
# Therefore, to be certain all specs pass with the current
|
|
30
|
+
# Facebook services, run koala_spec_without_mocks.rb.
|
|
31
|
+
Koala.http_service = Koala::MockHTTPService
|
|
32
|
+
|
|
33
|
+
$testing_data = Koala::MockHTTPService::TEST_DATA
|
|
34
|
+
else
|
|
35
|
+
# Runs Koala specs through the Facebook servers
|
|
36
|
+
#
|
|
37
|
+
# Note that you need a valid OAuth token and code for these
|
|
38
|
+
# specs to run. See facebook_data.yml for more information.
|
|
39
|
+
|
|
40
|
+
# load testing data (see note in readme.md)
|
|
41
|
+
$testing_data = YAML.load_file(File.join(File.dirname(__FILE__), '../fixtures/facebook_data.yml'))
|
|
42
|
+
|
|
43
|
+
unless $testing_data["oauth_token"]
|
|
44
|
+
puts "Access token tests will fail until you store a valid token in facebook_data.yml"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
unless $testing_data["oauth_test_data"] && $testing_data["oauth_test_data"]["code"] && $testing_data["oauth_test_data"]["secret"]
|
|
48
|
+
puts "OAuth code tests will fail until you store valid data for the user's OAuth code and the app secret in facebook_data.yml"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
KoalaTest.validate_user_info $testing_data["oauth_token"]
|
|
52
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
shared_examples_for "MIME::Types can't return results" do
|
|
2
|
+
{
|
|
3
|
+
"jpg" => "image/jpeg",
|
|
4
|
+
"jpeg" => "image/jpeg",
|
|
5
|
+
"png" => "image/png",
|
|
6
|
+
"gif" => "image/gif"
|
|
7
|
+
}.each_pair do |extension, mime_type|
|
|
8
|
+
it "should properly get content types for #{extension} using basic analysis" do
|
|
9
|
+
path = "filename.#{extension}"
|
|
10
|
+
if @koala_io_params[0].is_a?(File)
|
|
11
|
+
@koala_io_params[0].stub!(:path).and_return(path)
|
|
12
|
+
else
|
|
13
|
+
@koala_io_params[0] = path
|
|
14
|
+
end
|
|
15
|
+
Koala::UploadableIO.new(*@koala_io_params).content_type.should == mime_type
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should get content types for #{extension} using basic analysis with file names with more than one dot" do
|
|
19
|
+
path = "file.name.#{extension}"
|
|
20
|
+
if @koala_io_params[0].is_a?(File)
|
|
21
|
+
@koala_io_params[0].stub!(:path).and_return(path)
|
|
22
|
+
else
|
|
23
|
+
@koala_io_params[0] = path
|
|
24
|
+
end
|
|
25
|
+
Koala::UploadableIO.new(*@koala_io_params).content_type.should == mime_type
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "if the MIME type can't be determined" do
|
|
30
|
+
before :each do
|
|
31
|
+
path = "badfile.badextension"
|
|
32
|
+
if @koala_io_params[0].is_a?(File)
|
|
33
|
+
@koala_io_params[0].stub!(:path).and_return(path)
|
|
34
|
+
else
|
|
35
|
+
@koala_io_params[0] = path
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should throw an exception if the MIME type can't be determined and the HTTP service requires content type" do
|
|
40
|
+
Koala.stub!(:multipart_requires_content_type?).and_return(true)
|
|
41
|
+
lambda { Koala::UploadableIO.new(*@koala_io_params) }.should raise_exception(Koala::KoalaError)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should just have @content_type == nil if the HTTP service doesn't require content type" do
|
|
45
|
+
Koala.stub!(:multipart_requires_content_type?).and_return(false)
|
|
46
|
+
Koala::UploadableIO.new(*@koala_io_params).content_type.should be_nil
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
shared_examples_for "determining a mime type" do
|
|
52
|
+
describe "if MIME::Types is available" do
|
|
53
|
+
it "should return an UploadIO with MIME::Types-determined type if the type exists" do
|
|
54
|
+
type_result = ["type"]
|
|
55
|
+
Koala::MIME::Types.stub(:type_for).and_return(type_result)
|
|
56
|
+
Koala::UploadableIO.new(*@koala_io_params).content_type.should == type_result.first
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "if MIME::Types is unavailable" do
|
|
61
|
+
before :each do
|
|
62
|
+
# fake that MIME::Types doesn't exist
|
|
63
|
+
Koala::MIME::Types.stub(:type_for).and_raise(NameError)
|
|
64
|
+
end
|
|
65
|
+
it_should_behave_like "MIME::Types can't return results"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "if MIME::Types can't find the result" do
|
|
69
|
+
before :each do
|
|
70
|
+
# fake that MIME::Types doesn't exist
|
|
71
|
+
Koala::MIME::Types.stub(:type_for).and_return([])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it_should_behave_like "MIME::Types can't return results"
|
|
75
|
+
end
|
|
76
|
+
end
|
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koala
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 23
|
|
5
|
+
prerelease:
|
|
5
6
|
segments:
|
|
7
|
+
- 1
|
|
6
8
|
- 0
|
|
7
|
-
- 9
|
|
8
9
|
- 0
|
|
9
|
-
version: 0.
|
|
10
|
+
version: 1.0.0
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
|
|
@@ -14,70 +15,132 @@ autorequire:
|
|
|
14
15
|
bindir: bin
|
|
15
16
|
cert_chain: []
|
|
16
17
|
|
|
17
|
-
date:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
date: 2011-05-01 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
prerelease: false
|
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
23
|
+
none: false
|
|
24
|
+
requirements:
|
|
25
|
+
- - ~>
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
hash: 15
|
|
28
|
+
segments:
|
|
29
|
+
- 1
|
|
30
|
+
- 0
|
|
31
|
+
version: "1.0"
|
|
32
|
+
type: :runtime
|
|
33
|
+
name: json
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ~>
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
hash: 15
|
|
43
|
+
segments:
|
|
44
|
+
- 1
|
|
45
|
+
- 0
|
|
46
|
+
version: "1.0"
|
|
47
|
+
type: :runtime
|
|
48
|
+
name: multipart-post
|
|
49
|
+
version_requirements: *id002
|
|
50
|
+
- !ruby/object:Gem::Dependency
|
|
51
|
+
prerelease: false
|
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - ~>
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
hash: 27
|
|
58
|
+
segments:
|
|
59
|
+
- 2
|
|
60
|
+
- 5
|
|
61
|
+
- 0
|
|
62
|
+
version: 2.5.0
|
|
63
|
+
type: :development
|
|
64
|
+
name: rspec
|
|
65
|
+
version_requirements: *id003
|
|
66
|
+
- !ruby/object:Gem::Dependency
|
|
67
|
+
prerelease: false
|
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
69
|
+
none: false
|
|
70
|
+
requirements:
|
|
71
|
+
- - ~>
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
hash: 49
|
|
74
|
+
segments:
|
|
75
|
+
- 0
|
|
76
|
+
- 8
|
|
77
|
+
- 7
|
|
78
|
+
version: 0.8.7
|
|
79
|
+
type: :development
|
|
80
|
+
name: rake
|
|
81
|
+
version_requirements: *id004
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
prerelease: false
|
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
85
|
+
none: false
|
|
86
|
+
requirements:
|
|
87
|
+
- - ~>
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
hash: 31
|
|
90
|
+
segments:
|
|
91
|
+
- 0
|
|
92
|
+
- 2
|
|
93
|
+
- 4
|
|
94
|
+
version: 0.2.4
|
|
95
|
+
type: :development
|
|
96
|
+
name: typhoeus
|
|
97
|
+
version_requirements: *id005
|
|
98
|
+
description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write access to the social graph via the Graph and REST APIs, as well as support for realtime updates and OAuth and Facebook Connect authentication. Koala is fully tested and supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services.
|
|
22
99
|
email: alex@alexkoppel.com
|
|
23
100
|
executables: []
|
|
24
101
|
|
|
25
102
|
extensions: []
|
|
26
103
|
|
|
27
104
|
extra_rdoc_files:
|
|
105
|
+
- readme.md
|
|
28
106
|
- CHANGELOG
|
|
29
|
-
- LICENSE
|
|
30
|
-
- lib/koala.rb
|
|
31
|
-
- lib/koala/graph_api.rb
|
|
32
|
-
- lib/koala/http_services.rb
|
|
33
|
-
- lib/koala/realtime_updates.rb
|
|
34
|
-
- lib/koala/rest_api.rb
|
|
35
107
|
files:
|
|
108
|
+
- .gitignore
|
|
36
109
|
- CHANGELOG
|
|
110
|
+
- Gemfile
|
|
37
111
|
- LICENSE
|
|
38
112
|
- Manifest
|
|
39
113
|
- Rakefile
|
|
40
|
-
- examples/oauth_playground/Capfile
|
|
41
|
-
- examples/oauth_playground/LICENSE
|
|
42
|
-
- examples/oauth_playground/Rakefile
|
|
43
|
-
- examples/oauth_playground/config.ru
|
|
44
|
-
- examples/oauth_playground/config/deploy.rb
|
|
45
|
-
- examples/oauth_playground/config/facebook.yml
|
|
46
|
-
- examples/oauth_playground/lib/load_facebook.rb
|
|
47
|
-
- examples/oauth_playground/lib/oauth_playground.rb
|
|
48
|
-
- examples/oauth_playground/readme.md
|
|
49
|
-
- examples/oauth_playground/spec/oauth_playground_spec.rb
|
|
50
|
-
- examples/oauth_playground/spec/spec_helper.rb
|
|
51
|
-
- examples/oauth_playground/tmp/restart.txt
|
|
52
|
-
- examples/oauth_playground/views/index.erb
|
|
53
|
-
- examples/oauth_playground/views/layout.erb
|
|
54
|
-
- init.rb
|
|
55
114
|
- koala.gemspec
|
|
56
115
|
- lib/koala.rb
|
|
57
116
|
- lib/koala/graph_api.rb
|
|
58
117
|
- lib/koala/http_services.rb
|
|
59
118
|
- lib/koala/realtime_updates.rb
|
|
60
119
|
- lib/koala/rest_api.rb
|
|
120
|
+
- lib/koala/test_users.rb
|
|
121
|
+
- lib/koala/uploadable_io.rb
|
|
61
122
|
- readme.md
|
|
62
|
-
- spec/
|
|
63
|
-
- spec/
|
|
64
|
-
- spec/
|
|
65
|
-
- spec/
|
|
66
|
-
- spec/
|
|
67
|
-
- spec/
|
|
68
|
-
- spec/
|
|
69
|
-
- spec/
|
|
70
|
-
- spec/
|
|
71
|
-
- spec/
|
|
72
|
-
- spec/
|
|
73
|
-
- spec/
|
|
74
|
-
- spec/
|
|
75
|
-
- spec/
|
|
76
|
-
- spec/
|
|
77
|
-
- spec/
|
|
78
|
-
- spec/
|
|
79
|
-
- spec/mock_http_service.rb
|
|
80
|
-
|
|
123
|
+
- spec/cases/api_base_spec.rb
|
|
124
|
+
- spec/cases/graph_and_rest_api_spec.rb
|
|
125
|
+
- spec/cases/graph_api_spec.rb
|
|
126
|
+
- spec/cases/http_services/http_service_spec.rb
|
|
127
|
+
- spec/cases/http_services/net_http_service_spec.rb
|
|
128
|
+
- spec/cases/http_services/typhoeus_service_spec.rb
|
|
129
|
+
- spec/cases/oauth_spec.rb
|
|
130
|
+
- spec/cases/realtime_updates_spec.rb
|
|
131
|
+
- spec/cases/rest_api_spec.rb
|
|
132
|
+
- spec/cases/test_users_spec.rb
|
|
133
|
+
- spec/cases/uploadable_io_spec.rb
|
|
134
|
+
- spec/fixtures/beach.jpg
|
|
135
|
+
- spec/fixtures/facebook_data.yml
|
|
136
|
+
- spec/fixtures/mock_facebook_responses.yml
|
|
137
|
+
- spec/spec_helper.rb
|
|
138
|
+
- spec/support/graph_api_shared_examples.rb
|
|
139
|
+
- spec/support/live_testing_data_helper.rb
|
|
140
|
+
- spec/support/mock_http_service.rb
|
|
141
|
+
- spec/support/rest_api_shared_examples.rb
|
|
142
|
+
- spec/support/setup_mocks_or_live.rb
|
|
143
|
+
- spec/support/uploadable_io_shared_examples.rb
|
|
81
144
|
homepage: http://github.com/arsduo/koala
|
|
82
145
|
licenses: []
|
|
83
146
|
|
|
@@ -87,31 +150,53 @@ rdoc_options:
|
|
|
87
150
|
- --inline-source
|
|
88
151
|
- --title
|
|
89
152
|
- Koala
|
|
90
|
-
- --main
|
|
91
|
-
- readme.md
|
|
92
153
|
require_paths:
|
|
93
154
|
- lib
|
|
94
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
|
+
none: false
|
|
95
157
|
requirements:
|
|
96
158
|
- - ">="
|
|
97
159
|
- !ruby/object:Gem::Version
|
|
160
|
+
hash: 3
|
|
98
161
|
segments:
|
|
99
162
|
- 0
|
|
100
163
|
version: "0"
|
|
101
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
|
+
none: false
|
|
102
166
|
requirements:
|
|
103
167
|
- - ">="
|
|
104
168
|
- !ruby/object:Gem::Version
|
|
169
|
+
hash: 11
|
|
105
170
|
segments:
|
|
106
171
|
- 1
|
|
107
172
|
- 2
|
|
108
173
|
version: "1.2"
|
|
109
174
|
requirements: []
|
|
110
175
|
|
|
111
|
-
rubyforge_project:
|
|
112
|
-
rubygems_version: 1.
|
|
176
|
+
rubyforge_project:
|
|
177
|
+
rubygems_version: 1.7.2
|
|
113
178
|
signing_key:
|
|
114
179
|
specification_version: 3
|
|
115
|
-
summary: A lightweight, flexible library for Facebook with support for the Graph API, the
|
|
116
|
-
test_files:
|
|
117
|
-
|
|
180
|
+
summary: A lightweight, flexible library for Facebook with support for the Graph API, the REST API, realtime updates, and OAuth authentication.
|
|
181
|
+
test_files:
|
|
182
|
+
- spec/cases/api_base_spec.rb
|
|
183
|
+
- spec/cases/graph_and_rest_api_spec.rb
|
|
184
|
+
- spec/cases/graph_api_spec.rb
|
|
185
|
+
- spec/cases/http_services/http_service_spec.rb
|
|
186
|
+
- spec/cases/http_services/net_http_service_spec.rb
|
|
187
|
+
- spec/cases/http_services/typhoeus_service_spec.rb
|
|
188
|
+
- spec/cases/oauth_spec.rb
|
|
189
|
+
- spec/cases/realtime_updates_spec.rb
|
|
190
|
+
- spec/cases/rest_api_spec.rb
|
|
191
|
+
- spec/cases/test_users_spec.rb
|
|
192
|
+
- spec/cases/uploadable_io_spec.rb
|
|
193
|
+
- spec/fixtures/beach.jpg
|
|
194
|
+
- spec/fixtures/facebook_data.yml
|
|
195
|
+
- spec/fixtures/mock_facebook_responses.yml
|
|
196
|
+
- spec/spec_helper.rb
|
|
197
|
+
- spec/support/graph_api_shared_examples.rb
|
|
198
|
+
- spec/support/live_testing_data_helper.rb
|
|
199
|
+
- spec/support/mock_http_service.rb
|
|
200
|
+
- spec/support/rest_api_shared_examples.rb
|
|
201
|
+
- spec/support/setup_mocks_or_live.rb
|
|
202
|
+
- spec/support/uploadable_io_shared_examples.rb
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2010 Alex Koppel
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person
|
|
4
|
-
obtaining a copy of this software and associated documentation
|
|
5
|
-
files (the "Software"), to deal in the Software without
|
|
6
|
-
restriction, including without limitation the rights to use,
|
|
7
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the
|
|
9
|
-
Software is furnished to do so, subject to the following
|
|
10
|
-
conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be
|
|
13
|
-
included in all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
set :application, "oauth_playground"
|
|
2
|
-
set :repository, "git://github.com/arsduo/oauth_playground.git"
|
|
3
|
-
set :domain, "oauth.twoalex.com"
|
|
4
|
-
set :deploy_to, "$HOME/rails_apps/#{application}/"
|
|
5
|
-
|
|
6
|
-
# authentication
|
|
7
|
-
set :scm, "git"
|
|
8
|
-
set :user, "alexkm"
|
|
9
|
-
set :use_sudo, false
|
|
10
|
-
ssh_options[:forward_agent] = true
|
|
11
|
-
|
|
12
|
-
# web server
|
|
13
|
-
role :web, "oauth.twoalex.com" # Your HTTP server, Apache/etc
|
|
14
|
-
role :app, "oauth.twoalex.com" # This may be the same as your `Web` server
|
|
15
|
-
role :db, "oauth.twoalex.com", :primary => true # This is where Rails migrations will run
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# other git-related commands
|
|
19
|
-
set :branch, "master"
|
|
20
|
-
default_run_options[:pty] = true
|
|
21
|
-
# cache the repository locally to speed updates
|
|
22
|
-
set :repository_cache, "git_cache"
|
|
23
|
-
set :deploy_via, :remote_cache
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# passenger-specific deploy tasks
|
|
27
|
-
namespace :deploy do
|
|
28
|
-
task :start do
|
|
29
|
-
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
task :stop do
|
|
33
|
-
# nothing
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
task :restart, :roles => :app, :except => { :no_release => true } do
|
|
37
|
-
run "touch #{File.join(current_path,'tmp','restart.txt')}"
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
development:
|
|
2
|
-
api_key: 171e3563d4fee42e0ba27450838bba32
|
|
3
|
-
secret_key: c81302ccef57cbdd2e68b2229e54cd2f
|
|
4
|
-
app_id: 119347844754245
|
|
5
|
-
|
|
6
|
-
test:
|
|
7
|
-
api_key:
|
|
8
|
-
secret_key:
|
|
9
|
-
|
|
10
|
-
production:
|
|
11
|
-
api_key: 25e1cec0df2b3bfa781da3ed78da3a1e
|
|
12
|
-
secret_key: e45e55a333eec232d4206d2703de1307
|
|
13
|
-
app_id: 119908831367602
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# gems
|
|
2
|
-
require 'sinatra'
|
|
3
|
-
require 'logger'
|
|
4
|
-
require 'yaml'
|
|
5
|
-
|
|
6
|
-
# app files
|
|
7
|
-
require 'koala'
|
|
8
|
-
require File.join(File.dirname(__FILE__), 'lib', 'load_facebook.rb')
|
|
9
|
-
require File.join(File.dirname(__FILE__), 'lib', 'oauth_playground.rb')
|
|
10
|
-
|
|
11
|
-
# LOGGING
|
|
12
|
-
# set up the logfile
|
|
13
|
-
Dir.mkdir('log') unless File.exists?('log')
|
|
14
|
-
log_filename = File.join(File.dirname(__FILE__), "log", "sinatra.log")
|
|
15
|
-
log = File.new(log_filename, "a+")
|
|
16
|
-
|
|
17
|
-
# log requests
|
|
18
|
-
use Rack::CommonLogger, log
|
|
19
|
-
# log application-generated code
|
|
20
|
-
LOGGER = Logger.new(log_filename)
|
|
21
|
-
# log output to stdout and stderr as well
|
|
22
|
-
$stdout.reopen(log)
|
|
23
|
-
$stderr.reopen(log)
|
|
24
|
-
|
|
25
|
-
# activate the app
|
|
26
|
-
disable :run
|
|
27
|
-
run OAuthPlayground
|