jekyll-shields_io 0.1.1 → 0.2.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
2
  SHA256:
3
- metadata.gz: 0cdfb519e88b7ea828926072a6dc4cca8e4597de5c7a5beda7be9def4e950f96
4
- data.tar.gz: dba38e0c77372579fffcb82489f6fbb5f77d8dc0ca6a7cb4237e0fbbca4128a8
3
+ metadata.gz: da56ec98cade20594c39cf8a2edd0cd8bc26b8cdbf14261ae9c154c8feadcfd0
4
+ data.tar.gz: 83f59e9a56ac524998aa85ef35e127e10c3d745eca0e6e340f30ce536e180867
5
5
  SHA512:
6
- metadata.gz: cee91d48bd6363219da448526b009a70f7bd74e59b4f8cdec0e61d03f21ba0ac3f4049e3f320fcb9d6c2d3f738bd1b8fc1f378d777c6975418c8e4d9c64f6130
7
- data.tar.gz: 146afeaa59f4a378e25200fcfd2feff8325514477c70c0a88acdd421cf85c7fceb6d1d60563a5aaf76e42994d53dc88e96db2ea342e7eadf083da5ece9204c9f
6
+ metadata.gz: 215f6baa8e0ba9ba5dbd3d47bc700b3b216f4ba37571ac7113c1099ff9e87061c22e3695d9c7dcb5e233dded5b529d52142a87e2861917bd50af7015d7fc60c8
7
+ data.tar.gz: e228ebfedeca26f818bd7adc92f35fbb56b308cd8b4eed6665b7f414de82a1444be14895357e9e2e33d1cb467171759c060e9935919cee094f1be290c4229c0e
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!-- Thanks for opening an issue! To make it easier for us to solve your issues, please fill out the form below! -->
11
+
12
+ ## The issue
13
+ <!-- Brief description of your issue. -->
14
+
15
+ ## Steps to reproduce
16
+ <!-- Steps to reproduce the behavior here. It will greatly help us! -->
17
+
18
+ ## Expected behavior
19
+ <!-- A clear and concise description of what you expected to happen. -->
20
+
21
+ ## Actual behavior
22
+ <!-- What happened instead? This part can be a screenshot. -->
23
+
24
+ ## Screenshots
25
+ <!-- If applicable, add screenshots to help explain your problem. -->
26
+
27
+ ## Environment
28
+ <!-- What are your Ruby, Jekyll versions? Do you have any other plugins? -->
29
+
30
+ ## Additional context
31
+ <!-- Add any other context about the problem here. -->
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ## The issue
11
+ <!-- Please explain the problem - e.g., what part of the plugin are you frustrated with? -->
12
+
13
+ ## Potential solution
14
+ <!-- A clear and concise description of what you want to happen. -->
15
+
16
+ ## Alternative solution
17
+ <!-- A clear and concise description of any alternative solutions or features you've considered. -->
18
+
19
+ ## Additional context
20
+ <!-- Add any other context or screenshots about the feature request here. -->
@@ -0,0 +1,21 @@
1
+ name: Check code style
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ base ]
6
+ paths-ignore:
7
+ - 'lib/**'
8
+ - 'spec/**'
9
+ - '.github/workflows/**'
10
+
11
+ concurrency:
12
+ group: ${{ github.head_ref }}-code-style
13
+
14
+ jobs:
15
+ code_style:
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ ruby-version: [ '3.1', '2.7' ]
20
+ steps:
21
+ - run: 'echo "No syntax check required"'
@@ -3,18 +3,33 @@ name: Check code style
3
3
  on:
4
4
  push:
5
5
  branches: [ base ]
6
+ paths:
7
+ - 'lib/**'
8
+ - 'spec/**'
9
+ - '.github/workflows/**'
6
10
  pull_request:
7
11
  branches: [ base ]
