Class: SugarJar::Forge
- Inherits:
-
Object
- Object
- SugarJar::Forge
- Defined in:
- lib/sugarjar/forge.rb
Constant Summary collapse
- CMD_MAP =
{ 'github' => 'gh', 'gitlab' => 'glab', 'forgejo' => 'fj', }.freeze
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #all_versions ⇒ Object
- #cmd ⇒ Object
-
#initialize(type, host) ⇒ Forge
constructor
A new instance of Forge.
- #run ⇒ Object
- #run_nofail ⇒ Object
- #run_with_system(*args) ⇒ Object
Constructor Details
#initialize(type, host) ⇒ Forge
Returns a new instance of Forge.
15 16 17 18 19 |
# File 'lib/sugarjar/forge.rb', line 15 def initialize(type, host) @type = type @host = host assert_cli_avail! end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/sugarjar/forge.rb', line 7 def type @type end |
Instance Method Details
#all_versions ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sugarjar/forge.rb', line 25 def all_versions CMD_MAP.values.map do |cli| bin = SugarJar::Util.which_nofail(cli) _forge_nofail(cli, 'version').stdout if bin end.compact end |
#cmd ⇒ Object
21 22 23 |
# File 'lib/sugarjar/forge.rb', line 21 def cmd @cmd ||= CMD_MAP[@type] end |
#run ⇒ Object
36 37 38 39 40 |
# File 'lib/sugarjar/forge.rb', line 36 def run(*) s = _forge_nofail(cmd, *) s.error! s end |
#run_nofail ⇒ Object
32 33 34 |
# File 'lib/sugarjar/forge.rb', line 32 def run_nofail(*) _forge_nofail(cmd, *) end |