Class: Rpremote::PicoRubySourcePatch
- Inherits:
-
Object
- Object
- Rpremote::PicoRubySourcePatch
- Defined in:
- lib/rpremote/picoruby_source_patch.rb,
sig/rpremote.rbs
Defined Under Namespace
Classes: Error
Constant Summary collapse
- JOB_PATH =
"mrbgems/picoruby-shell/mrblib/job.rb"- BOOTSEL_PATH =
"mrbgems/picoruby-machine/include/machine.h"- PATCH_ALIASES =
{ "3.4.2" => "3.4.5" }.freeze
Instance Attribute Summary collapse
-
#version ⇒ String
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #apply(source) ⇒ void
-
#initialize(version:) ⇒ PicoRubySourcePatch
constructor
A new instance of PicoRubySourcePatch.
Constructor Details
#initialize(version:) ⇒ PicoRubySourcePatch
Returns a new instance of PicoRubySourcePatch.
13 14 15 |
# File 'lib/rpremote/picoruby_source_patch.rb', line 13 def initialize(version:) @version = version end |
Instance Attribute Details
#version ⇒ String (readonly)
Returns the value of attribute version.
11 12 13 |
# File 'lib/rpremote/picoruby_source_patch.rb', line 11 def version @version end |
Instance Method Details
#apply(source) ⇒ void
This method returns an undefined value.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rpremote/picoruby_source_patch.rb', line 17 def apply(source) return unless Dir.exist?(source) patch_version = PATCH_ALIASES.fetch(version, version) patches(patch_version).each do |patch, prerequisite| next unless File.file?(patch) && File.file?(File.join(source, prerequisite)) next if prerequisite == BOOTSEL_PATH && File.read(File.join(source, prerequisite)).include?("Machine_bootsel") next 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 nil end |