12
+ paths:
13
+ - 'lib/**'
14
+ - 'spec/**'
15
+ - '.github/workflows/**'
16
+
17
+ concurrency:
18
+ group: ${{ github.head_ref }}-code-style
19
+ cancel-in-progress: true
8
20
 
9
21
  jobs:
10
22
  code_style:
11
23
  runs-on: ubuntu-latest
24
+ strategy:
25
+ matrix:
26
+ ruby-version: [ '3.1', '2.7' ]
12
27
  steps:
13
28
  - uses: actions/checkout@v3
14
- - name: Set up Ruby
15
- uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
29
+ - name: Set up Ruby ${{ matrix.ruby-version }}
30
+ uses: ruby/setup-ruby@d3c9825d67b0d8720afdfdde5af56c79fdb38d16
16
31
  with:
17
- ruby-version: '2.7'
32
+ ruby-version: ${{ matrix.ruby-version }}
18
33
  bundler-cache: true
19
34
  - name: Install dependencies
20
35
  run: bundle install
@@ -0,0 +1,55 @@
1
+ # RubyGems publish GitHub Actions workflow file by @ybiquitous.
2
+ # https://ybiquitous.me/blog/2022/release-gem-using-github-actions
3
+ # License for this file: CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/
4
+
5
+ name: Release
6
+
7
+ on:
8
+ workflow_dispatch:
9
+ inputs:
10
+ otp:
11
+ description: "One-time password for RubyGems.org"
12
+ required: true
13
+
14
+ concurrency:
15
+ group: ${{ github.workflow }}
16
+ cancel-in-progress: true
17
+
18
+ jobs:
19
+ release:
20
+ runs-on: ubuntu-latest
21
+ permissions:
22
+ contents: write
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v3
26
+
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: "3.1"
31
+ bundler-cache: true
32
+
33
+ - name: Configure Git
34
+ run: |
35
+ git config --global user.name "${GITHUB_ACTOR}"
36
+ git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
37
+
38
+ - name: Publish to gem registry
39
+ run: bundle exec rake release
40
+ env:
41
+ GEM_HOST_API_KEY: ${{ secrets.API_KEY }}
42
+ GEM_HOST_OTP_CODE: ${{ inputs.otp }}
43
+
44
+ - name: Push tag
45
+ run: git push --follow-tags
46
+
47
+ - name: Get tag
48
+ run: echo "::set-output name=name::$(git describe --abbrev=0)"
49
+ id: tag
50
+
51
+ - name: Create GitHub release
52
+ run: gh release create "${TAG_NAME}" --draft
53
+ env:
54
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
+ TAG_NAME: ${{ steps.tag.outputs.name }}
@@ -0,0 +1,39 @@
1
+ name: Check functionality
2
+ on:
3
+ pull_request:
4
+ paths-ignore:
5
+ - 'lib/**'
6
+ - 'spec/**'
7
+ - '.github/workflows/**'
8
+
9
+ concurrency:
10
+ group: ${{ github.head_ref }}-code-style
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ ruby_version: [ "3.1", "2.7" ]
18
+ appraisal:
19
+ - jekyll-35
20
+ - jekyll-36
21
+ - jekyll-37
22
+ - jekyll-38
23
+ - jekyll-39
24
+ - jekyll-40
25
+ - jekyll-41
26
+ - jekyll-42
27
+ - jekyll-43
28
+ exclude:
29
+ # exclude incompatible dependency combos
30
+ - ruby_version: "3.1"
31
+ appraisal: jekyll-35
32
+ - ruby_version: "3.1"
33
+ appraisal: jekyll-36
34
+ - ruby_version: "3.1"
35
+ appraisal: jekyll-37
36
+ - ruby_version: "3.1"
37
+ appraisal: jekyll-38
38
+ steps:
39
+ - run: 'echo "No functionality check required"'
@@ -3,21 +3,63 @@ name: Check functionality
3
3
  on:
4
4
  push:
