facebooker 1.0.65 → 1.0.66

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.
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{facebooker}
5
- s.version = "1.0.65"
5
+ s.version = "1.0.66"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis", "Mike Mangino"]
9
- s.date = %q{2010-03-17}
9
+ s.date = %q{2010-03-24}
10
10
  s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
11
11
 
12
12
  * Idiomatic Ruby
@@ -5,6 +5,6 @@
5
5
  <title>Cross-Domain Receiver Page</title>
6
6
  </head>
7
7
  <body>
8
- <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js" type="text/javascript"></script>
8
+ <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
9
9
  </body>
10
- </html>
10
+ </html>
@@ -477,6 +477,12 @@ module Facebooker
477
477
  ext_perms.all?{|p| has_permission?(p)}
478
478
  end
479
479
 
480
+ ##
481
+ ## Revoke any extended permission given by a user
482
+ def revoke_permission(ext_perm)
483
+ session.post('facebook.auth.revokeExtendedPermission', { :perm => ext_perm, :uid => uid }, false)
484
+ end
485
+
480
486
  ##
481
487
  # Convenience method to send email to the current user
482
488
  def send_email(subject, text=nil, fbml=nil)
@@ -109,34 +109,35 @@ module Facebooker
109
109
  end #do |hash, child|
110
110
  end
111
111
 
112
- def self.hash_by_key_or_value_for(element)
112
+ def self.hash_by_key_or_value_for(element, convert_1_to_true=false)
113
113
  if element.children.size == 0
114
114
  { element['key'] => nil }
115
115
  elsif element.children.size == 1 && element.children.first.text?
116
- { element['key'] => element.content.strip }
116
+ { element['key'] => (convert_1_to_true ? element.content.strip == '1' : element.content.strip) }
117
117
  else
118
- hashinate_by_key(element)
118
+ hashinate_by_key(element, convert_1_to_true)
119
119
  end
120
120
  end
121
121
 
122
122
  # A modification to hashinate. The new dashboard API returns XML in a different format than
123
123
  # the other calls. What used to be the element name has become an attribute called "key".
124
- def self.hashinate_by_key(response_element)
124
+ def self.hashinate_by_key(response_element, convert_1_to_true=false)
125
125
  response_element.children.reject{|c| c.text? }.inject({}) do |hash, child|
126
+
126
127
  # If the node hasn't any child, and is not a list, we want empty strings, not empty hashes,
127
128
  # except if attributes['nil'] == true
128
129
  hash[child['key']] =
129
130
  if (child['nil'] == 'true')
130
131
  nil
131
132
  elsif (child.children.size == 1 && child.children.first.text?) || (child.children.size == 0 && child['list'] != 'true')
132
- anonymous_field_from(child, hash) || child.content.strip
133
- elsif child['list'] == 'true' && child.children.all? { |subchild| subchild['key'].nil? }
134
- child.children.reject{|c| c.text? }.map { |subchild| hash_by_key_or_value_for(subchild)}
133
+ anonymous_field_from(child, hash) || (convert_1_to_true ? child.content.strip == '1' : child.content.strip)
134
+ elsif child['list'] == 'true' && child.children.reject {|subchild| subchild.text?}.all? { |subchild| !subchild.text? && subchild['key'].nil? }
135
+ child.children.reject{|c| c.text? }.map { |subchild| hash_by_key_or_value_for(subchild, convert_1_to_true)}
135
136
  elsif child['list'] == 'true'
136
- hash_by_key_or_value_for(child)
137
+ hash_by_key_or_value_for(child, convert_1_to_true)
137
138
  else
138
139
  child.children.reject{|c| c.text? }.inject({}) do |subhash, subchild|
139
- subhash[subchild['key']] = hash_by_key_or_value_for(subchild)
140
+ subhash[subchild['key']] = hash_by_key_or_value_for(subchild, convert_1_to_true)
140
141
  subhash
141
142
  end
142
143
  end
@@ -164,6 +165,12 @@ module Facebooker
164
165
  end
165
166
  end
166
167
 
168
+ class RevokeExtendedPermission < Parser#:nodoc:
169
+ def self.process(data)
170
+ booleanize(element('auth_revokeExtendedPermission_response', data).content.strip)
171
+ end
172
+ end
173
+
167
174
  class CreateToken < Parser#:nodoc:
168
175
  def self.process(data)
169
176
  element('auth_createToken_response', data).content.strip
@@ -711,40 +718,22 @@ module Facebooker
711
718
 
712
719
  class DashboardMultiSetCount < Parser
713
720
  def self.process(data)
714
- hashinate_by_key(element('dashboard_multiSetCount_response', data))
721
+ hashinate_by_key(element('dashboard_multiSetCount_response', data), true)
715
722
  end
716
723
  end
717
724
 
718
725
  class DashboardMultiIncrementCount < Parser
719
726
  def self.process(data)
720
- hashinate_by_key(element('dashboard_multiIncrementCount_response', data))
727
+ hashinate_by_key(element('dashboard_multiIncrementCount_response', data), true)
721
728
  end
