flakey 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e8ed80023a112ce6933d258fd187acd36cc4934
4
- data.tar.gz: fefaa9d180d0634a6ea3af541fb10241f408e456
3
+ metadata.gz: 9d187c4c3ce3d93de1645f91188907f18e16dc02
4
+ data.tar.gz: 650a378fb981aaad343ffaecf3f9d9f6f857424d
5
5
  SHA512:
6
- metadata.gz: cb887103c4e8051540b4e86def11f364e3b7d620ad38810332f2cd94613b4a625396f3696d935d280ed02d1a6ef86880e1f89bcf6bcd437c0c34f5e2c60168ee
7
- data.tar.gz: 0e76af570f101688569d7c14ec9a82acdf3b8b987201d59d2eca5f43e43e0b9718ebaaeddf9d0145205a6400a97ddd2d044e031c4cdec82145856a98b13beb43
6
+ metadata.gz: 0191415d53b96b87038fca53fa7ee125db6c44f4fad61f459e81075ae91d79e805dd6bb5578b04e9e39d0bb3a94f59dc4fae41558efa7fa634d4255538a85abf
7
+ data.tar.gz: b5e89cf998a0abbb42c8fa194e1e5fbb4b2830bcf39d73a5319b71140fd3178c48d47cd7e6015f9703f8af5dbecb8aa1d3c77e49e396bebcc92cfa1a17bdeb27
@@ -1,5 +1,7 @@
1
1
  require "flakey/configuration"
2
+ require "flakey/base"
2
3
  require "flakey/twitter"
4
+ require "flakey/buffer"
3
5
  require "flakey/facebook"
4
6
  require "flakey/engine"
5
7
  require "flakey/github"
@@ -0,0 +1,9 @@
1
+ module Flakey
2
+ module Base
3
+ # Allow inclusion in classes that don't respond to :request, or
4
+ # where request is nil (such as mailers).
5
+ def default_url
6
+ respond_to?(:request) && request.try(:url)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ module Flakey
2
+ module Buffer
3
+ include Base
4
+
5
+ SHARE_URL = "https://bufferapp.com/add"
6
+
7
+ def buffer_button(options = {})
8
+ defaults = {
9
+ url: default_url,
10
+ label: "Buffer",
11
+ target: '_blank',
12
+ class: 'buffer-add-button'
13
+ }
14
+ settings = defaults.merge(options)
15
+
16
+ url = "#{SHARE_URL}?url=#{CGI.escape(settings[:url])}"
17
+
18
+ if settings.has_key?(:text) && settings[:text] != ''
19
+ url += "&text=#{CGI.escape(settings[:text])}"
20
+ end
21
+
22
+ # Delete these so we can pass the settings directly into link_to
23
+ %w[url text].each { |url_key| settings.delete(url_key.to_sym) }
24
+
25
+ if block_given?
26
+ link_to(url, settings, &block)
27
+ else
28
+ link_to settings.delete(:label), url, settings
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,7 @@
1
1
  module Flakey
2
2
  module Facebook
3
+ include Base
4
+
3
5
  SHARE_URL = 'https://www.facebook.com/sharer/sharer.php'
4
6
  #
5
7
  # Needed to be able to pass a block down into link_to.
@@ -32,7 +34,7 @@ module Flakey
32
34
  #
33
35
  # Returns a HTML string.
34
36
  def like_button(options = {})
35
- url = options[:url] || request.url
37
+ url = options[:url] || default_url
36
38
  layout = options[:layout] || 'button_count'
37
39
  width = options[:width] || 250
38
40
  send = options[:send] || false
@@ -52,7 +54,7 @@ module Flakey
52
54
  # Returns a HTML string.
53
55
  def share_button(options = {}, &block)
54
56
  defaults = {
55
- url: request.url,
57
+ url: default_url,
56
58
  label: 'Share',
57
59
  target: '_blank',
58
60
  class: 'facebook-share-button'
@@ -5,6 +5,7 @@ require 'active_support/core_ext/hash/except'
5
5
 
6
6
  module Flakey
7
7
  module Twitter
8
+ include Base
8
9
 
9
10
  BASE_URL = "https://twitter.com"
10
11
  SHARE_URL = BASE_URL + "/share"
@@ -64,7 +65,7 @@ module Flakey
64
65
  #
65
66
  # Returns a HTML string.
66
67
  def tweet_button(options = {})
67
- url = options[:url] || request.url
68
+ url = options[:url] || default_url
68
69
  text = options[:text] || ''
69
70
  hashtags = options[:hashtags] || Flakey.configuration.tweet_hashtags
70
71
  via = options[:via] || Flakey.configuration.tweet_via
@@ -138,7 +139,7 @@ module Flakey
138
139
 
139
140
  def tweet_url(options = {})
140
141
  defaults = {
141
- url: respond_to?(:request) && request.url, # allow inclusion in classes that don't respond to :request, or where request is nil
142
+ url: default_url,
142
143
  related: Flakey.configuration.tweet_related,
143
144
  hashtags: Flakey.configuration.tweet_hashtags,
144
145
  via: Flakey.configuration.tweet_via
@@ -166,8 +167,6 @@ module Flakey
166
167
  }
167
168
  settings = defaults.merge(options)
168
169
 
169
- label = settings.delete(:label)
170
-
171
170
  # Delete these so we can pass the settings directly into link_to
172
171
  %w[url text hashtags related via].each do |url_key|
173
172
  settings.delete(url_key.to_sym)
@@ -176,7 +175,7 @@ module Flakey
176
175
  if block_given?
177
176
  link_to(url, settings, &block)
178
177
  else
179
- link_to label, url, settings
178
+ link_to settings.delete(:label), url, settings
180
179
  end
181
180
  end
182
181
  end
@@ -1,3 +1,3 @@
1
1
  module Flakey
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
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.0
4
+ version: 0.5.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-10-24 00:00:00.000000000 Z
11
+ date: 2013-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -81,6 +81,8 @@ files:
81
81
  - Rakefile
82
82
  - flakey.gemspec
83
83
  - lib/flakey.rb
84
+ - lib/flakey/base.rb
85
+ - lib/flakey/buffer.rb
84
86
  - lib/flakey/configuration.rb
85
87
  - lib/flakey/engine.rb
86
88
  - lib/flakey/facebook.rb
@@ -115,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
117
  version: '0'
116
118
  requirements: []
117
119
  rubyforge_project:
118
- rubygems_version: 2.0.3
120
+ rubygems_version: 2.1.11
119
121
  signing_key:
120
122
  specification_version: 4
121
123
  summary: Makes a bunch of helper methods available for including in your Rails views.