5
5
  branches: [ base ]
6
+ paths:
7
+ - 'lib/**'
8
+ - 'spec/**'
9
+ - '.github/workflows/**'
6
10
  pull_request:
7
11
  branches: [ base ]
12
+ paths:
13
+ - 'lib/**'
14
+ - 'spec/**'
15
+ - '.github/workflows/**'
16
+
17
+ concurrency:
18
+ group: ${{ github.head_ref }}-test
19
+ cancel-in-progress: true
8
20
 
9
21
  jobs:
10
22
  test:
11
23
  runs-on: ubuntu-latest
24
+ strategy:
25
+ fail-fast: false
26
+ matrix:
27
+ ruby_version: [ "3.1", "2.7" ]
28
+ appraisal:
29
+ - jekyll-35
30
+ - jekyll-36
31
+ - jekyll-37
32
+ - jekyll-38
33
+ - jekyll-39
34
+ - jekyll-40
35
+ - jekyll-41
36
+ - jekyll-42
37
+ - jekyll-43
38
+ exclude:
39
+ # exclude incompatible dependency combos
40
+ - ruby_version: "3.1"
41
+ appraisal: jekyll-35
42
+ - ruby_version: "3.1"
43
+ appraisal: jekyll-36
44
+ - ruby_version: "3.1"
45
+ appraisal: jekyll-37
46
+ - ruby_version: "3.1"
47
+ appraisal: jekyll-38
12
48
  steps:
13
49
  - uses: actions/checkout@v3
14
- - name: Set up Ruby
15
- uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
50
+ - name: Set up Ruby ${{ matrix.ruby_version }}
51
+ uses: ruby/setup-ruby@d3c9825d67b0d8720afdfdde5af56c79fdb38d16
16
52
  with:
17
- ruby-version: '2.7'
18
- bundler-cache: true
19
- - name: Install dependencies
53
+ ruby-version: ${{ matrix.ruby_version }}
54
+ - if: matrix.ruby_version == '2.7'
55
+ name: Update RubyGems version
56
+ # This is the version that NEITHER appraisal or jekyll-sass-converter
57
+ # blows up from incompatible dependencies
58
+ run: gem update --system 3.3.22
59
+ - name: Install base dependencies
20
60
  run: bundle install
61
+ - name: Install dependencies for appraisal
62
+ # This creates appraisal-specific Gemfiles
63
+ run: bundle exec appraisal install
21
64
  - name: Run tests
22
- run: bundle exec rake spec
23
-
65
+ run: bundle exec appraisal ${{ matrix.appraisal }} rake spec
data/.gitignore CHANGED
@@ -10,6 +10,9 @@ Gemfile.lock
10
10
  # Also if somebody wants to install dependencies locally, we need to prevent them being checked in
11
11
  vendor/
12
12
 
13
+ # Appraisal make this directory which must be ignored
14
+ gemfiles/
15
+
13
16
  # Created by https://www.toptal.com/developers/gitignore/api/ruby,rubymine,macos
14
17
  # Edit at https://www.toptal.com/developers/gitignore?templates=ruby,rubymine,macos
15
18
 
@@ -10,10 +10,14 @@
10
10
  <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
11
  <excludeFolder url="file://$MODULE_DIR$/.jekyll-cache/Jekyll" />
12
12
  <excludeFolder url="file://$MODULE_DIR$/.bundle" />
13
+ <excludeFolder url="file://$MODULE_DIR$/gemfiles/.bundle" />
14
+ <excludeFolder url="file://$MODULE_DIR$/_cache" />
15
+ <excludeFolder url="file://$MODULE_DIR$/gemfiles" />
13
16
  </content>
14
17
  <orderEntry type="jdk" jdkName="RVM: ruby-2.7.6" jdkType="RUBY_SDK" />
15
18
  <orderEntry type="sourceFolder" forTests="false" />