722
729
  end
723
730
 
724
731
  class DashboardMultiDecrementCount < Parser
725
732
  def self.process(data)
726
- hashinate_by_key(element('dashboard_multiDecrementCount_response', data))
733
+ hashinate_by_key(element('dashboard_multiDecrementCount_response', data), true)
727
734
  end
728
735
  end
729
736
 
730
- class DashboardMultiSetCount < Parser
731
- def self.process(data)
732
- hashinate_by_key(element('dashboard_multiSetCount_response', data))
733
- end
734
- end
735
-
736
- class DashboardMultiIncrementCount < Parser
737
- def self.process(data)
738
- hashinate_by_key(element('dashboard_multiIncrementCount_response', data))
739
- end
740
- end
741
-
742
- class DashboardMultiDecrementCount < Parser
743
- def self.process(data)
744
- hashinate_by_key(element('dashboard_multiDecrementCount_response', data))
745
- end
746
- end
747
-
748
737
  class DashboardAddGlobalNews < Parser
749
738
  def self.process(data)
750
739
  element('dashboard_addGlobalNews_response', data).content.strip
@@ -760,7 +749,7 @@ module Facebooker
760
749
 
761
750
  class DashboardClearGlobalNews < Parser
762
751
  def self.process(data)
763
- hashinate_by_key(element('dashboard_clearGlobalNews_response', data))
752
+ hashinate_by_key(element('dashboard_clearGlobalNews_response', data), true)
764
753
  end
765
754
  end
766
755
 
@@ -778,7 +767,7 @@ module Facebooker
778
767
 
779
768
  class DashboardClearNews < Parser
780
769
  def self.process(data)
781
- hashinate_by_key(element('dashboard_clearNews_response', data))
770
+ hashinate_by_key(element('dashboard_clearNews_response', data), true)
782
771
  end
783
772
  end
784
773
 
@@ -790,7 +779,7 @@ module Facebooker
790
779
 
791
780
  class DashboardMultiClearNews < Parser
792
781
  def self.process(data)
793
- hashinate_by_key(element('dashboard_multiClearNews_response', data))
782
+ hashinate_by_key(element('dashboard_multiClearNews_response', data), true)
794
783
  end
795
784
  end
796
785
 
@@ -808,7 +797,7 @@ module Facebooker
808
797
 
809
798
  class DashboardRemoveActivity < Parser
810
799
  def self.process(data)
811
- hashinate_by_key(element('dashboard_removeActivity_response', data))
800
+ hashinate_by_key(element('dashboard_removeActivity_response', data), true)
812
801
  end
813
802
  end
814
803
 
@@ -875,6 +864,7 @@ module Facebooker
875
864
  class Parser
