lib/hoe.rb in hoe-3.13.0 vs lib/hoe.rb in hoe-3.13.1
- old
+ new
@@ -1,26 +1,26 @@
# -*- mode: ruby; coding: us-ascii; -*-
-require 'rubygems'
+require "rubygems"
begin
- gem 'rake'
+ gem "rake"
rescue Gem::LoadError
warn "Using the crusty system installed rake... you probably want to upgrade"
end
-require 'rake'
-require 'rake/testtask'
-require 'rbconfig'
+require "rake"
+require "rake/testtask"
+require "rbconfig"
begin
- require 'psych'
+ require "psych"
rescue LoadError
# do nothing
end
-require 'yaml'
+require "yaml"
-require 'hoe/rake'
+require "hoe/rake"
##
# Hoe is a simple rake/rubygems helper for project Rakefiles. It helps
# generate rubygems and includes a dynamic plug-in system allowing for
# easy extensibility. Hoe ships with plug-ins for all your usual
@@ -89,29 +89,29 @@
class Hoe
include Rake::DSL if defined?(Rake::DSL)
# duh
- VERSION = "3.13.0"
+ VERSION = "3.13.1"
@@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package,
:publish, :gemcutter, :signing, :test]
@bad_plugins = []
##
# Used to add extra flags to RUBY_FLAGS.
- RUBY_DEBUG = ENV['RUBY_DEBUG']
+ RUBY_DEBUG = ENV["RUBY_DEBUG"]
- default_ruby_flags = "-w -I#{%w(lib bin test .).join(File::PATH_SEPARATOR)}" +
- (RUBY_DEBUG ? " #{RUBY_DEBUG}" : '')
+ default_ruby_flags = "-w -I#{%w[lib bin test .].join(File::PATH_SEPARATOR)}" +
+ (RUBY_DEBUG ? " #{RUBY_DEBUG}" : "")
##
# Used to specify flags to ruby [has smart default].
- RUBY_FLAGS = ENV['RUBY_FLAGS'] || default_ruby_flags
+ RUBY_FLAGS = ENV["RUBY_FLAGS"] || default_ruby_flags
##
# Default configuration values for .hoerc. Plugins should populate
# this on load.
@@ -120,11 +120,11 @@
}
##
# True if you're a masochistic developer. Used for building commands.
- WINDOZE = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
+ WINDOZE = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
##
# *MANDATORY*: The author(s) of the package. (can be array)
#
# Use the #developer method to fill in both author and email cleanly.
@@ -341,15 +341,15 @@
# Klass names are CamelCase with :: separating extension parts.
#
# Test klass names are same as Klass with Test prepended to each part.
def self.normalize_names project # :nodoc:
- project = project.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
+ project = project.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, "")
klass = project.gsub(/(?:^|_)([a-z])/) { $1.upcase }
klass = klass. gsub(/(?:^|-)([a-z])/) { "::#{$1.upcase}" }
test_klass = klass. gsub(/(^|::)([A-Z])/) { "#{$1}Test#{$2}" }
- file_name = project.gsub(/-/, '/')
+ file_name = project.gsub(/-/, "/")
return project, file_name, klass, test_klass
end
##
@@ -394,18 +394,18 @@
##
# Activate plugin modules and add them to the current instance.
def activate_plugins
with_config do |config, _|
- config_plugins = config['plugins']
+ config_plugins = config["plugins"]
break unless config_plugins
- Hoe.plugins.concat config_plugins.map { |plugin| plugin.intern }
+ Hoe.plugins.concat config_plugins.map(&:intern)
end
Hoe.load_plugins Hoe.plugins
- names = Hoe.constants.map { |s| s.to_s }
+ names = Hoe.constants.map(&:to_s)
names.reject! { |n| n =~ /^[A-Z_]+$/ }
names.each do |name|
next unless Hoe.plugins.include? name.downcase.intern
warn "extend #{name}" if $DEBUG
@@ -469,11 +469,11 @@
def add_dependencies
self.extra_deps = normalize_deps extra_deps
self.extra_dev_deps = normalize_deps extra_dev_deps
case name
- when 'hoe' then
+ when "hoe" then
dependency "rake", [">= 0.8", "< 11.0"]
else
version = VERSION.split(/\./).first(2).join(".")
dependency "hoe", "~> #{version}", :development
end
@@ -497,27 +497,27 @@
##
# Returns the proper dependency list for the thingy.
def dependency_target
- self.name == 'hoe' ? extra_deps : extra_dev_deps
+ self.name == "hoe" ? extra_deps : extra_dev_deps
end
##
# Define the Gem::Specification.
def define_spec
self.spec = Gem::Specification.new do |s|
- dirs = Dir['lib']
+ dirs = Dir["lib"]
manifest = read_manifest
abort [
"Manifest is missing or couldn't be read.",
"The Manifest is kind of a big deal.",
"Maybe you're using a gem packaged by a linux project.",
- "It seems like they enjoy breaking other people's code."
+ "It seems like they enjoy breaking other people's code.",
].join "\n" unless manifest
s.name = name
s.version = version if version
s.summary = summary
@@ -533,13 +533,12 @@
s.description = description
s.files = manifest
s.executables = s.files.grep(/^bin/) { |f| File.basename(f) }
s.bindir = "bin"
s.require_paths = dirs unless dirs.empty?
- s.rdoc_options = ['--main', readme_file]
+ s.rdoc_options = ["--main", readme_file]
s.post_install_message = post_install_message
- s.test_files = Dir[*self.test_globs].uniq
missing "Manifest.txt" if s.files.empty?
case author
when Array
@@ -565,28 +564,28 @@
run_spec_extras
end
def check_for_version # :nodoc:
- unless self.version then
- version = nil
- version_re = /VERSION += +([\"\'])([\d][\w\.]+)\1/
+ return if self.version
- spec.files.each do |file|
- next unless File.exist? file
- version = File.read_utf(file)[version_re, 2] rescue nil
- break if version
- end
+ version = nil
+ version_re = /VERSION += +([\"\'])([\d][\w\.]+)\1/
- spec.version = self.version = version if version
+ spec.files.each do |file|
+ next unless File.exist? file
+ version = File.read_utf(file)[version_re, 2] rescue nil
+ break if version
+ end
- unless self.version then
- spec.version = self.version = "0.borked"
- warn "** Add 'VERSION = \"x.y.z\"' to your code,"
- warn " add a version to your hoe spec,"
- warn " or fix your Manifest.txt"
- end
+ spec.version = self.version = version if version
+
+ unless self.version then
+ spec.version = self.version = "0.borked"
+ warn "** Add 'VERSION = \"x.y.z\"' to your code,"
+ warn " add a version to your hoe spec,"
+ warn " or fix your Manifest.txt"
end
end
def run_spec_extras # :nodoc:
# Do any extra stuff the user wants
@@ -625,11 +624,11 @@
self.version = version
self.author = []
self.changes = nil
self.description = nil
- self.description_sections = %w(description)
+ self.description_sections = %w[description]
self.email = []
self.extra_deps = []
self.extra_dev_deps = []
self.extra_rdoc_files = []
self.licenses = []
@@ -637,14 +636,16 @@
self.group_name = name.downcase
self.spec = nil
self.spec_extras = {}
self.summary = nil
self.summary_sentences = 1
- self.test_globs = ['test/**/{test,spec}_*.rb',
- 'test/**/*_{test,spec}.rb']
+ self.test_globs = ["test/**/{test,spec}_*.rb",
+ "test/**/*_{test,spec}.rb"]
- if manifest = read_manifest then
+ manifest = read_manifest
+
+ if manifest then
self.readme_file = manifest.grep(/^README\./).first
self.history_file = manifest.grep(/^History\./).first
end
self.history_file ||= Dir.glob("History.{txt,md}").first
@@ -656,15 +657,15 @@
##
# Intuit values from the readme and history files.
def intuit_values
header_re = /^((?:=+|#+) .*)$/
- readme = File.read_utf(readme_file).split(header_re)[1..-1] rescue ''
+ readme = File.read_utf(readme_file).split(header_re)[1..-1] rescue ""
unless readme.empty? then
sections = Hash[*readme.map { |s|
- s =~ /^[=#]/ ? s.strip.downcase.chomp(':').split.last : s.strip
+ s =~ /^[=#]/ ? s.strip.downcase.chomp(":").split.last : s.strip
}]
desc = sections.values_at(*description_sections).join("\n\n")
summ = desc.split(/\.\s+/).first(summary_sentences).join(". ")
urls = parse_urls(readme[1])
@@ -678,11 +679,11 @@
self.changes ||= begin
h = File.read_utf(history_file)
h.split(/^(={2,}|\#{2,})/)[1..2].join.strip
rescue
missing history_file
- ''
+ ""
end
end
##
# Parse the urls section of the readme file. Returns a hash or an
@@ -701,13 +702,12 @@
# The hash format is preferred as it will be used to populate gem
# metadata. The array format will work, but will warn that you
# should update the readme.
def parse_urls text
+ lines = text.gsub(/^\* /, "").delete("<>").split(/\n/).grep(/\S+/)
- lines = text.gsub(/^\* /, '').delete("<>").split(/\n/).grep(/\S+/)
-
if lines.first =~ /::/ then
Hash[lines.map { |line| line.split(/\s*::\s*/) }]
else
lines
end
@@ -779,11 +779,11 @@
# This uses require_rubygems_version. Last one wins. Make sure you
# account for that.
def pluggable!
abort "update rubygems to >= 1.3.1" unless Gem.respond_to? :find_files
- require_rubygems_version '>= 1.3.1'
+ require_rubygems_version ">= 1.3.1"
end
##
# Is a plugin activated? Used for guarding missing plugins in your
# hoe spec:
@@ -836,11 +836,11 @@
# Provide a linear degrading value from n to m over start to finis
# dates. If not provided, start and finis will default to 1/1 and
# 12/31 of the current year.
def timebomb n, m, finis = nil, start = nil
- require 'time'
+ require "time"
finis = Time.parse(finis || "#{Time.now.year}-12-31")
start = Time.parse(start || "#{Time.now.year}-01-01")
rest = (finis - Time.now)
full = (finis - start)
@@ -849,11 +849,11 @@
##
# Verify that mandatory fields are set.
def validate_fields
- %w(email author).each do |field|
+ %w[email author].each do |field|
value = self.send(field)
abort "Hoe #{field} value not set. aborting" if value.nil? or value.empty?
end
end
@@ -868,11 +868,11 @@
exists = File.exist? rc
homeconfig = exists ? YAML.load_file(rc) : {}
config = config.merge homeconfig
- localrc = File.join Dir.pwd, '.hoerc'
+ localrc = File.join Dir.pwd, ".hoerc"
exists = File.exist? localrc
localconfig = exists ? YAML.load_file(localrc) : {}
config = config.merge localconfig
@@ -888,10 +888,10 @@
open path, opt do |f|
if r19 then
f.read
else
- f.read.sub %r/\A\xEF\xBB\xBF/, ''
+ f.read.sub %r%\A\xEF\xBB\xBF%, ""
end
end
end
end