16
19
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.1, RVM: ruby-2.7.6) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="appraisal (v2.2.0, RVM: ruby-2.7.6) [gem]" level="application" />
17
21
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.6) [gem]" level="application" />
18
22
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.2, RVM: ruby-2.7.6) [gem]" level="application" />
19
23
  <orderEntry type="library" scope="PROVIDED" name="colorator (v1.1.0, RVM: ruby-2.7.6) [gem]" level="application" />
@@ -23,6 +27,7 @@
23
27
  <orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, RVM: ruby-2.7.6) [gem]" level="application" />
24
28
  <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, RVM: ruby-2.7.6) [gem]" level="application" />
25
29
  <orderEntry type="library" scope="PROVIDED" name="forwardable-extended (v2.6.0, RVM: ruby-2.7.6) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="gemika (v0.8.1, RVM: ruby-2.7.6) [gem]" level="application" />
26
31
  <orderEntry type="library" scope="PROVIDED" name="google-protobuf (v3.22.0, RVM: ruby-2.7.6) [gem]" level="application" />
27
32
  <orderEntry type="library" scope="PROVIDED" name="http_parser.rb (v0.8.0, RVM: ruby-2.7.6) [gem]" level="application" />
28
33
  <orderEntry type="library" scope="PROVIDED" name="httparty (v0.21.0, RVM: ruby-2.7.6) [gem]" level="application" />
@@ -65,42 +70,13 @@
65
70
  <orderEntry type="library" scope="PROVIDED" name="sass-embedded (v1.58.2, RVM: ruby-2.7.6) [gem]" level="application" />
66
71
  <orderEntry type="library" scope="PROVIDED" name="standard (v1.24.3, RVM: ruby-2.7.6) [gem]" level="application" />
67
72
  <orderEntry type="library" scope="PROVIDED" name="terminal-table (v3.0.2, RVM: ruby-2.7.6) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.6) [gem]" level="application" />
68
74
  <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.4.2, RVM: ruby-2.7.6) [gem]" level="application" />
69
75
  <orderEntry type="library" scope="PROVIDED" name="webrick (v1.8.1, RVM: ruby-2.7.6) [gem]" level="application" />
70
76
  </component>
71
77
  <component name="RakeTasksCache">
72
78
  <option name="myRootTask">
73
- <RakeTaskImpl id="rake">
74
- <subtasks>
75
- <RakeTaskImpl description="Build jekyll-shields_io-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
76
- <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
77
- <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
78
- <RakeTaskImpl description="Build and install jekyll-shields_io-0.1.0.gem into system gems" fullCommand="install" id="install" />
79
- <RakeTaskImpl id="install">
80
- <subtasks>
81
- <RakeTaskImpl description="Build and install jekyll-shields_io-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
82
- </subtasks>
83
- </RakeTaskImpl>
84
- <RakeTaskImpl description="Create tag v0.1.0 and build and push jekyll-shields_io-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
85
- <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
86
- <RakeTaskImpl description="Lint with the Standard Ruby style guide" fullCommand="standard" id="standard" />
87
- <RakeTaskImpl id="standard">
88
- <subtasks>
89
- <RakeTaskImpl description="Lint and automatically fix with the Standard Ruby style guide" fullCommand="standard:fix" id="fix" />
90
- </subtasks>
91
- </RakeTaskImpl>
92
- <RakeTaskImpl description="" fullCommand="default" id="default" />
93
- <RakeTaskImpl description="" fullCommand="release" id="release" />
94
- <RakeTaskImpl id="release">
95
- <subtasks>
96
- <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
97
- <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
98
- <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
99
- </subtasks>
100
- </RakeTaskImpl>
101
- <RakeTaskImpl description="" fullCommand="test" id="test" />
102
- </subtasks>
103
- </RakeTaskImpl>
79
+ <RakeTaskImpl id="rake" />
104
80
  </option>
105
81
  </component>
