Class: GemKit::Release::Commands::Command
- Inherits:
-
Object
- Object
- GemKit::Release::Commands::Command
- Defined in:
- lib/gem_kit/release/commands/command.rb
Overview
Shared base for the commands behind gem kit. Each is thin — ask a
library object a question, report — and knows nothing about Thor. The
work stays in Gate, VersionFile, Changelog and Deprecate; the parsing,
the help pages and the generator machinery stay in Thor.
Direct Known Subclasses
Constant Summary collapse
- RED =
"\e[0;31m"- RESET =
"\e[0m"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #fail_with(message) ⇒ Object
- #gate ⇒ Object
-
#initialize(options = {}) ⇒ Command
constructor
A new instance of Command.
-
#lines(entries) ⇒ Object
Deprecation entries as display lines: the deadline, the rename, and where it was declared.
-
#project ⇒ Object
The gem in the working directory.
-
#refuse(heading, problems) ⇒ Object
Report a problem list under a heading and stop.
- #relative(path) ⇒ Object
- #render(entries) ⇒ Object
- #say(message = "") ⇒ Object
- #version_file ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Command
Returns a new instance of Command.
22 23 24 |
# File 'lib/gem_kit/release/commands/command.rb', line 22 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/gem_kit/release/commands/command.rb', line 20 def @options end |
Instance Method Details
#fail_with(message) ⇒ Object
45 46 47 |
# File 'lib/gem_kit/release/commands/command.rb', line 45 def fail_with() raise Failure, end |
#gate ⇒ Object
35 36 37 |
# File 'lib/gem_kit/release/commands/command.rb', line 35 def gate @gate ||= Gate.new(project) end |
#lines(entries) ⇒ Object
Deprecation entries as display lines: the deadline, the rename, and where it was declared.
63 64 65 66 67 68 |
# File 'lib/gem_kit/release/commands/command.rb', line 63 def lines(entries) entries.sort_by { |entry| [entry.removed_in, entry.name] }.flat_map do |entry| line = "#{entry.removed_in.to_s.ljust(8)} #{entry}" entry.declared_at ? [line, "#{" " * 8} #{entry.declared_at}"] : [line] end end |
#project ⇒ Object
The gem in the working directory. Everything is inferred from its
.gemspec, so there is nothing to configure in the common case.
--gem picks one out of a repository holding several.
29 30 31 32 33 |
# File 'lib/gem_kit/release/commands/command.rb', line 29 def project @project ||= Project.detect(Dir.pwd, name: [:gem]) rescue Project::NotFound, Project::Ambiguous => error fail_with(error.) end |
#refuse(heading, problems) ⇒ Object
Report a problem list under a heading and stop. One message — a refusal is not half output and half diagnostics.
51 52 53 |
# File 'lib/gem_kit/release/commands/command.rb', line 51 def refuse(heading, problems) fail_with([heading, "", *problems.map { |problem| " #{problem}" }].join("\n")) end |
#relative(path) ⇒ Object
55 |
# File 'lib/gem_kit/release/commands/command.rb', line 55 def relative(path) = path.sub("#{project.root}/", "") |
#render(entries) ⇒ Object
57 58 59 |
# File 'lib/gem_kit/release/commands/command.rb', line 57 def render(entries) lines(entries).each { |line| say(" #{line}") } end |
#say(message = "") ⇒ Object
43 |
# File 'lib/gem_kit/release/commands/command.rb', line 43 def say( = "") = $stdout.puts() |
#version_file ⇒ Object
39 40 41 |
# File 'lib/gem_kit/release/commands/command.rb', line 39 def version_file VersionFile.new(project.version_file, template: project.version_template) end |