Implemented Rubocop
- just took a stab at running the StringLiterals cop to get a taste.
This commit is contained in:
parent
e996868033
commit
03d6e6c990
80 changed files with 510 additions and 477 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?('/')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue