lib/ggem/gemspec.rb in ggem-1.9.5 vs lib/ggem/gemspec.rb in ggem-1.10.0
- old
+ new
@@ -2,14 +2,15 @@
require "pathname"
require "scmd"
module GGem; end
+
class GGem::Gemspec
PUSH_HOST_META_KEY = "allowed_push_host"
- DEFAULT_PUSH_HOST = "https://rubygems.org".freeze
- BUILD_TO_DIRNAME = "pkg".freeze
+ DEFAULT_PUSH_HOST = "https://rubygems.org"
+ BUILD_TO_DIRNAME = "pkg"
NotFoundError = Class.new(ArgumentError)
LoadError = Class.new(ArgumentError)
CmdError = Class.new(RuntimeError)
@@ -53,28 +54,37 @@
private
def run_cmd(cmd_string)
cmd = Scmd.new(cmd_string)
cmd.run
- if !cmd.success?
- raise CmdError, "#{cmd_string}\n" \
- "#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
+ unless cmd.success?
+ raise(
+ CmdError,
+ "#{cmd_string}\n#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}",
+ )
end
[cmd_string, cmd.exitstatus, cmd.stdout]
end
def load_gemspec(path)
- eval(path.read, TOPLEVEL_BINDING, path.expand_path.to_s)
- rescue ScriptError, StandardError => e
- original_line = e.backtrace.find{ |line| line.include?(path.to_s) }
- msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
+ eval( # rubocop:disable Security/Eval
+ path.read,
+ TOPLEVEL_BINDING,
+ path.expand_path.to_s,
+ )
+ rescue ScriptError, StandardError => ex
+ original_line = ex.backtrace.find{ |line| line.include?(path.to_s) }
+ msg =
+ "There was a #{ex.class} while loading #{path.basename}: \n#{ex.message}"
msg << " from\n #{original_line}" if original_line
msg << "\n"
raise LoadError, msg
end
def get_push_host(spec)
- ENV["GGEM_PUSH_HOST"] || get_meta(spec)[PUSH_HOST_META_KEY] || DEFAULT_PUSH_HOST
+ ENV["GGEM_PUSH_HOST"] ||
+ get_meta(spec)[PUSH_HOST_META_KEY] ||
+ DEFAULT_PUSH_HOST
end
def get_meta(spec)
(spec.respond_to?(:metadata) ? spec.metadata : {}) || {}
end