carrot-facebook 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Carrot
2
2
  module Facebook
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 13
5
+ TINY = 14
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -59,7 +59,7 @@ module Carrot
59
59
  opts.merge!(options.first) unless options.empty?
60
60
 
61
61
  %Q{
62
- <div id="fb-root"></div>'
62
+ <div id="fb-root"></div>
63
63
  <script src="//connect.facebook.net/en_US/all.js"></script>
64
64
  <script>
65
65
  FB.init({ appId: '#{opts[:app_id]}', xfbml: '#{opts[:xfbml]}' });
@@ -70,6 +70,25 @@ module Carrot
70
70
  def auto_grow(timer = true)
71
71
  content_tag(:script, "FB.Canvas.setAutoGrow(#{timer});")
72
72
  end
73
+
74
+ def facepile(*options)
75
+ opts = {:href => ENV['FACEBOOK_APP_URL'],
76
+ :max_rows => 1,
77
+ :width => 300,
78
+ :show_count => true }
79
+ opts.merge!(options.first) unless options.empty?
80
+
81
+ raise "Must provide a :url option parameter or ENV['FACEBOOK_APP_URL']" unless opts[:href]
82
+
83
+ %Q{
84
+ <div class="fb-facepile"
85
+ data-href="#{opts[:href]}"
86
+ data-max-rows="#{opts[:max_rows]}"
87
+ data-show-count="#{opts[:show_count]}"
88
+ data-width="#{opts[:width]}">
89
+ </div>
90
+ }.html_safe
91
+ end
73
92
  end
74
93
  end
75
94
  end
@@ -77,4 +77,27 @@ describe Carrot::Facebook::ViewHelpers, :type => :helper do
77
77
  expect(output).to match /xfbml: 'false'/
78
78
  end
79
79
  end
80
+
81
+ context "#facepile" do
82
+ it "should raise error if url is not provided" do
83
+ expect { helper.facepile }.to raise_error
84
+ end
85
+
86
+ it "should not raise error if ENV variable is provided" do
87
+ ENV.stub(:[]).with("FACEBOOK_APP_URL").and_return("asdf")
88
+ expect { helper.facepile }.to_not raise_error
89
+ end
90
+
91
+ it "should not raise error if :href parameter is provided" do
92
+ expect { helper.facepile(href: "http://carrotcreative.com/") }.to_not raise_error
93
+ end
94
+
95
+ it "should correctly set output HTML" do
96
+ ENV.stub(:[]).with("FACEBOOK_APP_URL").and_return("http://carrotcreative.com/")
97
+ expect(helper.facepile).to match /data-href="http:\/\/carrotcreative.com\//
98
+ expect(helper.facepile(max_rows: 2)).to match /data-max-rows="2"/
99
+ expect(helper.facepile(width: 400)).to match /data-width="400"/
100
+ expect(helper.facepile(show_count: false)).to match /data-show-count="false"/
101
+ end
102
+ end
80
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrot-facebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.13
4
+ version: 0.9.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-13 00:00:00.000000000 Z
13
+ date: 2013-02-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yajl-ruby
17
- requirement: &70179946408900 !ruby/object:Gem::Requirement
17
+ requirement: &70237102216440 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70179946408900
25
+ version_requirements: *70237102216440
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: p3p
28
- requirement: &70179946407980 !ruby/object:Gem::Requirement
28
+ requirement: &70237102216020 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70179946407980
36
+ version_requirements: *70237102216020
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rails
39
- requirement: &70179946407480 !ruby/object:Gem::Requirement
39
+ requirement: &70237102215600 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70179946407480
47
+ version_requirements: *70237102215600
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &70179946407040 !ruby/object:Gem::Requirement
50
+ requirement: &70237102215180 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70179946407040
58
+ version_requirements: *70237102215180
59
59
  description: Facebook view helpers and signed request handling.
60
60
  email:
61
61
  - tmilewski@gmail.com