Skip to content

Commit

Permalink
Merge pull request #53 from matthodan/jekyll-4
Browse files Browse the repository at this point in the history
Jekyll 4 compatibility
  • Loading branch information
janosrusiczki authored Oct 16, 2019
2 parents 585f8da + ed849a6 commit a794402
Show file tree
Hide file tree
Showing 18 changed files with 178 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ AllCops:
Metrics/BlockLength:
ExcludedMethods: ['describe', 'it', 'context']

MethodLength:
Metrics/MethodLength:
Max: 15
2 changes: 1 addition & 1 deletion jekyll_asset_pipeline.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.rubygems_version = '2.2.2'

# Runtime dependencies
s.add_runtime_dependency 'jekyll', '~> 3.5'
s.add_runtime_dependency 'jekyll', '>= 3.5', '< 5.0'
s.add_runtime_dependency 'liquid', '~> 4.0'

# Development dependencies
Expand Down
4 changes: 2 additions & 2 deletions lib/jekyll_asset_pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
require 'jekyll_asset_pipeline/extensions/liquid/liquid_block_extensions'
require 'jekyll_asset_pipeline/extensions/liquid/asset_tag'
require 'jekyll_asset_pipeline/extensions/liquid/asset_tags/css_asset_tag'
# rubocop:disable LineLength
# rubocop:disable Metrics/LineLength
require 'jekyll_asset_pipeline/extensions/liquid/asset_tags/javascript_asset_tag'
# rubocop:enable LineLength
# rubocop:enable Metrics/LineLength

# Ruby extensions
require 'jekyll_asset_pipeline/extensions/ruby/subclass_tracking'
Expand Down
12 changes: 6 additions & 6 deletions lib/jekyll_asset_pipeline/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module JekyllAssetPipeline
# The pipeline itself, the run method is where it all happens
# rubocop:disable ClassLength
# rubocop:disable Metrics/ClassLength
class Pipeline
# rubocop:enable ClassLength
# rubocop:enable Metrics/ClassLength
class << self
# Generate hash based on manifest
def hash(source, manifest, options = {})
Expand All @@ -23,9 +23,9 @@ def hash(source, manifest, options = {})
# This is called from JekyllAssetPipeline::LiquidBlockExtensions.render
# or, to be more precise, from JekyllAssetPipeline::CssAssetTag.render and
# JekyllAssetPipeline::JavaScriptAssetTag.render
# rubocop:disable ParameterLists
# rubocop:disable Metrics/ParameterLists
def run(manifest, prefix, source, destination, tag, type, config)
# rubocop:enable ParameterLists
# rubocop:enable Metrics/ParameterLists
# Get hash for pipeline
hash = hash(source, manifest, config)

Expand Down Expand Up @@ -84,9 +84,9 @@ def process_pipeline(hash, pipeline)
end

# Initialize new pipeline
# rubocop:disable ParameterLists
# rubocop:disable Metrics/ParameterLists
def initialize(manifest, prefix, source, destination, type, options = {})
# rubocop:enable ParameterLists
# rubocop:enable Metrics/ParameterLists
@manifest = manifest
@prefix = prefix
@source = source
Expand Down
20 changes: 12 additions & 8 deletions spec/jekyll_asset_pipeline/asset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,44 @@ module JekyllAssetPipeline

describe '#new(content, filename)' do
specify do
subject.instance_variable_get(:@content).must_equal('foo')
subject.instance_variable_get(:@filename).must_equal('bar')
_(subject.instance_variable_get(:@content)).must_equal('foo')
_(subject.instance_variable_get(:@filename)).must_equal('bar')
end
end

describe '#content' do
before { subject.instance_variable_set(:@content, 'foobar') }
specify { subject.content.must_equal('foobar') }
specify { _(subject.content).must_equal('foobar') }
end

describe '#content=' do
before { subject.content = 'foobar' }
specify { subject.instance_variable_get(:@content).must_equal('foobar') }
specify do
_(subject.instance_variable_get(:@content)).must_equal('foobar')
end
end

describe '#filename' do
before { subject.instance_variable_set(:@filename, 'foobar') }
specify { subject.filename.must_equal('foobar') }
specify { _(subject.filename).must_equal('foobar') }
end

describe '#filename=' do
before { subject.filename = 'foobar' }
specify { subject.instance_variable_get(:@filename).must_equal('foobar') }
specify do
_(subject.instance_variable_get(:@filename)).must_equal('foobar')
end
end

