jekyll-gist 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 80753f3b576cd9ade3d547147b187ce45acbc447
4
- data.tar.gz: 38fcbfd0e9f1d2bc7854a6ab5b7f0e66eeb516fa
2
+ SHA256:
3
+ metadata.gz: 757d317fa616c25fbc421865aa14d567d4d73c671d8971319028a9664f02861b
4
+ data.tar.gz: a37a1d5dcf8f82cbdfdb01d0f31bc084a4ede7fd3a39bee7a7101baf765ff5b4
5
5
  SHA512:
6
- metadata.gz: d7b28c4b95e96a1eb47e4e02542bfd9c0da61865c80f53159b7fce4c3de184cc2446af79942621692b9ea40ca502d7860b71f7bac927dc48e15b32551df8db99
7
- data.tar.gz: 266bfd8cb221b5b4a9d5f1607444c2a5496fbe77480e26cd77286dfa22d7889e91447b33b25d79bfbc08d086b75b5c504872b0d5fdd0f2a733272463a93659fb
6
+ metadata.gz: 160a3e7de9ffd5432d947e803fade71f8d0f424d1ef03cf7746a8c4452be69ae752da4e169668c19d625aef4c2df72045f31e96d260c9cbc1b1cdbfbd96693b4
7
+ data.tar.gz: 7bd1510aabcb67f277648cb028499b44dbcd3228271c9ee81c0111556c302e6e2db9b06b6e6332e8bb05cb1bfc932032cc5180ed69d2683d8c8589fb01fd95b3
@@ -0,0 +1,28 @@
1
+ inherit_gem:
2
+ jekyll: .rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.1
6
+ Exclude:
7
+ - vendor/**/*
8
+ - spec/*.rb
9
+
10
+ Lint/IneffectiveAccessModifier:
11
+ Exclude:
12
+ - lib/jekyll-gist/gist_tag.rb
13
+
14
+ Lint/ShadowedException:
15
+ Exclude:
16
+ - lib/jekyll-gist/gist_tag.rb
17
+
18
+ Metrics/AbcSize:
19
+ Exclude:
20
+ - lib/jekyll-gist/gist_tag.rb
21
+
22
+ Metrics/MethodLength:
23
+ Exclude:
24
+ - lib/jekyll-gist/gist_tag.rb
25
+
26
+ Style/PreferredHashMethods:
27
+ Exclude:
28
+ - lib/jekyll-gist/gist_tag.rb
@@ -14,7 +14,7 @@ rvm:
14
14
  - 2.1
15
15
  env:
16
16
  - ""
17
- - JEKYLL_VERSION=3.4.4
17
+ - JEKYLL_VERSION=3.6.2
18
18
  matrix:
19
19
  include:
20
20
  - # GitHub Pages
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
  gemspec
3
5
 
4
6
  if ENV["GH_PAGES"]
@@ -1,3 +1,19 @@
1
+ ## HEAD
2
+
3
+ ### Documentation
4
+
5
+ * replace 'plugins' key in config with 'gems' (#46)
6
+ * Docs: Remove username in gist (#54)
7
+
8
+ ### Development Fixes
9
+
10
+ * Remove testing for Jekyll 2.x
11
+ * Requires Ruby > 2.1
12
+ * Add release script
13
+ * Inherit Jekyll's rubocop config for consistency (#48)
14
+ * define path with __dir__ (#47)
15
+
16
+
1
17
  ## 1.4.1 / 2017-06-21
2
18
 
3
19
  * Don't ask .empty? until it's a String. (#38)
data/README.md CHANGED
@@ -8,7 +8,7 @@ Liquid tag for displaying GitHub Gists in Jekyll sites: `{% gist %}`.
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'jekyll-gist'
11
+ $ gem 'jekyll-gist'
12
12
 
13
13
  And then execute:
14
14
 
@@ -18,19 +18,21 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install jekyll-gist
20
20
 
21
- Finally, add the following to your site's `_config.yml`:
21
+ Then add the following to your site's `_config.yml`:
22
22
 
23
23
  ```
24
- gems:
24
+ plugins:
25
25
  - jekyll-gist
26
26
  ```
27
27
 
28
+ 💡 If you are using a Jekyll version less than 3.5.0, use the `gems` key instead of `plugins`.
29
+
28
30
  ## Usage
29
31
 
30
32
  Use the tag as follows in your Jekyll pages, posts and collections:
31
33
 
32
34
  ```liquid
33
- {% gist parkr/c08ee0f2726fd0e3909d %}
35
+ {% gist c08ee0f2726fd0e3909d %}
34
36
  ```
35
37
 
36
38
  This will create the associated script tag:
@@ -42,7 +44,7 @@ This will create the associated script tag:
42
44
  You may optionally specify a `filename` after the `gist_id`:
43
45
 
44
46
  ```liquid
45
- {% gist parkr/c08ee0f2726fd0e3909d test.md %}
47
+ {% gist c08ee0f2726fd0e3909d test.md %}
46
48
  ```
47
49
 
48
50
  This will produce the correct URL to show just the specified file in your post rather than the entire Gist.
@@ -51,7 +53,7 @@ This will produce the correct URL to show just the specified file in your post r
51
53
 
52
54
  ## Disabling `noscript` support
53
55
 
54
- By default, Jekyll Gist will make an HTTP call per Gist to retrieve the raw content of the Gist. This information is used to propagate `noscript` tags for search engines and browsers without Javascript support. If you'd like to disable this feature, for example, to speed up builds locally, simply add the following to your site's `_config.yml`:
56
+ By default, Jekyll Gist will make an HTTP call per Gist to retrieve the raw content of the Gist. This information is used to propagate `noscript` tags for search engines and browsers without Javascript support. If you'd like to disable this feature, for example, to speed up builds locally, add the following to your site's `_config.yml`:
55
57
 
56
58
  ```yml
57
59
  gist:
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
@@ -1,28 +1,31 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll-gist/version'
6
+ require "jekyll-gist/version"
5
7
 
6
8
  Gem::Specification.new do |spec|
7
9
  spec.name = "jekyll-gist"
8
10
  spec.version = Jekyll::Gist::VERSION
9
11
  spec.authors = ["Parker Moore"]
10
12
  spec.email = ["parkrmoore@gmail.com"]
11
- spec.summary = %q{Liquid tag for displaying GitHub Gists in Jekyll sites.}
13
+ spec.summary = "Liquid tag for displaying GitHub Gists in Jekyll sites."
12
14
  spec.homepage = "https://github.com/jekyll/jekyll-gist"
13
15
  spec.license = "MIT"
14
16
 
15
- spec.required_ruby_version = '>= 1.9.3'
17
+ spec.required_ruby_version = ">= 2.1"
16
18
 
17
19
  spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
20
22
  spec.require_paths = ["lib"]
21
23
 
22
24
  spec.add_dependency "octokit", "~> 4.2"
23
25
  spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "jekyll", ">= 3.0"
24
27
  spec.add_development_dependency "rake"
25
28
  spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "rubocop", "~> 0.51"
26
30
  spec.add_development_dependency "webmock"
27
- spec.add_development_dependency "jekyll", ">= 2.0"
28
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "jekyll-gist/version"
2
4
  require "jekyll-gist/gist_tag"
3
5
 
@@ -1,6 +1,8 @@
1
- require 'cgi'
2
- require 'net/http'
3
- require 'octokit'
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+ require "net/http"
5
+ require "octokit"
4
6
 
5
7
  Net::OpenTimeout = Class.new(RuntimeError) unless Net.const_defined?(:OpenTimeout)
6
8
  Net::ReadTimeout = Class.new(RuntimeError) unless Net.const_defined?(:ReadTimeout)
@@ -8,12 +10,12 @@ Net::ReadTimeout = Class.new(RuntimeError) unless Net.const_defined?(:ReadTimeou
8
10
  module Jekyll
9
11
  module Gist
10
12
  class GistTag < Liquid::Tag
11
-
12
13
  def render(context)
13
- @encoding = context.registers[:site].config['encoding'] || 'utf-8'
14
- @settings = context.registers[:site].config['gist']
15
- if tag_contents = determine_arguments(@markup.strip)
16
- gist_id, filename = tag_contents[0], tag_contents[1]
14
+ @encoding = context.registers[:site].config["encoding"] || "utf-8"
15
+ @settings = context.registers[:site].config["gist"]
16
+ if (tag_contents = determine_arguments(@markup.strip))
17
+ gist_id = tag_contents[0]
18
+ filename = tag_contents[1]
17
19
  if context_contains_key?(context, gist_id)
18
20
  gist_id = context[gist_id]
19
21
  end
@@ -24,7 +26,7 @@ module Jekyll
24
26
  script_tag = gist_script_tag(gist_id, filename)
25
27
  "#{noscript_tag}#{script_tag}"
26
28
  else
27
- raise ArgumentError.new <<-eos
29
+ raise ArgumentError, <<-EOS
28
30
  Syntax error in tag 'gist' while parsing the following markup:
29
31
 
30
32
  #{@markup}
@@ -34,14 +36,14 @@ module Jekyll
34
36
  {% gist user/1234567 foo.js %}
35
37
  {% gist 28949e1d5ee2273f9fd3 %}
36
38
  {% gist 28949e1d5ee2273f9fd3 best.md %}
37
- eos
39
+ EOS
38
40
  end
39
41
  end
40
42
 
41
43
  private
42
44
 
43
45
  def determine_arguments(input)
44
- matched = input.match(/\A([\S]+|.*(?=\/).+)\s?(\S*)\Z/)
46
+ matched = input.match(%r!\A([\S]+|.*(?=\/).+)\s?(\S*)\Z!)
45
47
  [matched[1].strip, matched[2].strip] if matched && matched.length >= 3
46
48
  end
47
49
 
@@ -74,9 +76,9 @@ module Jekyll
74
76
 
75
77
  "<noscript><pre>#{code}</pre></noscript>"
76
78
  else
77
- Jekyll.logger.warn "Warning:", "The <noscript> tag for your gist #{gist_id} could not"
78
- Jekyll.logger.warn "", "be generated. This will affect users who do not have"
79
- Jekyll.logger.warn "", "JavaScript available or enabled in their browsers."
79
+ Jekyll.logger.warn "Warning:", "The <noscript> tag for your gist #{gist_id} "
80
+ Jekyll.logger.warn "", "could not be generated. This will affect users who do "
81
+ Jekyll.logger.warn "", "not have JavaScript enabled in their browsers."
80
82
  end
81
83
  end
82
84
 
@@ -87,8 +89,8 @@ module Jekyll
87
89
  url = "#{url}/#{filename}" unless filename.to_s.empty?
88
90
  uri = URI(url)
89
91
  Net::HTTP.start(uri.host, uri.port,
90
- use_ssl: uri.scheme == 'https',
91
- read_timeout: 3, open_timeout: 3) do |http|
92
+ :use_ssl => uri.scheme == "https",
93
+ :read_timeout => 3, :open_timeout => 3) do |http|
92
94
  request = Net::HTTP::Get.new uri.to_s
93
95
  response = http.request(request)
94
96
  response.body
@@ -103,15 +105,15 @@ module Jekyll
103
105
  gist = GistTag.client.gist gist_id
104
106
 
105
107
  file = if filename.to_s.empty?
106
- # No file specified, return the value of the first key/value pair
107
- gist.files.first[1]
108
- else
109
- # .files is a hash of :"filename.extension" => data pairs
110
- # Rather than using to_sym on arbitrary user input,
111
- # Find our file by calling to_s on the keys
112
- match = gist.files.find { |name, data| name.to_s == filename }
113
- match[1] if match
114
- end
108
+ # No file specified, return the value of the first key/value pair
109
+ gist.files.first[1]
110
+ else
111
+ # .files is a hash of :"filename.extension" => data pairs
112
+ # Rather than using to_sym on arbitrary user input,
113
+ # Find our file by calling to_s on the keys
114
+ match = gist.files.find { |name, _data| name.to_s == filename }
115
+ match[1] if match
116
+ end
115
117
 
116
118
  file[:content] if file
117
119
  end
@@ -123,4 +125,4 @@ module Jekyll
123
125
  end
124
126
  end
125
127
 
126
- Liquid::Template.register_tag('gist', Jekyll::Gist::GistTag)
128
+ Liquid::Template.register_tag("gist", Jekyll::Gist::GistTag)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jekyll
2
4
  module Gist
3
- VERSION = "1.4.1"
5
+ VERSION = "1.5.0".freeze
4
6
  end
5
7
  end
@@ -1,3 +1,4 @@
1
1
  #! /usr/bin/env bash
2
+ set -ex
2
3
 
3
4
  bundle install
@@ -1,4 +1,5 @@
1
1
  #! /usr/bin/env bash
2
2
  set -e
3
3
 
4
+ script/fmt
4
5
  bundle exec rspec
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "Rubocop $(bundle exec rubocop --version)"
5
+ bundle exec rubocop -D -E $@
6
+ success=$?
7
+ if ((success != 0)); then
8
+ echo -e "\nTry running \`script/fmt -a\` to automatically fix errors"
9
+ fi
10
+ exit $success
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+
3
+ rake release
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe(Jekyll::Gist::GistTag) do
4
4
  let(:http_output) { "<test>true</test>" }
5
5
  let(:doc) { doc_with_content(content) }
6
- let(:content) { "{% gist #{gist} %}" }
6
+ let(:content) { "{% gist #{gist} %}" }
7
7
  let(:output) do
8
8
  doc.content = content
9
9
  doc.output = Jekyll::Renderer.new(doc.site, doc).run
@@ -13,139 +13,138 @@ describe(Jekyll::Gist::GistTag) do
13
13
 
14
14
  context "valid gist" do
15
15
  context "with user prefix" do
16
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw").to_return(body: http_output) }
16
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw").to_return(:body => http_output) }
17
17
  let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
18
18
 
19
19
  it "produces the correct script tag" do
20
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
20
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>!)
21
21
  end
22
22
  it "produces the correct noscript tag" do
23
- expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
23
+ expect(output).to match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
24
24
  end
25
25
  end
26
26
 
27
27
  context "without user prefix" do
28
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw").to_return(body: http_output) }
28
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw").to_return(:body => http_output) }
29
29
  let(:gist) { "28949e1d5ee2273f9fd3" }
30
30
 
31
31
  it "produces the correct script tag" do
32
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
32
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>!)
33
33
  end
34
34
  it "produces the correct noscript tag" do
35
- expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
35
+ expect(output).to match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
36
36
  end
37
37
  end
38
38
 
39
39
  context "classic Gist id style" do
40
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw").to_return(body: http_output) }
40
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw").to_return(:body => http_output) }
41
41
  let(:gist) { "1234321" }
42
42
 
43
43
  it "produces the correct script tag" do
44
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
44
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>!)
45
45
  end
46
46
  it "produces the correct noscript tag" do
47
- expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
47
+ expect(output).to match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
48
48
  end
49
49
  end
50
50
 
51
51
  context "with file specified" do
52
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw/#{filename}").to_return(body: http_output) }
52
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw/#{filename}").to_return(:body => http_output) }
53
53
  let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
54
54
  let(:filename) { "myfile.ext" }
55
55
  let(:content) { "{% gist #{gist} #{filename} %}" }
56
56
 
57
57
  it "produces the correct script tag" do
58
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js\?file=#{filename}">\s<\/script>/)
58
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{gist}.js\?file=#{filename}">\s<\/script>!)
59
59
  end
60
60
  it "produces the correct noscript tag" do
61
- expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
61
+ expect(output).to match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
62
62
  end
63
63
  end
64
64
 
65
65
  context "with variable gist id" do
66
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw").to_return(body: http_output) }
66
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw").to_return(:body => http_output) }
67
67
  let(:gist_id) { "1342013" }
68
68
  let(:gist) { "page.gist_id" }
69
69
  let(:output) do
70
- doc.data['gist_id'] = gist_id
70
+ doc.data["gist_id"] = gist_id
71
71
  doc.content = content
72
72
  doc.output = Jekyll::Renderer.new(doc.site, doc).run
73
73
  end
74
74
 
75
75
  it "produces the correct script tag" do
76
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{doc.data['gist_id']}.js">\s<\/script>/)
76
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{doc.data['gist_id']}.js">\s<\/script>!)
77
77
  end
78
78
  it "produces the correct noscript tag" do
79
- expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
79
+ expect(output).to match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
80
80
  end
81
81
  end
82
82
 
83
83
  context "with variable gist id and filename" do
84
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw/#{gist_filename}").to_return(body: http_output) }
84
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw/#{gist_filename}").to_return(:body => http_output) }
85
85
  let(:gist_id) { "1342013" }
86
86
  let(:gist_filename) { "atom.xml" }
87
87
  let(:gist) { "page.gist_id" }
88
88
  let(:filename) { "page.gist_filename" }
89
89
  let(:content) { "{% gist #{gist} #{filename} %}" }
90
90
  let(:output) do
91
- doc.data['gist_id'] = "1342013"
92
- doc.data['gist_filename'] = "atom.xml"
91
+ doc.data["gist_id"] = "1342013"
92
+ doc.data["gist_filename"] = "atom.xml"
93
93
  doc.content = content
94
94
  doc.output = Jekyll::Renderer.new(doc.site, doc).run
95
95
  end
96
96
 
97
97
  it "produces the correct script tag" do
98
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{doc.data['gist_id']}.js\?file=#{doc.data['gist_filename']}">\s<\/script>/)
98
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{doc.data['gist_id']}.js\?file=#{doc.data['gist_filename']}">\s<\/script>!)
99
99
  end
100
100
 
101
101
  it "produces the correct noscript tag" do
102
- expect(output).to match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
102
+ expect(output).to match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
103
103
  end
104
104
  end
105
105
 
106
106
  context "with valid gist id and invalid filename" do
107
- before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw/#{gist_filename}").to_return(status: 404) }
108
- let(:gist_id) { "mattr-/24081a1d93d2898ecf0f" }
107
+ before { stub_request(:get, "https://gist.githubusercontent.com/#{gist_id}/raw/#{gist_filename}").to_return(:status => 404) }
108
+ let(:gist_id) { "mattr-/24081a1d93d2898ecf0f" }
109
109
  let(:gist_filename) { "myfile.ext" }
110
- let(:content) { "{% gist #{gist_id} #{gist_filename} %}" }
110
+ let(:content) { "{% gist #{gist_id} #{gist_filename} %}" }
111
111
 
112
112
  it "produces the correct script tag" do
113
- expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist_id}.js\?file=#{gist_filename}">\s<\/script>/)
113
+ expect(output).to match(%r!<script src="https:\/\/gist.github.com\/#{gist_id}.js\?file=#{gist_filename}">\s<\/script>!)
114
114
  end
115
115
 
116
116
  it "does not produce the noscript tag" do
117
- expect(output).to_not match(/<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n/)
117
+ expect(output).to_not match(%r!<noscript><pre>&lt;test&gt;true&lt;\/test&gt;<\/pre><\/noscript>\n!)
118
118
  end
119
-
120
119
  end
121
120
 
122
121
  context "with token" do
123
122
  before { ENV["JEKYLL_GITHUB_TOKEN"] = "1234" }
124
- before {
125
- stub_request(:get, "https://api.github.com/gists/1342013").
126
- to_return(:status => 200, :body => fixture("single-file"), :headers => {"Content-Type" => "application/json"})
127
- }
123
+ before do
124
+ stub_request(:get, "https://api.github.com/gists/1342013")
125
+ .to_return(:status => 200, :body => fixture("single-file"), :headers => { "Content-Type" => "application/json" })
126
+ end
128
127
  let(:gist_id) { "1342013" }
129
128
  let(:gist) { "page.gist_id" }
130
129
  let(:output) do
131
- doc.data['gist_id'] = gist_id
130
+ doc.data["gist_id"] = gist_id
132
131
  doc.content = content
133
132
  doc.output = Jekyll::Renderer.new(doc.site, doc).run
134
133
  end
135
134
 
136
135
  it "produces the noscript tag" do
137
- expect(output).to match(/<noscript><pre>contents of gist<\/pre><\/noscript>/)
136
+ expect(output).to match(%r!<noscript><pre>contents of gist<\/pre><\/noscript>!)
138
137
  end
139
138
 
140
139
  context "with a filename" do
141
- before {
142
- stub_request(:get, "https://api.github.com/gists/1342013").
143
- to_return(:status => 200, :body => fixture("multiple-files"), :headers => {"Content-Type" => "application/json"})
144
- }
145
- let(:content) { "{% gist 1342013 hello-world.rb %}" }
140
+ before do
141
+ stub_request(:get, "https://api.github.com/gists/1342013")
142
+ .to_return(:status => 200, :body => fixture("multiple-files"), :headers => { "Content-Type" => "application/json" })
143
+ end
144
+ let(:content) { "{% gist 1342013 hello-world.rb %}" }
146
145
 
147
146
  it "produces the noscript tag" do
148
- expect(output).to match(/<noscript><pre>puts &#39;hello world&#39;<\/pre><\/noscript>/)
147
+ expect(output).to match(%r!<noscript><pre>puts &#39;hello world&#39;<\/pre><\/noscript>!)
149
148
  end
150
149
  end
151
150
  end
@@ -159,22 +158,18 @@ describe(Jekyll::Gist::GistTag) do
159
158
  let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
160
159
 
161
160
  it "does not produce the noscript tag" do
162
- expect(output).to_not match(/<noscript>/)
161
+ expect(output).to_not match(%r!<noscript>!)
163
162
  end
164
163
  end
165
-
166
164
  end
167
165
 
168
166
  context "invalid gist" do
169
-
170
167
  context "no gist id present" do
171
168
  let(:gist) { "" }
172
169
 
173
170
  it "raises an error" do
174
- expect(->{ output }).to raise_error
171
+ expect(-> { output }).to raise_error
175
172
  end
176
173
  end
177
-
178
174
  end
179
-
180
175
  end
@@ -1,9 +1,11 @@
1
- TEST_DIR = File.dirname(__FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ TEST_DIR = __dir__
2
4
  TMP_DIR = File.expand_path("../tmp", TEST_DIR)
3
5
 
4
- require 'webmock/rspec'
5
- require 'cgi'
6
- require 'jekyll'
6
+ require "webmock/rspec"
7
+ require "cgi"
8
+ require "jekyll"
7
9
  require File.expand_path("../lib/jekyll-gist.rb", TEST_DIR)
8
10
 
9
11
  Jekyll.logger.log_level = :error
@@ -11,39 +13,39 @@ Jekyll.logger.log_level = :error
11
13
  RSpec.configure do |config|
12
14
  config.run_all_when_everything_filtered = true
13
15
  config.filter_run :focus
14
- config.order = 'random'
16
+ config.order = "random"
15
17
 
16
18
  def tmp_dir(*files)
17
19
  File.join(TMP_DIR, *files)
18
20
  end
19
21
 
20
22
  def source_dir(*files)
21
- tmp_dir('source', *files)
23
+ tmp_dir("source", *files)
22
24
  end
23
25
 
24
26
  def dest_dir(*files)
25
- tmp_dir('dest', *files)
27
+ tmp_dir("dest", *files)
26
28
  end
27
29
 
28
- def doc_with_content(content, opts = {})
30
+ def doc_with_content(_content, opts = {})
29
31
  my_site = site(opts)
30
- Jekyll::Document.new(source_dir('_test/doc.md'), {site: my_site, collection: collection(my_site)})
32
+ Jekyll::Document.new(source_dir("_test/doc.md"), { :site => my_site, :collection => collection(my_site) })
31
33
  end
32
34
 
33
- def collection(site, label = 'test')
35
+ def collection(site, label = "test")
34
36
  Jekyll::Collection.new(site, label)
35
37
  end
36
38
 
37
39
  def site(opts = {})
38
40
  conf = Jekyll::Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, opts.merge({
39
41
  "source" => source_dir,
40
- "destination" => dest_dir
42
+ "destination" => dest_dir,
41
43
  }))
42
44
  Jekyll::Site.new(conf)
43
45
  end
44
46
 
45
47
  def fixture(name)
46
- path = File.expand_path "./fixtures/#{name}.json", File.dirname(__FILE__)
48
+ path = File.expand_path "fixtures/#{name}.json", __dir__
47
49
  File.open(path).read
48
50
  end
49
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-gist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-21 00:00:00.000000000 Z
11
+ date: 2017-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -39,21 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: jekyll
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: webmock
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,19 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: jekyll
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.51'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.51'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '2.0'
103
+ version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '2.0'
110
+ version: '0'
97
111
  description:
98
112
  email:
99
113
  - parkrmoore@gmail.com
@@ -103,6 +117,7 @@ extra_rdoc_files: []
103
117
  files:
104
118
  - ".gitignore"
105
119
  - ".rspec"
120
+ - ".rubocop.yml"
106
121
  - ".travis.yml"
107
122
  - Gemfile
108
123
  - History.markdown
@@ -115,6 +130,8 @@ files:
115
130
  - lib/jekyll-gist/version.rb
116
131
  - script/bootstrap
117
132
  - script/cibuild
133
+ - script/fmt
134
+ - script/release
118
135
  - spec/fixtures/multiple-files.json
119
136
  - spec/fixtures/single-file.json
120
137
  - spec/gist_tag_spec.rb
@@ -131,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
148
  requirements:
132
149
  - - ">="
133
150
  - !ruby/object:Gem::Version
134
- version: 1.9.3
151
+ version: '2.1'
135
152
  required_rubygems_version: !ruby/object:Gem::Requirement
136
153
  requirements:
137
154
  - - ">="
@@ -139,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
156
  version: '0'
140
157
  requirements: []
141
158
  rubyforge_project:
142
- rubygems_version: 2.6.11
159
+ rubygems_version: 2.7.1
143
160
  signing_key:
144
161
  specification_version: 4
145
162
  summary: Liquid tag for displaying GitHub Gists in Jekyll sites.