876
865
  PARSERS = {
877
866
  'facebook.auth.revokeAuthorization' => RevokeAuthorization,
867
+ 'facebook.auth.revokeExtendedPermission' => RevokeExtendedPermission,
878
868
  'facebook.auth.createToken' => CreateToken,
879
869
  'facebook.auth.getSession' => GetSession,
880
870
  'facebook.connect.registerUsers' => RegisterUsers,
@@ -20,14 +20,18 @@ module Facebooker
20
20
  # and Rails' Hash#to_json always quotes strings so there is no way to indicate when the value should be a javascript function.
21
21
  # For this reason :app_settings needs to be a string that is valid JSON (including the {}'s).
22
22
  #
23
- def init_fb_connect(*required_features,&proc)
23
+ def init_fb_connect(*required_features, &proc)
24
+ init_fb_connect_with_options({},*required_features, &proc)
25
+ end
26
+
27
+ def init_fb_connect_with_options(options = {},*required_features, &proc)
24
28
  additions = ""
25
29
  if block_given?
26
30
  additions = capture(&proc)
27
31
  end
28
32
 
29
33
  # Yes, app_settings is set to a string of an empty JSON element. That's intentional.
30
- options = {:js => :prototype, :app_settings => '{}'}
34
+ options = options.merge({:app_settings => '{}'})
31
35
 
32
36
  if required_features.last.is_a?(Hash)
33
37
  options.merge!(required_features.pop.symbolize_keys)
@@ -42,7 +46,6 @@ module Facebooker
42
46
  init_string = <<-FBML
43
47
  #{case options[:js]
44
48
  when :jquery then "jQuery(document).ready("
45
- when :mootools then "window.addEvent('domready',"
46
49
  when :dojo then "dojo.addOnLoad("
47
50
  else "Element.observe(window,'load',"
48
51
  end} function() {
@@ -2,7 +2,7 @@ module Facebooker #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 65
5
+ TINY = 66
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -41,7 +41,7 @@ class Facebooker::ApplicationTest < Test::Unit::TestCase
41
41
 
42
42
  def test_can_parse_global_news
43
43
  expect_http_posts_with_responses(clear_global_news_xml)
44
- assert_equal({"342345290762"=>"1"}, @session.application.clear_global_news('342345290762'))
44
+ assert_equal({"342345290762"=>true}, @session.application.clear_global_news('342345290762'))
45
45
  end
46
46
 
47
47
  private
@@ -356,7 +356,6 @@ class Facebooker::UserTest < Test::Unit::TestCase
356
356
 
357
357
  def test_parse_increment_dashboard_count
358
358
  expect_http_posts_with_responses(dashboard_increment_count_xml)
359
- debugger
360
359
  assert_equal true, @user.dashboard_increment_count
361
360
  end
362
361
 
@@ -426,7 +425,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
426
425
 
427
426
  def test_parse_dashboard_multi_set_count
428
427
  expect_http_posts_with_responses(dashboard_multi_set_count_xml)
429
- assert_equal({ '1234' => '1', '4321' => '1' }, Facebooker::User.dashboard_multi_set_count({ '1234' => '11', '5678' => '22' }))
428
+ assert_equal({ '1234' => true, '4321' => true }, Facebooker::User.dashboard_multi_set_count({ '1234' => '11', '5678' => '22' }))
430
429
  end
431
430
 
432
431
  def test_can_dashboard_multi_get_count
@@ -456,7 +455,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
456
455
 
457
456
  def test_parse_dashboard_multi_increment_count
458
457
  expect_http_posts_with_responses(dashboard_multi_increment_count_xml)
459
- assert_equal({ '1234' => '1', '4321' => '1' }, Facebooker::User.dashboard_multi_increment_count(['1234', '4321']))
458
+ assert_equal({ '1234' => true, '4321' => true }, Facebooker::User.dashboard_multi_increment_count(['1234', '4321']))
460
459
  end
461
460
 
462
461
  def test_can_dashboard_multi_decrement_count_with_single_uid
@@ -471,7 +470,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
471
470
 
472
471
  def test_parse_dashboard_multi_decrement_count_with_array_of_uids
473
472
  expect_http_posts_with_responses(dashboard_multi_decrement_count_xml)
474
- assert_equal({ '1234' => '1', '4321' => '1' }, Facebooker::User.dashboard_multi_decrement_count(['1234', '4321']))
473
+ assert_equal({ '1234' => true, '4321' => true }, Facebooker::User.dashboard_multi_decrement_count(['1234', '4321']))
475
474
  end
476
475
  # Dashboard
477
476
 
@@ -507,7 +506,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
507
506
 
508
507
  def test_parse_clear_news
509
508
  expect_http_posts_with_responses(clear_news_xml)
510
- assert_equal({"362466171040"=>"1"}, @user.clear_news('362466171040'))
509
+ assert_equal({"362466171040"=>true}, @user.clear_news('362466171040'))
511
510
  end
512
511
 
513
512
  def test_can_multi_add_news
@@ -537,7 +536,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
537
536
 
538
537
  def test_parse_multi_clear_news
539
538
  expect_http_posts_with_responses(multi_clear_news_xml)
540
- assert_equal({"1234"=>{"319103117527"=>"1"}, "4321"=>{"313954287803"=>"1"}}, Facebooker::User.multi_clear_news({"1234"=>["319103117527"], "4321"=>["313954287803"]}))
539
+ assert_equal({"1234"=>{"319103117527"=>true}, "4321"=>{"313954287803"=>true}}, Facebooker::User.multi_clear_news({"1234"=>["319103117527"], "4321"=>["313954287803"]}))
541
540
  end
542
541
 
543
542
  def test_can_publish_activity
@@ -567,7 +566,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
567
566
 
568
567
  def test_parse_remove_activity
569
568
  expect_http_posts_with_responses(remove_activity_xml)
570
- assert_equal({"342454152268"=>"1"}, @user.remove_activity('123'))
569
+ assert_equal({"342454152268"=>true}, @user.remove_activity('123'))
571
570
  end
572
571
 
573
572
 
@@ -403,7 +403,10 @@ class TestFacebooker < Test::Unit::TestCase
403
403
  assert_equal false, @session.post('facebook.auth.revokeAuthorization', :uid => 123)
404
404
  end
405
405
 
406
-
406
+ def test_revoke_extended_permission
407
+ expect_http_posts_with_responses(example_revoke_extended_permission)
408
+ assert_equal true, @session.post('facebook.auth.revokeExtendedPermission', {:perm => 'email', :uid => 123}, false)
409
+ end
407
410
 
408
411
  def test_remove_comment_true
409
412
  expect_http_posts_with_responses(example_remove_comment_true)
@@ -1182,7 +1185,13 @@ class TestFacebooker < Test::Unit::TestCase
1182
1185
  "0"
1183
1186
  end
1184
1187
 
1185
-
1188
+ def example_revoke_extended_permission
1189
+ <<-XML
1190
+ <?xml version="1.0" encoding="UTF-8"?>
1191
+ <auth_revokeExtendedPermission_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</auth_revokeExtendedPermission_response>
1192
+ XML
1193
+ end
1194
+
1186
1195
  def example_remove_comment_true
1187
1196
  "1"
1188
1197
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.65
4
+ version: 1.0.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fowler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-17 00:00:00 -04:00
17
+ date: 2010-03-24 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency