flakey 0.3.1 → 0.4.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: 60aacac058c0a16e290380a51173862b00e9f696
4
- data.tar.gz: a335d65b83b8b5c74ee53592611826896300b258
3
+ metadata.gz: 0e8ed80023a112ce6933d258fd187acd36cc4934
4
+ data.tar.gz: fefaa9d180d0634a6ea3af541fb10241f408e456
5
5
  SHA512:
6
- metadata.gz: 887d44fce9a2af4482d8064c67b7b279ac049cbd7a2396db5ed05cfba4b207f162e185c309f5da7adab6a576dbd36f8037f0d15e46162467dc5912541a2f5664
7
- data.tar.gz: e251bcbdafddd823a5e2f2d1f90f40cc1366c41e460b993ba39b950acb3bc18cafaf30ee98d8a0962c2cb26842489bd28e80efac96bf9d5c1970bf678f8f91b7
6
+ metadata.gz: cb887103c4e8051540b4e86def11f364e3b7d620ad38810332f2cd94613b4a625396f3696d935d280ed02d1a6ef86880e1f89bcf6bcd437c0c34f5e2c60168ee
7
+ data.tar.gz: 0e76af570f101688569d7c14ec9a82acdf3b8b987201d59d2eca5f43e43e0b9718ebaaeddf9d0145205a6400a97ddd2d044e031c4cdec82145856a98b13beb43
@@ -136,28 +136,40 @@ module Flakey
136
136
  link_to text, intent_url, options.except(:user_id, :screen_name)
137
137
  end
138
138
 
139
- def custom_tweet_button(options = {}, &block)
139
+ def tweet_url(options = {})
140
140
  defaults = {
141
- label: 'Tweet',
142
- url: request.url,
141
+ url: respond_to?(:request) && request.url, # allow inclusion in classes that don't respond to :request, or where request is nil
143
142
  related: Flakey.configuration.tweet_related,
144
143
  hashtags: Flakey.configuration.tweet_hashtags,
145
- via: Flakey.configuration.tweet_via,
146
- class: 'custom-tweet-button',
147
- target: '_blank'
144
+ via: Flakey.configuration.tweet_via
148
145
  }
149
146
  settings = defaults.merge(options)
150
147
  url = "#{SHARE_URL}?url=#{CGI.escape settings[:url]}"
151
148
 
152
- label = settings[:label]
153
- # Delete these so we can pass the settings directly into link_to
154
- settings.delete(:label)
155
- settings.delete(:url)
156
-
157
149
  %w[text hashtags related via].each do |url_key|
158
150
  if settings.has_key?(url_key.to_sym) && settings[url_key.to_sym] != ''
159
151
  url += "&#{url_key}=#{CGI.escape settings[url_key.to_sym]}"
160
152
  end
153
+ end
154
+
155
+ url
156
+ end
157
+
158
+ def custom_tweet_button(options = {}, &block)
159
+
160
+ url = tweet_url(options)
161
+
162
+ defaults = {
163
+ label: 'Tweet',
164
+ class: 'custom-tweet-button',
165
+ target: '_blank'
166
+ }
167
+ settings = defaults.merge(options)
168
+
169
+ label = settings.delete(:label)
170
+
171
+ # Delete these so we can pass the settings directly into link_to
172
+ %w[url text hashtags related via].each do |url_key|
161
173
  settings.delete(url_key.to_sym)
162
174
  end
163
175
 
@@ -1,3 +1,3 @@
1
1
  module Flakey
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -56,6 +56,31 @@ describe Flakey::Twitter do
56
56
  end
57
57
  end
58
58
 
59
+ describe "#tweet_url" do
60
+ before { subject.stub_chain('request.url') { 'http://www.example.com' } }
61
+
62
+ it "should include the url" do
63
+ subject.tweet_url().should == "https://twitter.com/share?url=http%3A%2F%2Fwww.example.com"
64
+ end
65
+
66
+ it "should include via" do
67
+ subject.tweet_url(:via => "kieran").should =~ /[&?]via=kieran/
68
+ end
69
+
70
+ it "should include hashtags" do
71
+ subject.tweet_url(:hashtags => "cupoftea").should =~ /[&?]hashtags=cupoftea/
72
+ end
73
+
74
+ it "should include text" do
75
+ subject.tweet_url(:text => "hello").should =~ /[&?]text=hello/
76
+ end
77
+
78
+ it "should include related" do
79
+ subject.tweet_url(:related => "someone").should =~ /[&?]related=someone/
80
+ end
81
+
82
+ end
83
+
59
84
  describe 'custom_tweet_button' do
60
85
  before { subject.stub_chain('request.url') { 'http://example.com/hello' } }
61
86
  let(:default_url) do
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.3.1
4
+ version: 0.4.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-10 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport