mattapayne-gistr 1.0.1
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/README +30 -0
- data/gistr.gemspec +14 -0
- data/gistr.rb +24 -0
- data/test/test_gistr.rb +34 -0
- metadata +55 -0
data/README
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Gistr is a super simple Ruby plugin that extends your Rails or Sinatra application to make use
|
2
|
+
of GitHub's awesome Gist service (http://gist.github.com).
|
3
|
+
|
4
|
+
Currently this plugin is incredibly simple and only allows you to embed Gists in your views.
|
5
|
+
|
6
|
+
Installation:
|
7
|
+
=============
|
8
|
+
|
9
|
+
a) gem sources -a http://gems.github.com (you only have to do this once)
|
10
|
+
b) sudo gem install mattapayne-gistr
|
11
|
+
|
12
|
+
Usage:
|
13
|
+
======
|
14
|
+
|
15
|
+
Sinatra:
|
16
|
+
========
|
17
|
+
After requiring Sinatra, require 'gistr'
|
18
|
+
View helper methods are added to Sinatra's helpers
|
19
|
+
|
20
|
+
Rails:
|
21
|
+
======
|
22
|
+
Add config.gem 'mattapayne-gistr', :source => 'http://gems.github.com', :lib => "gistr"
|
23
|
+
to your environment.rb file.
|
24
|
+
|
25
|
+
View Helper methods are added to ActionView
|
26
|
+
|
27
|
+
For Views in Both:
|
28
|
+
==================
|
29
|
+
|
30
|
+
<%= gist(12345) -%>
|
data/gistr.gemspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#The GemSpec to build the gem
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'gistr'
|
4
|
+
s.version = '1.0.1'
|
5
|
+
s.date = "2009-04-18"
|
6
|
+
s.summary = "Ruby Gist View helper library."
|
7
|
+
s.description = %{A Ruby library that adds view helpers for embedding Gists in views.}
|
8
|
+
s.has_rdoc = false
|
9
|
+
s.author = "Matt Payne"
|
10
|
+
s.email = "matt@mattpayne.ca"
|
11
|
+
s.homepage = "http://mattpayne.ca"
|
12
|
+
s.files = ['README', 'gistr.gemspec', 'gistr.rb']
|
13
|
+
s.test_files = ['test/test_gistr.rb']
|
14
|
+
end
|
data/gistr.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Gistr
|
2
|
+
|
3
|
+
GIST_URL = "http://gist.github.com"
|
4
|
+
|
5
|
+
module ViewHelpers
|
6
|
+
def gist(gist_id)
|
7
|
+
(gist_id.nil? || gist_id.to_s.empty?) ? nil :
|
8
|
+
"<script src=\"#{GIST_URL}/#{gist_id}.js\"></script>"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
#If ActionView is defined, include Gistr
|
15
|
+
if defined?(ActionView)
|
16
|
+
ActionView::Base.send(:include, Gistr::ViewHelpers)
|
17
|
+
end
|
18
|
+
|
19
|
+
#Add to Sinatra if possible
|
20
|
+
if defined?(Sinatra)
|
21
|
+
helpers do
|
22
|
+
include Gistr::ViewHelpers
|
23
|
+
end
|
24
|
+
end
|
data/test/test_gistr.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
local_path = File.dirname(__FILE__)
|
3
|
+
require File.join(local_path, "..", "gistr")
|
4
|
+
|
5
|
+
class MyTestClass
|
6
|
+
include Gistr::ViewHelpers
|
7
|
+
end
|
8
|
+
|
9
|
+
class GistrTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@tc = MyTestClass.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
@tc = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_it_should_return_nil_if_gist_id_is_nil
|
20
|
+
result = @tc.gist(nil)
|
21
|
+
assert_nil(result)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_it_should_return_nil_if_gist_id_is_empty
|
25
|
+
result = @tc.gist("")
|
26
|
+
assert_nil(result)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_it_should_return_a_script_tag_with_gist_id
|
30
|
+
result = @tc.gist("12345")
|
31
|
+
assert_equal("<script src=\"http://gist.github.com/12345.js\"></script>", result)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mattapayne-gistr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Payne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-18 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A Ruby library that adds view helpers for embedding Gists in views.
|
17
|
+
email: matt@mattpayne.ca
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- gistr.gemspec
|
27
|
+
- gistr.rb
|
28
|
+
has_rdoc: false
|
29
|
+
homepage: http://mattpayne.ca
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.2.0
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: Ruby Gist View helper library.
|
54
|
+
test_files:
|
55
|
+
- test/test_gistr.rb
|