Skip to content

Commit

Permalink
fixing windows mini_magick escape issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matthutchinson committed Apr 19, 2015
1 parent 083dcb0 commit f38a658
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Expand Up @@ -32,11 +32,6 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 1
# Cop supports --auto-correct.
Performance/Sample:
Enabled: false

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ rvm:
- 1.9.3
- 2.0.0
- 2.1.5
- 2.2.1
- 2.2.2
- ruby-head

before_install:
Expand Down
20 changes: 20 additions & 0 deletions lib/core_ext/mini_magick/utilities.rb
@@ -0,0 +1,20 @@
# -*- encoding : utf-8 -*-
module CoreExt
module MiniMagick
module Utilities
class << self
# fixes issue introduced in this commit
# https://github.com/minimagick/minimagick/commit/65b6427395cbfe6
def windows_escape(cmdline)
'"' + cmdline.gsub(/\\(?=\\*\")/, '\\\\\\').gsub(/\"/, '\\"').gsub(/\\$/, '\\\\\\').gsub('%', '%%') + '"'
end
end
end
end
end

# To maintain MiniMagick compatibility on Windows for v3.8.1 we need this patch
# If/when we upgrade MiniMagick to 4.2+ this patch can be removed
# We are locked at v3.8.1 since MiniMagick 4+ dropped support for Ruby 1.8.7

MiniMagick.send(:include, CoreExt::MiniMagick::Utilities)
1 change: 1 addition & 0 deletions lib/lolcommits.rb
Expand Up @@ -3,6 +3,7 @@

require 'core_ext/class'
require 'mini_magick'
require 'core_ext/mini_magick/utilities'
require 'fileutils'
require 'git'
require 'open3'
Expand Down
2 changes: 1 addition & 1 deletion lib/lolcommits/plugins/tranzlate.rb
Expand Up @@ -85,7 +85,7 @@ def tranzlate(str)
lolstr = str.dup
LOL_DICTIONARY.each do |english, lolspeak|
# ghetto ruby1.8/1.9 agnostic version of choice vs sample
lolstr.gsub!(english, lolspeak.shuffle.first)
lolstr.gsub!(english, lolspeak.sample)
end

lolstr << '! kthxbye!' if rand(10) == 2
Expand Down
2 changes: 1 addition & 1 deletion lolcommits.gemspec
Expand Up @@ -59,6 +59,6 @@ Gem::Specification.new do |s|

if RUBY_VERSION >= '1.9.3'
s.add_development_dependency('travis', '~> 1.7.4')
s.add_development_dependency('rubocop', '~> 0.28')
s.add_development_dependency('rubocop', '~> 0.30')
end
end

0 comments on commit f38a658

Please sign in to comment.