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,25 +1,25 @@
|
|||
# Using Tilt for templating
|
||||
require "tilt"
|
||||
require 'tilt'
|
||||
|
||||
# i18n Built-in
|
||||
require "i18n"
|
||||
require 'i18n'
|
||||
|
||||
# Don't fail on invalid locale, that's not what our current
|
||||
# users expect.
|
||||
::I18n.config.enforce_available_locales = false
|
||||
|
||||
# Use ActiveSupport JSON
|
||||
require "active_support/json"
|
||||
require "active_support/core_ext/integer/inflections"
|
||||
require "active_support/core_ext/float/rounding"
|
||||
require 'active_support/json'
|
||||
require 'active_support/core_ext/integer/inflections'
|
||||
require 'active_support/core_ext/float/rounding'
|
||||
|
||||
# Simple callback library
|
||||
require "vendored-middleman-deps/hooks-0.2.0/lib/hooks"
|
||||
require 'vendored-middleman-deps/hooks-0.2.0/lib/hooks'
|
||||
|
||||
require "middleman-core/sitemap"
|
||||
require 'middleman-core/sitemap'
|
||||
|
||||
require "middleman-core/configuration"
|
||||
require "middleman-core/core_extensions"
|
||||
require 'middleman-core/configuration'
|
||||
require 'middleman-core/core_extensions'
|
||||
|
||||
# Core Middleman Class
|
||||
module Middleman
|
||||
|
@ -51,7 +51,7 @@ module Middleman
|
|||
# Root project directory (overwritten in middleman build/server)
|
||||
# @return [String]
|
||||
def self.root
|
||||
ENV["MM_ROOT"] || Dir.pwd
|
||||
ENV['MM_ROOT'] || Dir.pwd
|
||||
end
|
||||
delegate :root, :to => :"self.class"
|
||||
|
||||
|
@ -63,7 +63,7 @@ module Middleman
|
|||
|
||||
# Name of the source directory
|
||||
# @return [String]
|
||||
config.define_setting :source, "source", 'Name of the source directory'
|
||||
config.define_setting :source, 'source', 'Name of the source directory'
|
||||
|
||||
# Middleman environment. Defaults to :development, set to :build by the build process
|
||||
# @return [String]
|
||||
|
@ -71,7 +71,7 @@ module Middleman
|
|||
|
||||
# Which file should be used for directory indexes
|
||||
# @return [String]
|
||||
config.define_setting :index_file, "index.html", 'Which file should be used for directory indexes'
|
||||
config.define_setting :index_file, 'index.html', 'Which file should be used for directory indexes'
|
||||
|
||||
# Whether to strip the index file name off links to directory indexes
|
||||
# @return [Boolean]
|
||||
|
@ -83,35 +83,35 @@ module Middleman
|
|||
|
||||
# Location of javascripts within source.
|
||||
# @return [String]
|
||||
config.define_setting :js_dir, "javascripts", 'Location of javascripts within source'
|
||||
config.define_setting :js_dir, 'javascripts', 'Location of javascripts within source'
|
||||
|
||||
# Location of stylesheets within source. Used by Compass.
|
||||
# @return [String]
|
||||
config.define_setting :css_dir, "stylesheets", 'Location of stylesheets within source'
|
||||
config.define_setting :css_dir, 'stylesheets', 'Location of stylesheets within source'
|
||||
|
||||
# Location of images within source. Used by HTML helpers and Compass.
|
||||
# @return [String]
|
||||
config.define_setting :images_dir, "images", 'Location of images within source'
|
||||
config.define_setting :images_dir, 'images', 'Location of images within source'
|
||||
|
||||
# Location of fonts within source. Used by Compass.
|
||||
# @return [String]
|
||||
config.define_setting :fonts_dir, "fonts", 'Location of fonts within source'
|
||||
config.define_setting :fonts_dir, 'fonts', 'Location of fonts within source'
|
||||
|
||||
# Location of partials within source. Used by renderers.
|
||||
# @return [String]
|
||||
config.define_setting :partials_dir, "", 'Location of partials within source'
|
||||
config.define_setting :partials_dir, '', 'Location of partials within source'
|
||||
|
||||
# Location of layouts within source. Used by renderers.
|
||||
# @return [String]
|
||||
config.define_setting :layouts_dir, "layouts", 'Location of layouts within source'
|
||||
config.define_setting :layouts_dir, 'layouts', 'Location of layouts within source'
|
||||
|
||||
# Where to build output files
|
||||
# @return [String]
|
||||
config.define_setting :build_dir, "build", 'Where to build output files'
|
||||
config.define_setting :build_dir, 'build', 'Where to build output files'
|
||||
|
||||
# Default prefix for building paths. Used by HTML helpers and Compass.
|
||||
# @return [String]
|
||||
config.define_setting :http_prefix, "/", 'Default prefix for building paths'
|
||||
config.define_setting :http_prefix, '/', 'Default prefix for building paths'
|
||||
|
||||
# Default layout name
|
||||
# @return [String, Symbold]
|
||||
|
@ -119,7 +119,7 @@ module Middleman
|
|||
|
||||
# Default string encoding for templates and output.
|
||||
# @return [String]
|
||||
config.define_setting :encoding, "utf-8", 'Default string encoding for templates and output'
|
||||
config.define_setting :encoding, 'utf-8', 'Default string encoding for templates and output'
|
||||
|
||||
# Should Padrino include CRSF tag
|
||||
# @return [Boolean]
|
||||
|
@ -172,7 +172,7 @@ module Middleman
|
|||
# Evaluate a passed block if given
|
||||
instance_exec(&block) if block_given?
|
||||
|
||||
config[:source] = ENV["MM_SOURCE"] if ENV["MM_SOURCE"]
|
||||
config[:source] = ENV['MM_SOURCE'] if ENV['MM_SOURCE']
|
||||
|
||||
super
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Require thor since that's what the who CLI is built around
|
||||
require 'thor'
|
||||
require "thor/group"
|
||||
require 'thor/group'
|
||||
|
||||
# CLI Module
|
||||
module Middleman
|
||||
|
@ -12,18 +12,18 @@ module Middleman
|
|||
class << self
|
||||
def start(*args)
|
||||
# Change flag to a module
|
||||
ARGV.unshift("help") if ARGV.delete("--help")
|
||||
ARGV.unshift('help') if ARGV.delete('--help')
|
||||
|
||||
# Default command is server
|
||||
if ARGV[0] != "help" && (ARGV.length < 1 || ARGV.first.include?("-"))
|
||||
ARGV.unshift("server")
|
||||
if ARGV[0] != 'help' && (ARGV.length < 1 || ARGV.first.include?('-'))
|
||||
ARGV.unshift('server')
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
desc "version", "Show version"
|
||||
desc 'version', 'Show version'
|
||||
def version
|
||||
require 'middleman-core/version'
|
||||
say "Middleman #{Middleman::VERSION}"
|
||||
|
@ -36,7 +36,7 @@ module Middleman
|
|||
def help(meth = nil, subcommand = false)
|
||||
if meth && !self.respond_to?(meth)
|
||||
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
||||
klass.start(["-h", task].compact, :shell => self.shell)
|
||||
klass.start(['-h', task].compact, :shell => self.shell)
|
||||
else
|
||||
list = []
|
||||
Thor::Util.thor_classes_in(Middleman::Cli).each do |thor_class|
|
||||
|
@ -44,7 +44,7 @@ module Middleman
|
|||
end
|
||||
list.sort!{ |a,b| a[0] <=> b[0] }
|
||||
|
||||
shell.say "Tasks:"
|
||||
shell.say 'Tasks:'
|
||||
shell.print_table(list, :ident => 2, :truncate => true)
|
||||
shell.say
|
||||
end
|
||||
|
@ -62,10 +62,10 @@ module Middleman
|
|||
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
||||
|
||||
if klass.nil?
|
||||
tasks_dir = File.join(Dir.pwd, "tasks")
|
||||
tasks_dir = File.join(Dir.pwd, 'tasks')
|
||||
|
||||
if File.exists?(tasks_dir)
|
||||
Dir[File.join(tasks_dir, "**/*_task.rb")].each { |f| require f }
|
||||
Dir[File.join(tasks_dir, '**/*_task.rb')].each { |f| require f }
|
||||
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
||||
end
|
||||
end
|
||||
|
@ -82,9 +82,9 @@ module Middleman
|
|||
end
|
||||
|
||||
# Include the core CLI items
|
||||
require "middleman-core/cli/init"
|
||||
require "middleman-core/cli/bundler"
|
||||
require "middleman-core/cli/extension"
|
||||
require "middleman-core/cli/server"
|
||||
require "middleman-core/cli/build"
|
||||
require "middleman-core/cli/console"
|
||||
require 'middleman-core/cli/init'
|
||||
require 'middleman-core/cli/bundler'
|
||||
require 'middleman-core/cli/extension'
|
||||
require 'middleman-core/cli/server'
|
||||
require 'middleman-core/cli/build'
|
||||
require 'middleman-core/cli/console'
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require "middleman-core"
|
||||
require "fileutils"
|
||||
require 'middleman-core'
|
||||
require 'fileutils'
|
||||
require 'set'
|
||||
|
||||
# CLI Module
|
||||
module Middleman::Cli
|
||||
# Alias "b" to "build"
|
||||
Base.map({ "b" => "build" })
|
||||
Base.map({ 'b' => 'build' })
|
||||
|
||||
# The CLI Build class
|
||||
class Build < Thor
|
||||
|
@ -18,14 +18,14 @@ module Middleman::Cli
|
|||
|
||||
namespace :build
|
||||
|
||||
desc "build [options]", "Builds the static site for deployment"
|
||||
desc 'build [options]', 'Builds the static site for deployment'
|
||||
method_option :clean,
|
||||
:type => :boolean,
|
||||
:default => true,
|
||||
:desc => 'Remove orphaned files from build (--no-clean to disable)'
|
||||
method_option :glob,
|
||||
:type => :string,
|
||||
:aliases => "-g",
|
||||
:aliases => '-g',
|
||||
:default => nil,
|
||||
:desc => 'Build a subset of the project'
|
||||
method_option :verbose,
|
||||
|
@ -44,33 +44,33 @@ module Middleman::Cli
|
|||
# Core build Thor command
|
||||
# @return [void]
|
||||
def build
|
||||
if !ENV["MM_ROOT"]
|
||||
raise Thor::Error, "Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
|
||||
if !ENV['MM_ROOT']
|
||||
raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?'
|
||||
end
|
||||
|
||||
# Use Rack::Test for inspecting a running server for output
|
||||
require "rack"
|
||||
require "rack/test"
|
||||
require 'rack'
|
||||
require 'rack/test'
|
||||
|
||||
require 'find'
|
||||
|
||||
@debugging = Middleman::Cli::Base.respond_to?(:debugging) && Middleman::Cli::Base.debugging
|
||||
self.had_errors = false
|
||||
|
||||
self.class.shared_instance(options["verbose"], options["instrument"])
|
||||
self.class.shared_instance(options['verbose'], options['instrument'])
|
||||
|
||||
opts = {}
|
||||
opts[:glob] = options["glob"] if options.has_key?("glob")
|
||||
opts[:clean] = options["clean"]
|
||||
opts[:glob] = options['glob'] if options.has_key?('glob')
|
||||
opts[:clean] = options['clean']
|
||||
|
||||
action BuildAction.new(self, opts)
|
||||
|
||||
self.class.shared_instance.run_hook :after_build, self
|
||||
|
||||
if self.had_errors && !self.debugging
|
||||
msg = "There were errors during this build"
|
||||
unless options["verbose"]
|
||||
msg << ", re-run with `middleman build --verbose` to see the full exception."
|
||||
msg = 'There were errors during this build'
|
||||
unless options['verbose']
|
||||
msg << ', re-run with `middleman build --verbose` to see the full exception.'
|
||||
end
|
||||
self.shell.say msg, :red
|
||||
end
|
||||
|
@ -134,7 +134,7 @@ module Middleman::Cli
|
|||
base.remove_file f, :force => true
|
||||
end
|
||||
|
||||
Dir[@build_dir.join("**", "*")].select {|d| File.directory?(d) }.each do |d|
|
||||
Dir[@build_dir.join('**', '*')].select {|d| File.directory?(d) }.each do |d|
|
||||
base.remove_file d, :force => true if directory_empty? d
|
||||
end
|
||||
end
|
||||
|
@ -177,15 +177,15 @@ module Middleman::Cli
|
|||
sort_order = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .ico .woff .otf .ttf .eot .js .css)
|
||||
|
||||
# Pre-request CSS to give Compass a chance to build sprites
|
||||
logger.debug "== Prerendering CSS"
|
||||
logger.debug '== Prerendering CSS'
|
||||
|
||||
@app.sitemap.resources.select do |resource|
|
||||
resource.ext == ".css"
|
||||
resource.ext == '.css'
|
||||
end.each do |resource|
|
||||
@rack.get(URI.escape(resource.destination_path))
|
||||
end
|
||||
|
||||
logger.debug "== Checking for Compass sprites"
|
||||
logger.debug '== Checking for Compass sprites'
|
||||
|
||||
# Double-check for compass sprites
|
||||
@app.files.find_new_files((@source_dir + @app.images_dir).relative_path_from(@app.root_path))
|
||||
|
@ -195,7 +195,7 @@ module Middleman::Cli
|
|||
# find files in the build folder when it needs to generate sprites for the
|
||||
# css files
|
||||
|
||||
logger.debug "== Building files"
|
||||
logger.debug '== Building files'
|
||||
|
||||
resources = @app.sitemap.resources.sort_by do |r|
|
||||
sort_order.index(r.ext) || 100
|
||||
|
@ -222,7 +222,7 @@ module Middleman::Cli
|
|||
end
|
||||
end
|
||||
|
||||
::Middleman::Profiling.report("build")
|
||||
::Middleman::Profiling.report('build')
|
||||
end
|
||||
|
||||
# Render a resource to a file.
|
||||
|
@ -268,14 +268,14 @@ module Middleman::Cli
|
|||
if base.debugging
|
||||
raise e
|
||||
exit(1)
|
||||
elsif base.options["verbose"]
|
||||
elsif base.options['verbose']
|
||||
base.shell.say response, :red
|
||||
end
|
||||
end
|
||||
|
||||
def binary_encode(string)
|
||||
if string.respond_to?(:force_encoding)
|
||||
string.force_encoding("ascii-8bit")
|
||||
string.force_encoding('ascii-8bit')
|
||||
end
|
||||
string
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Middleman::Cli
|
|||
|
||||
namespace :bundle
|
||||
|
||||
desc "bundle", "Setup initial bundle", :hide => true
|
||||
desc 'bundle', 'Setup initial bundle', :hide => true
|
||||
|
||||
# The setup task
|
||||
def bundle
|
||||
|
@ -23,11 +23,11 @@ module Middleman::Cli
|
|||
|
||||
namespace :upgrade
|
||||
|
||||
desc "upgrade", "Upgrade installed bundle"
|
||||
desc 'upgrade', 'Upgrade installed bundle'
|
||||
|
||||
# The upgrade task
|
||||
def upgrade
|
||||
inside(ENV["MM_ROOT"]) do
|
||||
inside(ENV['MM_ROOT']) do
|
||||
run('bundle update')#, :capture => true)
|
||||
end
|
||||
end
|
||||
|
@ -35,6 +35,6 @@ module Middleman::Cli
|
|||
|
||||
# Map "u" to "upgrade"
|
||||
Base.map({
|
||||
"u" => "upgrade"
|
||||
'u' => 'upgrade'
|
||||
})
|
||||
end
|
||||
|
|
|
@ -9,18 +9,18 @@ module Middleman::Cli
|
|||
|
||||
namespace :console
|
||||
|
||||
desc "console [options]", "Start an interactive console in the context of your Middleman application"
|
||||
desc 'console [options]', 'Start an interactive console in the context of your Middleman application'
|
||||
method_option :environment,
|
||||
:aliases => "-e",
|
||||
:aliases => '-e',
|
||||
:default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
||||
:desc => "The environment Middleman will run under"
|
||||
:desc => 'The environment Middleman will run under'
|
||||
method_option :verbose,
|
||||
:type => :boolean,
|
||||
:default => false,
|
||||
:desc => 'Print debug messages'
|
||||
def console
|
||||
require "middleman-core"
|
||||
require "irb"
|
||||
require 'middleman-core'
|
||||
require 'irb'
|
||||
|
||||
opts = {
|
||||
:environment => options['environment'],
|
||||
|
|
|
@ -15,22 +15,22 @@ module Middleman::Cli
|
|||
# Template files are relative to this file
|
||||
# @return [String]
|
||||
def self.source_root
|
||||
File.join(File.dirname(__FILE__), "..", "templates", "extension")
|
||||
File.join(File.dirname(__FILE__), '..', 'templates', 'extension')
|
||||
end
|
||||
|
||||
desc "extension [options]", "Create Middleman extension scaffold NAME"
|
||||
desc 'extension [options]', 'Create Middleman extension scaffold NAME'
|
||||
|
||||
# The extension task
|
||||
# @param [String] name
|
||||
def extension
|
||||
generate_gitignore!
|
||||
template "Rakefile", File.join(name, "Rakefile")
|
||||
template "gemspec", File.join(name, "#{name}.gemspec")
|
||||
template "Gemfile", File.join(name, "Gemfile")
|
||||
template "lib/middleman_extension.rb", File.join(name, "lib", "middleman_extension.rb")
|
||||
template "lib/lib.rb", File.join(name, "lib", "#{name}.rb")
|
||||
template "features/support/env.rb", File.join(name, "features", "support", "env.rb")
|
||||
empty_directory File.join(name, "fixtures")
|
||||
template 'Rakefile', File.join(name, 'Rakefile')
|
||||
template 'gemspec', File.join(name, "#{name}.gemspec")
|
||||
template 'Gemfile', File.join(name, 'Gemfile')
|
||||
template 'lib/middleman_extension.rb', File.join(name, 'lib', 'middleman_extension.rb')
|
||||
template 'lib/lib.rb', File.join(name, 'lib', "#{name}.rb")
|
||||
template 'features/support/env.rb', File.join(name, 'features', 'support', 'env.rb')
|
||||
empty_directory File.join(name, 'fixtures')
|
||||
end
|
||||
|
||||
# Output a .gitignore file
|
||||
|
@ -41,7 +41,7 @@ module Middleman::Cli
|
|||
# @return [void]
|
||||
def generate_gitignore!
|
||||
return unless options[:git]
|
||||
copy_file "gitignore", File.join(name, ".gitignore")
|
||||
copy_file 'gitignore', File.join(name, '.gitignore')
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "middleman-core/templates"
|
||||
require 'middleman-core/templates'
|
||||
|
||||
# CLI Module
|
||||
module Middleman::Cli
|
||||
|
@ -9,35 +9,35 @@ module Middleman::Cli
|
|||
|
||||
namespace :init
|
||||
|
||||
desc "init NAME [options]", "Create new project NAME"
|
||||
available_templates = ::Middleman::Templates.registered.keys.join(", ")
|
||||
method_option "template",
|
||||
:aliases => "-T",
|
||||
:default => "default",
|
||||
desc 'init NAME [options]', 'Create new project NAME'
|
||||
available_templates = ::Middleman::Templates.registered.keys.join(', ')
|
||||
method_option 'template',
|
||||
:aliases => '-T',
|
||||
:default => 'default',
|
||||
:desc => "Use a project template: #{available_templates}"
|
||||
method_option "css_dir",
|
||||
method_option 'css_dir',
|
||||
# :default => "stylesheets",
|
||||
:desc => 'The path to the css files'
|
||||
method_option "js_dir",
|
||||
method_option 'js_dir',
|
||||
# :default => "javascripts",
|
||||
:desc => 'The path to the javascript files'
|
||||
method_option "images_dir",
|
||||
method_option 'images_dir',
|
||||
# :default => "images",
|
||||
:desc => 'The path to the image files'
|
||||
method_option "rack",
|
||||
method_option 'rack',
|
||||
:type => :boolean,
|
||||
:default => false,
|
||||
:desc => 'Include a config.ru file'
|
||||
method_option "skip-gemfile",
|
||||
method_option 'skip-gemfile',
|
||||
:type => :boolean,
|
||||
:default => false,
|
||||
:desc => "Don't create a Gemfile"
|
||||
method_option "skip-bundle",
|
||||
method_option 'skip-bundle',
|
||||
:type => :boolean,
|
||||
:aliases => "-B",
|
||||
:aliases => '-B',
|
||||
:default => false,
|
||||
:desc => "Don't run bundle install"
|
||||
method_option "skip-git",
|
||||
method_option 'skip-git',
|
||||
:type => :boolean,
|
||||
:default => false,
|
||||
:desc => 'Skip Git ignores and keeps'
|
||||
|
@ -60,8 +60,8 @@ module Middleman::Cli
|
|||
|
||||
# Map "i", "new" and "n" to "init"
|
||||
Base.map({
|
||||
"i" => "init",
|
||||
"new" => "init",
|
||||
"n" => "init"
|
||||
'i' => 'init',
|
||||
'new' => 'init',
|
||||
'n' => 'init'
|
||||
})
|
||||
end
|
||||
|
|
|
@ -7,20 +7,20 @@ module Middleman::Cli
|
|||
|
||||
namespace :server
|
||||
|
||||
desc "server [options]", "Start the preview server"
|
||||
desc 'server [options]', 'Start the preview server'
|
||||
method_option :environment,
|
||||
:aliases => "-e",
|
||||
:aliases => '-e',
|
||||
:default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
||||
:desc => "The environment Middleman will run under"
|
||||
:desc => 'The environment Middleman will run under'
|
||||
method_option :host,
|
||||
:type => :string,
|
||||
:aliases => "-h",
|
||||
:default => "0.0.0.0",
|
||||
:desc => "Bind to HOST address"
|
||||
:aliases => '-h',
|
||||
:default => '0.0.0.0',
|
||||
:desc => 'Bind to HOST address'
|
||||
method_option :port,
|
||||
:aliases => "-p",
|
||||
:default => "4567",
|
||||
:desc => "The port Middleman will listen on"
|
||||
:aliases => '-p',
|
||||
:default => '4567',
|
||||
:desc => 'The port Middleman will listen on'
|
||||
method_option :verbose,
|
||||
:type => :boolean,
|
||||
:default => false,
|
||||
|
@ -47,35 +47,35 @@ module Middleman::Cli
|
|||
:desc => 'Force file watcher into polling mode'
|
||||
method_option :latency,
|
||||
:type => :numeric,
|
||||
:aliases => "-l",
|
||||
:aliases => '-l',
|
||||
:default => 0.25,
|
||||
:desc => 'Set file watcher latency, in seconds'
|
||||
|
||||
# Start the server
|
||||
def server
|
||||
require "middleman-core"
|
||||
require "middleman-core/preview_server"
|
||||
require 'middleman-core'
|
||||
require 'middleman-core/preview_server'
|
||||
|
||||
if !ENV["MM_ROOT"]
|
||||
puts "== Could not find a Middleman project config.rb"
|
||||
puts "== Treating directory as a static site to be served"
|
||||
ENV["MM_ROOT"] = Dir.pwd
|
||||
ENV["MM_SOURCE"] = ""
|
||||
if !ENV['MM_ROOT']
|
||||
puts '== Could not find a Middleman project config.rb'
|
||||
puts '== Treating directory as a static site to be served'
|
||||
ENV['MM_ROOT'] = Dir.pwd
|
||||
ENV['MM_SOURCE'] = ''
|
||||
end
|
||||
|
||||
params = {
|
||||
:port => options["port"],
|
||||
:host => options["host"],
|
||||
:environment => options["environment"],
|
||||
:debug => options["verbose"],
|
||||
:instrumenting => options["instrument"],
|
||||
:disable_watcher => options["disable_watcher"],
|
||||
:reload_paths => options["reload_paths"],
|
||||
:force_polling => options["force_polling"],
|
||||
:latency => options["latency"]
|
||||
:port => options['port'],
|
||||
:host => options['host'],
|
||||
:environment => options['environment'],
|
||||
:debug => options['verbose'],
|
||||
:instrumenting => options['instrument'],
|
||||
:disable_watcher => options['disable_watcher'],
|
||||
:reload_paths => options['reload_paths'],
|
||||
:force_polling => options['force_polling'],
|
||||
:latency => options['latency']
|
||||
}
|
||||
|
||||
puts "== The Middleman is loading"
|
||||
puts '== The Middleman is loading'
|
||||
::Middleman::PreviewServer.start(params)
|
||||
end
|
||||
end
|
||||
|
@ -85,5 +85,5 @@ module Middleman::Cli
|
|||
end
|
||||
|
||||
# Map "s" to "server"
|
||||
Base.map({ "s" => "server" })
|
||||
Base.map({ 's' => 'server' })
|
||||
end
|
||||
|
|
|
@ -156,7 +156,7 @@ module Middleman
|
|||
def define_setting(key, default=nil, description=nil)
|
||||
raise "Setting #{key} doesn't exist" if @finalized
|
||||
raise "Setting #{key} already defined" if @settings.has_key?(key)
|
||||
raise "Setting key must be a Symbol" unless key.is_a? Symbol
|
||||
raise 'Setting key must be a Symbol' unless key.is_a? Symbol
|
||||
|
||||
@settings[key] = ConfigSetting.new(key, default, description)
|
||||
end
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
# Rack Request
|
||||
require "middleman-core/core_extensions/request"
|
||||
require 'middleman-core/core_extensions/request'
|
||||
|
||||
# File Change Notifier
|
||||
require "middleman-core/core_extensions/file_watcher"
|
||||
require 'middleman-core/core_extensions/file_watcher'
|
||||
|
||||
# Custom Feature API
|
||||
require "middleman-core/core_extensions/extensions"
|
||||
require 'middleman-core/core_extensions/extensions'
|
||||
|
||||
# Data looks at the data/ folder for YAML files and makes them available
|
||||
# to dynamic requests.
|
||||
require "middleman-core/core_extensions/data"
|
||||
require 'middleman-core/core_extensions/data'
|
||||
|
||||
# Parse YAML from templates
|
||||
require "middleman-core/core_extensions/front_matter"
|
||||
require 'middleman-core/core_extensions/front_matter'
|
||||
|
||||
# External helpers looks in the helpers/ folder for helper modules
|
||||
require "middleman-core/core_extensions/external_helpers"
|
||||
require 'middleman-core/core_extensions/external_helpers'
|
||||
|
||||
# Extended version of Padrino's rendering
|
||||
require "middleman-core/core_extensions/rendering"
|
||||
require 'middleman-core/core_extensions/rendering'
|
||||
|
||||
# Pass custom options to views
|
||||
require "middleman-core/core_extensions/routing"
|
||||
require 'middleman-core/core_extensions/routing'
|
||||
|
||||
# Catch and show exceptions at the Rack level
|
||||
require "middleman-core/core_extensions/show_exceptions"
|
||||
require 'middleman-core/core_extensions/show_exceptions'
|
||||
|
||||
# Setup default helpers
|
||||
require "middleman-more/core_extensions/default_helpers"
|
||||
require 'middleman-more/core_extensions/default_helpers'
|
||||
|
||||
require "middleman-more/core_extensions/i18n"
|
||||
require 'middleman-more/core_extensions/i18n'
|
||||
|
||||
# Compass framework
|
||||
begin
|
||||
require "middleman-more/core_extensions/compass"
|
||||
require 'middleman-more/core_extensions/compass'
|
||||
rescue LoadError
|
||||
$stderr.puts "Compass not installed: #{$!}"
|
||||
end
|
||||
|
@ -44,52 +44,52 @@ end
|
|||
|
||||
# CacheBuster adds a query string to assets in dynamic templates to
|
||||
# avoid browser caches failing to update to your new content.
|
||||
require "middleman-more/extensions/cache_buster"
|
||||
require 'middleman-more/extensions/cache_buster'
|
||||
Middleman::Extensions::CacheBuster.register
|
||||
|
||||
# RelativeAssets allow any asset path in dynamic templates to be either
|
||||
# relative to the root of the project or use an absolute URL.
|
||||
require "middleman-more/extensions/relative_assets"
|
||||
require 'middleman-more/extensions/relative_assets'
|
||||
Middleman::Extensions::RelativeAssets.register
|
||||
|
||||
# AssetHost allows you to setup multiple domains to host your static
|
||||
# assets. Calls to asset paths in dynamic templates will then rotate
|
||||
# through each of the asset servers to better spread the load.
|
||||
require "middleman-more/extensions/asset_host"
|
||||
require 'middleman-more/extensions/asset_host'
|
||||
Middleman::Extensions::AssetHost.register
|
||||
|
||||
# MinifyCss compresses CSS
|
||||
require "middleman-more/extensions/minify_css"
|
||||
require 'middleman-more/extensions/minify_css'
|
||||
Middleman::Extensions::MinifyCss.register
|
||||
|
||||
# MinifyJavascript compresses JS
|
||||
require "middleman-more/extensions/minify_javascript"
|
||||
require 'middleman-more/extensions/minify_javascript'
|
||||
Middleman::Extensions::MinifyJavascript.register
|
||||
|
||||
# GZIP assets and pages during build
|
||||
require "middleman-more/extensions/gzip"
|
||||
require 'middleman-more/extensions/gzip'
|
||||
Middleman::Extensions::Gzip.register
|
||||
|
||||
# AssetHash appends a hash of the file contents to the assets filename
|
||||
# to avoid browser caches failing to update to your new content.
|
||||
require "middleman-more/extensions/asset_hash"
|
||||
require 'middleman-more/extensions/asset_hash'
|
||||
Middleman::Extensions::AssetHash.register
|
||||
|
||||
# Provide Apache-style index.html files for directories
|
||||
require "middleman-more/extensions/directory_indexes"
|
||||
require 'middleman-more/extensions/directory_indexes'
|
||||
Middleman::Extensions::DirectoryIndexes.register
|
||||
|
||||
# Lorem provides a handful of helpful prototyping methods to generate
|
||||
# words, paragraphs, fake images, names and email addresses.
|
||||
require "middleman-more/extensions/lorem"
|
||||
require 'middleman-more/extensions/lorem'
|
||||
|
||||
# AutomaticImageSizes inspects the images used in your dynamic templates
|
||||
# and automatically adds width and height attributes to their HTML
|
||||
# elements.
|
||||
require "middleman-more/extensions/automatic_image_sizes"
|
||||
require 'middleman-more/extensions/automatic_image_sizes'
|
||||
Middleman::Extensions::AutomaticImageSizes.register
|
||||
|
||||
# AutomaticAltTags uses the file name of the `image_tag` to generate
|
||||
# a default `:alt` value.
|
||||
require "middleman-more/extensions/automatic_alt_tags"
|
||||
require 'middleman-more/extensions/automatic_alt_tags'
|
||||
Middleman::Extensions::AutomaticAltTags.register
|
||||
|
|
|
@ -10,10 +10,10 @@ module Middleman
|
|||
# @private
|
||||
def registered(app)
|
||||
# Data formats
|
||||
require "yaml"
|
||||
require "active_support/json"
|
||||
require 'yaml'
|
||||
require 'active_support/json'
|
||||
|
||||
app.config.define_setting :data_dir, "data", "The directory data files are stored in"
|
||||
app.config.define_setting :data_dir, 'data', 'The directory data files are stored in'
|
||||
app.send :include, InstanceMethods
|
||||
end
|
||||
alias :included :registered
|
||||
|
@ -101,7 +101,7 @@ module Middleman
|
|||
|
||||
if %w(.yaml .yml).include?(extension)
|
||||
data = YAML.load_file(full_path)
|
||||
elsif extension == ".json"
|
||||
elsif extension == '.json'
|
||||
data = ActiveSupport::JSON.decode(full_path.read)
|
||||
else
|
||||
return
|
||||
|
|
|
@ -45,7 +45,7 @@ module Middleman
|
|||
app.define_hook :development_config
|
||||
|
||||
app.config.define_setting :autoload_sprockets, true, 'Automatically load sprockets at startup?'
|
||||
app.config[:autoload_sprockets] = (ENV["AUTOLOAD_SPROCKETS"] == "true") if ENV["AUTOLOAD_SPROCKETS"]
|
||||
app.config[:autoload_sprockets] = (ENV['AUTOLOAD_SPROCKETS'] == 'true') if ENV['AUTOLOAD_SPROCKETS']
|
||||
|
||||
app.extend ClassMethods
|
||||
app.send :include, InstanceMethods
|
||||
|
@ -147,7 +147,7 @@ module Middleman
|
|||
|
||||
if config[:autoload_sprockets]
|
||||
begin
|
||||
require "middleman-sprockets"
|
||||
require 'middleman-sprockets'
|
||||
activate(:sprockets)
|
||||
rescue LoadError
|
||||
end
|
||||
|
@ -156,9 +156,9 @@ module Middleman
|
|||
run_hook :before_configuration
|
||||
|
||||
# Check for and evaluate local configuration
|
||||
local_config = File.join(root, "config.rb")
|
||||
local_config = File.join(root, 'config.rb')
|
||||
if File.exists? local_config
|
||||
logger.debug "== Reading: Local config"
|
||||
logger.debug '== Reading: Local config'
|
||||
instance_eval File.read(local_config), local_config, 1
|
||||
end
|
||||
|
||||
|
@ -171,14 +171,14 @@ module Middleman
|
|||
# don't completely reload middleman, I18n.load_path can get
|
||||
# polluted with paths from other test app directories that don't
|
||||
# exist anymore.
|
||||
if ENV["TEST"]
|
||||
if ENV['TEST']
|
||||
::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}}
|
||||
::I18n.reload!
|
||||
end
|
||||
|
||||
run_hook :after_configuration
|
||||
|
||||
logger.debug "Loaded extensions:"
|
||||
logger.debug 'Loaded extensions:'
|
||||
self.extensions.each do |ext, klass|
|
||||
if ext.is_a?(Hash)
|
||||
ext.each do |k,_|
|
||||
|
|
|
@ -9,8 +9,8 @@ module Middleman
|
|||
# once registered
|
||||
def registered(app)
|
||||
# Setup a default helpers paths
|
||||
app.config.define_setting :helpers_dir, "helpers", 'Directory to autoload helper modules from'
|
||||
app.config.define_setting :helpers_filename_glob, "**.rb", 'Glob pattern for matching helper ruby files'
|
||||
app.config.define_setting :helpers_dir, 'helpers', 'Directory to autoload helper modules from'
|
||||
app.config.define_setting :helpers_filename_glob, '**.rb', 'Glob pattern for matching helper ruby files'
|
||||
app.config.define_setting :helpers_filename_to_module_name_proc, Proc.new { |filename|
|
||||
basename = File.basename(filename, File.extname(filename))
|
||||
basename.camelcase
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require "pathname"
|
||||
require "set"
|
||||
require 'pathname'
|
||||
require 'set'
|
||||
|
||||
# API for watching file change events
|
||||
module Middleman
|
||||
|
@ -128,7 +128,7 @@ module Middleman
|
|||
path = Pathname(path)
|
||||
return unless path.exist?
|
||||
|
||||
glob = (path + "**").to_s
|
||||
glob = (path + '**').to_s
|
||||
subset = @known_paths.select { |p| p.fnmatch(glob) }
|
||||
|
||||
::Middleman::Util.all_files_under(path).each do |filepath|
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require "active_support/core_ext/hash/keys"
|
||||
require 'active_support/core_ext/hash/keys'
|
||||
require 'pathname'
|
||||
|
||||
# Parsing YAML frontmatter
|
||||
require "yaml"
|
||||
require 'yaml'
|
||||
|
||||
# Parsing JSON frontmatter
|
||||
require "active_support/json"
|
||||
require 'active_support/json'
|
||||
|
||||
# Extensions namespace
|
||||
module Middleman::CoreExtensions
|
||||
|
@ -108,9 +108,9 @@ module Middleman::CoreExtensions
|
|||
# Copied from Sitemap::Store#file_to_path, but without
|
||||
# removing the file extension
|
||||
file = File.join(app.root, file)
|
||||
prefix = app.source_dir.sub(/\/$/, "") + "/"
|
||||
prefix = app.source_dir.sub(/\/$/, '') + '/'
|
||||
return unless file.include?(prefix)
|
||||
path = file.sub(prefix, "").sub(/\.frontmatter$/, "")
|
||||
path = file.sub(prefix, '').sub(/\.frontmatter$/, '')
|
||||
|
||||
@cache.delete(path)
|
||||
end
|
||||
|
@ -122,7 +122,7 @@ module Middleman::CoreExtensions
|
|||
def parse_yaml_front_matter(content, full_path)
|
||||
yaml_regex = /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
||||
if content =~ yaml_regex
|
||||
content = content.sub(yaml_regex, "")
|
||||
content = content.sub(yaml_regex, '')
|
||||
|
||||
begin
|
||||
data = YAML.load($1) || {}
|
||||
|
@ -144,10 +144,10 @@ module Middleman::CoreExtensions
|
|||
json_regex = /\A(;;;\s*\n.*?\n?)^(;;;\s*$\n?)/m
|
||||
|
||||
if content =~ json_regex
|
||||
content = content.sub(json_regex, "")
|
||||
content = content.sub(json_regex, '')
|
||||
|
||||
begin
|
||||
json = ($1+$2).sub(";;;", "{").sub(";;;", "}")
|
||||
json = ($1+$2).sub(';;;', '{').sub(';;;', '}')
|
||||
data = ActiveSupport::JSON.decode(json).symbolize_keys
|
||||
rescue => e
|
||||
app.logger.error "JSON Exception parsing #{full_path}: #{e.message}"
|
||||
|
@ -196,7 +196,7 @@ module Middleman::CoreExtensions
|
|||
end
|
||||
|
||||
def normalize_path(path)
|
||||
path.sub(%r{^#{Regexp.escape(app.source_dir)}\/}, "")
|
||||
path.sub(%r{^#{Regexp.escape(app.source_dir)}\/}, '')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,65 +28,65 @@ module Middleman
|
|||
require 'active_support/core_ext/string/output_safety'
|
||||
|
||||
# Activate custom renderers
|
||||
require "middleman-core/renderers/erb"
|
||||
require 'middleman-core/renderers/erb'
|
||||
app.register Middleman::Renderers::ERb
|
||||
|
||||
# CoffeeScript Support
|
||||
begin
|
||||
require "middleman-core/renderers/coffee_script"
|
||||
require 'middleman-core/renderers/coffee_script'
|
||||
app.register Middleman::Renderers::CoffeeScript
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Haml Support
|
||||
begin
|
||||
require "middleman-core/renderers/haml"
|
||||
require 'middleman-core/renderers/haml'
|
||||
app.register Middleman::Renderers::Haml
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Sass Support
|
||||
begin
|
||||
require "middleman-core/renderers/sass"
|
||||
require 'middleman-core/renderers/sass'
|
||||
app.register Middleman::Renderers::Sass
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Markdown Support
|
||||
require "middleman-core/renderers/markdown"
|
||||
require 'middleman-core/renderers/markdown'
|
||||
app.register Middleman::Renderers::Markdown
|
||||
|
||||
# AsciiDoc Support
|
||||
begin
|
||||
require "middleman-core/renderers/asciidoc"
|
||||
require 'middleman-core/renderers/asciidoc'
|
||||
app.register Middleman::Renderers::AsciiDoc
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Liquid Support
|
||||
begin
|
||||
require "middleman-core/renderers/liquid"
|
||||
require 'middleman-core/renderers/liquid'
|
||||
app.register Middleman::Renderers::Liquid
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Slim Support
|
||||
begin
|
||||
require "middleman-core/renderers/slim"
|
||||
require 'middleman-core/renderers/slim'
|
||||
app.register Middleman::Renderers::Slim
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Less Support
|
||||
begin
|
||||
require "middleman-core/renderers/less"
|
||||
require 'middleman-core/renderers/less'
|
||||
app.register Middleman::Renderers::Less
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
# Stylus Support
|
||||
begin
|
||||
require "middleman-core/renderers/stylus"
|
||||
require 'middleman-core/renderers/stylus'
|
||||
app.register Middleman::Renderers::Stylus
|
||||
rescue LoadError
|
||||
end
|
||||
|
@ -198,7 +198,7 @@ module Middleman
|
|||
engine = File.extname(resource.source_file)[1..-1].to_sym
|
||||
|
||||
# Look for partials relative to the current path
|
||||
relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ""), data)
|
||||
relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ''), data)
|
||||
|
||||
# Try to use the current engine first
|
||||
found_partial, found_engine = resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true)
|
||||
|
@ -246,7 +246,7 @@ module Middleman
|
|||
context.current_engine, engine_was = engine, context.current_engine
|
||||
|
||||
# Save current buffer for later
|
||||
@_out_buf, _buf_was = "", @_out_buf
|
||||
@_out_buf, _buf_was = '', @_out_buf
|
||||
|
||||
# Read from disk or cache the contents of the file
|
||||
body = if opts[:template_body]
|
||||
|
@ -284,7 +284,7 @@ module Middleman
|
|||
content = callback.call(content, path, locs, template_class)
|
||||
end
|
||||
|
||||
output = ::ActiveSupport::SafeBuffer.new ""
|
||||
output = ::ActiveSupport::SafeBuffer.new ''
|
||||
output.safe_concat content
|
||||
output
|
||||
ensure
|
||||
|
@ -400,7 +400,7 @@ module Middleman
|
|||
# @return [void]
|
||||
def wrap_layout(layout_name, &block)
|
||||
# Save current buffer for later
|
||||
@_out_buf, _buf_was = "", @_out_buf
|
||||
@_out_buf, _buf_was = '', @_out_buf
|
||||
|
||||
layout_path = locate_layout(layout_name, self.current_engine)
|
||||
|
||||
|
@ -414,7 +414,7 @@ module Middleman
|
|||
content = if block_given?
|
||||
capture_html(&block)
|
||||
else
|
||||
""
|
||||
''
|
||||
end
|
||||
ensure
|
||||
# Reset stored buffer
|
||||
|
@ -450,7 +450,7 @@ module Middleman
|
|||
on_disk_path = File.expand_path(relative_path, self.source_dir)
|
||||
|
||||
# By default, any engine will do
|
||||
preferred_engine = "*"
|
||||
preferred_engine = '*'
|
||||
|
||||
# Unless we're specifically looking for a preferred engine
|
||||
if options.has_key?(:preferred_engine)
|
||||
|
@ -466,14 +466,14 @@ module Middleman
|
|||
|
||||
# Change the glob to only look for the matched extensions
|
||||
if matched_exts.length > 0
|
||||
preferred_engine = "{" + matched_exts.join(",") + "}"
|
||||
preferred_engine = '{' + matched_exts.join(',') + '}'
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# Look for files that match
|
||||
path_with_ext = on_disk_path + "." + preferred_engine
|
||||
path_with_ext = on_disk_path + '.' + preferred_engine
|
||||
|
||||
found_path = Dir[path_with_ext].find do |path|
|
||||
::Tilt[path]
|
||||
|
@ -481,8 +481,8 @@ module Middleman
|
|||
|
||||
if !found_path && options[:try_without_underscore] &&
|
||||
path_no_underscore = path_with_ext.
|
||||
sub(relative_path, relative_path.sub(/^_/, "").
|
||||
sub(/\/_/, "/"))
|
||||
sub(relative_path, relative_path.sub(/^_/, '').
|
||||
sub(/\/_/, '/'))
|
||||
found_path = Dir[path_no_underscore].find do |path|
|
||||
::Tilt[path]
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Built on Rack
|
||||
require "rack"
|
||||
require "rack/file"
|
||||
require "rack/lint"
|
||||
require "rack/head"
|
||||
require 'rack'
|
||||
require 'rack/file'
|
||||
require 'rack/lint'
|
||||
require 'rack/head'
|
||||
|
||||
module Middleman
|
||||
module CoreExtensions
|
||||
|
@ -77,7 +77,7 @@ module Middleman
|
|||
end
|
||||
|
||||
inner_app = inst(&block)
|
||||
app.map("/") { run inner_app }
|
||||
app.map('/') { run inner_app }
|
||||
|
||||
Array(@mappings).each do |path, block|
|
||||
app.map(path, &block)
|
||||
|
@ -227,7 +227,7 @@ module Middleman
|
|||
start_time = Time.now
|
||||
current_path = nil
|
||||
|
||||
request_path = URI.decode(env["PATH_INFO"].dup)
|
||||
request_path = URI.decode(env['PATH_INFO'].dup)
|
||||
if request_path.respond_to? :force_encoding
|
||||
request_path.force_encoding('UTF-8')
|
||||
end
|
||||
|
@ -296,7 +296,7 @@ module Middleman
|
|||
# Do not set Content-Type if status is 1xx, 204, 205 or 304, otherwise
|
||||
# Rack will throw an error (500)
|
||||
if !(100..199).include?(status) && ![204, 205, 304].include?(status)
|
||||
response[1]['Content-Type'] = resource.content_type || "application/octet-stream"
|
||||
response[1]['Content-Type'] = resource.content_type || 'application/octet-stream'
|
||||
end
|
||||
halt response
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module Middleman
|
|||
opts[:layout] = config[:layout] if opts[:layout].nil?
|
||||
|
||||
# If the url is a regexp
|
||||
if url.is_a?(Regexp) || url.include?("*")
|
||||
if url.is_a?(Regexp) || url.include?('*')
|
||||
|
||||
# Use the metadata loop for matching against paths at runtime
|
||||
sitemap.provides_metadata_for_path(url) do |_|
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require "active_support/core_ext/class/attribute"
|
||||
require "active_support/core_ext/module/delegation"
|
||||
require 'active_support/core_ext/class/attribute'
|
||||
require 'active_support/core_ext/module/delegation'
|
||||
|
||||
module Middleman
|
||||
|
||||
|
@ -53,7 +53,7 @@ module Middleman
|
|||
end
|
||||
|
||||
# Where to look in gems for extensions to auto-register
|
||||
EXTENSION_FILE = File.join("lib", "middleman_extension.rb") unless const_defined?(:EXTENSION_FILE)
|
||||
EXTENSION_FILE = File.join('lib', 'middleman_extension.rb') unless const_defined?(:EXTENSION_FILE)
|
||||
|
||||
class << self
|
||||
# Automatically load extensions from available RubyGems
|
||||
|
@ -61,7 +61,7 @@ module Middleman
|
|||
#
|
||||
# @private
|
||||
def load_extensions_in_path
|
||||
require "rubygems"
|
||||
require 'rubygems'
|
||||
|
||||
extensions = rubygems_latest_specs.select do |spec|
|
||||
spec_has_file?(spec, EXTENSION_FILE)
|
||||
|
@ -130,7 +130,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def extension_name
|
||||
self.ext_name || self.name.underscore.split("/").last.to_sym
|
||||
self.ext_name || self.name.underscore.split('/').last.to_sym
|
||||
end
|
||||
|
||||
def register(n=self.extension_name)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Core Pathname library used for traversal
|
||||
require "pathname"
|
||||
require 'pathname'
|
||||
|
||||
module Middleman
|
||||
|
||||
|
@ -8,20 +8,20 @@ module Middleman
|
|||
@_is_setup ||= begin
|
||||
|
||||
# Only look for config.rb if MM_ROOT isn't set
|
||||
if !ENV["MM_ROOT"] && found_path = locate_root
|
||||
ENV["MM_ROOT"] = found_path
|
||||
if !ENV['MM_ROOT'] && found_path = locate_root
|
||||
ENV['MM_ROOT'] = found_path
|
||||
end
|
||||
|
||||
is_bundler_setup = false
|
||||
|
||||
# If we've found the root, try to setup Bundler
|
||||
if ENV["MM_ROOT"]
|
||||
if ENV['MM_ROOT']
|
||||
|
||||
root_gemfile = File.expand_path('Gemfile', ENV["MM_ROOT"])
|
||||
root_gemfile = File.expand_path('Gemfile', ENV['MM_ROOT'])
|
||||
ENV['BUNDLE_GEMFILE'] ||= root_gemfile
|
||||
|
||||
if !File.exists?(ENV['BUNDLE_GEMFILE'])
|
||||
git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + "Gemfile"
|
||||
git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + 'Gemfile'
|
||||
ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Middleman
|
|||
end
|
||||
|
||||
# Automatically discover extensions in RubyGems
|
||||
require "middleman-core/extensions"
|
||||
require 'middleman-core/extensions'
|
||||
|
||||
if is_bundler_setup
|
||||
Bundler.require
|
||||
|
|
|
@ -27,7 +27,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def call(message, *args)
|
||||
return if @instrumenting.is_a?(String) && @instrumenting != "instrument" && !message.include?(@instrumenting)
|
||||
return if @instrumenting.is_a?(String) && @instrumenting != 'instrument' && !message.include?(@instrumenting)
|
||||
|
||||
evt = ActiveSupport::Notifications::Event.new(message, *args)
|
||||
self.info "== Instrument (#{evt.name.sub(/.middleman$/, '')}): #{evt.duration}ms"
|
||||
|
|
|
@ -19,7 +19,7 @@ module Middleman
|
|||
meta_pages = self
|
||||
@rack_app = Rack::Builder.new do
|
||||
# Serve assets from metadata/assets
|
||||
use Rack::Static, :urls => ["/assets"], :root => File.join(File.dirname(__FILE__), 'meta_pages')
|
||||
use Rack::Static, :urls => ['/assets'], :root => File.join(File.dirname(__FILE__), 'meta_pages')
|
||||
|
||||
map '/' do
|
||||
run meta_pages.method(:index)
|
||||
|
@ -96,7 +96,7 @@ module Middleman
|
|||
|
||||
# Respond to an HTML request
|
||||
def response(content)
|
||||
[ 200, {"Content-Type" => "text/html"}, Array(content) ]
|
||||
[ 200, {'Content-Type' => 'text/html'}, Array(content) ]
|
||||
end
|
||||
|
||||
def extension_options(extension)
|
||||
|
|
|
@ -10,18 +10,18 @@ module Middleman
|
|||
end
|
||||
|
||||
def render
|
||||
content = ""
|
||||
content = ''
|
||||
key_classes = ['key']
|
||||
key_classes << 'modified' if @setting.value_set?
|
||||
content << content_tag(:span, @setting.key.inspect, :class => key_classes.join(' '))
|
||||
content << " = "
|
||||
content << ' = '
|
||||
content << content_tag(:span, @setting.value.inspect, :class => 'value')
|
||||
if @setting.default
|
||||
content << content_tag(:span, :class => 'default') do
|
||||
if @setting.value_set?
|
||||
"Default: #{@setting.default.inspect}"
|
||||
else
|
||||
"(Default)"
|
||||
'(Default)'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,10 +17,10 @@ module Middleman
|
|||
def render
|
||||
content_tag :div, :class => 'resource-details' do
|
||||
content_tag :table do
|
||||
content = ""
|
||||
content = ''
|
||||
resource_properties.each do |label, value|
|
||||
content << content_tag(:tr) do
|
||||
row_content = ""
|
||||
row_content = ''
|
||||
row_content << content_tag(:th, label)
|
||||
row_content << content_tag(:td, value)
|
||||
row_content.html_safe
|
||||
|
|
|
@ -13,7 +13,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def render
|
||||
content = ""
|
||||
content = ''
|
||||
@children.keys.sort do |a,b|
|
||||
a_subtree = @children[a]
|
||||
b_subtree = @children[b]
|
||||
|
@ -35,11 +35,11 @@ module Middleman
|
|||
end.each do |path_part|
|
||||
subtree = @children[path_part]
|
||||
content << "<details class='#{subtree.css_classes.join(' ')}'>"
|
||||
content << "<summary>"
|
||||
content << '<summary>'
|
||||
content << "<i class='icon-folder-open'></i>" unless subtree.is_a? SitemapResource
|
||||
content << "#{path_part}</summary>"
|
||||
content << subtree.render
|
||||
content << "</details>"
|
||||
content << '</details>'
|
||||
end
|
||||
content
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def to_s
|
||||
"Sitemap Tree"
|
||||
'Sitemap Tree'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "webrick"
|
||||
require 'webrick'
|
||||
require 'middleman-core/meta_pages'
|
||||
|
||||
module Middleman
|
||||
|
@ -29,7 +29,7 @@ module Middleman
|
|||
|
||||
# Save the last-used @options so it may be re-used when
|
||||
# reloading later on.
|
||||
::Middleman::Profiling.report("server_start")
|
||||
::Middleman::Profiling.report('server_start')
|
||||
|
||||
loop do
|
||||
@webrick.start
|
||||
|
@ -50,7 +50,7 @@ module Middleman
|
|||
# @return [void]
|
||||
def stop
|
||||
begin
|
||||
logger.info "== The Middleman is shutting down"
|
||||
logger.info '== The Middleman is shutting down'
|
||||
rescue
|
||||
# if the user closed their terminal STDOUT/STDERR won't exist
|
||||
end
|
||||
|
@ -65,20 +65,20 @@ module Middleman
|
|||
# Simply stop, then start the server
|
||||
# @return [void]
|
||||
def reload
|
||||
logger.info "== The Middleman is reloading"
|
||||
logger.info '== The Middleman is reloading'
|
||||
|
||||
begin
|
||||
app = new_app
|
||||
rescue Exception => e
|
||||
logger.error "Error reloading Middleman: #{e}\n#{e.backtrace.join("\n")}"
|
||||
logger.info "== The Middleman is still running the application from before the error"
|
||||
logger.info '== The Middleman is still running the application from before the error'
|
||||
return
|
||||
end
|
||||
|
||||
unmount_instance
|
||||
mount_instance(app)
|
||||
|
||||
logger.info "== The Middleman has reloaded"
|
||||
logger.info '== The Middleman has reloaded'
|
||||
end
|
||||
|
||||
# Stop the current instance, exit Webrick
|
||||
|
@ -115,7 +115,7 @@ module Middleman
|
|||
|
||||
if first_run
|
||||
# Watcher Library
|
||||
require "listen"
|
||||
require 'listen'
|
||||
@listener = Listen.to(Dir.pwd, :relative_paths => true, :force_polling => @options[:force_polling])
|
||||
@listener.latency(@options[:latency])
|
||||
end
|
||||
|
@ -190,13 +190,13 @@ module Middleman
|
|||
start_file_watcher
|
||||
|
||||
rack_app = app.class.to_rack_app
|
||||
@webrick.mount "/", ::Rack::Handler::WEBrick, rack_app
|
||||
@webrick.mount '/', ::Rack::Handler::WEBrick, rack_app
|
||||
end
|
||||
|
||||
# Detach the current Middleman::Application instance
|
||||
# @return [void]
|
||||
def unmount_instance
|
||||
@webrick.unmount "/"
|
||||
@webrick.unmount '/'
|
||||
@app = nil
|
||||
end
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ module Middleman
|
|||
result = RubyProf.stop
|
||||
|
||||
printer = RubyProf::GraphHtmlPrinter.new(result)
|
||||
outfile = File.join("profile", report_name)
|
||||
outfile = File.join('profile', report_name)
|
||||
outfile = (outfile + '.html') unless outfile.end_with? '.html'
|
||||
FileUtils.mkdir_p(File.dirname(outfile))
|
||||
File.open(outfile, 'w') do |f|
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Require gem
|
||||
require "coffee_script"
|
||||
require 'coffee_script'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
|
|
@ -21,7 +21,7 @@ module Middleman
|
|||
# Convert symbols to classes
|
||||
if config[:erb_engine].is_a? Symbol
|
||||
engine = engine.to_s
|
||||
engine = engine == "erb" ? "ERB" : engine.camelize
|
||||
engine = engine == 'erb' ? 'ERB' : engine.camelize
|
||||
config[:erb_engine] = config[:erb_engine_prefix].const_get("#{engine}Template")
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Require gem
|
||||
require "haml"
|
||||
require 'haml'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "kramdown"
|
||||
require 'kramdown'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
@ -30,7 +30,7 @@ module Middleman
|
|||
|
||||
if el.attr['href'] =~ /\Amailto:/
|
||||
mail_addr = el.attr['href'].sub(/\Amailto:/, '')
|
||||
href = obfuscate('mailto') << ":" << obfuscate(mail_addr)
|
||||
href = obfuscate('mailto') << ':' << obfuscate(mail_addr)
|
||||
content = obfuscate(content) if content == mail_addr
|
||||
return %Q{<a href="#{href}">#{content}</a>}
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "less"
|
||||
require 'less'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
@ -37,7 +37,7 @@ module Middleman
|
|||
if ::Less.const_defined? :Engine
|
||||
@engine = ::Less::Engine.new(data)
|
||||
else
|
||||
parser = ::Less::Parser.new(options.merge :filename => eval_file, :line => line, :paths => [".", File.dirname(eval_file)])
|
||||
parser = ::Less::Parser.new(options.merge :filename => eval_file, :line => line, :paths => ['.', File.dirname(eval_file)])
|
||||
@engine = parser.parse(data)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Require Gem
|
||||
require "liquid"
|
||||
require 'liquid'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
|
|
@ -28,18 +28,18 @@ module Middleman
|
|||
begin
|
||||
# Look for the user's preferred engine
|
||||
if config[:markdown_engine] == :redcarpet
|
||||
require "middleman-core/renderers/redcarpet"
|
||||
require 'middleman-core/renderers/redcarpet'
|
||||
::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate, *markdown_exts)
|
||||
MiddlemanRedcarpetHTML.middleman_app = self
|
||||
elsif config[:markdown_engine] == :kramdown
|
||||
require "middleman-core/renderers/kramdown"
|
||||
require 'middleman-core/renderers/kramdown'
|
||||
::Tilt.prefer(::Middleman::Renderers::KramdownTemplate, *markdown_exts)
|
||||
MiddlemanKramdownHTML.middleman_app = self
|
||||
elsif !config[:markdown_engine].nil?
|
||||
# Map symbols to classes
|
||||
markdown_engine_klass = if config[:markdown_engine].is_a? Symbol
|
||||
engine = config[:markdown_engine].to_s
|
||||
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
|
||||
engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize
|
||||
config[:markdown_engine_prefix].const_get("#{engine}Template")
|
||||
else
|
||||
config[:markdown_engine_prefix]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "redcarpet"
|
||||
require 'redcarpet'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "sass"
|
||||
require 'sass'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
@ -79,7 +79,7 @@ module Middleman
|
|||
|
||||
parts = basename.split('.')
|
||||
parts.pop
|
||||
more_opts[:css_filename] = File.join(location_of_sass_file, @context.config[:css_dir], parts.join("."))
|
||||
more_opts[:css_filename] = File.join(location_of_sass_file, @context.config[:css_dir], parts.join('.'))
|
||||
end
|
||||
|
||||
options.merge(more_opts)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Load gem
|
||||
require "slim"
|
||||
require 'slim'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require "stylus"
|
||||
require "stylus/tilt"
|
||||
require 'stylus'
|
||||
require 'stylus/tilt'
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require "middleman-core/sitemap/store"
|
||||
require "middleman-core/sitemap/resource"
|
||||
require 'middleman-core/sitemap/store'
|
||||
require 'middleman-core/sitemap/resource'
|
||||
|
||||
require "middleman-core/sitemap/extensions/on_disk"
|
||||
require "middleman-core/sitemap/extensions/redirects"
|
||||
require "middleman-core/sitemap/extensions/request_endpoints"
|
||||
require "middleman-core/sitemap/extensions/proxies"
|
||||
require "middleman-core/sitemap/extensions/ignores"
|
||||
require 'middleman-core/sitemap/extensions/on_disk'
|
||||
require 'middleman-core/sitemap/extensions/redirects'
|
||||
require 'middleman-core/sitemap/extensions/request_endpoints'
|
||||
require 'middleman-core/sitemap/extensions/proxies'
|
||||
require 'middleman-core/sitemap/extensions/ignores'
|
||||
|
||||
# Core Sitemap Extensions
|
||||
module Middleman
|
||||
|
|
|
@ -28,7 +28,7 @@ module Middleman
|
|||
def ignored?
|
||||
@app.ignore_manager.ignored?(path) ||
|
||||
(!proxy? &&
|
||||
@app.ignore_manager.ignored?(source_file.sub("#{@app.source_dir}/", ""))
|
||||
@app.ignore_manager.ignored?(source_file.sub("#{@app.source_dir}/", ''))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -64,7 +64,7 @@ module Middleman
|
|||
@ignored_callbacks << Proc.new {|p| p =~ path }
|
||||
elsif path.is_a? String
|
||||
path_clean = ::Middleman::Util.normalize_path(path)
|
||||
if path_clean.include?("*") # It's a glob
|
||||
if path_clean.include?('*') # It's a glob
|
||||
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
|
||||
else
|
||||
# Add a specific-path ignore unless that path is already covered
|
||||
|
|
|
@ -8,7 +8,7 @@ module Middleman
|
|||
# This resource's parent resource
|
||||
# @return [Middleman::Sitemap::Resource, nil]
|
||||
def parent
|
||||
parts = path.split("/")
|
||||
parts = path.split('/')
|
||||
parts.pop if path.include?(app.index_file)
|
||||
|
||||
return nil if parts.length < 1
|
||||
|
@ -16,7 +16,7 @@ module Middleman
|
|||
parts.pop
|
||||
parts << app.index_file
|
||||
|
||||
parent_path = "/" + parts.join("/")
|
||||
parent_path = '/' + parts.join('/')
|
||||
|
||||
store.find_resource_by_destination_path(parent_path)
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ module Middleman
|
|||
base_path = eponymous_directory_path
|
||||
prefix = %r|^#{base_path.sub("/", "\\/")}|
|
||||
else
|
||||
base_path = path.sub("#{app.index_file}", "")
|
||||
base_path = path.sub("#{app.index_file}", '')
|
||||
prefix = %r|^#{base_path.sub("/", "\\/")}|
|
||||
end
|
||||
|
||||
|
@ -38,8 +38,8 @@ module Middleman
|
|||
if sub_resource.path == self.path || sub_resource.path !~ prefix
|
||||
false
|
||||
else
|
||||
inner_path = sub_resource.path.sub(prefix, "")
|
||||
parts = inner_path.split("/")
|
||||
inner_path = sub_resource.path.sub(prefix, '')
|
||||
parts = inner_path.split('/')
|
||||
if parts.length == 1
|
||||
true
|
||||
elsif parts.length == 2
|
||||
|
@ -79,7 +79,7 @@ module Middleman
|
|||
# (e.g., for 'gallery.html' this would return 'gallery/')
|
||||
# @return [String]
|
||||
def eponymous_directory_path
|
||||
path.sub(ext, '/').sub(/\/$/, "") + "/"
|
||||
path.sub(ext, '/').sub(/\/$/, '') + '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "active_support/core_ext/object/inclusion"
|
||||
require 'active_support/core_ext/object/inclusion'
|
||||
|
||||
module Middleman
|
||||
module Sitemap
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require "middleman-core/sitemap/extensions/traversal"
|
||||
require "middleman-core/sitemap/extensions/content_type"
|
||||
require 'middleman-core/sitemap/extensions/traversal'
|
||||
require 'middleman-core/sitemap/extensions/content_type'
|
||||
|
||||
module Middleman
|
||||
|
||||
|
@ -111,14 +111,14 @@ module Middleman
|
|||
|
||||
relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))
|
||||
|
||||
instrument "render.resource", :path => relative_source do
|
||||
instrument 'render.resource', :path => relative_source do
|
||||
md = metadata.dup
|
||||
opts = md[:options].deep_merge(opts)
|
||||
|
||||
# Pass "renderer_options" hash from frontmatter along to renderer
|
||||
if md[:page]["renderer_options"]
|
||||
if md[:page]['renderer_options']
|
||||
opts[:renderer_options] = {}
|
||||
md[:page]["renderer_options"].each do |k, v|
|
||||
md[:page]['renderer_options'].each do |k, v|
|
||||
opts[:renderer_options][k.to_sym] = v
|
||||
end
|
||||
end
|
||||
|
@ -127,7 +127,7 @@ module Middleman
|
|||
|
||||
# Forward remaining data to helpers
|
||||
if md.has_key?(:page)
|
||||
app.data.store("page", md[:page])
|
||||
app.data.store('page', md[:page])
|
||||
end
|
||||
|
||||
blocks = Array(md[:blocks]).dup
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Used for merging results of metadata callbacks
|
||||
require "active_support/core_ext/hash/deep_merge"
|
||||
require 'active_support/core_ext/hash/deep_merge'
|
||||
require 'monitor'
|
||||
require "middleman-core/sitemap/queryable"
|
||||
require 'middleman-core/sitemap/queryable'
|
||||
|
||||
module Middleman
|
||||
|
||||
|
@ -161,7 +161,7 @@ module Middleman
|
|||
when Regexp
|
||||
next result unless request_path =~ matcher
|
||||
when String
|
||||
next result unless File.fnmatch("/" + Util.strip_leading_slash(matcher), "/#{request_path}")
|
||||
next result unless File.fnmatch('/' + Util.strip_leading_slash(matcher), "/#{request_path}")
|
||||
end
|
||||
|
||||
metadata = callback.call(request_path).dup
|
||||
|
@ -178,14 +178,14 @@ module Middleman
|
|||
def file_to_path(file)
|
||||
file = File.join(@app.root, file)
|
||||
|
||||
prefix = @app.source_dir.sub(/\/$/, "") + "/"
|
||||
prefix = @app.source_dir.sub(/\/$/, '') + '/'
|
||||
return false unless file.start_with?(prefix)
|
||||
|
||||
path = file.sub(prefix, "")
|
||||
path = file.sub(prefix, '')
|
||||
|
||||
# Replace a file name containing automatic_directory_matcher with a folder
|
||||
unless @app.config[:automatic_directory_matcher].nil?
|
||||
path = path.gsub(@app.config[:automatic_directory_matcher], "/")
|
||||
path = path.gsub(@app.config[:automatic_directory_matcher], '/')
|
||||
end
|
||||
|
||||
extensionless_path(path)
|
||||
|
@ -211,7 +211,7 @@ module Middleman
|
|||
return unless @needs_sitemap_rebuild
|
||||
@needs_sitemap_rebuild = false
|
||||
|
||||
@app.logger.debug "== Rebuilding resource list"
|
||||
@app.logger.debug '== Rebuilding resource list'
|
||||
|
||||
@resources = @resource_list_manipulators.inject([]) do |result, (_, inst)|
|
||||
newres = inst.manipulate_resource_list(result)
|
||||
|
@ -244,7 +244,7 @@ module Middleman
|
|||
# @return [String]
|
||||
def remove_templating_extensions(path)
|
||||
# Strip templating extensions as long as Tilt knows them
|
||||
path = path.sub(File.extname(path), "") while ::Tilt[path]
|
||||
path = path.sub(File.extname(path), '') while ::Tilt[path]
|
||||
path
|
||||
end
|
||||
|
||||
|
@ -270,7 +270,7 @@ module Middleman
|
|||
input_ext = File.extname(file)
|
||||
|
||||
if !input_ext.empty?
|
||||
input_ext = input_ext.split(".").last.to_sym
|
||||
input_ext = input_ext.split('.').last.to_sym
|
||||
if @app.template_extensions.has_key?(input_ext)
|
||||
path << ".#{@app.template_extensions[input_ext]}"
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, "bin")
|
||||
MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, 'bin')
|
||||
ENV['PATH'] = "#{MIDDLEMAN_BIN_PATH}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
||||
|
||||
require "aruba/cucumber"
|
||||
require "middleman-core/step_definitions/middleman_steps"
|
||||
require "middleman-core/step_definitions/builder_steps"
|
||||
require "middleman-core/step_definitions/server_steps"
|
||||
require 'aruba/cucumber'
|
||||
require 'middleman-core/step_definitions/middleman_steps'
|
||||
require 'middleman-core/step_definitions/builder_steps'
|
||||
require 'middleman-core/step_definitions/server_steps'
|
||||
|
||||
Before do
|
||||
@aruba_timeout_seconds = 30
|
||||
|
|
|
@ -5,20 +5,20 @@ Before do
|
|||
end
|
||||
|
||||
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
|
||||
target = File.join(PROJECT_ROOT_PATH, "fixtures", path)
|
||||
target = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
||||
config_path = File.join(current_dir, "config-#{config_name}.rb")
|
||||
config_dest = File.join(current_dir, "config.rb")
|
||||
config_dest = File.join(current_dir, 'config.rb')
|
||||
FileUtils.cp(config_path, config_dest)
|
||||
end
|
||||
|
||||
Given /^an empty app$/ do
|
||||
step %Q{a directory named "empty_app"}
|
||||
step %Q{I cd to "empty_app"}
|
||||
ENV["MM_ROOT"] = nil
|
||||
ENV['MM_ROOT'] = nil
|
||||
end
|
||||
|
||||
Given /^a fixture app "([^\"]*)"$/ do |path|
|
||||
ENV["MM_ROOT"] = nil
|
||||
ENV['MM_ROOT'] = nil
|
||||
|
||||
# This step can be reentered from several places but we don't want
|
||||
# to keep re-copying and re-cd-ing into ever-deeper directories
|
||||
|
@ -26,7 +26,7 @@ Given /^a fixture app "([^\"]*)"$/ do |path|
|
|||
|
||||
step %Q{a directory named "#{path}"}
|
||||
|
||||
target_path = File.join(PROJECT_ROOT_PATH, "fixtures", path)
|
||||
target_path = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
||||
FileUtils.cp_r(target_path, current_dir)
|
||||
|
||||
step %Q{I cd to "#{path}"}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require "rack/test"
|
||||
require 'rack/test'
|
||||
|
||||
Given /^a clean server$/ do
|
||||
@initialize_commands = []
|
||||
|
@ -9,7 +9,7 @@ end
|
|||
Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
|
||||
@initialize_commands ||= []
|
||||
|
||||
if state == "enabled"
|
||||
if state == 'enabled'
|
||||
@initialize_commands << lambda { activate(feature.to_sym) }
|
||||
end
|
||||
end
|
||||
|
@ -34,13 +34,13 @@ end
|
|||
Given /^the Server is running$/ do
|
||||
root_dir = File.expand_path(current_dir)
|
||||
|
||||
if File.exists?(File.join(root_dir, "source"))
|
||||
ENV["MM_SOURCE"] = "source"
|
||||
if File.exists?(File.join(root_dir, 'source'))
|
||||
ENV['MM_SOURCE'] = 'source'
|
||||
else
|
||||
ENV["MM_SOURCE"] = ""
|
||||
ENV['MM_SOURCE'] = ''
|
||||
end
|
||||
|
||||
ENV["MM_ROOT"] = root_dir
|
||||
ENV['MM_ROOT'] = root_dir
|
||||
|
||||
initialize_commands = @initialize_commands || []
|
||||
initialize_commands.unshift lambda {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Use thor for template generation
|
||||
require "thor"
|
||||
require "thor/group"
|
||||
require 'thor'
|
||||
require 'thor/group'
|
||||
|
||||
# Templates namespace
|
||||
module Middleman::Templates
|
||||
|
@ -37,14 +37,14 @@ module Middleman::Templates
|
|||
# The gemfile template to use. Individual templates can define this class
|
||||
# method to override the template path.
|
||||
def self.gemfile_template
|
||||
"shared/Gemfile.tt"
|
||||
'shared/Gemfile.tt'
|
||||
end
|
||||
|
||||
# Required path for the new project to be generated
|
||||
argument :location, :type => :string
|
||||
|
||||
# Name of the template being used to generate the project.
|
||||
class_option :template, :default => "default"
|
||||
class_option :template, :default => 'default'
|
||||
|
||||
# Output a config.ru file for Rack if --rack is passed
|
||||
class_option :rack, :type => :boolean, :default => false
|
||||
|
@ -53,7 +53,7 @@ module Middleman::Templates
|
|||
# @return [void]
|
||||
def generate_rack!
|
||||
return unless options[:rack]
|
||||
template "shared/config.ru", File.join(location, "config.ru")
|
||||
template 'shared/config.ru', File.join(location, 'config.ru')
|
||||
end
|
||||
|
||||
class_option :'skip-bundle', :type => :boolean, :default => false
|
||||
|
@ -63,12 +63,12 @@ module Middleman::Templates
|
|||
# @return [void]
|
||||
def generate_bundler!
|
||||
return if options[:'skip-gemfile']
|
||||
template self.class.gemfile_template, File.join(location, "Gemfile")
|
||||
template self.class.gemfile_template, File.join(location, 'Gemfile')
|
||||
|
||||
return if options[:'skip-bundle']
|
||||
inside(location) do
|
||||
::Middleman::Cli::Bundle.new.invoke(:bundle)
|
||||
end unless ENV["TEST"]
|
||||
end unless ENV['TEST']
|
||||
end
|
||||
|
||||
# Output a .gitignore file
|
||||
|
@ -78,25 +78,25 @@ module Middleman::Templates
|
|||
# @return [void]
|
||||
def generate_gitignore!
|
||||
return if options[:'skip-git']
|
||||
copy_file "shared/gitignore", File.join(location, ".gitignore")
|
||||
copy_file 'shared/gitignore', File.join(location, '.gitignore')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Default template
|
||||
require "middleman-core/templates/default"
|
||||
require 'middleman-core/templates/default'
|
||||
|
||||
# HTML5 template
|
||||
require "middleman-core/templates/html5"
|
||||
require 'middleman-core/templates/html5'
|
||||
|
||||
# HTML5 Mobile template
|
||||
require "middleman-core/templates/mobile"
|
||||
require 'middleman-core/templates/mobile'
|
||||
|
||||
# SMACSS templates
|
||||
require "middleman-more/templates/smacss"
|
||||
require 'middleman-more/templates/smacss'
|
||||
|
||||
# Local templates
|
||||
require "middleman-core/templates/local"
|
||||
require 'middleman-core/templates/local'
|
||||
|
||||
# Barebones template
|
||||
require "middleman-core/templates/empty"
|
||||
require 'middleman-core/templates/empty'
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# Default Middleman template
|
||||
class Middleman::Templates::Default < 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,17 +20,17 @@ class Middleman::Templates::Default < Middleman::Templates::Base
|
|||
# Actually output the files
|
||||
# @return [void]
|
||||
def build_scaffold!
|
||||
template "shared/config.tt", File.join(location, "config.rb")
|
||||
copy_file "default/source/index.html.erb", File.join(location, "source/index.html.erb")
|
||||
copy_file "default/source/layouts/layout.erb", File.join(location, "source/layouts/layout.erb")
|
||||
empty_directory File.join(location, "source", options[:css_dir])
|
||||
copy_file "default/source/stylesheets/all.css", File.join(location, "source", options[:css_dir], "all.css")
|
||||
copy_file "default/source/stylesheets/normalize.css", File.join(location, "source", options[:css_dir], "normalize.css")
|
||||
empty_directory File.join(location, "source", options[:js_dir])
|
||||
copy_file "default/source/javascripts/all.js", File.join(location, "source", options[:js_dir], "all.js")
|
||||
empty_directory File.join(location, "source", options[:images_dir])
|
||||
copy_file "default/source/images/background.png", File.join(location, "source", options[:images_dir], "background.png")
|
||||
copy_file "default/source/images/middleman.png", File.join(location, "source", options[:images_dir], "middleman.png")
|
||||
template 'shared/config.tt', File.join(location, 'config.rb')
|
||||
copy_file 'default/source/index.html.erb', File.join(location, 'source/index.html.erb')
|
||||
copy_file 'default/source/layouts/layout.erb', File.join(location, 'source/layouts/layout.erb')
|
||||
empty_directory File.join(location, 'source', options[:css_dir])
|
||||
copy_file 'default/source/stylesheets/all.css', File.join(location, 'source', options[:css_dir], 'all.css')
|
||||
copy_file 'default/source/stylesheets/normalize.css', File.join(location, 'source', options[:css_dir], 'normalize.css')
|
||||
empty_directory File.join(location, 'source', options[:js_dir])
|
||||
copy_file 'default/source/javascripts/all.js', File.join(location, 'source', options[:js_dir], 'all.js')
|
||||
empty_directory File.join(location, 'source', options[:images_dir])
|
||||
copy_file 'default/source/images/background.png', File.join(location, 'source', options[:images_dir], 'background.png')
|
||||
copy_file 'default/source/images/middleman.png', File.join(location, 'source', options[:images_dir], 'middleman.png')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ class Middleman::Templates::Empty < Middleman::Templates::Base
|
|||
end
|
||||
|
||||
def self.gemfile_template
|
||||
"empty/Gemfile.tt"
|
||||
'empty/Gemfile.tt'
|
||||
end
|
||||
|
||||
# Actually output the files
|
||||
# @return [void]
|
||||
def build_scaffold!
|
||||
create_file File.join(location, "config.rb"), "\n"
|
||||
empty_directory File.join(location, "source")
|
||||
create_file File.join(location, 'config.rb'), "\n"
|
||||
empty_directory File.join(location, 'source')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,6 +9,6 @@ end
|
|||
|
||||
require 'rake/clean'
|
||||
|
||||
task :test => ["cucumber"]
|
||||
task :test => ['cucumber']
|
||||
|
||||
task :default => :test
|
|
@ -1,4 +1,4 @@
|
|||
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
require "middleman-core"
|
||||
require "middleman-core/step_definitions"
|
||||
require 'middleman-core'
|
||||
require 'middleman-core/step_definitions'
|
||||
require File.join(PROJECT_ROOT_PATH, 'lib', '<%= name %>')
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Require core library
|
||||
require "middleman-core"
|
||||
require 'middleman-core'
|
||||
|
||||
# Extension namespace
|
||||
class MyExtension < ::Middleman::Extension
|
||||
option :my_option, "default", "An example option"
|
||||
option :my_option, 'default', 'An example option'
|
||||
|
||||
def initialize(app, options_hash={}, &block)
|
||||
# Call super to build options from the options_hash
|
||||
|
|
|
@ -1 +1 @@
|
|||
require "<%= name %>"
|
||||
require '<%= name %>'
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# HTML5 Boilerplate template
|
||||
class Middleman::Templates::Html5 < Middleman::Templates::Base
|
||||
|
||||
class_option "css_dir",
|
||||
:default => "css",
|
||||
class_option 'css_dir',
|
||||
:default => 'css',
|
||||
:desc => 'The path to the css files'
|
||||
class_option "js_dir",
|
||||
:default => "js",
|
||||
class_option 'js_dir',
|
||||
:default => 'js',
|
||||
:desc => 'The path to the javascript files'
|
||||
class_option "images_dir",
|
||||
:default => "img",
|
||||
class_option 'images_dir',
|
||||
:default => 'img',
|
||||
:desc => 'The path to the image files'
|
||||
|
||||
# Templates are relative to this file
|
||||
|
@ -20,9 +20,9 @@ class Middleman::Templates::Html5 < Middleman::Templates::Base
|
|||
# Output the files
|
||||
# @return [void]
|
||||
def build_scaffold!
|
||||
template "shared/config.tt", File.join(location, "config.rb")
|
||||
directory "html5/source", File.join(location, "source")
|
||||
empty_directory File.join(location, "source")
|
||||
template 'shared/config.tt', File.join(location, 'config.rb')
|
||||
directory 'html5/source', File.join(location, 'source')
|
||||
empty_directory File.join(location, 'source')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class Middleman::Templates::Local < Middleman::Templates::Base
|
|||
# Look for templates in ~/.middleman
|
||||
# @return [String]
|
||||
def self.source_root
|
||||
File.join(File.expand_path("~/"), ".middleman")
|
||||
File.join(File.expand_path('~/'), '.middleman')
|
||||
end
|
||||
|
||||
# Just copy from the template path
|
||||
|
@ -15,10 +15,10 @@ class Middleman::Templates::Local < Middleman::Templates::Base
|
|||
end
|
||||
|
||||
# Iterate over the directories in the templates path and register each one.
|
||||
Dir[File.join(Middleman::Templates::Local.source_root, "*")].each do |dir|
|
||||
Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir|
|
||||
next unless File.directory?(dir)
|
||||
|
||||
template_file = File.join(dir, "template.rb")
|
||||
template_file = File.join(dir, 'template.rb')
|
||||
|
||||
if File.exists?(template_file)
|
||||
require template_file
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
class Middleman::Templates::Mobile < Middleman::Templates::Base
|
||||
|
||||
# Slightly different paths
|
||||
class_option :css_dir, :default => "css"
|
||||
class_option :js_dir, :default => "js"
|
||||
class_option :images_dir, :default => "img"
|
||||
class_option :css_dir, :default => 'css'
|
||||
class_option :js_dir, :default => 'js'
|
||||
class_option :images_dir, :default => 'img'
|
||||
|
||||
# Template files are relative to this file
|
||||
# @return [String]
|
||||
|
@ -15,9 +15,9 @@ class Middleman::Templates::Mobile < Middleman::Templates::Base
|
|||
# Output the files
|
||||
# @return [void]
|
||||
def build_scaffold!
|
||||
template "shared/config.tt", File.join(location, "config.rb")
|
||||
directory "mobile/source", File.join(location, "source")
|
||||
empty_directory File.join(location, "source")
|
||||
template 'shared/config.tt', File.join(location, 'config.rb')
|
||||
directory 'mobile/source', File.join(location, 'source')
|
||||
empty_directory File.join(location, 'source')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# Our custom logger
|
||||
require "middleman-core/logger"
|
||||
require 'middleman-core/logger'
|
||||
|
||||
# For instrumenting
|
||||
require "active_support/notifications"
|
||||
require 'active_support/notifications'
|
||||
|
||||
# Using Thor's indifferent hash access
|
||||
require "thor"
|
||||
require 'thor'
|
||||
|
||||
# Core Pathname library used for traversal
|
||||
require "pathname"
|
||||
require 'pathname'
|
||||
|
||||
require "tilt"
|
||||
require "rack/mime"
|
||||
require 'tilt'
|
||||
require 'rack/mime'
|
||||
|
||||
module Middleman
|
||||
|
||||
|
@ -59,7 +59,7 @@ module Middleman
|
|||
|
||||
# Facade for ActiveSupport/Notification
|
||||
def self.instrument(name, payload={}, &block)
|
||||
name << ".middleman" unless name =~ /\.middleman$/
|
||||
name << '.middleman' unless name =~ /\.middleman$/
|
||||
::ActiveSupport::Notifications.instrument(name, payload, &block)
|
||||
end
|
||||
|
||||
|
@ -90,13 +90,13 @@ module Middleman
|
|||
# @return [String]
|
||||
def self.normalize_path(path)
|
||||
# The tr call works around a bug in Ruby's Unicode handling
|
||||
path.sub(%r{^/}, "").tr('','')
|
||||
path.sub(%r{^/}, '').tr('','')
|
||||
end
|
||||
|
||||
# This is a separate method from normalize_path in case we
|
||||
# change how we normalize paths
|
||||
def self.strip_leading_slash(path)
|
||||
path.sub(%r{^/}, "")
|
||||
path.sub(%r{^/}, '')
|
||||
end
|
||||
|
||||
# Extract the text of a Rack response as a string.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue