flakey 0.2.2 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/flakey/facebook.rb +24 -4
- data/lib/flakey/version.rb +1 -1
- data/spec/flakey/facebook_spec.rb +31 -0
- data/spec/flakey/twitter_spec.rb +3 -1
- data/vendor/assets/javascripts/flakey/popup.js +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5e3a881d55a7d7af795bf39c525efe323afa076
|
4
|
+
data.tar.gz: 7dac21622501551c67bb98edb50b56a7a60c59e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fccba15c21831ae81f4bca70eb1ca14c4388706725ce86555f42f0cd5ebbda3cba04be07f9126a90ac2b54805858fc456d5fb283dc81219263b12183edfd78de
|
7
|
+
data.tar.gz: 4502b6794fc4aededa6b02bc6fbbb6fa7aa02e95579ef4430b189cdf35badd35844d8d271f33ef9d28dfe3e2ba9416e6637de46f635d5f7be6fb8be0afc4c525
|
data/lib/flakey/facebook.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Flakey
|
2
2
|
module Facebook
|
3
3
|
SHARE_URL = 'https://www.facebook.com/sharer/sharer.php'
|
4
|
+
#
|
5
|
+
# Needed to be able to pass a block down into link_to.
|
6
|
+
# See the share_button method.
|
7
|
+
# INFO: http://stackoverflow.com/a/7562194/574190
|
8
|
+
attr_accessor :output_buffer
|
4
9
|
|
5
10
|
def facebook_nickname(options = {})
|
6
11
|
options[:nickname] ||
|
@@ -45,11 +50,26 @@ module Flakey
|
|
45
50
|
# INFO: http://goo.gl/MvqIi4
|
46
51
|
#
|
47
52
|
# Returns a HTML string.
|
48
|
-
def share_button(options = {})
|
49
|
-
|
50
|
-
|
53
|
+
def share_button(options = {}, &block)
|
54
|
+
defaults = {
|
55
|
+
url: request.url,
|
56
|
+
label: 'Share',
|
57
|
+
target: '_blank',
|
58
|
+
class: 'facebook-share-button'
|
59
|
+
}
|
60
|
+
|
61
|
+
settings = defaults.merge options
|
62
|
+
|
63
|
+
url = "#{SHARE_URL}?u=#{CGI.escape settings[:url]}"
|
64
|
+
label = settings[:label]
|
65
|
+
settings.delete(:url)
|
66
|
+
settings.delete(:label)
|
51
67
|
|
52
|
-
|
68
|
+
if block_given?
|
69
|
+
link_to(url, settings, &block)
|
70
|
+
else
|
71
|
+
link_to label, url, settings
|
72
|
+
end
|
53
73
|
end
|
54
74
|
end
|
55
75
|
end
|
data/lib/flakey/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
require 'action_view'
|
4
|
+
|
5
|
+
class DummyHelper
|
6
|
+
include ::ActionView::Helpers::UrlHelper
|
7
|
+
include Flakey::Facebook
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Flakey::Facebook do
|
11
|
+
subject { DummyHelper.new }
|
12
|
+
|
13
|
+
describe 'share_button' do
|
14
|
+
before { subject.stub_chain('request.url') { 'http://example.com/hello' } }
|
15
|
+
let(:default_url) do
|
16
|
+
"#{Flakey::Facebook::SHARE_URL}?u=http%3A%2F%2Fexample.com%2Fhello"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should add the url' do
|
20
|
+
subject.share_button.should include(default_url)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have a class' do
|
24
|
+
subject.share_button.should include('class="facebook-share-but')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should render a label' do
|
28
|
+
subject.share_button(label: 'Grinnick').should include('>Grinnick</a>')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/flakey/twitter_spec.rb
CHANGED
@@ -58,7 +58,9 @@ describe Flakey::Twitter do
|
|
58
58
|
|
59
59
|
describe 'custom_tweet_button' do
|
60
60
|
before { subject.stub_chain('request.url') { 'http://example.com/hello' } }
|
61
|
-
let(:default_url)
|
61
|
+
let(:default_url) do
|
62
|
+
"#{Flakey::Twitter::SHARE_URL}?url=http%3A%2F%2Fexample.com%2Fhello"
|
63
|
+
end
|
62
64
|
|
63
65
|
it 'should include the default url and label' do
|
64
66
|
subject.should_receive(:link_to)
|
@@ -20,7 +20,7 @@ if (typeof jQuery === "undefined") {
|
|
20
20
|
};
|
21
21
|
|
22
22
|
$(function(){
|
23
|
-
$('.custom-tweet-button').on('click', function(e){
|
23
|
+
$('.custom-tweet-button, .facebook-share-button').on('click', function(e){
|
24
24
|
e.preventDefault();
|
25
25
|
openPopup($(e.target).closest('a').attr('href'), 'twitter');
|
26
26
|
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flakey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Tuite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/flakey/stackoverflow.rb
|
90
90
|
- lib/flakey/twitter.rb
|
91
91
|
- lib/flakey/version.rb
|
92
|
+
- spec/flakey/facebook_spec.rb
|
92
93
|
- spec/flakey/twitter_spec.rb
|
93
94
|
- spec/spec_helper.rb
|
94
95
|
- vendor/assets/javascripts/flakey/facebook.js.erb
|
@@ -119,5 +120,6 @@ signing_key:
|
|
119
120
|
specification_version: 4
|
120
121
|
summary: Makes a bunch of helper methods available for including in your Rails views.
|
121
122
|
test_files:
|
123
|
+
- spec/flakey/facebook_spec.rb
|
122
124
|
- spec/flakey/twitter_spec.rb
|
123
125
|
- spec/spec_helper.rb
|