Implemented Rubocop

- just took a stab at running the StringLiterals cop to get a taste.
This commit is contained in:
Karl Freeman 2013-12-28 00:26:31 +00:00
parent e996868033
commit 03d6e6c990
80 changed files with 510 additions and 477 deletions

View file

@ -1,5 +1,5 @@
require "middleman-core/renderers/sass"
require "compass"
require 'middleman-core/renderers/sass'
require 'compass'
class Middleman::CoreExtensions::Compass < ::Middleman::Extension
@ -44,7 +44,7 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension
compass_config.output_style = :nested
# No line-comments in test mode (changing paths mess with sha1)
compass_config.line_comments = false if ENV["TEST"]
compass_config.line_comments = false if ENV['TEST']
end
# Call hook

View file

@ -6,9 +6,9 @@ end
class Padrino::Helpers::OutputHelpers::ErbHandler
# Force Erb capture not to use safebuffer
def capture_from_template(*args, &block)
self.output_buffer, _buf_was = "", self.output_buffer
self.output_buffer, _buf_was = '', self.output_buffer
captured_block = block.call(*args)
ret = eval("@_out_buf", block.binding)
ret = eval('@_out_buf', block.binding)
self.output_buffer = _buf_was
[ ret, captured_block ]
end
@ -60,7 +60,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
def capture_html(*args, &block)
handler = auto_find_proper_handler(&block)
captured_block, captured_html = nil, ""
captured_block, captured_html = nil, ''
if handler && handler.is_type? && handler.block_is_type?(block)
captured_html, captured_block = handler.capture_from_template(*args, &block)
end
@ -134,7 +134,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
parts = path.split('.').first.split('/')
parts.each_with_index { |_, i| classes << parts.first(i+1).join('_') }
prefix = options[:numeric_prefix] || "x"
prefix = options[:numeric_prefix] || 'x'
classes.map do |c|
# Replace weird class name characters
c = c.gsub(/[^a-zA-Z0-9\-_]/, '-')
@ -162,7 +162,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
source = source.to_s.tr(' ', '')
ignore_extension = (kind == :images || kind == :fonts) # don't append extension
source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}")
asset_folder = "" if source.start_with?('/') # absolute path
asset_folder = '' if source.start_with?('/') # absolute path
asset_url(source, asset_folder)
end
@ -172,7 +172,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
# @param [String] path The path (such as "photo.jpg")
# @param [String] prefix The type prefix (such as "images")
# @return [String] The fully qualified asset url
def asset_url(path, prefix="")
def asset_url(path, prefix='')
# Don't touch assets which already have a full path
if path.include?('//') or path.start_with?('data:')
path
@ -215,12 +215,12 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
options_index = block_given? ? 1 : 2
if block_given? && args.size > 2
raise ArgumentError.new("Too many arguments to link_to(url, options={}, &block)")
raise ArgumentError.new('Too many arguments to link_to(url, options={}, &block)')
end
if url = args[url_arg_index]
options = args[options_index] || {}
raise ArgumentError.new("Options must be a hash") unless options.is_a?(Hash)
raise ArgumentError.new('Options must be a hash') unless options.is_a?(Hash)
# Transform the url through our magic url_for method
args[url_arg_index] = url_for(url, options)

View file

