Skip to content

Commit

Permalink
Consistently use double-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Mar 22, 2014
1 parent d6e3037 commit d634d24
Show file tree
Hide file tree
Showing 66 changed files with 2,092 additions and 2,089 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ PercentLiteralDelimiters:
'%w': '[]'
'%W': '[]'
'%x': ()

StringLiterals:
EnforcedStyle: double_quotes
30 changes: 15 additions & 15 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'rake', '>= 0.9'
gem 'rdoc', '>= 3.9'
gem "rake", ">= 0.9"
gem "rdoc", ">= 3.9"

group :development do
gem 'guard-rspec'
gem 'pry'
gem "guard-rspec"
gem "pry"
platforms :ruby_19, :ruby_20 do
gem 'pry-debugger'
gem 'pry-stack_explorer'
gem "pry-debugger"
gem "pry-stack_explorer"
end
end

group :test do
gem 'childlabor'
gem 'coveralls', '>= 0.5.7', :require => false
gem "childlabor"
gem "coveralls", ">= 0.5.7", :require => false
# mime-types is required indirectly by coveralls
# needs to be < 2.0 to work with Ruby 1.8.7
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
gem 'fakeweb', '>= 1.3'
gem 'rspec', '>= 2.14'
gem 'rspec-mocks', '>= 2.12.2'
gem 'rubocop', '>= 0.19', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'simplecov', :require => false
gem "mime-types", "~> 1.25", :platforms => [:jruby, :ruby_18]
gem "fakeweb", ">= 1.3"
gem "rspec", ">= 2.14"
gem "rspec-mocks", ">= 2.12.2"
gem "rubocop", ">= 0.19", :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem "simplecov", :require => false
end

gemspec
22 changes: 11 additions & 11 deletions Thorfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)

require 'bundler'
require 'thor/rake_compat'
require "bundler"
require "thor/rake_compat"

class Default < Thor
include Thor::RakeCompat
Bundler::GemHelper.install_tasks

desc 'build', "Build thor-#{Thor::VERSION}.gem into the pkg directory"
desc "build", "Build thor-#{Thor::VERSION}.gem into the pkg directory"
def build
Rake::Task['build'].execute
Rake::Task["build"].execute
end

desc 'install', "Build and install thor-#{Thor::VERSION}.gem into system gems"
desc "install", "Build and install thor-#{Thor::VERSION}.gem into system gems"
def install
Rake::Task['install'].execute
Rake::Task["install"].execute
end

desc 'release', "Create tag v#{Thor::VERSION} and build and push thor-#{Thor::VERSION}.gem to Rubygems"
desc "release", "Create tag v#{Thor::VERSION} and build and push thor-#{Thor::VERSION}.gem to Rubygems"
def release
Rake::Task['release'].execute
Rake::Task["release"].execute
end

desc 'spec', 'Run RSpec code examples'
desc "spec", "Run RSpec code examples"
def spec
exec 'rspec spec'
exec "rspec spec"
end
end
2 changes: 1 addition & 1 deletion bin/thor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# -*- mode: ruby -*-

require 'thor/runner'
require "thor/runner"
$thor_runner = true
Thor::Runner.start
32 changes: 16 additions & 16 deletions lib/thor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'set'
require 'thor/base'
require "set"
require "thor/base"

class Thor # rubocop:disable ClassLength
class << self
Expand All @@ -10,7 +10,7 @@ class << self
# options<Hash>
#
def package_name(name, options = {})
@package_name = name.nil? || name == '' ? nil : name
@package_name = name.nil? || name == "" ? nil : name
end

# Sets the default command when thor is executed without an explicit command to be called.
Expand All @@ -20,9 +20,9 @@ def package_name(name, options = {})
#
def default_command(meth = nil)
if meth
@default_command = meth == :none ? 'help' : meth.to_s
@default_command = meth == :none ? "help" : meth.to_s
else
@default_command ||= from_superclass(:default_command, 'help')
@default_command ||= from_superclass(:default_command, "help")
end
end
alias_method :default_task, :default_command
Expand Down Expand Up @@ -167,12 +167,12 @@ def command_help(shell, command_name)
command = all_commands[meth]
handle_no_command_error(meth) unless command

