jekyll_download_link 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad6f645b0095853aa2031c60d9a74475d671f45f717f9a26e1017e7f51ee476b
4
- data.tar.gz: b381115b1bbf6d62b2face7b26f8ae10e547f25b8f97625c0f51f499b469b452
3
+ metadata.gz: f13f89151e4dd91b17954c09b2a414c90282d61a1ca4f9267c45552db16009a5
4
+ data.tar.gz: 6292c9602c4d765eebdf61ac6674b802f53b44c4a86092401da4c2555b4db715
5
5
  SHA512:
6
- metadata.gz: 0bb16b7a80aa27d5bb9b6d4b4ebdba8880ee703e7848ddecdb5b3d7f118454e62847faf16557619076b4770af757ecd7dc48a3d76456f0841095951aa498f343
7
- data.tar.gz: f8ae5f90324c41a832937d8cfb46ba8244d5907cf980ad8d5359018a50aa20b3206268d56f940725d29e56e557d201c83ffe5ce2194dcd6a98e42e88fede3dab
6
+ metadata.gz: 4d0dae22ede737128c304a47a7569bb78f8ce336e3d9b7f7d2a8f791870ceae8f5296eca7e302225a2e4b59d64482689e6aea2715773352311b0881bba465860
7
+ data.tar.gz: d01a17d406143c750470a929ff0a7d57e6eb62488cb1ee29cd6664e0cb8ed30b5e3db9acecc526584f3e63487441d53e95d0c6a84c5be04a01d423fe0bb86c9f
data/.rubocop.yml CHANGED
@@ -1,17 +1,69 @@
1
- require: rubocop-jekyll
2
- inherit_gem:
3
- rubocop-jekyll: .rubocop.yml
1
+ require:
2
+ # - rubocop-jekyll
3
+ - rubocop-md
4
+ - rubocop-performance
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
8
+ # inherit_gem:
9
+ # rubocop-jekyll: .rubocop.yml
4
10
 
5
11
  AllCops:
6
12
  Exclude:
7
- - vendor/**/*
8
- - Gemfile*
9
- - '*.gemspec' # This does nothing. Why?
13
+ - binstub/**/*
14
+ - vendor/**/*
15
+ - Gemfile*
16
+ - jekyll_download_link.gemspec
10
17
  NewCops: enable
11
- TargetRubyVersion: 2.6
18
+
19
+ Gemspec/DeprecatedAttributeAssignment:
20
+ Enabled: false
21
+
22
+ Gemspec/RequireMFA:
23
+ Enabled: false
24
+
25
+ Gemspec/RequiredRubyVersion:
26
+ Enabled: false
27
+
28
+ Layout/InitialIndentation:
29
+ Exclude:
30
+ - README.md
31
+
32
+ Layout/HashAlignment:
33
+ EnforcedColonStyle: table
34
+ Exclude:
35
+ - jekyll_download_link.gemspec
12
36
 
13
37
  Layout/LineLength:
14
38
  Max: 150
15
39
 
16
- # Gemspec/RequireMFA:
17
- # enable: false
40
+ Lint/RedundantCopDisableDirective:
41
+ Exclude:
42
+ - jekyll_download_link.gemspec
43
+
44
+ Lint/SymbolConversion:
45
+ Exclude:
46
+ - jekyll_download_link.gemspec
47
+
48
+ Metrics/BlockLength:
49
+ Exclude:
50
+ - jekyll_download_link.gemspec
51
+ - spec/**/*
52
+ Max: 35
53
+
54
+ Metrics/ClassLength:
55
+ Exclude:
56
+ - spec/**/*
57
+
58
+ Naming/FileName:
59
+ Exclude:
60
+ - Rakefile
61
+
62
+ RSpec/MultipleExpectations:
63
+ Enabled: false
64
+
65
+ Style/FrozenStringLiteralComment:
66
+ Enabled: false
67
+
68
+ Style/TrailingCommaInHashLiteral:
69
+ EnforcedStyleForMultiline: comma
data/CHANGELOG.md CHANGED
@@ -1,8 +1,22 @@
1
+ # Change Log
2
+
3
+ ## 1.0.2 / 2023-12-02
4
+
5
+ * Now depends on `jekyll_plugin_support`
6
+ * Demo website added
7
+ * Better Rubocop support
8
+ * Pinned to `json` gem v3.6.2 because Jekyll 4.3.2 requires it
9
+
10
+
1
11
  ## 1.0.1 / 2022-04-05