describe '#output_path' do
before { subject.instance_variable_set(:@output_path, 'foobar') }
specify { subject.output_path.must_equal('foobar') }
specify { _(subject.output_path).must_equal('foobar') }
end

describe '#output_path=' do
before { subject.output_path = 'foobar' }
specify do
subject.instance_variable_get(:@output_path).must_equal('foobar')
_(subject.instance_variable_get(:@output_path)).must_equal('foobar')
end
end
end
Expand Down
31 changes: 19 additions & 12 deletions spec/jekyll_asset_pipeline/compressor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

module JekyllAssetPipeline
describe Compressor do
specify { Compressor.extend?(SubclassTracking).must_equal(true) }
specify { _(Compressor.extend?(SubclassTracking)).must_equal(true) }

context 'with default compressor class' do
describe 'class methods' do
describe '::filetype' do
specify { Compressor.filetype.must_be_instance_of(String) }
specify { _(Compressor.filetype).must_be_instance_of(String) }
end
end

Expand All @@ -18,18 +18,21 @@ module JekyllAssetPipeline

describe '#new(content)' do
specify do
subject.instance_variable_get(:@content).must_equal('uncompressed')
subject
.instance_variable_get(:@compressed).must_equal('uncompressed')
_(
subject.instance_variable_get(:@content)
).must_equal('uncompressed')
_(
subject.instance_variable_get(:@compressed)
).must_equal('uncompressed')
end
end

describe '#compressed' do
specify { subject.compressed.must_equal('uncompressed') }
specify { _(subject.compressed).must_equal('uncompressed') }
end

describe '#compress' do
specify { subject.compress.must_equal('uncompressed') }
specify { _(subject.compress).must_equal('uncompressed') }
end
end
end
Expand All @@ -41,7 +44,7 @@ module JekyllAssetPipeline

describe 'class methods' do
describe '::filetype' do
specify { TestCompressor.filetype.must_equal('.foo') }
specify { _(TestCompressor.filetype).must_equal('.foo') }
end
end

Expand All @@ -50,17 +53,21 @@ module JekyllAssetPipeline

describe '#new(content)' do
specify do
subject.instance_variable_get(:@content).must_equal('uncompressed')
subject.instance_variable_get(:@compressed).must_equal('compressed')
_(
subject.instance_variable_get(:@content)
).must_equal('uncompressed')
_(
subject.instance_variable_get(:@compressed)
).must_equal('compressed')
end
end

describe '#compressed' do
specify { subject.compressed.must_equal('compressed') }
specify { _(subject.compressed).must_equal('compressed') }
end

describe '#compress' do
specify { subject.compress.must_equal('compressed') }
specify { _(subject.compress).must_equal('compressed') }
end
end
end
Expand Down
36 changes: 19 additions & 17 deletions spec/jekyll_asset_pipeline/converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

module JekyllAssetPipeline
describe Converter do
specify { Converter.extend?(SubclassTracking).must_equal(true) }
specify { _(Converter.extend?(SubclassTracking)).must_equal(true) }

context 'with default converter class' do
describe 'class methods' do
describe '::filetype' do
specify { Converter.filetype.must_be_instance_of(String) }
specify { _(Converter.filetype).must_be_instance_of(String) }
end
end

Expand All @@ -25,19 +25,19 @@ module JekyllAssetPipeline
subject { Converter.new(asset) }

describe '#new(asset)' do
specify { subject.instance_variable_get(:@content).must_equal('foo') }
specify { subject.instance_variable_get(:@type).must_equal('.baz') }
specify do
subject.instance_variable_get(:@converted).must_equal('foo')
_(subject.instance_variable_get(:@content)).must_equal('foo')
_(subject.instance_variable_get(:@type)).must_equal('.baz')
_(subject.instance_variable_get(:@converted)).must_equal('foo')
end
end

describe '#converted' do
specify { subject.converted.must_equal('foo') }
specify { _(subject.converted).must_equal('foo') }
end

describe '#convert' do
specify { subject.convert.must_equal('foo') }
specify { _(subject.convert).must_equal('foo') }
end
end
end
Expand All @@ -49,7 +49,7 @@ module JekyllAssetPipeline

describe 'class methods' do
describe '::filetype' do
specify { TestConverter.filetype.must_equal('.foo') }
specify { _(TestConverter.filetype).must_equal('.foo') }
end
end

Expand All @@ -66,22 +66,24 @@ module JekyllAssetPipeline

