github-buttons 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/github-buttons.rb +13 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0967640dfd2d5929c0a5d2b9b6f326f756751708
|
4
|
+
data.tar.gz: 60497ccbc5679d60056e4d100c59bd3ab282bd68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c279279c5d86971dcab823845d772432248414a89734dc4b328d438536334c21015e9c3d44404398d622dbd853d382d50806eff51ac8fbabdf16c25a1d21e21e
|
7
|
+
data.tar.gz: 99864f16a3c44cd300895580031c062f871af8abe4b48a33f2e7cd93f250645062f36f9ee7ea219e0b2048defe942c9d8aea8167f5dbf1ce865e1d2299d7af11
|
data/lib/github-buttons.rb
CHANGED
@@ -10,23 +10,16 @@ module GitHub
|
|
10
10
|
# Available GitHub Button types
|
11
11
|
types = ['fork', 'star', 'follow']
|
12
12
|
|
13
|
-
# Ensure button type exists
|
14
|
-
unless types.include? type
|
15
|
-
raise ArgumentError, %Q(#{type} button not available. Try "fork", "star" or "follow")
|
16
|
-
end
|
17
|
-
|
18
|
-
# Work around bug in GitHub Button repository
|
19
|
-
# Requesting "watch" actually returns "star"
|
20
|
-
# See: https://github.com/mdo/github-buttons/issues/42#issuecomment-19951052
|
21
|
-
if type == 'star'
|
22
|
-
type = 'watch'
|
23
|
-
end
|
24
|
-
|
25
13
|
# Ensure argument type is valid
|
26
14
|
unless type.is_a? String
|
27
15
|
raise ArgumentError, "Expected String, got #{type.class}"
|
28
16
|
end
|
29
17
|
|
18
|
+
# Ensure button type exists
|
19
|
+
unless types.include? type
|
20
|
+
raise ArgumentError, %Q(#{type} button not available. Try "fork", "star" or "follow")
|
21
|
+
end
|
22
|
+
|
30
23
|
# If no options are specified, pass none
|
31
24
|
if options.empty?
|
32
25
|
large = count = nil
|
@@ -36,8 +29,15 @@ module GitHub
|
|
36
29
|
if options[:large] then size = "&size=large" end
|
37
30
|
if options[:count] then count = "&count=true" end
|
38
31
|
|
32
|
+
# Work around bug in GitHub Button repository
|
33
|
+
# Requesting "watch" actually returns "star"
|
34
|
+
# See: https://github.com/mdo/github-buttons/issues/42#issuecomment-19951052
|
35
|
+
if type == 'star'
|
36
|
+
type = 'watch'
|
37
|
+
end
|
38
|
+
|
39
39
|
# Return GitHub Button
|
40
|
-
%Q(<iframe src="http://ghbtns.com/github-btn.html?user=#{@user}&repo=#{@repo}&type=#{type}#{size}#{count}" allowtransparency="true" frameborder="0" scrolling="0" width="
|
40
|
+
%Q(<iframe class="github-button #{type}" src="http://ghbtns.com/github-btn.html?user=#{@user}&repo=#{@repo}&type=#{type}#{size}#{count}" allowtransparency="true" frameborder="0" scrolling="0" width="120" height="30"></iframe>)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|