jekyll-gist 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89c64f48a5473df55630a25447a74711c6452b69
4
+ data.tar.gz: e0d1fc2b2a0aef66a73790d6dad0ebfa87dae692
5
+ SHA512:
6
+ metadata.gz: a4a2778e58b2d3f1e4f6a111a82ce8ac6d888f73eb45576ca6f67b2d85f808004df1574ffaf0d42d995e7c36adb50b3a05418bb4a4fe77602569447137107ce8
7
+ data.tar.gz: c5c8a0f63e2f8fede34da128eaf68ea4540be883a6b0171872f7092dca028a80ab1ee447fed27b24fcfc3fcf22fda1984879e867aa79d75c08815137c7777233
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-gist.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Parker Moore
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Jekyll::Gist
2
+
3
+ Liquid tag for displaying GitHub Gists in Jekyll sites: `{% gist %}`.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jekyll-gist'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jekyll-gist
18
+
19
+ ## Usage
20
+
21
+ Use the tag as follows in your Jekyll pages, posts and collections:
22
+
23
+ ```liquid
24
+ {% gist parkr/c08ee0f2726fd0e3909d %}
25
+ ```
26
+
27
+ This will create the associated script tag:
28
+
29
+ ```html
30
+ <script src="https://gist.github.com/parkr/c08ee0f2726fd0e3909d.js"> </script>
31
+ ```
32
+
33
+ You may optionally specify a `filename` after the `gist_id`:
34
+
35
+ ```liquid
36
+ {% gist parkr/c08ee0f2726fd0e3909d test.md %}
37
+ ```
38
+
39
+ This will produce the correct URL to show just the specified file in your post rather than the entire Gist.
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/jekyll/jekyll-gist/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-gist/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-gist"
8
+ spec.version = Jekyll::Gist::VERSION
9
+ spec.authors = ["Parker Moore"]
10
+ spec.email = ["parkrmoore@gmail.com"]
11
+ spec.summary = %q{Liquid tag for displaying GitHub Gists in Jekyll sites.}
12
+ spec.homepage = "https://github.com/jekyll/jekyll-gist"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "jekyll", "~> 2.0"
24
+ end
@@ -0,0 +1,7 @@
1
+ require "jekyll-gist/version"
2
+ require "jekyll-gist/gist_tag"
3
+
4
+ module Jekyll
5
+ module Gist
6
+ end
7
+ end
@@ -0,0 +1,44 @@
1
+ module Jekyll
2
+ module Gist
3
+ class GistTag < Liquid::Tag
4
+
5
+ def render(context)
6
+ if tag_contents = determine_arguments(@markup.strip)
7
+ gist_id, filename = tag_contents[0], tag_contents[1]
8
+ gist_script_tag(gist_id, filename)
9
+ else
10
+ raise ArgumentError.new <<-eos
11
+ Syntax error in tag 'gist' while parsing the following markup:
12
+
13
+ #{@markup}
14
+
15
+ Valid syntax:
16
+ for all gists: {% gist user/1234567 %}
17
+ eos
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def determine_arguments(input)
24
+ matched = if input.include?("/")
25
+ input.match(/\A([a-zA-Z0-9\/\-_]+) ?(\S*)\Z/)
26
+ else
27
+ input.match(/\A(\d+) ?(\S*)\Z/)
28
+ end
29
+ [matched[1].strip, matched[2].strip] if matched && matched.length >= 3
30
+ end
31
+
32
+ def gist_script_tag(gist_id, filename = nil)
33
+ if filename.empty?
34
+ "<script src=\"https://gist.github.com/#{gist_id}.js\"> </script>"
35
+ else
36
+ "<script src=\"https://gist.github.com/#{gist_id}.js?file=#{filename}\"> </script>"
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+ Liquid::Template.register_tag('gist', Jekyll::Gist::GistTag)
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Gist
3
+ VERSION = "1.0.0.rc1"
4
+ end
5
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe(Jekyll::Gist::GistTag) do
4
+ let(:doc) { doc_with_content(content) }
5
+ let(:content) { "{% gist #{gist} %}" }
6
+ let(:output) do
7
+ doc.content = content
8
+ doc.output = Jekyll::Renderer.new(doc.site, doc).run
9
+ end
10
+
11
+ context "simple gist" do
12
+ let(:gist) { 358471 }
13
+
14
+ it "produces the correct script tag" do
15
+ expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
16
+ end
17
+ end
18
+
19
+ context "private gist" do
20
+
21
+ context "when valid" do
22
+ let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
23
+
24
+ it "produces the correct script tag" do
25
+ expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
26
+ end
27
+ end
28
+
29
+ context "with file specified" do
30
+ let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
31
+ let(:filename) { "myfile.ext" }
32
+ let(:content) { "{% gist #{gist} #{filename} %}" }
33
+
34
+ it "produces the correct script tag" do
35
+ expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js\?file=#{filename}">\s<\/script>/)
36
+ end
37
+ end
38
+
39
+ context "when invalid" do
40
+ let(:gist) { "mattr-24081a1d93d2898ecf0f" }
41
+
42
+ it "raises an error" do
43
+ expect(->{ output }).to raise_error
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ context "no gist id present" do
50
+ let(:gist) { "" }
51
+
52
+ it "raises an error" do
53
+ expect(->{ output }).to raise_error
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,44 @@
1
+ TEST_DIR = File.dirname(__FILE__)
2
+ TMP_DIR = File.expand_path("../tmp", TEST_DIR)
3
+
4
+ require 'jekyll'
5
+ require File.expand_path("../lib/jekyll-gist.rb", TEST_DIR)
6
+
7
+ Jekyll.logger.log_level = :error
8
+ STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+ config.order = 'random'
15
+
16
+ def tmp_dir(*files)
17
+ File.join(TMP_DIR, *files)
18
+ end
19
+
20
+ def source_dir(*files)
21
+ tmp_dir('source', *files)
22
+ end
23
+
24
+ def dest_dir(*files)
25
+ tmp_dir('dest', *files)
26
+ end
27
+
28
+ def doc_with_content(content, opts = {})
29
+ my_site = site
30
+ Jekyll::Document.new(source_dir('_test/doc.md'), {site: my_site, collection: collection(my_site)})
31
+ end
32
+
33
+ def collection(site, label = 'test')
34
+ Jekyll::Collection.new(site, label)
35
+ end
36
+
37
+ def site(opts = {})
38
+ conf = Jekyll::Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, opts.merge({
39
+ "source" => source_dir,
40
+ "destination" => dest_dir
41
+ }))
42
+ Jekyll::Site.new(conf)
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-gist
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Parker Moore
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jekyll
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ description:
70
+ email:
71
+ - parkrmoore@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - jekyll-gist.gemspec
83
+ - lib/jekyll-gist.rb
84
+ - lib/jekyll-gist/gist_tag.rb
85
+ - lib/jekyll-gist/version.rb
86
+ - spec/gist_tag_spec.rb
87
+ - spec/spec_helper.rb
88
+ homepage: https://github.com/jekyll/jekyll-gist
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">"
104
+ - !ruby/object:Gem::Version
105
+ version: 1.3.1
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Liquid tag for displaying GitHub Gists in Jekyll sites.
112
+ test_files:
113
+ - spec/gist_tag_spec.rb
114
+ - spec/spec_helper.rb