2
- * Updated to `jekyll_plugin_logger` v2.1.0
12
+
13
+ * Updated to `jekyll_plugin_logger` v2.1.0
14
+
3
15
 
4
16
  ## 1.0.0 / 2022-03-16
5
- * Published as a gem
17
+
18
+ * Published as a gem
6
19
 
7
20
  ## 2020-10-03
8
- * Initial version published at https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html
21
+
22
+ * Initial version published at https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html
data/README.md CHANGED
@@ -1,19 +1,19 @@
1
- `jekyll_download_link`
2
- [![Gem Version](https://badge.fury.io/rb/jekyll_download_link.svg)](https://badge.fury.io/rb/jekyll_download_link)
3
- ===========
1
+ # `jekyll_download_link` [![Gem Version](https://badge.fury.io/rb/jekyll_download_link.svg)](https://badge.fury.io/rb/jekyll_download_link)
4
2
 
5
- `jekyll_download_link` is a Jekyll tag plugin that generates a link to the given URI, which must be a file on the server.
6
- The file name can be absolute or relative to the top-level directory of the web site.
3
+ `jekyll_download_link` is a Jekyll tag plugin that generates a link to the given URI,
4
+ which must be a file on the server.
5
+ The file name can be absolute or relative to the top-level directory of the website.
7
6
 
8
7
 
9
8
  ## Usage
10
- ```
9
+
10
+ ```html
11
11
  {% download_link cloud9.tar %}
12
12
  ```
13
13
 
14
14
  Generates:
15
15
 
16
- ```
16
+ ```html
17
17
  <a href="/cloud9.tar"><code>cloud9.tar</code></a> (4.5 KB)
18
18
  ```
19
19
 
@@ -31,16 +31,15 @@ gem 'jekyll_download_link'
31
31
 
32
32
  And then execute:
33
33
 
34
- $ bundle install
35
-
36
- Or install it yourself as:
37
-
38
- $ gem install jekyll_download_link
34
+ ```shell
35
+ $ bundle install
36
+ ```
39
37
 
40
38
 
41
39
  ## Additional Information
40
+
42
41
  More information is available on
43
- [Mike Slinn&rsquo;s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
42
+ [Mike Slinn&rsquo;s website](https://mslinn.com/jekyll/3000-jekyll-plugins.html#download_link).
44
43
 
45
44
 
46
45
  ## Development
@@ -51,12 +50,9 @@ You can also run `bin/console` for an interactive prompt that will allow you to
51
50
 
52
51
 
53
52
  ### Build and Install Locally
54
- To build and install this gem onto your local machine, run:
55
- ```shell
56
- $ rake install:local
57
- ```
58
53
 
59
- The following also does the same thing:
54
+ To build and install this gem onto your local machine, type:
55
+
60
56
  ```shell
61
57
  $ bundle exec rake install
62
58
  jekyll_download_link 1.0.0 built to pkg/jekyll_download_link-0.1.0.gem.
@@ -64,6 +60,7 @@ jekyll_download_link (1.0.0) installed.
64
60
  ```
65
61
 
66
62
  Examine the newly built gem:
63
+
67
64
  ```shell
68
65
  $ gem info jekyll_download_link
69
66
 
@@ -80,14 +77,56 @@ jekyll_download_link (1.0.0)
80
77
  ```
81
78
 
82
79
 
80
+ ## Demo Website
81
+
82
+ A test/demo website is provided in the `demo` directory.
83
+ You can run it under a debugger, or let it run free.
84
+
85
+ The `demo/_bin/debug` script can set various parameters for the demo.
86
+ View the help information with the `-h` option:
87
+
88
+ ```shell
89
+ $ demo/_bin/debug -h
90
+
91
+ debug - Run the demo Jekyll website.
92
+
93
+ By default the demo Jekyll website runs without restriction under ruby-debug-ide and debase.
94
+ View it at http://localhost:4444
95
+
96
+ Options:
97
+ -h Show this error message
98
+
99
+ -r Run freely, without a debugger
100
+ ```
101
+
102
+
103
+ ### Debugging the Demo
104
+
105
+ To run under a debugger, for example Visual Studio Code:
106
+
107
+ 1. Set breakpoints.
108
+ 2. Initiate a debug session from the command line:
109
+
110
+ ```shell
111
+ $ demo/bin/debug
112
+ ```
113
+
114
+ 3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch configuration called `Attach rdebug-ide`.
115
+ 4. View the generated website at [`http://localhost:4444`](http://localhost:4444).
116
+
117
+
83
118
  ### Build and Push to RubyGems
119
+
84
120
  To release a new version,
121
+
85
122
  1. Update the version number in `version.rb`.
86
123
  2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
87
124
  3. Run the following:
125
+
88
126
  ```shell
89
127
  $ bundle exec rake release
90
128
  ```
129
+
91
130
  The above creates a git tag for the version, commits the created tag,
92
131
  and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
93
132
 
data/Rakefile CHANGED
@@ -1,7 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
5
3
 
6
4
  RSpec::Core::RakeTask.new(:spec)
7
- task :default => :spec
5
+ task default: :spec
@@ -1,10 +1,7 @@
1
- # frozen_string_literal: true
1
+ require_relative 'lib/jekyll_download_link/version'
2
2
 
3
- require_relative "lib/jekyll_download_link/version"
4
-
5
- # rubocop:disable Metrics/BlockLength, Style/StringLiterals
6
- Gem::Specification.new do |spec|
7
- github = "https://github.com/mslinn/jekyll_download_link"
3
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
4
+ github = 'https://github.com/mslinn/jekyll_download_link'
8
5
 
9
6
  spec.authors = ['Mike Slinn']
10
7
  spec.bindir = 'exe'
@@ -12,15 +9,15 @@ Gem::Specification.new do |spec|
12
9
  Provides a Jekyll tag that generates an href to a file for the user to download, plus human-friendly filesize.
13
10
  END_OF_DESC
14
11
  spec.email = ['mslinn@mslinn.com']
15
- spec.files = Dir[".rubocop.yml", "LICENSE.*", "Rakefile", "{lib,spec}/**/*", "*.gemspec", "*.md"]
16
- spec.homepage = "https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#download"
12
+ spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
13
+ spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_download_link.html'
17
14
  spec.license = 'MIT'
18
15
  spec.metadata = {
19
- "allowed_push_host" => "https://rubygems.org",
20
- "bug_tracker_uri" => "#{github}/issues",
21
- "changelog_uri" => "#{github}/CHANGELOG.md",
22
- "homepage_uri" => spec.homepage,
23
- "source_code_uri" => github,
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,
24
21
  }
25
22
  spec.name = 'jekyll_download_link'
26
23
  spec.post_install_message = <<~END_MESSAGE
@@ -34,13 +31,7 @@ Gem::Specification.new do |spec|
34
31
  spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
35
32
  spec.version = JekyllDownloadLinkVersion::VERSION
36
33
 
37
- spec.add_dependency "jekyll", ">= 3.5.0"
38
- spec.add_dependency "jekyll_plugin_logger"
39
-
40
- spec.add_development_dependency "debase"
41
- # spec.add_development_dependency "rubocop-jekyll"
42
- # spec.add_development_dependency "rubocop-rake"
43
- # spec.add_development_dependency "rubocop-rspec"
44
- spec.add_development_dependency "ruby-debug-ide"
34
+ spec.add_dependency 'jekyll', '>= 3.5.0'
35
+ spec.add_dependency 'json', '= 2.6.3'
36
+ spec.add_dependency 'jekyll_plugin_support'
45
37
  end
46
- # rubocop:enable Metrics/BlockLength, Style/StringLiterals
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module JekyllDownloadLinkVersion
4
- VERSION = "1.0.1"
2
+ VERSION = '1.0.2'.freeze
5
3
  end
@@ -1,48 +1,36 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll"
4
- require "jekyll_plugin_logger"
5
- require_relative "jekyll_download_link/version"
1
+ require 'jekyll_plugin_support'
2
+ require_relative 'jekyll_download_link/version'
6
3
 
7
4
  module JekyllPluginDownloadLinkName
8
- PLUGIN_NAME = "download_link"
5
+ PLUGIN_NAME = 'download_link'.freeze
9
6
  end
10
7
 
11
8
  # Generates an href to a file for the user to download from the site.
12
9
  # Also shows the file size in a human-readable format.
13
- class DownloadLink < Liquid::Tag
14
- # Constructor.
15
- # @param tag_name [String] is the name of the tag, which we already know.
16
- # Contains the name of the file, relative to the website top level directory
17
- # @param text [Hash, String, Liquid::Tag::Parser] the arguments from the web page.
18
- # @param tokens [Liquid::ParseContext] tokenized command line
19
- # @return [void]
20
- def initialize(tag_name, text, tokens)
21
- super
22
- @logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
23
- @filename = text.delete('"').delete("'").strip
24
- end
10
+ class DownloadLink < JekyllSupport::JekyllTagNoArgParsing
11
+ include JekyllDownloadLinkVersion
25
12
 
26
- # Method prescribed by the Jekyll plugin lifecycle.
27
- # @return [String]
28
- def render(context)
29
- source = context.registers[:site].config["source"]
30
- file_fq = File.join(source, @filename)
31
- abort "Error: '#{file_fq}' not found. See the link tag in" unless File.exist?(file_fq)
13
+ def self.as_size(string)
14
+ units = %w[B KB MB GB TB]
15
+
16
+ size, unit = units.reduce(string.to_f) do |(fsize, _), utype|
17
+ fsize > 512 ? [fsize / 1024, utype] : (break [fsize, utype])
18
+ end
32
19
 
33
- "<a href='/#{@filename}'><code>#{@filename}</code></a> (#{as_size(File.size(file_fq))})"
20
+ fmt_str = "#{size > 9 || size.modulo(1) < 0.1 ? '%d' : '%.1f'} %s"
21
+ format(fmt_str, size, unit)
34
22
  end
35
23
 
36
- def as_size(s)
37
- units = %w(B KB MB GB TB)
24
+ def render_impl
25
+ @filename = @argument_string.delete('"').delete("'").strip
38
26
 
39
- size, unit = units.reduce(s.to_f) do |(fsize, _), utype|
40
- fsize > 512 ? [fsize / 1024, utype] : (break [fsize, utype])
41
- end
27
+ source = @config['source']
28
+ file_fq = File.join(source, @filename)
29
+ abort "Error: '#{file_fq}' not found. See the link tag in" unless File.exist?(file_fq)
42
30
 
43
- "#{size > 9 || size.modulo(1) < 0.1 ? "%d" : "%.1f"} %s" % [size, unit]
31
+ size_str = self.class.as_size(File.size(file_fq))
32
+ "<a href='/#{@filename}'><code>#{@filename}</code></a> (#{size_str})"
44
33
  end
45
- end
46
34
 
47
- PluginMetaLogger.instance.info { "Loaded #{JekyllPluginDownloadLinkName::PLUGIN_NAME} v#{JekyllDownloadLinkVersion::VERSION} plugin." }
48
- Liquid::Template.register_tag(JekyllPluginDownloadLinkName::PLUGIN_NAME, DownloadLink)
35
+ JekyllPluginHelper.register(self, JekyllPluginDownloadLinkName::PLUGIN_NAME)
36
+ end
@@ -0,0 +1,19 @@
1
+ require 'jekyll_plugin_support'
2
+ require_relative '../lib/jekyll_download_link'
3
+
4
+ RSpec.describe(DownloadLink) do
5
+ let(:config) { instance_double(Configuration) }
6
+ let(:context) do
7
+ context_ = instance_double(Liquid::Context)
8
+ context_.config = config
9
+ context_
10
+ end
11
+
12
+ it 'generates proper size comment' do
13
+ expect(described_class.as_size('123')).to eq('123 B')
14
+ expect(described_class.as_size('123456')).to eq('120 KB')
15
+ expect(described_class.as_size('123456789')).to eq('117 MB')
16
+ expect(described_class.as_size('123456789012')).to eq('114 GB')
17
+ expect(described_class.as_size('123456789012345')).to eq('112 TB')
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,10 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll"
4
- require_relative "../lib/jekyll_download_link"
1
+ require 'jekyll'
2
+ require_relative '../lib/jekyll_download_link'
5
3
 
6
4
  RSpec.configure do |config|
7
- config.filter_run :focus
8
- config.order = "random"
9
- config.run_all_when_everything_filtered = true
5
+ config.filter_run_when_matching focus: true
6
+ # config.order = 'random'
10
7
 
11
8
  # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
12
- config.example_status_persistence_file_path = "spec/status_persistence.txt"
9
+ config.example_status_persistence_file_path = 'spec/status_persistence.txt'
13
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_download_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-06 00:00:00.000000000 Z
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -25,41 +25,27 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.5.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: jekyll_plugin_logger
28
+ name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.6.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.6.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: debase
42
+ name: jekyll_plugin_support
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
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: ruby-debug-ide
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
48
+ type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
@@ -69,7 +55,7 @@ dependencies:
69
55
  description: 'Provides a Jekyll tag that generates an href to a file for the user
70
56
  to download, plus human-friendly filesize.
71
57
 
72
- '
58
+ '
73
59
  email:
74
60
  - mslinn@mslinn.com
75
61
  executables: []
@@ -84,16 +70,16 @@ files:
84
70
  - jekyll_download_link.gemspec
85
71
  - lib/jekyll_download_link.rb
86
72
  - lib/jekyll_download_link/version.rb
87
- - spec/jekyll_download_link_spec.rb
73
+ - spec/download_link_spec.rb
88
74
  - spec/spec_helper.rb
89
- homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#download
75
+ homepage: https://www.mslinn.com/jekyll_plugins/jekyll_download_link.html
90
76
  licenses:
91
77
  - MIT
92
78
  metadata:
93
79
  allowed_push_host: https://rubygems.org
94
80
  bug_tracker_uri: https://github.com/mslinn/jekyll_download_link/issues
95
81
  changelog_uri: https://github.com/mslinn/jekyll_download_link/CHANGELOG.md
96
- homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#download
82
+ homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_download_link.html
97
83
  source_code_uri: https://github.com/mslinn/jekyll_download_link
98
84
  post_install_message: |2+
99
85
 
@@ -113,11 +99,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
99
  - !ruby/object:Gem::Version
114
100
  version: '0'
115
101
  requirements: []
116
- rubygems_version: 3.1.4
117
- signing_key:
102
+ rubygems_version: 3.4.22
103
+ signing_key:
118
104
  specification_version: 4
119
105
  summary: Provides a Jekyll tag that generates an href to a file for the user to download,
120
106
  plus human-friendly filesize.
121
107
  test_files:
122
- - spec/jekyll_download_link_spec.rb
108
+ - spec/download_link_spec.rb
123
109
  - spec/spec_helper.rb
110
+ ...
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "jekyll"
4
- require_relative "../lib/jekyll_download_link"
5
-
6
- RSpec.describe(Jekyll) do
7
- include Jekyll
8
-
9
- let(:config) { instance_double("Configuration") }
10
- let(:context) {
11
- context_ = instance_double("Liquid::Context")
12
- context_.config = config
13
- context_
14
- }
15
-
16
- it "is created properly" do
17
- # run_tag = RunTag.new("run", "echo asdf")
18
- # output = run_tag.render(context)
19
- # expect(output).to eq("asdf")
20
- end
21
- end