Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix middleman v4 compatibility issues #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "http://rubygems.org"
source "https://rubygems.org"

# Specify your gem's dependencies in middleman-smusher.gemspec
gemspec
4 changes: 1 addition & 3 deletions lib/middleman-smusher.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require "middleman-core"

require "middleman-smusher/version"

::Middleman::Extensions.register(:smusher) do
require "middleman-smusher/extension"
::Middleman::Smusher
end
end
11 changes: 6 additions & 5 deletions lib/middleman-smusher/extension.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
require 'smusher'
require 'middleman-core'

module Middleman
class Smusher < ::Middleman::Extension
option :service, 'SmushIt', 'Smushing service (SmushIt, PunyPng)'
option :path, null, 'Path to images to smush, defaults to :images_dir if not set'
option :path, nil, 'Path to images to smush, defaults to :images_dir if not set'
option :with_gifs, false, 'Also smush GIFs'

def initialize(app, options_hash={}, &block)
super
require 'smusher'
end

def after_build(builder)
smush_dir = options.path || File.join(app.config[:build_dir], app.config[:images_dir])
prefix = build_dir + File::SEPARATOR
prefix = app.config[:build_dir] + File::SEPARATOR

files = ::Smusher.send :images_in_folder, smush_dir, options.with_gifs

files.each do |file|
::Smusher.optimize_image(file, service: options.service, quiet: true, with_gifs: options.with_gifs)
builder.say_status :smushed, file.sub(prefix, "")
::Smusher.optimize_image(file, service: options.service, quiet: true, convert_gifs: options.with_gifs)
builder.thor.say_status :smushed, file.sub(prefix, "")
end
end
end
Expand Down
5 changes: 0 additions & 5 deletions lib/middleman-smusher/version.rb

This file was deleted.

5 changes: 2 additions & 3 deletions middleman-smusher.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "middleman-smusher/version"

Gem::Specification.new do |s|
s.name = "middleman-smusher"
s.version = Middleman::Smusher::VERSION
s.version = '4.0.0'
s.platform = Gem::Platform::RUBY
s.authors = ["Thomas Reynolds"]
s.email = ["[email protected]"]
Expand All @@ -19,6 +18,6 @@ Gem::Specification.new do |s|
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency("middleman-core", [">= 3.2.0"])
s.add_runtime_dependency("middleman-core", [">= 4.2.1"])
s.add_runtime_dependency("smusher", ["~> 0.4.9"])
end