@ -1,11 +1,11 @@
class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
option :no_fallbacks, false, "Disable I18n fallbacks"
option :langs, nil, "List of langs, will autodiscover by default"
option :lang_map, {}, "Language shortname map"
option :path, "/:locale/", "URL prefix path"
option :templates_dir, "localizable", "Location of templates to be localized"
option :mount_at_root, nil, "Mount a specific language at the root of the site"
option :data, "locales", "The directory holding your locale configurations"
option :no_fallbacks, false, 'Disable I18n fallbacks'
option :langs, nil, 'List of langs, will autodiscover by default'
option :lang_map, {}, 'Language shortname map'
option :path, '/:locale/', 'URL prefix path'
option :templates_dir, 'localizable', 'Location of templates to be localized'
option :mount_at_root, nil, 'Mount a specific language at the root of the site'
option :data, 'locales', 'The directory holding your locale configurations'
def initialize(app, options_hash={}, &block)
super
@ -17,11 +17,11 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
# See https://github.com/svenfuchs/i18n/wiki/Fallbacks
unless options[:no_fallbacks]
require "i18n/backend/fallbacks"
require 'i18n/backend/fallbacks'
::I18n::Backend::Simple.send(:include, ::I18n::Backend::Fallbacks)
end
app.config.define_setting :locales_dir, "locales", 'The directory holding your locale configurations'
app.config.define_setting :locales_dir, 'locales', 'The directory holding your locale configurations'
app.send :include, LocaleHelpers
end
@ -29,7 +29,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
def after_configuration
app.files.reload_path(app.config[:locals_dir] || options[:data])
@locales_glob = File.join(app.config[:locals_dir] || options[:data], "**", "*.{rb,yml,yaml}")
@locales_glob = File.join(app.config[:locals_dir] || options[:data], '**', '*.{rb,yml,yaml}')
@locales_regex = convert_glob_to_regex(@locales_glob)
@maps = {}
@ -42,7 +42,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
end
# Don't output localizable files
app.ignore File.join(options[:templates_dir], "**")
app.ignore File.join(options[:templates_dir], '**')
app.sitemap.provides_metadata_for_path(&method(:metadata_for_path))
app.files.changed(&method(:on_file_changed))
@ -75,11 +75,11 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
lang, path, page_id = result
new_resources << build_resource(path, resource.path, page_id, lang)
# If it's a "localizable template"
elsif File.fnmatch?(File.join(options[:templates_dir], "**"), resource.path)
elsif File.fnmatch?(File.join(options[:templates_dir], '**'), resource.path)
page_id = File.basename(resource.path, File.extname(resource.path))
langs.each do |lang|
# Remove folder name
path = resource.path.sub(options[:templates_dir], "")
path = resource.path.sub(options[:templates_dir], '')
new_resources << build_resource(path, resource.path, page_id, lang)
end
end
@ -100,7 +100,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
def convert_glob_to_regex(glob)
# File.fnmatch doesn't support brackets: {rb,yml,yaml}
regex = @locales_glob.sub(/\./, '\.').sub(File.join("**", "*"), ".*").sub(/\//, '\/').sub("{rb,yml,yaml}", "(rb|ya?ml)")
regex = @locales_glob.sub(/\./, '\.').sub(File.join('**', '*'), '.*').sub(/\//, '\/').sub('{rb,yml,yaml}', '(rb|ya?ml)')
%r{^#{regex}}
end
@ -148,7 +148,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
known_langs = app.files.known_paths.select do |p|
p.to_s.match(@locales_regex) && (p.to_s.split(File::SEPARATOR).length === 2)
end.map { |p|
File.basename(p.to_s).sub(/\.ya?ml$/, "").sub(/\.rb$/, "")
File.basename(p.to_s).sub(/\.ya?ml$/, '').sub(/\.rb$/, '')
}.sort.map(&:to_sym)
end
end
@ -179,10 +179,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id, :fallback => [])
prefix = if (options[:mount_at_root] == lang) || (options[:mount_at_root] == nil && langs[0] == lang)
"/"
'/'
else
replacement = options[:lang_map].fetch(lang, lang)
options[:path].sub(":locale", replacement.to_s)
options[:path].sub(':locale', replacement.to_s)
end
# path needs to be changed if file has a localizable extension. (options[mount_at_root] == lang)
@ -190,7 +190,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
File.join(prefix, path.sub(page_id, localized_page_id))
)
path.gsub!(options[:templates_dir]+"/", "")
path.gsub!(options[:templates_dir]+'/', '')
@_localization_data[path] = [lang, path, localized_page_id]

View file

@ -1,6 +1,6 @@
class Middleman::Extensions::AssetHash < ::Middleman::Extension
option :exts, %w(.jpg .jpeg .png .gif .js .css .otf .woff .eot .ttf .svg), "List of extensions that get asset hashes appended to them."
option :ignore, [], "Regexes of filenames to skip adding asset hashes to"
option :exts, %w(.jpg .jpeg .png .gif .js .css .otf .woff .eot .ttf .svg), 'List of extensions that get asset hashes appended to them.'
option :ignore, [], 'Regexes of filenames to skip adding asset hashes to'
def initialize(app, options_hash={}, &block)
super
@ -41,7 +41,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
return if ignored_resource?(resource)
# Render through the Rack interface so middleware and mounted apps get a shot
response = @rack_client.get(URI.escape(resource.destination_path), {}, { "bypass_asset_hash" => "true" })
response = @rack_client.get(URI.escape(resource.destination_path), {}, { 'bypass_asset_hash' => 'true' })
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
digest = Digest::SHA1.hexdigest(response.body)[0..7]
@ -68,9 +68,9 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
status, headers, response = @rack_app.call(env)
# We don't want to use this middleware when rendering files to figure out their hash!
return [status, headers, response] if env["bypass_asset_hash"] == 'true'
return [status, headers, response] if env['bypass_asset_hash'] == 'true'
path = @middleman_app.full_path(env["PATH_INFO"])
path = @middleman_app.full_path(env['PATH_INFO'])
if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
body = ::Middleman::Util.extract_response_text(response)

View file

@ -32,7 +32,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
# @param [String] path
# @param [String] prefix
# @return [String]
def asset_url(path, prefix="")
def asset_url(path, prefix='')
controller = extensions[:asset_host]
original_output = super

View file

@ -10,8 +10,8 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
# containing image name.
def image_tag(path)
if !path.include?("://")
params[:alt] ||= ""
if !path.include?('://')
params[:alt] ||= ''
real_path = path
real_path = File.join(images_dir, real_path) unless real_path.start_with?('/')
@ -19,7 +19,7 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
if File.exists?(full_path)
begin
alt_text = File.basename(full_path, ".*")
alt_text = File.basename(full_path, '.*')
alt_text.capitalize!
params[:alt] = alt_text
end

View file

@ -5,7 +5,7 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
super
# Include 3rd-party fastimage library
require "vendored-middleman-deps/fastimage"
require 'vendored-middleman-deps/fastimage'
end
helpers do
@ -16,8 +16,8 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
# @param [Hash] params
# @return [String]
def image_tag(path, params={})
if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?("://")
params[:alt] ||= ""
if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?('://')
params[:alt] ||= ''
real_path = path
real_path = File.join(images_dir, real_path) unless real_path.start_with?('/')

View file

@ -10,7 +10,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
real_path = real_path.path if real_path.is_a? File
real_path = real_path.gsub(File.join(root, build_dir), source)
if File.readable?(real_path)
File.mtime(real_path).strftime("%s")
File.mtime(real_path).strftime('%s')
else
logger.warn "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
end
@ -22,10 +22,10 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
# asset_url override if we're using cache busting
# @param [String] path
# @param [String] prefix
def asset_url(path, prefix="")
def asset_url(path, prefix='')
http_path = super
if http_path.include?("://") || !%w(.css .png .jpg .jpeg .svg .svgz .js .gif).include?(File.extname(http_path))
if http_path.include?('://') || !%w(.css .png .jpg .jpeg .svg .svgz .js .gif).include?(File.extname(http_path))
http_path
else
if respond_to?(:http_images_path) && prefix == http_images_path
@ -37,15 +37,15 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
if build?
real_path_dynamic = File.join(build_dir, prefix, path)
real_path_dynamic = File.expand_path(real_path_dynamic, root)
http_path << "?" + File.mtime(real_path_dynamic).strftime("%s") if File.readable?(real_path_dynamic)
http_path << '?' + File.mtime(real_path_dynamic).strftime('%s') if File.readable?(real_path_dynamic)
elsif resource = sitemap.find_resource_by_path(real_path_static)
if !resource.template?
http_path << "?" + File.mtime(resource.source_file).strftime("%s")
http_path << '?' + File.mtime(resource.source_file).strftime('%s')
else
# It's a template, possible with partials. We can't really
# know when it's updated, so generate fresh cache buster every
# time during developement
http_path << "?" + Time.now.strftime("%s")
http_path << '?' + Time.now.strftime('%s')
end
end

View file

@ -12,7 +12,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
# @param [Hash] options
# @return [String]
def placekitten(size, options={})
options[:domain] = "http://placekitten.com"
options[:domain] = 'http://placekitten.com'
lorem.image(size, options)
end
end
@ -110,14 +110,14 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
# Get a placeholder first name
# @return [String]
def first_name
names = "Judith Angelo Margarita Kerry Elaine Lorenzo Justice Doris Raul Liliana Kerry Elise Ciaran Johnny Moses Davion Penny Mohammed Harvey Sheryl Hudson Brendan Brooklynn Denis Sadie Trisha Jacquelyn Virgil Cindy Alexa Marianne Giselle Casey Alondra Angela Katherine Skyler Kyleigh Carly Abel Adrianna Luis Dominick Eoin Noel Ciara Roberto Skylar Brock Earl Dwayne Jackie Hamish Sienna Nolan Daren Jean Shirley Connor Geraldine Niall Kristi Monty Yvonne Tammie Zachariah Fatima Ruby Nadia Anahi Calum Peggy Alfredo Marybeth Bonnie Gordon Cara John Staci Samuel Carmen Rylee Yehudi Colm Beth Dulce Darius inley Javon Jason Perla Wayne Laila Kaleigh Maggie Don Quinn Collin Aniya Zoe Isabel Clint Leland Esmeralda Emma Madeline Byron Courtney Vanessa Terry Antoinette George Constance Preston Rolando Caleb Kenneth Lynette Carley Francesca Johnnie Jordyn Arturo Camila Skye Guy Ana Kaylin Nia Colton Bart Brendon Alvin Daryl Dirk Mya Pete Joann Uriel Alonzo Agnes Chris Alyson Paola Dora Elias Allen Jackie Eric Bonita Kelvin Emiliano Ashton Kyra Kailey Sonja Alberto Ty Summer Brayden Lori Kelly Tomas Joey Billie Katie Stephanie Danielle Alexis Jamal Kieran Lucinda Eliza Allyson Melinda Alma Piper Deana Harriet Bryce Eli Jadyn Rogelio Orlaith Janet Randal Toby Carla Lorie Caitlyn Annika Isabelle inn Ewan Maisie Michelle Grady Ida Reid Emely Tricia Beau Reese Vance Dalton Lexi Rafael Makenzie Mitzi Clinton Xena Angelina Kendrick Leslie Teddy Jerald Noelle Neil Marsha Gayle Omar Abigail Alexandra Phil Andre Billy Brenden Bianca Jared Gretchen Patrick Antonio Josephine Kyla Manuel Freya Kellie Tonia Jamie Sydney Andres Ruben Harrison Hector Clyde Wendell Kaden Ian Tracy Cathleen Shawn".split(" ")
names = 'Judith Angelo Margarita Kerry Elaine Lorenzo Justice Doris Raul Liliana Kerry Elise Ciaran Johnny Moses Davion Penny Mohammed Harvey Sheryl Hudson Brendan Brooklynn Denis Sadie Trisha Jacquelyn Virgil Cindy Alexa Marianne Giselle Casey Alondra Angela Katherine Skyler Kyleigh Carly Abel Adrianna Luis Dominick Eoin Noel Ciara Roberto Skylar Brock Earl Dwayne Jackie Hamish Sienna Nolan Daren Jean Shirley Connor Geraldine Niall Kristi Monty Yvonne Tammie Zachariah Fatima Ruby Nadia Anahi Calum Peggy Alfredo Marybeth Bonnie Gordon Cara John Staci Samuel Carmen Rylee Yehudi Colm Beth Dulce Darius inley Javon Jason Perla Wayne Laila Kaleigh Maggie Don Quinn Collin Aniya Zoe Isabel Clint Leland Esmeralda Emma Madeline Byron Courtney Vanessa Terry Antoinette George Constance Preston Rolando Caleb Kenneth Lynette Carley Francesca Johnnie Jordyn Arturo Camila Skye Guy Ana Kaylin Nia Colton Bart Brendon Alvin Daryl Dirk Mya Pete Joann Uriel Alonzo Agnes Chris Alyson Paola Dora Elias Allen Jackie Eric Bonita Kelvin Emiliano Ashton Kyra Kailey Sonja Alberto Ty Summer Brayden Lori Kelly Tomas Joey Billie Katie Stephanie Danielle Alexis Jamal Kieran Lucinda Eliza Allyson Melinda Alma Piper Deana Harriet Bryce Eli Jadyn Rogelio Orlaith Janet Randal Toby Carla Lorie Caitlyn Annika Isabelle inn Ewan Maisie Michelle Grady Ida Reid Emely Tricia Beau Reese Vance Dalton Lexi Rafael Makenzie Mitzi Clinton Xena Angelina Kendrick Leslie Teddy Jerald Noelle Neil Marsha Gayle Omar Abigail Alexandra Phil Andre Billy Brenden Bianca Jared Gretchen Patrick Antonio Josephine Kyla Manuel Freya Kellie Tonia Jamie Sydney Andres Ruben Harrison Hector Clyde Wendell Kaden Ian Tracy Cathleen Shawn'.split(' ')
names[rand(names.size)]
end
# Get a placeholder last name
# @return [String]
def last_name
names = "Chung Chen Melton Hill Puckett Song Hamilton Bender Wagner McLaughlin McNamara Raynor Moon Woodard Desai Wallace Lawrence Griffin Dougherty Powers May Steele Teague Vick Gallagher Solomon Walsh Monroe Connolly Hawkins Middleton Goldstein Watts Johnston Weeks Wilkerson Barton Walton Hall Ross Chung Bender Woods Mangum Joseph Rosenthal Bowden Barton Underwood Jones Baker Merritt Cross Cooper Holmes Sharpe Morgan Hoyle Allen Rich Rich Grant Proctor Diaz Graham Watkins Hinton Marsh Hewitt Branch Walton O'Brien Case Watts Christensen Parks Hardin Lucas Eason Davidson Whitehead Rose Sparks Moore Pearson Rodgers Graves Scarborough Sutton Sinclair Bowman Olsen Love McLean Christian Lamb James Chandler Stout Cowan Golden Bowling Beasley Clapp Abrams Tilley Morse Boykin Sumner Cassidy Davidson Heath Blanchard McAllister McKenzie Byrne Schroeder Griffin Gross Perkins Robertson Palmer Brady Rowe Zhang Hodge Li Bowling Justice Glass Willis Hester Floyd Graves Fischer Norman Chan Hunt Byrd Lane Kaplan Heller May Jennings Hanna Locklear Holloway Jones Glover Vick O'Donnell Goldman McKenna Starr Stone McClure Watson Monroe Abbott Singer Hall Farrell Lucas Norman Atkins Monroe Robertson Sykes Reid Chandler Finch Hobbs Adkins Kinney Whitaker Alexander Conner Waters Becker Rollins Love Adkins Black Fox Hatcher Wu Lloyd Joyce Welch Matthews Chappell MacDonald Kane Butler Pickett Bowman Barton Kennedy Branch Thornton McNeill Weinstein Middleton Moss Lucas Rich Carlton Brady Schultz Nichols Harvey Stevenson Houston Dunn West O'Brien Barr Snyder Cain Heath Boswell Olsen Pittman Weiner Petersen Davis Coleman Terrell Norman Burch Weiner Parrott Henry Gray Chang McLean Eason Weeks Siegel Puckett Heath Hoyle Garrett Neal Baker Goldman Shaffer Choi Carver".split(" ")
names = "Chung Chen Melton Hill Puckett Song Hamilton Bender Wagner McLaughlin McNamara Raynor Moon Woodard Desai Wallace Lawrence Griffin Dougherty Powers May Steele Teague Vick Gallagher Solomon Walsh Monroe Connolly Hawkins Middleton Goldstein Watts Johnston Weeks Wilkerson Barton Walton Hall Ross Chung Bender Woods Mangum Joseph Rosenthal Bowden Barton Underwood Jones Baker Merritt Cross Cooper Holmes Sharpe Morgan Hoyle Allen Rich Rich Grant Proctor Diaz Graham Watkins Hinton Marsh Hewitt Branch Walton O'Brien Case Watts Christensen Parks Hardin Lucas Eason Davidson Whitehead Rose Sparks Moore Pearson Rodgers Graves Scarborough Sutton Sinclair Bowman Olsen Love McLean Christian Lamb James Chandler Stout Cowan Golden Bowling Beasley Clapp Abrams Tilley Morse Boykin Sumner Cassidy Davidson Heath Blanchard McAllister McKenzie Byrne Schroeder Griffin Gross Perkins Robertson Palmer Brady Rowe Zhang Hodge Li Bowling Justice Glass Willis Hester Floyd Graves Fischer Norman Chan Hunt Byrd Lane Kaplan Heller May Jennings Hanna Locklear Holloway Jones Glover Vick O'Donnell Goldman McKenna Starr Stone McClure Watson Monroe Abbott Singer Hall Farrell Lucas Norman Atkins Monroe Robertson Sykes Reid Chandler Finch Hobbs Adkins Kinney Whitaker Alexander Conner Waters Becker Rollins Love Adkins Black Fox Hatcher Wu Lloyd Joyce Welch Matthews Chappell MacDonald Kane Butler Pickett Bowman Barton Kennedy Branch Thornton McNeill Weinstein Middleton Moss Lucas Rich Carlton Brady Schultz Nichols Harvey Stevenson Houston Dunn West O'Brien Barr Snyder Cain Heath Boswell Olsen Pittman Weiner Petersen Davis Coleman Terrell Norman Burch Weiner Parrott Henry Gray Chang McLean Eason Weeks Siegel Puckett Heath Hoyle Garrett Neal Baker Goldman Shaffer Choi Carver".split(' ')
names[rand(names.size)]
end
@ -145,7 +145,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
# @param [Hash] options
# @return [String]
def image(size, options={})
domain = options[:domain] || "http://placehold.it"
domain = options[:domain] || 'http://placehold.it'
src = "#{domain}/#{size}"
hex = %w[a b c d e f 0 1 2 3 4 5 6 7 8 9]
background_color = options[:background_color]
@ -157,7 +157,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
end
src << "/#{background_color.sub(/^#/, '')}" if background_color
src << "/ccc" if background_color.nil? && color
src << '/ccc' if background_color.nil? && color
src << "/#{color.sub(/^#/, '')}" if color
src << "&text=#{Rack::Utils::escape(options[:text])}" if options[:text]

View file

@ -47,18 +47,18 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
def call(env)
status, headers, response = @app.call(env)
if inline_html_content?(env["PATH_INFO"])
if inline_html_content?(env['PATH_INFO'])
minified = ::Middleman::Util.extract_response_text(response)
minified.gsub!(INLINE_CSS_REGEX) do |match|
$1 << @compressor.compress($2) << $3
end
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
headers['Content-Length'] = ::Rack::Utils.bytesize(minified).to_s
response = [minified]
elsif standalone_css_content?(env["PATH_INFO"])
elsif standalone_css_content?(env['PATH_INFO'])
minified_css = @compressor.compress(::Middleman::Util.extract_response_text(response))
headers["Content-Length"] = ::Rack::Utils.bytesize(minified_css).to_s
headers['Content-Length'] = ::Rack::Utils.bytesize(minified_css).to_s
response = [minified_css]
end

View file

@ -41,7 +41,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
def call(env)
status, headers, response = @app.call(env)
path = env["PATH_INFO"]
path = env['PATH_INFO']
begin
if @inline && (path.end_with?('.html') || path.end_with?('.php'))
@ -49,13 +49,13 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
minified = minify_inline_content(uncompressed_source)
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
headers['Content-Length'] = ::Rack::Utils.bytesize(minified).to_s
response = [minified]
elsif path.end_with?('.js') && @ignore.none? {|ignore| Middleman::Util.path_match(ignore, path) }
uncompressed_source = ::Middleman::Util.extract_response_text(response)
minified = @compressor.compress(uncompressed_source)
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
headers['Content-Length'] = ::Rack::Utils.bytesize(minified).to_s
response = [minified]
end
rescue ExecJS::ProgramError => e

View file

@ -15,7 +15,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
# @param [String] path
# @param [String] prefix
# @return [String]
def asset_url(path, prefix="")
def asset_url(path, prefix='')
path = super(path, prefix)
if path.include?('//') || path.start_with?('data:') || !current_resource

View file

@ -1,14 +1,14 @@
# SMACSS
class Middleman::Templates::Smacss < Middleman::Templates::Base
class_option "css_dir",
:default => "stylesheets",
class_option 'css_dir',
:default => 'stylesheets',
:desc => 'The path to the css files'
class_option "js_dir",
:default => "javascripts",
class_option 'js_dir',
:default => 'javascripts',
:desc => 'The path to the javascript files'
class_option "images_dir",
:default => "images",
class_option 'images_dir',
:default => 'images',
:desc => 'The path to the image files'
# Template files are relative to this file
@ -20,9 +20,9 @@ class Middleman::Templates::Smacss < Middleman::Templates::Base
# Output the files
# @return [void]
def build_scaffold!
template "shared/config.tt", File.join(location, "config.rb")
directory "smacss/source", File.join(location, "source")
empty_directory File.join(location, "source")
template 'shared/config.tt', File.join(location, 'config.rb')
directory 'smacss/source', File.join(location, 'source')
empty_directory File.join(location, 'source')
end
end