jekyll-anticache-tag 0.1.1

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: fc851d3361649439c973b04c77927ced7fcf44d404d8590ec1ee371aea943f61
4
+ data.tar.gz: 04c3211759cdf08de05bf6d338a268aca6cf8e746d4ff952067009560a89bac6
5
+ SHA512:
6
+ metadata.gz: a06f9ba8406daf60d6dfa1c0f91d2c90dffa11ae93cf002cc02a4b9d994ea682a70ff9a1dce72db915b94fdcf3aa975718319c2af7b5929be685575b97753ec6
7
+ data.tar.gz: 798aac3e5b838108cc8c89ddfaa9487e2a86ddde1aa3f3eeee026b2391b209faae25eeecc3c80e017a72580b46acbecb78e9790fbea3cd9d12372281f9d75da6
data/.editorconfig ADDED
@@ -0,0 +1,4 @@
1
+ [*]
2
+ indent_size = 2
3
+ indent_style = space
4
+ insert_final_newline = true
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/dummy_jekyll/*
9
+ !/spec/dummy_jekyll/_site/.keep
10
+ !/spec/dummy_jekyll/source/.keep
11
+ /vendor/
12
+ /tmp/
13
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jekyll_anticache_tag.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright 2021
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Jekyll::Anticache::Tag
2
+
3
+ A simple Jekyll tag for cache busting.
4
+
5
+ add unixtime query string for assets every build
6
+
7
+ ## Usecase
8
+
9
+ ```
10
+ {% acasset foo.png %}
11
+ # => foo.png?1624352400
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'jekyll-anticache-tag'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install jekyll-anticache-tag
29
+
30
+ ## Usage
31
+
32
+ add line as below in `plugins:` key of `_config.yml `
33
+
34
+ ```yaml
35
+ - jekyll-anticache-tag
36
+ ```
37
+
38
+ ### replace tag_name
39
+
40
+ If you want to write just `asset` in order to use this, add as below in `_config.yaml`
41
+
42
+ ```yaml
43
+ anticache_tag:
44
+ tag: 'asset'
45
+ ```
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/colorfulcompany/jekyll-anticache-tag.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:spec) do |t|
5
+ t.libs << "spec"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["spec/**/*_spec.rb"]
8
+ end
9
+
10
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll_anticache_tag"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "jekyll/anticache_tag/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-anticache-tag"
7
+ spec.version = Jekyll::Anticache::VERSION
8
+ spec.authors = ["T.Watanabe"]
9
+ spec.email = ["watanabe@colorfulcompany.co.jp"]
10
+
11
+ spec.summary = %q{A simple Jekyll tag for cache busting.}
12
+ spec.description = %q{add unixtime query string for assets every build.}
13
+ spec.homepage = "https://github.com/colorfulcompany/jekyll-anticache-tag"
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
+ spec.add_development_dependency "minitest", "~> 5.0"
33
+ spec.add_development_dependency "minitest-power_assert"
34
+ spec.add_development_dependency "minitest-reporters"
35
+ spec.add_development_dependency "jekyll", "> 3"
36
+ spec.add_development_dependency "liquid", "> 4"
37
+ spec.add_development_dependency "byebug"
38
+ spec.add_development_dependency "yard"
39
+ end
@@ -0,0 +1 @@
1
+ require 'jekyll_anticache_tag'
@@ -0,0 +1,67 @@
1
+ module Jekyll
2
+ module Anticache
3
+ class Error < StandardError; end
4
+
5
+ #
6
+ # anticache tag
7
+ #
8
+ class Tag < ::Liquid::Tag
9
+ CONFIG_NAMESPACE ||= 'anticache_tag'.freeze
10
+
11
+ class << self
12
+ #
13
+ # register tag with site config
14
+ #
15
+ # @param site [Object]
16
+ #
17
+ # :reek:DuplicateMethodCall
18
+ def register(site)
19
+ config = site.config[CONFIG_NAMESPACE]
20
+
21
+ tag = if config && config.dig('tag')
22
+ config.dig('tag')
23
+ else
24
+ 'acasset'
25
+ end
26
+
27
+ Liquid::Template.register_tag(tag, self)
28
+ end
29
+ end
30
+
31
+ #
32
+ # @param tag_name [String]
33
+ # @param text [String]
34
+ # @param tokens [Object]
35
+ #
36
+ def initialize(tag_name, text, tokens)
37
+ super
38
+ @text = text
39
+ end
40
+
41
+ #
42
+ # render string with time-based cache busting number when build
43
+ #
44
+ # @param context [Object]
45
+ # @return [String]
46
+ #
47
+ # :reek:FeatureEnvy
48
+ def render(context)
49
+ env = context.environments&.first['jekyll']&.environment || ENV['JEKYLL_ENV']
50
+
51
+ text = @text.strip.gsub(/['"]/, '')
52
+
53
+ if env != 'development'
54
+ site = context.registers[:site]
55
+
56
+ "#{text}?#{site.time.to_i}"
57
+ else
58
+ text
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ Jekyll::Hooks.register(:site, :post_read) do |site|
66
+ Jekyll::Anticache::Tag.register(site)
67
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Anticache
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "jekyll/anticache_tag/version"
2
+ require "jekyll/anticache_tag"
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-anticache-tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - T.Watanabe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-power_assert
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: minitest-reporters
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: jekyll
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">"
88
+ - !ruby/object:Gem::Version
89
+ version: '3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">"
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: liquid
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">"
102
+ - !ruby/object:Gem::Version
103
+ version: '4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">"
109
+ - !ruby/object:Gem::Version
110
+ version: '4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
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
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: add unixtime query string for assets every build.
140
+ email:
141
+ - watanabe@colorfulcompany.co.jp
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".editorconfig"
147
+ - ".gitignore"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - LICENSE
151
+ - README.md
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/setup
155
+ - jekyll-anticache-tag.gemspec
156
+ - lib/jekyll-anticache-tag.rb
157
+ - lib/jekyll/anticache_tag.rb
158
+ - lib/jekyll/anticache_tag/version.rb
159
+ - lib/jekyll_anticache_tag.rb
160
+ homepage: https://github.com/colorfulcompany/jekyll-anticache-tag
161
+ licenses: []
162
+ metadata:
163
+ allowed_push_host: https://rubygems.org
164
+ homepage_uri: https://github.com/colorfulcompany/jekyll-anticache-tag
165
+ source_code_uri: https://github.com/colorfulcompany/jekyll-anticache-tag
166
+ changelog_uri: https://github.com/colorfulcompany/jekyll-anticache-tag/blob/master/CHANGELOG.md
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubygems_version: 3.0.3
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: A simple Jekyll tag for cache busting.
186
+ test_files: []