106
82
  </module>
data/Appraisals ADDED
@@ -0,0 +1,35 @@
1
+ appraise "jekyll-35" do
2
+ gem "jekyll", "~> 3.5.0"
3
+ end
4
+
5
+ appraise "jekyll-36" do
6
+ gem "jekyll", "~> 3.6.0"
7
+ end
8
+
9
+ appraise "jekyll-37" do
10
+ gem "jekyll", "~> 3.7.0"
11
+ end
12
+
13
+ appraise "jekyll-38" do
14
+ gem "jekyll", "~> 3.8.0"
15
+ end
16
+
17
+ appraise "jekyll-39" do
18
+ gem "jekyll", "~> 3.9.0"
19
+ end
20
+
21
+ appraise "jekyll-40" do
22
+ gem "jekyll", "~> 4.0.0"
23
+ end
24
+
25
+ appraise "jekyll-41" do
26
+ gem "jekyll", "~> 4.1.0"
27
+ end
28
+
29
+ appraise "jekyll-42" do
30
+ gem "jekyll", "~> 4.2.0"
31
+ end
32
+
33
+ appraise "jekyll-43" do
34
+ gem "jekyll", "~> 4.3.0"
35
+ end
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  > **Adding shields (badges) to your Jekyll blog, made more readable**
4
4
 