describe '#new(asset)' do
specify do
subject.instance_variable_get(:@content).must_equal('unconverted')
end
specify do
subject.instance_variable_get(:@type).must_equal('.foo')
end
specify do
subject.instance_variable_get(:@converted).must_equal('converted')
_(
subject.instance_variable_get(:@content)
).must_equal('unconverted')
_(
subject.instance_variable_get(:@type)
).must_equal('.foo')
_(
subject.instance_variable_get(:@converted)
).must_equal('converted')
end
end

describe '#converted' do
specify { subject.converted.must_equal('converted') }
specify { _(subject.converted).must_equal('converted') }
end

describe '#convert' do
specify { subject.convert.must_equal('converted') }
specify { _(subject.convert).must_equal('converted') }
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion spec/jekyll_asset_pipeline/extensions/jekyll/site_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

module JekyllAssetPipeline
describe Jekyll::Site do
specify { Jekyll::Site.include?(JekyllSiteExtensions).must_equal(true) }
specify do
_(Jekyll::Site.include?(JekyllSiteExtensions)).must_equal(true)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def write; end
obj.cleanup
end

# rubocop:disable LineLength
# rubocop:disable Metrics/LineLength
it 'clears JekyllAssetPipeline::Cache (when Jekyll::Site#cleanup is called)' do
# rubocop:enable LineLength
# rubocop:enable Metrics/LineLength
subject # Setup subject
Pipeline.cache.key?('foo').must_equal(false)
_(Pipeline.cache.key?('foo')).must_equal(false)
end

it 'returns the same value as the original Jekyll::Site#cleanup method' do
subject.must_equal('old_return_value')
_(subject).must_equal('old_return_value')
end
end

Expand Down Expand Up @@ -64,13 +64,13 @@ def source
end

it 'returns the same value as the original Jekyll::Site#write method' do
subject.must_equal('old_write_return_value')
_(subject).must_equal('old_write_return_value')
end

it 'removes the staged assets via Pipeline.remove_staged_assets' do
FileUtils.touch('/tmp/.asset_pipeline')
subject
File.exist?('/tmp/.asset_pipeline').must_equal(false)
_(File.exist?('/tmp/.asset_pipeline')).must_equal(false)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
module JekyllAssetPipeline
describe AssetTag do
specify do
AssetTag.extend?(LiquidBlockExtensions::ClassMethods).must_equal(true)
AssetTag.include?(LiquidBlockExtensions).must_equal(true)
_(AssetTag.extend?(LiquidBlockExtensions::ClassMethods)).must_equal(true)
_(AssetTag.include?(LiquidBlockExtensions)).must_equal(true)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
module JekyllAssetPipeline
describe CssAssetTag do
specify do
CssAssetTag.tag_name.must_equal('css_asset_tag')
CssAssetTag.output_type.must_equal('.css')
(CssAssetTag.superclass == JekyllAssetPipeline::AssetTag)
_(CssAssetTag.tag_name).must_equal('css_asset_tag')
_(CssAssetTag.output_type).must_equal('.css')
_(CssAssetTag.superclass == JekyllAssetPipeline::AssetTag)
.must_equal(true)
end

it 'registers tag with Liquid' do
::Liquid::Template.tags[JekyllAssetPipeline::CssAssetTag.tag_name]
.must_equal(JekyllAssetPipeline::CssAssetTag)
_(
::Liquid::Template.tags[JekyllAssetPipeline::CssAssetTag.tag_name]
).must_equal(JekyllAssetPipeline::CssAssetTag)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
module JekyllAssetPipeline
describe JavaScriptAssetTag do
specify do
JavaScriptAssetTag.tag_name.must_equal('javascript_asset_tag')
JavaScriptAssetTag.output_type.must_equal('.js')
(JavaScriptAssetTag.superclass == JekyllAssetPipeline::AssetTag)
_(JavaScriptAssetTag.tag_name).must_equal('javascript_asset_tag')
_(JavaScriptAssetTag.output_type).must_equal('.js')
_(JavaScriptAssetTag.superclass == JekyllAssetPipeline::AssetTag)
.must_equal(true)
end

it 'registers tag with Liquid' do
::Liquid::Template.tags[JekyllAssetPipeline::JavaScriptAssetTag.tag_name]
.must_equal(JekyllAssetPipeline::JavaScriptAssetTag)
_(
::Liquid::Template
.tags[JekyllAssetPipeline::JavaScriptAssetTag.tag_name]
).must_equal(JekyllAssetPipeline::JavaScriptAssetTag)
end
end
end
Loading

0 comments on commit a794402

Please sign in to comment.