mini_fb 1.1.6 → 1.1.7
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/LICENSE.txt +20 -0
- data/lib/mini_fb.rb +2 -7
- data/test/test_mini_fb.rb +49 -47
- metadata +5 -3
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Appoxy LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/mini_fb.rb
CHANGED
@@ -652,14 +652,9 @@ module MiniFB
|
|
652
652
|
res_hash = JSON.parse("{\"response\": #{resp.to_s}}")
|
653
653
|
end
|
654
654
|
end
|
655
|
-
|
656
|
-
#This is bad because it strips off paging parameters and what not.
|
657
|
-
# if res_hash.size == 1 && res_hash["data"]
|
658
|
-
# res_hash = res_hash["data"]
|
659
|
-
# end
|
660
655
|
|
661
656
|
if res_hash.is_a? Array # fql return this
|
662
|
-
res_hash.collect! { |x| Hashie::Mash.new(x) }
|
657
|
+
res_hash.collect! { |x| x.is_a?(Hash) ? Hashie::Mash.new(x) : x }
|
663
658
|
else
|
664
659
|
res_hash = Hashie::Mash.new(res_hash)
|
665
660
|
end
|
@@ -670,7 +665,7 @@ module MiniFB
|
|
670
665
|
|
671
666
|
return res_hash
|
672
667
|
rescue RestClient::Exception => ex
|
673
|
-
puts ex.http_code.to_s
|
668
|
+
puts "ex.http_code=" + ex.http_code.to_s
|
674
669
|
puts 'ex.http_body=' + ex.http_body if @@logging
|
675
670
|
res_hash = JSON.parse(ex.http_body) # probably should ensure it has a good response
|
676
671
|
raise MiniFB::FaceBookError.new(ex.http_code, "#{res_hash["error"]["type"]}: #{res_hash["error"]["message"]}")
|
data/test/test_mini_fb.rb
CHANGED
@@ -1,67 +1,69 @@
|
|
1
1
|
require 'test/unit'
|
2
|
+
require 'rspec'
|
2
3
|
require 'uri'
|
3
4
|
require 'yaml'
|
4
5
|
require 'active_support/core_ext'
|
5
6
|
require '../lib/mini_fb'
|
6
7
|
|
7
|
-
|
8
|
+
describe "Some Feature" do
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
@config
|
12
|
-
puts @config.inspect
|
10
|
+
before :all do
|
11
|
+
@is_setup = true
|
12
|
+
@config = File.open(File.expand_path("~/.test_configs/mini_fb_tests.yml")) { |yf| YAML::load(yf) }
|
13
|
+
puts "@config=" + @config.inspect
|
13
14
|
MiniFB.log_level = :debug
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def test_authenticate_as_app
|
23
|
-
res = MiniFB.authenticate_as_app(@config["fb_api_key"], @config["fb_secret"])
|
24
|
-
puts 'res=' + res.inspect
|
25
|
-
assert res["access_token"].present?
|
26
|
-
assert res["access_token"].starts_with?(@config["fb_app_id"].to_s)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Test signature verification.
|
30
|
-
def test_signature
|
31
|
-
|
16
|
+
@oauth_url = MiniFB.oauth_url(@config['fb_app_id'], # your Facebook App ID (NOT API_KEY)
|
17
|
+
"http://localhost:3000", # redirect url
|
18
|
+
:scope=>MiniFB.scopes.join(","))
|
19
|
+
puts "If you need an access token, go here in your browser:"
|
20
|
+
puts "#{@oauth_url}"
|
21
|
+
puts "Then grab the 'code' parameter in the redirect url and add it to mini_fb_tests.yml."
|
32
22
|
end
|
33
23
|
|
34
|
-
def test_me_with_fields
|
35
|
-
fields = {
|
36
|
-
'interests' => [:name],
|
37
|
-
'activities'=> [:name],
|
38
|
-
'music' => [:name],
|
39
|
-
'videos' => [:name],
|
40
|
-
'television'=> [:name],
|
41
|
-
'movies' => [:name],
|
42
|
-
'likes' => [:name],
|
43
|
-
'work' => [:name],
|
44
|
-
'education' => [:name],
|
45
|
-
'books' => [:name]
|
46
|
-
}
|
47
24
|
|
48
|
-
snap = MiniFB.get(access_token, 'me', :fields =>fields.keys)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_basic_calls
|
52
25
|
|
26
|
+
before :each do
|
27
|
+
# this code runs once per-test
|
53
28
|
end
|
54
29
|
|
55
|
-
|
56
|
-
|
30
|
+
it "should do something useful, rather than just being called test1" do
|
31
|
+
# el code here
|
32
|
+
puts 'whatup'
|
33
|
+
true.should be_true
|
57
34
|
end
|
58
35
|
|
59
|
-
|
60
|
-
|
36
|
+
it 'test_uri_escape' do
|
37
|
+
URI.escape("x=y").should eq("x=y")
|
61
38
|
end
|
62
39
|
|
63
|
-
|
64
|
-
|
40
|
+
it 'test_authenticate_as_app' do
|
41
|
+
res = MiniFB.authenticate_as_app(@config["fb_api_key"], @config["fb_secret"])
|
42
|
+
puts 'res=' + res.inspect
|
43
|
+
res.should include("access_token")
|
44
|
+
res["access_token"].should match(/^#{@config['fb_app_id']}/)#starts_with?(@config["fb_app_id"].to_s)
|
65
45
|
end
|
66
|
-
|
67
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def access_token
|
50
|
+
@config['access_token']
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_me_with_fields
|
55
|
+
fields = {
|
56
|
+
'interests' => [:name],
|
57
|
+
'activities'=> [:name],
|
58
|
+
'music' => [:name],
|
59
|
+
'videos' => [:name],
|
60
|
+
'television'=> [:name],
|
61
|
+
'movies' => [:name],
|
62
|
+
'likes' => [:name],
|
63
|
+
'work' => [:name],
|
64
|
+
'education' => [:name],
|
65
|
+
'books' => [:name]
|
66
|
+
}
|
67
|
+
|
68
|
+
snap = MiniFB.get(access_token, 'me', :fields =>fields.keys)
|
69
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 7
|
9
|
+
version: 1.1.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Reeder
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-13 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -50,9 +50,11 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
|
52
52
|
extra_rdoc_files:
|
53
|
+
- LICENSE.txt
|
53
54
|
- README.markdown
|
54
55
|
files:
|
55
56
|
- lib/mini_fb.rb
|
57
|
+
- LICENSE.txt
|
56
58
|
- README.markdown
|
57
59
|
- test/test_mini_fb.rb
|
58
60
|
has_rdoc: true
|