github-buttons 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/github-buttons.rb +43 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a8b21b6d3f7ee69cb9469fb53e62f12f79872f0
|
4
|
+
data.tar.gz: 8ca848f6eb5266d36be3c8482f431171ccf66427
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2e21ecee60e53c38936a80297970a249857dfcbf03d9c3779454689e3181ae70481373e64c9d3b0e790d74f0ff6a088e66b64fbe3e831df795078d4f460360f
|
7
|
+
data.tar.gz: c6f25c890cf6219800a6ef1470a82d750cfca4f067c405d4673d585f32a9ee90eabeafff8bc162c42c31cb355591bf573637e536e30721c9decccfaeb664884f
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GitHub
|
2
|
+
class Button
|
3
|
+
attr_accessor :user, :repo
|
4
|
+
def initialize(user, repo)
|
5
|
+
@user = user
|
6
|
+
@repo = repo
|
7
|
+
end
|
8
|
+
|
9
|
+
def style(type="follow", options={})
|
10
|
+
# Available GitHub Button types
|
11
|
+
types = ['fork', 'star', 'follow']
|
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
|
+
# Ensure argument type is valid
|
26
|
+
unless type.is_a? String
|
27
|
+
raise ArgumentError, "Expected String, got #{type.class}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# If no options are specified, pass none
|
31
|
+
if options.empty?
|
32
|
+
large = count = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Format options as URL query parameters for final iFrame
|
36
|
+
if options[:large] then size = "&size=large" end
|
37
|
+
if options[:count] then count = "&count=true" end
|
38
|
+
|
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="250" height="30"></iframe>)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github-buttons
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- M. Maxwell Watson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: A little wrapper for Mark Ottos GitHub Buttons to print <iframe> elements
|
28
|
+
for your views
|
29
|
+
email: mwatson@dosomething.org
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/github-buttons.rb
|
35
|
+
homepage: https://github.com/mmwtsn/github-buttons
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.0.6
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: GitHub Buttons Wrapper
|
59
|
+
test_files: []
|