shell.say 'Usage:'
shell.say "Usage:"
shell.say " #{banner(command)}"
shell.say
class_options_help(shell, nil => command.options.map { |_, o| o })
if command.long_description
shell.say 'Description:'
shell.say "Description:"
shell.print_wrapped(command.long_description, :indent => 2)
else
shell.say command.description
Expand All @@ -195,7 +195,7 @@ def help(shell, subcommand = false)
if defined?(@package_name) && @package_name
shell.say "#{@package_name} commands:"
else
shell.say 'Commands:'
shell.say "Commands:"
end

shell.print_table(list, :indent => 2, :truncate => true)
Expand All @@ -209,7 +209,7 @@ def printable_commands(all = true, subcommand = false)
next if command.hidden?
item = []
item << banner(command, false, subcommand)
item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" : '')
item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" : "")
item
end.compact
end
Expand All @@ -231,7 +231,7 @@ def subcommand(subcommand, subcommand_class)

define_method(subcommand) do |*args|
args, opts = Thor::Arguments.split(args)
args.unshift('help') if opts.include? '--help' or opts.include? '-h'
args.unshift("help") if opts.include? "--help" or opts.include? "-h"
invoke subcommand_class, args, opts, :invoked_via_subcommand => true, :class_options => options
end
end
Expand Down Expand Up @@ -386,11 +386,11 @@ def create_command(meth) #:nodoc:
commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
@usage, @desc, @long_desc, @method_options, @hide = nil
true
elsif all_commands[meth] || meth == 'method_missing'
elsif all_commands[meth] || meth == "method_missing"
true
else
puts "[WARNING] Attempted to create command #{meth.inspect} without usage or description. " <<
'Call desc if you want this method to be available as command or declare it inside a ' <<
"Call desc if you want this method to be available as command or declare it inside a " <<
"no_commands{} block. Invoked from #{caller[1].inspect}."
false
end
Expand Down Expand Up @@ -421,7 +421,7 @@ def retrieve_command_name(args) #:nodoc:
# +normalize_command_name+ also converts names like +animal-prison+
# into +animal_prison+.
def normalize_command_name(meth) #:nodoc:
return default_command.to_s.gsub('-', '_') unless meth
return default_command.to_s.gsub("-", "_") unless meth

possibilities = find_command_possibilities(meth)
if possibilities.size > 1
Expand All @@ -434,7 +434,7 @@ def normalize_command_name(meth) #:nodoc:
meth = possibilities.first
end

meth.to_s.gsub('-', '_') # treat foo-bar as foo_bar
meth.to_s.gsub("-", "_") # treat foo-bar as foo_bar
end
alias_method :normalize_task_name, :normalize_command_name

Expand All @@ -457,7 +457,7 @@ def find_command_possibilities(meth)
alias_method :find_task_possibilities, :find_command_possibilities

def subcommand_help(cmd)
desc 'help [COMMAND]', 'Describe subcommands or one specific subcommand'
desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
class_eval "
def help(command = nil, subcommand = true); super; end
"
Expand All @@ -469,7 +469,7 @@ def help(command = nil, subcommand = true); super; end

map HELP_MAPPINGS => :help

desc 'help [COMMAND]', 'Describe available commands or one specific command'
desc "help [COMMAND]", "Describe available commands or one specific command"
def help(command = nil, subcommand = false)
if command
if self.class.subcommands.include? command
Expand Down
54 changes: 27 additions & 27 deletions lib/thor/actions.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'fileutils'
require 'uri'
require 'thor/core_ext/io_binary_read'
require 'thor/actions/create_file'
require 'thor/actions/create_link'
require 'thor/actions/directory'
require 'thor/actions/empty_directory'
require 'thor/actions/file_manipulation'
require 'thor/actions/inject_into_file'
require "fileutils"
require "uri"
require "thor/core_ext/io_binary_read"
require "thor/actions/create_file"
require "thor/actions/create_link"
require "thor/actions/directory"
require "thor/actions/empty_directory"
require "thor/actions/file_manipulation"
require "thor/actions/inject_into_file"

