flakey 0.0.1 → 0.0.2
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.
- data/.travis.yml +2 -0
- data/Rakefile +6 -0
- data/flakey.gemspec +1 -0
- data/lib/flakey/configuration.rb +2 -0
- data/lib/flakey/twitter.rb +53 -5
- data/lib/flakey/version.rb +1 -1
- data/spec/spec_helper.rb +6 -1
- metadata +16 -5
- data/.rspec +0 -1
data/.travis.yml
ADDED
data/Rakefile
CHANGED
data/flakey.gemspec
CHANGED
data/lib/flakey/configuration.rb
CHANGED
@@ -11,6 +11,7 @@ module Flakey
|
|
11
11
|
class Configuration
|
12
12
|
attr_accessor :default_twitter_handle, :default_tweet_hashtags,
|
13
13
|
:default_tweet_via, :default_tweet_related,
|
14
|
+
:default_tweet_button_size, :default_tweet_button_class,
|
14
15
|
:default_facebook_nickname, :facebook_app_id,
|
15
16
|
:default_stackoverflow_nickname, :default_stackoverflow_user_id,
|
16
17
|
:default_github_name, :plus_one_button_language
|
@@ -20,6 +21,7 @@ module Flakey
|
|
20
21
|
self.default_tweet_hashtags = ''
|
21
22
|
self.default_tweet_via = ''
|
22
23
|
self.default_tweet_related = ''
|
24
|
+
self.default_tweet_button_class = "twitter-share-button"
|
23
25
|
|
24
26
|
self.default_facebook_nickname = ''
|
25
27
|
|
data/lib/flakey/twitter.rb
CHANGED
@@ -1,15 +1,59 @@
|
|
1
|
+
# THis class is used to generate standard Twitter buttons as documented
|
2
|
+
# on the [Twitter developers site](https://twitter.com/about/resources/buttons).
|
3
|
+
|
1
4
|
module Flakey
|
2
5
|
module Twitter
|
3
6
|
|
4
|
-
|
5
|
-
|
7
|
+
# Get the default Twitter handle for this configuration. If a
|
8
|
+
# handle argument is supplied, it will be returned.
|
9
|
+
#
|
10
|
+
# twitter_handle
|
11
|
+
# # => The default handle.
|
12
|
+
#
|
13
|
+
# twitter_handle('peter')
|
14
|
+
# # => 'peter'
|
15
|
+
#
|
16
|
+
# Returns a string.
|
17
|
+
def twitter_handle(handle = nil)
|
18
|
+
handle || Flakey.configuration.default_twitter_handle
|
6
19
|
end
|
7
20
|
|
8
|
-
|
9
|
-
|
21
|
+
# Get the Twitter profile URL for a handle. If no handle is
|
22
|
+
# specified then this method returns the profile URL of the
|
23
|
+
# default handle.
|
24
|
+
#
|
25
|
+
# twitter_url
|
26
|
+
# # => "https://twitter.com/default
|
27
|
+
#
|
28
|
+
# twitter_url('peter')
|
29
|
+
# # => "https://twitter.com/peter"
|
30
|
+
#
|
31
|
+
# Returns a string.
|
32
|
+
def twitter_url(handle = nil)
|
33
|
+
handle = handle || twitter_handle
|
10
34
|
"https://twitter.com/#{handle}"
|
11
35
|
end
|
12
36
|
|
37
|
+
# Generate a tweet button. This method needs the Twitter JavaScript
|
38
|
+
# to be loaded on the page to work correctly.
|
39
|
+
#
|
40
|
+
# Takes a hash of options to use when generating the button.
|
41
|
+
#
|
42
|
+
# [+url+] The URL to tweet. Default to the current request url.
|
43
|
+
# [+text+] The textual body of the Tweet. Defaults to the current
|
44
|
+
# page title. This is a Twitter convention.
|
45
|
+
# [+hashtags+] A list of hashtags to include in the tweet.
|
46
|
+
# [+label+] The text to appear on the tweet button.
|
47
|
+
# [+via+] Tweet via an associated abbout. Defaults to the
|
48
|
+
# +default_tweet_via+ configuration setting.
|
49
|
+
# [+related+] A related Twitter handle. Defaults to the
|
50
|
+
# +default_tweet_related+ configuration setting.
|
51
|
+
# [+class+] HTML classes to apply to the Tweet button. Defaults
|
52
|
+
# to the +default_tweet_button_class+ configuration setting which
|
53
|
+
# is <i>"twitter-share-button"</i>.
|
54
|
+
# [+size+]
|
55
|
+
#
|
56
|
+
# Returns a HTML string.
|
13
57
|
def tweet_button(options = {})
|
14
58
|
url = options[:url] || request.url
|
15
59
|
text = options[:text]
|
@@ -20,7 +64,10 @@ module Flakey
|
|
20
64
|
Flakey.configuration.default_tweet_via
|
21
65
|
related = options[:related] ||
|
22
66
|
Flakey.configuration.default_tweet_related
|
23
|
-
|
67
|
+
size = options[:size] ||
|
68
|
+
Flakey.configuration.default_tweet_button_size
|
69
|
+
class_list = options[:class] ||
|
70
|
+
Flakey.configuration.default_tweet_button_class
|
24
71
|
|
25
72
|
data_attr = {
|
26
73
|
:via => via,
|
@@ -30,6 +77,7 @@ module Flakey
|
|
30
77
|
}
|
31
78
|
# Twitter will take the page title if we just leave it out.
|
32
79
|
data_attr.merge!(text: text) unless text.nil?
|
80
|
+
data_attr.merge!(size: size) unless size.nil?
|
33
81
|
|
34
82
|
link_to label, "https://twitter.com/share",
|
35
83
|
:class => class_list, :data => data_attr
|
data/lib/flakey/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
require "flakey"
|
1
|
+
require "flakey/configuration"
|
2
|
+
require "flakey/twitter"
|
3
|
+
require "flakey/facebook"
|
4
|
+
require "flakey/github"
|
5
|
+
require "flakey/google_plus"
|
6
|
+
require "flakey/stackoverflow"
|
2
7
|
|
3
8
|
Flakey.configure do |c|
|
4
9
|
c.default_twitter_handle = 'grinnick'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flakey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70265412068800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70265412068800
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70265412068380 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70265412068380
|
25
36
|
description: Social helpers for Rails apps.
|
26
37
|
email:
|
27
38
|
- dtuite@gmail.com
|
@@ -30,7 +41,7 @@ extensions: []
|
|
30
41
|
extra_rdoc_files: []
|
31
42
|
files:
|
32
43
|
- .gitignore
|
33
|
-
- .
|
44
|
+
- .travis.yml
|
34
45
|
- Gemfile
|
35
46
|
- LICENSE
|
36
47
|
- README.md
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|