Class: Rpremote::PicoRubySourcePatch

Inherits:
Object
  • Object
show all
Defined in:
lib/rpremote/picoruby_source_patch.rb,
sig/rpremote.rbs

Defined Under Namespace

Classes: Error

Constant Summary collapse

JOB_PATH =

Returns:

  • (String)
"mrbgems/picoruby-shell/mrblib/job.rb"
PATCH_ALIASES =

Returns:

  • (Hash[String, String])
{ "3.4.2" => "3.4.5" }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version:) ⇒ PicoRubySourcePatch

Returns a new instance of PicoRubySourcePatch.

Parameters:

  • version: (String)


12
13
14
# File 'lib/rpremote/picoruby_source_patch.rb', line 12

def initialize(version:)
  @version = version
end

Instance Attribute Details

#versionString (readonly)

Returns the value of attribute version.

Returns:

  • (String)


10
11
12
# File 'lib/rpremote/picoruby_source_patch.rb', line 10

def version
  @version
end

Instance Method Details

#apply(source) ⇒ void

This method returns an undefined value.

Parameters:

  • source (String)

Raises:



16
17
18
19
20
21
22
23
24
# File 'lib/rpremote/picoruby_source_patch.rb', line 16

def apply(source)
  patch_version = PATCH_ALIASES.fetch(version, version)
  patch = File.expand_path("../../patches/picoruby-#{patch_version}-ruby-exception-status.patch", __dir__)
  return unless File.file?(patch) && File.file?(File.join(source, JOB_PATH))
  return if git_apply?(source, patch, "--reverse", "--check")

  raise Error, "cannot apply rpremote patch to PicoRuby #{version}" unless git_apply?(source, patch, "--check")
  raise Error, "cannot apply rpremote patch to PicoRuby #{version}" unless git_apply?(source, patch)
end