5
+ ![Ruby 2.7 and 3.1 supported](https://img.shields.io/badge/Ruby-2.7%20%7C%203.1-%23CC342D?logo=ruby)
6
+ ![Jekyll 3.5 through 4.3 supported](https://img.shields.io/badge/Jekyll-3.5%20~%204.x-%23CC0000?logo=jekyll)
7
+ ![Test status](https://github.com/clpsplug/jekyll-shields_io/actions/workflows/test.yml/badge.svg)
8
+
5
9
  This is a Jekyll plugin to generate a [Shields.io](https://shields.io) badge in your Jekyll blog
6
10
  with a more readable way.
7
11
 
@@ -96,7 +100,7 @@ For markdown files, this syntax is required because the other one causes the shi
96
100
 
97
101
  ## Features
98
102
 
99
- ### Easy to debug shield parameters
103
+ ### Debuggable shield parameters
100
104
 
101
105
  You can specify the parameters passed to Shields.io using JSON,
102
106
  which prevents accidental and hard-to-spot mistakes.
@@ -163,6 +167,43 @@ If you happen to see this behavior, please report it or send me a PR so that we
163
167
 
164
168
  Bug reports & pull requests are welcome on [GitHub repo](https://github.com/clpsplug/jekyll-shields_io).
165
169
 
170
+ ### Development setup
171
+
172
+ To set up the plugin development env only:
173
+ ```sh
174
+ git clone https://github.com/Clpsplug/jekyll-shields_io.git
175
+ # OR
176
+ git clone git@github.com:Clpsplug/jekyll-shields_io.git
177
+ # OR
178
+ gh repo clone Clpsplug/jekyll-shields_io
179
+
180
+ # Get dependencies
181
+ bundle install
182
+ # Run checks that are run on Github Actions
183
+ rake
184
+ # Run test for latest Jekyll available in your environment
185
+ rake spec
186
+ # Check code style using "standard" gem
187
+ rake standard
188
+
189
+ # To test every supported Jekyll & Ruby combination:
190
+ bundle exec appraisal install
191
+ bundle exec appraisal rake spec
192
+ ```
193
+
194
+ When contributing, please at least run `rake` and check that
195
+ no issues are raised from "standard" gem and that specs passes!
196
+ (If you're having trouble passing the specs, don't hesitate note so in the PR.)
197
+
198
+ To test the plugin with real Jekyll environment,
199
+ follow the [Installation](#installation) guide except for adding a line to Gemfile.
200
+ You will need to add this line to your Gemfile instead:
201
+ ```ruby
202
+ gem "jekyll-shields_io", path: "<Wherever you have this repository, can be relative path>"
203
+ # for example
204
+ gem "jekyll-shields_io", path: "../jekyll-shields_io"
205
+ ```
206
+
166
207
  ## License
167
208
 
168
209
  [MIT License](https://opensource.org/licenses/MIT)
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
20
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
21
  end
22
22
  s.require_paths = ["lib"]
23
+ s.required_ruby_version = ">= 2.7", "< 4"
23
24
  s.add_dependency "jekyll", ">= 3.5", "< 5.0"
24
25
  s.add_dependency "nokogiri", "~> 1.4", "< 2.0"
25
26
  s.add_dependency "httparty", "~> 0.17", "< 1.0"
27
+ s.add_development_dependency "appraisal"
26
28
  end
@@ -0,0 +1,71 @@
1
+ module Jekyll
2
+ module ShieldsIO
3
+ # Object to represent the Shields.IO shield (plus some extra stuff)
4
+ class Shield
5
+ # To be used for img tag.
6
+ # @return [Integer]
7
+ attr_reader :width
8
+ # To be used for img tag.
9
+ # @return [Integer]
10
+ attr_reader :height
11
+ # If not nil, make the shield image a link.
12
+ # @return [String]
13
+ attr_reader :href
14
+ # Alternative string for this shield, should the browser fails to load the image
15
+ # @return [String]
16
+ attr_reader :alt
17
+ # HTML class for this shield image.
18
+ # @return [String]
19
+ attr_reader :cls
20
+ # Path to the cache file. *Not* to be used for HTML - use :basename instead.
21
+ # @return [String]
22
+ attr_reader :path
23
+ # Basename of the shield.
24
+ # Specifying "assets/img/shields/" + :basename to src attribute should display this shield.
25
+ # @return [String]
26
+ attr_reader :basename
27
+
28
+ def initialize(width, height, path, href, alt, cls)
29
+ @width = width
30
+ @height = height
31
+ @path = path
32
+ @basename = File.basename path
33
+ @href = href
34
+ @alt = alt
35
+ @cls = cls
36
+ end
37
+ end
38
+
39
+ # Jekyll representation for the cached shield SVG files.
40
+ class StaticShieldFile < Jekyll::StaticFile
41
+ attr_reader :name
42
+
43
+ # Initialize a new CachedShield.
44
+ # site - The Site.
45
+ # base - The String path to the <source>.
46
+ # dir - The String path between <source> and the file.
47
+ # name - The String filename of the file.
48
+ # dest - The String destination path override.
49
+ def initialize(site, base, dir, name, dest)
50
+ super site, base, dir, name
51
+ @name = name
52
+ @dest = dest
53
+ end
54
+
55
+ def destination(dest)
56
+ File.join dest, @dest, @name
57
+ end
58
+ end
59
+
60
+ # Thrown when the plugin encounters malformed input.
61
+ class ShieldConfigMalformedError < StandardError
62
+ def initialize(msg = "Malformed configuration was passed to the plugin")
63
+ super
64
+ end
65
+ end
66
+
67
+ # Thrown when the plugin fails to fetch the shield image.
68
+ class ShieldFetchError < StandardError
69
+ end
70
+ end
71
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module ShieldsIO
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,8 +1,9 @@
1
1
  require "digest"
2
2
  require "fileutils"
3
+ require "httparty"
4
+ require "jekyll-shields_io/domain"
3
5
  require "json"
4
6
  require "nokogiri"
5
- require "httparty"
6
7
 
7
8
  module Jekyll
8
9
  module ShieldsIO
@@ -61,9 +62,6 @@ module Jekyll
61
62
  # @param [Shield] shield Shield to queue for this Jekyll site's Jekyll::StaticFile.
62
63
  # @raise [ShieldFileError] when specified cache file does not exist
63
64
  def queue_shield(shield)
64
- unless File.exist? shield.path
65
- raise ShieldFileError.new
66
- end
67
65
  if @site.static_files.select { |f|
68
66
  f.is_a? StaticShieldFile
69
67
  }.select { |s| s.name == shield.basename }.any?
@@ -107,85 +105,19 @@ module Jekyll
107
105
  # Same as warn but will print an identifying tag ([Shields.IO Plugin]) and
108
106
  # will not print unless verbose mode is on, or the message is marked important
109
107
  # @param [String] mes
110
- # @param [TrueClass, FalseClass] important
111
- def log(mes, important = false)
112
- unless @site.config["verbose"] != true || important
108
+ def log(mes)
109
+ if @site.config["verbose"] == true
113
110
  warn "[Shields.IO Plugin] #{mes}"
114
111
  end
115
112
  end
116
113
  end
117
114
 
118
- # Object to represent the Shields.IO shield (plus some extra stuff)
119
- class Shield
120
- # To be used for img tag.
121
- # @return [Integer]
122
- attr_reader :width
123
- # To be used for img tag.
124
- # @return [Integer]
125
- attr_reader :height
126
- # If not nil, make the shield image a link.
127
- # @return [String]
128
- attr_reader :href
129
- # Alternative string for this shield, should the browser fails to load the image
130
- # @return [String]
131
- attr_reader :alt
132
- # HTML class for this shield image.
133
- # @return [String]
134
- attr_reader :cls
135
- # Path to the cache file. *Not* to be used for HTML - use :basename instead.
136
- # @return [String]
137
- attr_reader :path
138
- # Basename of the shield.
139
- # Specifying "assets/img/shields/" + :basename to src attribute should display this shield.
140
- # @return [String]
141
- attr_reader :basename
142
-
143
- def initialize(width, height, path, href, alt, cls)
144
- @width = width
145
- @height = height
146
- @path = path
147
- @basename = File.basename path
148
- @href = href
149
- @alt = alt
150
- @cls = cls
151
- end
152
- end
153
-
154
- # Jekyll representation for the cached shield SVG files.
155
- class StaticShieldFile < Jekyll::StaticFile
156
- attr_reader :name
157
-
158
- # Initialize a new CachedShield.
159
- # site - The Site.
160
- # base - The String path to the <source>.
161
- # dir - The String path between <source> and the file.
162
- # name - The String filename of the file.
163
- # dest - The String destination path override.
164
- def initialize(site, base, dir, name, dest)
165
- super site, base, dir, name
166
- @name = name
167
- @dest = dest
168
- end
169
-
170
- def destination(dest)
171
- File.join dest, @dest, @name
172
- end
173
- end
174
-
175
- # Thrown when the plugin fails to fetch the shield image.
176
- class ShieldFetchError < StandardError
177
- end
178
-
179
- # Thrown when the plugin fails to access the cached shield file.
180
- # Realistically, if this happens something must be very wrong with the disk the cache is written to
181
- # because the plugin would've crashed with IO errors well before this is thrown.
182
- class ShieldFileError < StandardError
183
- end
184
-
185
115
  # Jekyll Liquid Tag for Shields.io
186
- #
187
116
  # Usage: {% shields_io <query param + special param as json> %}
188
117
  class ShieldsIOTag < Liquid::Tag
118
+ # @param [String] tag_name == shields_io
119
+ # @param [String] input User input
120
+ # @param [Liquid::Context] parse_context
189
121
  def initialize(tag_name, input, parse_context)
190
122
  super
191
123
  # @type [Hash]
@@ -193,16 +125,19 @@ module Jekyll
193
125
  # This only appears if there is an error trying to fetch the shield.
194
126
  # @type [String]
195
127
  @last_ditch_alt = "<p>#{@payload[:label]} #{@payload[:message]}</p>"
128
+ rescue JSON::ParserError => pe
129
+ warn "[Shields.IO Plugin] Shield configuration is malformed (#{pe.message})"
130
+ raise ShieldConfigMalformedError
196
131
  end
197
132
 
198
133
  def render(context)
199
- fct = ShieldFactory.new context
200
- shield = fct.get_shield @payload
201
- fct.queue_shield shield
134
+ @factory = ShieldFactory.new context
135
+ shield = @factory.get_shield @payload
136
+ @factory.queue_shield shield
202
137
 
203
- shield_tag = <<HTML
204
- <img src="/#{fct.target_dir}/#{shield.basename}" width="#{shield.width}" height="#{shield.height}"
205
- HTML
138
+ shield_tag = <<~HTML
139
+ <img src="/#{@factory.target_dir}/#{shield.basename}" width="#{shield.width}" height="#{shield.height}"
140
+ HTML
206
141
  shield_tag += if !shield.alt.nil?
207
142
  " alt=\"#{shield.alt}\" class=\"#{shield.cls}\"/>"
208
143
  else
@@ -220,9 +155,6 @@ HTML
220
155
  rescue ShieldFetchError
221
156
  warn "[Shields.IO Plugin] Failed to fetch shields! (input: #{JSON.dump @payload})"
222
157
  @last_ditch_alt
223
- rescue ShieldFileError
224
- warn "[Shields.IO Plugin] Failed to access cached shields!"
225
- @last_ditch_alt
226
158
  end
227
159
  end
228
160
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-shields_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Plug
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-18 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -70,6 +70,20 @@ dependencies:
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
72
  version: '1.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: appraisal
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
73
87
  description: |
74
88
  This Jekyll plugin allows you to add a shields.io badge in your blog
75
89
  without forming very long URLs - instead, the properties are set via JSON.
@@ -79,7 +93,12 @@ extensions: []
79
93
  extra_rdoc_files: []
80
94
  files:
81
95
  - ".editorconfig"
96
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
97
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
98
+ - ".github/workflows/code_style-skip.yml"
82
99
  - ".github/workflows/code_style.yml"
100
+ - ".github/workflows/release.yml"
101
+ - ".github/workflows/test-skip.yml"
83
102
  - ".github/workflows/test.yml"
84
103
  - ".gitignore"
85
104
  - ".idea/.gitignore"
@@ -89,18 +108,20 @@ files:
89
108
  - ".idea/modules.xml"
90
109
  - ".idea/vcs.xml"
91
110
  - ".rspec"
111
+ - Appraisals
92
112
  - Gemfile
93
113
  - LICENSE.txt
94
114
  - README.md
95
115
  - Rakefile
96
116
  - jekyll-shields_io.gemspec
97
117
  - lib/jekyll-shields_io.rb
118
+ - lib/jekyll-shields_io/domain.rb
98
119
  - lib/jekyll-shields_io/version.rb
99
120
  homepage: https://github.com/clpsplug/jekyll-shields_io
100
121
  licenses:
101
122
  - MIT
102
123
  metadata: {}
103
- post_install_message:
124
+ post_install_message:
104
125
  rdoc_options: []
105
126
  require_paths:
106
127
  - lib
@@ -108,15 +129,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
129
  requirements:
109
130
  - - ">="
110
131
  - !ruby/object:Gem::Version
111
- version: '0'
132
+ version: '2.7'
133
+ - - "<"
134
+ - !ruby/object:Gem::Version
135
+ version: '4'
112
136
  required_rubygems_version: !ruby/object:Gem::Requirement
113
137
  requirements:
114
138
  - - ">="
115
139
  - !ruby/object:Gem::Version
116
140
  version: '0'
117
141
  requirements: []
118
- rubygems_version: 3.1.6
119
- signing_key:
142
+ rubygems_version: 3.3.26
143
+ signing_key:
120
144
  specification_version: 4
121
145
  summary: Adds ability to put shields.io badges in your Jekyll blog
122
146
  test_files: []