jekyll_quote 0.1.0

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
+ SHA256:
3
+ metadata.gz: 65b7377a2c75d3e1418bcab4842b7e804b1d2757a3c1447c419314833117582d
4
+ data.tar.gz: a3598bdd5c4edc526f408ae33dc8db6d179c9ed9e9a5839da65b6cd6fc574de8
5
+ SHA512:
6
+ metadata.gz: d2204156fb0b7f2c1cd8a23c771364d22ccd3d5c3bbb649ad376dc8585fa5515c683a304a53c35f89b49217472586aacbea7d6696ccc4f603621b810bd2664b8
7
+ data.tar.gz: 1d6e5b223ffa416bd83610fbc6cdf1ee4af53e7d8e788b3a859dc2638c4935db1b7a640229904b9c494dcd804679e287d4279c45d0acbd46a616867db4ddc285
data/.rubocop.yml ADDED
@@ -0,0 +1,27 @@
1
+ AllCops:
2
+ Exclude:
3
+ - vendor/**/*
4
+ - exe/**/*
5
+ - Gemfile*
6
+ - Rakefile
7
+ - '*.gemspec'
8
+ NewCops: enable
9
+ TargetRubyVersion: 2.6
10
+
11
+ Layout/HashAlignment:
12
+ Enabled: false
13
+
14
+ Layout/LineLength:
15
+ Max: 150
16
+
17
+ Metrics/MethodLength:
18
+ Max: 30
19
+
20
+ Layout/MultilineMethodCallIndentation:
21
+ Enabled: false
22
+
23
+ Metrics/CyclomaticComplexity:
24
+ Max: 10
25
+
26
+ Metrics/PerceivedComplexity:
27
+ Max: 10
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0 / 2023-01-12
2
+ * Initial version
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Mike Slinn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,106 @@
1
+ `jekyll_quote`
2
+ [![Gem Version](https://badge.fury.io/rb/jekyll_quote.svg)](https://badge.fury.io/rb/jekyll_quote)
3
+ ===========
4
+
5
+ `jekyll_quote` is a Jekyll plugin that displays formatted quotes.
6
+
7
+ See [demo/index.html](demo/index.html) for examples.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your Jekyll project's Gemfile, within the `jekyll_plugins` group:
13
+
14
+ ```ruby
15
+ group :jekyll_plugins do
16
+ gem 'jekyll_quote'
17
+ end
18
+ ```
19
+
20
+ Also add it to `_config.yml`:
21
+ ```yaml
22
+ plugins:
23
+ - jekyll_quote
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle install
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install jekyll_quote
33
+
34
+
35
+ ## Additional Information
36
+ More information is available on
37
+ [Mike Slinn’s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
38
+
39
+
40
+ ## Development
41
+ After checking out the repo, run `bin/setup` to install dependencies.
42
+
43
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+
46
+ To build and install this gem onto your local machine, run:
47
+ ```shell
48
+ $ bundle exec rake install
49
+ jekyll_quote 0.1.0 built to pkg/jekyll_quote-0.1.0.gem.
50
+ jekyll_quote (0.1.0) installed.
51
+ ```
52
+
53
+ Examine the newly built gem:
54
+ ```shell
55
+ $ gem info jekyll_quote
56
+
57
+ *** LOCAL GEMS ***
58
+
59
+ jekyll_quote (0.1.0)
60
+ Author: Mike Slinn
61
+ Homepage:
62
+ https://github.com/mslinn/jekyll_quote
63
+ License: MIT
64
+ Installed at: /home/mslinn/.gems
65
+
66
+ Generates Jekyll logger with colored output.
67
+ ```
68
+
69
+ ### Testing
70
+ Examine the output by running:
71
+ ```shell
72
+ $ demo/_bin/debug -r
73
+ ```
74
+ ... and pointing your web browser to http://localhost:4444/
75
+
76
+ ### Unit Tests
77
+ Either run `rspec` from Visual Studio Code's *Run and Debug* environment
78
+ (<kbd>Ctrl</kbd>-<kbd>shift</kbd>-<kbd>D</kbd>) and view the *Debug Console* output,
79
+ or run it from the command line:
80
+ ```shell
81
+ $ rspec
82
+ ```
83
+
84
+ ### Build and Push to RubyGems
85
+ To release a new version,
86
+ 1. Update the version number in `version.rb`.
87
+ 2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
88
+ 3. Run the following:
89
+ ```shell
90
+ $ bundle exec rake release
91
+ ```
92
+ The above creates a git tag for the version, commits the created tag,
93
+ and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
94
+
95
+
96
+ ## Contributing
97
+
98
+ 1. Fork the project
99
+ 2. Create a descriptively named feature branch
100
+ 3. Add your feature
101
+ 4. Submit a pull request
102
+
103
+
104
+ ## License
105
+
106
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task default: :spec
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/jekyll_quote/version'
4
+
5
+ # rubocop:disable Metrics/BlockLength
6
+ Gem::Specification.new do |spec|
7
+ github = 'https://github.com/mslinn/jekyll_quote'
8
+
9
+ spec.bindir = 'exe'
10
+ spec.authors = ['Mike Slinn']
11
+ spec.email = ['mslinn@mslinn.com']
12
+ spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
13
+ spec.homepage = 'https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#quote'
14
+ spec.license = 'MIT'
15
+ spec.metadata = {
16
+ 'allowed_push_host' => 'https://rubygems.org',
17
+ 'bug_tracker_uri' => "#{github}/issues",
18
+ 'changelog_uri' => "#{github}/CHANGELOG.md",
19
+ 'homepage_uri' => spec.homepage,
20
+ 'source_code_uri' => github,
21
+ }
22
+ spec.name = 'jekyll_quote'
23
+ spec.post_install_message = <<~END_MESSAGE
24
+
25
+ Thanks for installing #{spec.name}!
26
+
27
+ END_MESSAGE
28
+ spec.post_install_message = <<~END_MESSAGE
29
+
30
+ Thanks for installing #{spec.name}!
31
+
32
+ END_MESSAGE
33
+ spec.require_paths = ['lib']
34
+ spec.required_ruby_version = '>= 2.6.0'
35
+ spec.summary = 'Provides a Jekyll filter that creates formatted quotes.'
36
+ spec.test_files = spec.files.grep %r{^(test|spec|features)/}
37
+ spec.version = JekyllQuoteVersion::VERSION
38
+
39
+ spec.add_dependency 'jekyll', '>= 3.5.0'
40
+
41
+ spec.add_development_dependency 'debase'
42
+ spec.add_development_dependency 'jekyll_plugin_support'
43
+ spec.add_development_dependency 'rspec-match_ignoring_whitespace'
44
+ spec.add_development_dependency 'rubocop'
45
+ # spec.add_development_dependency 'rubocop-jekyll'
46
+ spec.add_development_dependency 'rubocop-rake'
47
+ spec.add_development_dependency 'rubocop-rspec'
48
+ spec.add_development_dependency 'ruby-debug-ide'
49
+ end
50
+ # rubocop:enable Metrics/BlockLength
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllQuoteVersion
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll_plugin_support'
4
+ require 'jekyll_plugin_support_helper'
5
+ require_relative 'jekyll_quote/version'
6
+
7
+ # @author Copyright 2022 Michael Slinn
8
+ # @license SPDX-License-Identifier: Apache-2.0
9
+
10
+ module QuoteModule
11
+ PLUGIN_NAME = 'quote'
12
+ end
13
+
14
+ module Jekyll
15
+ # Usage: {% quote [break] [by] [cite='Joe Blow'] [noprep] [url='https://blabla.com'] %}Bla bla.{% endquote %}
16
+ # Output looks like:
17
+ # <div class='quote'>
18
+ # Bla bla.
19
+ # <br><br> <span style='font-style:normal;'>&nbsp;&ndash; From Source cite.</span>
20
+ # </div>
21
+ class Quote < JekyllSupport::JekyllBlock
22
+ attr_accessor :cite, :url
23
+
24
+ def render_impl(text)
25
+ @break = @helper.parameter_specified? 'break' # enforced by CSS if a list ends the body
26
+ @by = @helper.parameter_specified? 'by'
27
+ @cite = @helper.parameter_specified? 'cite'
28
+ @noprep = @helper.parameter_specified? 'noprep'
29
+ @url = @helper.parameter_specified? 'url'
30
+
31
+ preposition = 'From'
32
+ preposition = 'By' if @by
33
+ preposition = '' if @noprep
34
+ if @cite
35
+ attribution = if @url && !@url.empty?
36
+ "<a href='#{@url}' rel='nofollow' target='_blank'>#{@cite}</a>"
37
+ else
38
+ "#{@cite}\n"
39
+ end
40
+ tag = @break ? 'div' : 'span'
41
+ attribution = "<#{tag} style='font-style:normal;'> &nbsp;&ndash; #{preposition} #{attribution}</#{tag}>\n"
42
+ text = "<div>#{text}</div>" if @break
43
+ end
44
+ <<~END_HERE
45
+ <div class='quote'>
46
+ #{text}#{attribution}
47
+ </div>
48
+ END_HERE
49
+ end
50
+ end
51
+ end
52
+
53
+ PluginMetaLogger.instance.info { "Loaded #{QuoteModule::PLUGIN_NAME} v0.1.0 plugin." }
54
+ Liquid::Template.register_tag(QuoteModule::PLUGIN_NAME, Jekyll::Quote)
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'jekyll_plugin_logger'
5
+ require 'rspec/match_ignoring_whitespace'
6
+ require_relative '../lib/jekyll_quote'
7
+
8
+ Registers = Struct.new(:page, :site)
9
+
10
+ # Mock for Collections
11
+ class Collections
12
+ def values
13
+ []
14
+ end
15
+ end
16
+
17
+ # Mock for Site
18
+ class SiteMock
19
+ attr_reader :config
20
+
21
+ def collections
22
+ Collections.new
23
+ end
24
+ end
25
+
26
+ # Mock for Liquid::ParseContent
27
+ class TestParseContext < Liquid::ParseContext
28
+ attr_reader :line_number, :registers
29
+
30
+ def initialize
31
+ super
32
+ @line_number = 123
33
+
34
+ @registers = Registers.new(
35
+ { 'path' => 'https://feeds.soundcloud.com/users/soundcloud:users:7143896/sounds.rss' },
36
+ SiteMock.new
37
+ )
38
+ end
39
+ end
40
+
41
+ # These tests all fail because I have not figured out how to provide a Jekyll block body to a test
42
+ class MyTest
43
+ RSpec.describe Jekyll::Quote do # rubocop:disable Metrics/BlockLength
44
+ let(:logger) do
45
+ PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
46
+ end
47
+
48
+ let(:parse_context) { TestParseContext.new }
49
+
50
+ let(:helper) do
51
+ JekyllPluginHelper.new(
52
+ 'quote',
53
+ 'This is a quote.',
54
+ logger
55
+ )
56
+ end
57
+
58
+ it 'has no cite or url' do
59
+ helper.reinitialize('Quote has no cite or url.')
60
+ quote = Jekyll::Quote.send(
61
+ :new,
62
+ 'quote',
63
+ helper.markup.dup,
64
+ parse_context
65
+ )
66
+ result = quote.send(:render_impl, helper.markup)
67
+ expect(result).to match_ignoring_whitespace <<-END_RESULT
68
+ <div class='quote'>
69
+ Quote has no cite or url.
70
+ </div>
71
+ END_RESULT
72
+ end
73
+
74
+ it 'has a cite but no url' do
75
+ helper.reinitialize("cite='This is a citation' The quote has a cite but no url.")
76
+ quote = Jekyll::Quote.send(
77
+ :new,
78
+ 'quote',
79
+ helper.markup.dup,
80
+ parse_context
81
+ )
82
+ result = quote.send(:render_impl, helper.markup)
83
+ expect(result).to match_ignoring_whitespace <<-END_RESULT
84
+ <div class='quote'>
85
+ This is the quoted text.
86
+ <br><br>
87
+ <span style='font-style:normal;'> &nbsp;&ndash; From This is a citation </span>
88
+ </div>
89
+ END_RESULT
90
+ end
91
+
92
+ it 'has a url but no cite' do
93
+ helper.reinitialize("url='https://blah.com' The quote has a url but no cite.")
94
+ quote = Jekyll::Quote.send(
95
+ :new,
96
+ 'quote',
97
+ helper.markup.dup,
98
+ parse_context
99
+ )
100
+ result = quote.send(:render_impl, helper.markup)
101
+ expect(result).to match_ignoring_whitespace <<-END_RESULT
102
+ <div class='quote'>
103
+ The quote has a url but no cite.
104
+ </div>
105
+ END_RESULT
106
+ end
107
+
108
+ it 'has a cite and a url' do
109
+ helper.reinitialize "cite='This is a citation' url='https://blah.com' The quote has a url and a cite.".dup
110
+ quote = Jekyll::Quote.send(
111
+ :new,
112
+ 'quote',
113
+ helper.markup.dup,
114
+ parse_context
115
+ )
116
+ result = quote.send(:render_impl, helper.markup)
117
+ expect(result).to match_ignoring_whitespace <<-END_RESULT
118
+ <div class='quote'>
119
+ The quote has a url but no cite.
120
+ <br><br>
121
+ <span style='font-style:normal;'> &nbsp;&ndash; From
122
+ <a href='https://blah.com' rel='nofollow' target='_blank'>This is a citation.</a>
123
+ </span>
124
+ </div>
125
+ END_RESULT
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require_relative '../lib/jekyll_quote'
5
+
6
+ RSpec.configure do |config|
7
+ config.filter_run :focus
8
+ config.order = 'random'
9
+ config.run_all_when_everything_filtered = true
10
+
11
+ # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
12
+ config.example_status_persistence_file_path = 'spec/status_persistence.txt'
13
+ end
@@ -0,0 +1,6 @@
1
+ example_id | status | run_time |
2
+ -------------------------------- | ------ | --------------- |
3
+ ./spec/jekyll_quote_spec.rb[1:1] | failed | 0.01849 seconds |
4
+ ./spec/jekyll_quote_spec.rb[1:2] | failed | 0.00035 seconds |
5
+ ./spec/jekyll_quote_spec.rb[1:3] | failed | 0.00018 seconds |
6
+ ./spec/jekyll_quote_spec.rb[1:4] | failed | 0.00009 seconds |
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_quote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Slinn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-01-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: debase
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: jekyll_plugin_support
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: rspec-match_ignoring_whitespace
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ruby-debug-ide
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - mslinn@mslinn.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".rubocop.yml"
133
+ - CHANGELOG.md
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - jekyll_quote.gemspec
138
+ - lib/jekyll_quote.rb
139
+ - lib/jekyll_quote/version.rb
140
+ - spec/jekyll_quote_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/status_persistence.txt
143
+ homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#quote
144
+ licenses:
145
+ - MIT
146
+ metadata:
147
+ allowed_push_host: https://rubygems.org
148
+ bug_tracker_uri: https://github.com/mslinn/jekyll_quote/issues
149
+ changelog_uri: https://github.com/mslinn/jekyll_quote/CHANGELOG.md
150
+ homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#quote
151
+ source_code_uri: https://github.com/mslinn/jekyll_quote
152
+ post_install_message: |2+
153
+
154
+ Thanks for installing jekyll_quote!
155
+
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: 2.6.0
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.3.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Provides a Jekyll filter that creates formatted quotes.
174
+ test_files:
175
+ - spec/jekyll_quote_spec.rb
176
+ - spec/spec_helper.rb
177
+ - spec/status_persistence.txt
178
+ ...