class Thor
module Actions
Expand Down Expand Up @@ -48,17 +48,17 @@ def source_paths_for_search
# Add runtime options that help actions execution.
#
def add_runtime_options!
class_option :force, :type => :boolean, :aliases => '-f', :group => :runtime,
:desc => 'Overwrite files that already exist'
class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
:desc => "Overwrite files that already exist"

class_option :pretend, :type => :boolean, :aliases => '-p', :group => :runtime,
:desc => 'Run but do not make any changes'
class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
:desc => "Run but do not make any changes"

class_option :quiet, :type => :boolean, :aliases => '-q', :group => :runtime,
:desc => 'Suppress status output'
class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
:desc => "Suppress status output"

class_option :skip, :type => :boolean, :aliases => '-s', :group => :runtime,
:desc => 'Skip files that already exist'
class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
:desc => "Skip files that already exist"
end
end

Expand All @@ -73,10 +73,10 @@ def add_runtime_options!
#
def initialize(args = [], options = {}, config = {})
self.behavior = case config[:behavior].to_s
when 'force', 'skip'
when "force", "skip"
_cleanup_options_and_set(options, config[:behavior])
:invoke
when 'revoke'
when "revoke"
:revoke
else
:invoke
Expand Down Expand Up @@ -106,16 +106,16 @@ def destination_root
#
def destination_root=(root)
@destination_stack ||= []
@destination_stack[0] = File.expand_path(root || '')
@destination_stack[0] = File.expand_path(root || "")
end

# Returns the given path relative to the absolute root (ie, root where
# the script started).
#
def relative_to_original_destination_root(path, remove_dot = true)
path = path.dup
if path.gsub!(@destination_stack[0], '.')
remove_dot ? (path[2..-1] || '') : path
if path.gsub!(@destination_stack[0], ".")
remove_dot ? (path[2..-1] || "") : path
else
path
end
Expand Down Expand Up @@ -147,7 +147,7 @@ def find_in_source_paths(file) # rubocop:disable MethodLength
end

if source_paths.empty?
message << 'Currently you have no source paths.'
message << "Currently you have no source paths."
else
message << "Your current source paths are: \n#{source_paths.join("\n")}"
end
Expand All @@ -164,7 +164,7 @@ def find_in_source_paths(file) # rubocop:disable MethodLength
# dir<String>:: the directory to move to.
# config<Hash>:: give :verbose => true to log and use padding.
#
def inside(dir = '', config = {}, &block)
def inside(dir = "", config = {}, &block)
verbose = config.fetch(:verbose, false)
pretend = options[:pretend]

Expand Down Expand Up @@ -215,7 +215,7 @@ def apply(path, config = {})
shell.padding += 1 if verbose

if is_uri
contents = open(path, 'Accept' => 'application/x-thor-template') { |io| io.read }
contents = open(path, "Accept" => "application/x-thor-template") { |io| io.read }
else
contents = open(path) { |io| io.read }
end
Expand Down Expand Up @@ -292,7 +292,7 @@ def thor(command, *args)

args.unshift(command)
args.push Thor::Options.to_switches(config)
command = args.join(' ').strip
command = args.join(" ").strip

run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
end
Expand All @@ -311,7 +311,7 @@ def _cleanup_options_and_set(options, key) #:nodoc:
%w[--force -f --skip -s].each { |i| options.delete(i) }
options << "--#{key}"
when Hash
[:force, :skip, 'force', 'skip'].each { |i| options.delete(i) }
[:force, :skip, "force", "skip"].each { |i| options.delete(i) }
options.merge!(key => true)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/thor/actions/create_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'thor/actions/empty_directory'
require "thor/actions/empty_directory"

class Thor
module Actions
Expand Down Expand Up @@ -59,7 +59,7 @@ def render
def invoke!
invoke_with_conflict_check do
FileUtils.mkdir_p(File.dirname(destination))
File.open(destination, 'wb') { |f| f.write render }
File.open(destination, "wb") { |f| f.write render }
end
given_destination
end
Expand Down
2 changes: 1 addition & 1 deletion lib/thor/actions/create_link.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'thor/actions/create_file'
require "thor/actions/create_file"

class Thor
module Actions
Expand Down
Loading

0 comments on commit d634d24

Please sign in to comment.