prremote 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d080a70a00d10af1e419cae964da017bbc6650f85f54f3a18223b81bb204fe7
4
- data.tar.gz: 158c193d72d4d414726f79183f6016017132077f37f0adc2f3238cd843e5672b
3
+ metadata.gz: 9069bbf984dd62c31390570c934396581e816ad884511d248ebdf3a40657ae9d
4
+ data.tar.gz: 853acaa0a69a126503b90ce6726958d194cd56fd5abaf559ff759284d26bf1a6
5
5
  SHA512:
6
- metadata.gz: 47d36cf128e0106b732273bad92aeb3af77c97a4e93f167e77d3ea34999578976a75f7babe8e3e910c6cf364422821cca6e5886cc7c7e5fa327a032a7d3bafb9
7
- data.tar.gz: a63fae436f971e92d97386933706f99396dfcfc1ecf105c4ded5215aa1410d3ba3fadeb49805a9735a7285c1b6202da51dad325438d9b13d444756d48d88906e
6
+ metadata.gz: dff7ed500809d4d457b68ae7483e4d47632c5ced344d0c01237bcec981b589b57794a086508ac99ae7ac28f1b2f351e25dc3c3498b99fb87dac172c43720ebc9
7
+ data.tar.gz: 58fe0f9d4911c33c8ed9456810cef1405784ab9d778d8bb14502fb9832611877e897880ebfbbd84c29b6c69a82bf42add2f020037534fe809908816cff3409ef
data/README.md CHANGED
@@ -12,9 +12,12 @@ Inspired by [mpremote](https://docs.micropython.org/en/latest/reference/mpremote
12
12
 
13
13
  - Ruby 3.x or later
14
14
  - Raspberry Pi Pico W
15
- - `mrbc` in your PATH (for `run`, `deploy`, and `eval`)
15
+ - `mrbc` (mruby 4.x) for `run`, `deploy`, and `eval`
16
16
  - macOS: `brew install mruby`
17
- - Ubuntu / Raspberry Pi OS: `sudo apt install mruby`
17
+ - Linux: build from source [github.com/mruby/mruby/releases](https://github.com/mruby/mruby/releases)
18
+ (`sudo apt install mruby` installs mruby 3.x which is **not compatible**)
19
+ - If `mrbc` is not on your PATH, set the `MRBC` environment variable:
20
+ `MRBC=/path/to/mrbc prremote run app.rb`
18
21
 
19
22
  ---
20
23
 
data/lib/prremote/cli.rb CHANGED
@@ -20,6 +20,8 @@ module Prremote
20
20
  true
21
21
  end
22
22
 
23
+ remove_command :tree
24
+
23
25
  desc 'install', 'Flash prremote runtime firmware to Pico W or Pico'
24
26
  option :version, type: :string, desc: "Firmware version to install (default: #{RUNTIME_VERSION})"
25
27
  option :board, type: :string, desc: 'Board type: pico or picow (default: picow)'
@@ -104,7 +106,12 @@ module Prremote
104
106
  puts "prremote: #{VERSION}"
105
107
 
106
108
  begin
109
+ major = Mrbc.major_version
107
110
  puts "mrbc: #{Mrbc.version} (#{Mrbc.bin})"
111
+ unless major && major >= Mrbc::REQUIRED_MAJOR
112
+ puts " ** mrbc is too old (need #{Mrbc::REQUIRED_MAJOR}.x) **"
113
+ puts " Hint: the path can be set via MRBC environment variable."
114
+ end
108
115
  rescue StandardError => e
109
116
  puts "mrbc: (#{e.message})"
110
117
  end
@@ -26,6 +26,7 @@ module Prremote
26
26
  private
27
27
 
28
28
  def compile(rb_path)
29
+ Mrbc.check_version!
29
30
  tmp = Tempfile.new(['prremote', '.mrb'])
30
31
  out, status = Open3.capture2e(Mrbc.bin, '-o', tmp.path, rb_path)
31
32
  raise "mrbc failed:\n#{out.chomp}" unless status.success?
@@ -23,6 +23,7 @@ module Prremote
23
23
  private
24
24
 
25
25
  def compile(rb_path)
26
+ Mrbc.check_version!
26
27
  tmp = Tempfile.new(['prremote', '.mrb'])
27
28
  out, status = Open3.capture2e(Mrbc.bin, '-o', tmp.path, rb_path)
28
29
  raise "mrbc failed:\n#{out.chomp}" unless status.success?
data/lib/prremote/mrbc.rb CHANGED
@@ -1,18 +1,21 @@
1
1
  require 'open3'
2
2
 
3
3
  module Prremote
4
+ # mrbc lookup order:
5
+ # 1. MRBC env var if set (use this to point at a non-PATH binary)
6
+ # 2. PATH entries, excluding rbenv shims — shims delegate to the project's
7
+ # .ruby-version (typically CRuby) and do not work as a standalone mrbc
8
+ # 3. rbenv direct installs (~/.rbenv/versions/mruby-*/bin/mrbc)
9
+ # The first candidate wins; version compatibility is checked in check_version!.
4
10
  module Mrbc
5
11
  SHIMS_RE = %r{\.rbenv/shims}
12
+ REQUIRED_MAJOR = 4
6
13
 
7
14
  def self.bin
8
15
  return ENV['MRBC'] if ENV['MRBC'] && File.executable?(ENV['MRBC'])
9
16
 
10
- found = ENV['PATH'].split(File::PATH_SEPARATOR)
11
- .grep_v(SHIMS_RE)
12
- .map { |d| File.join(d, 'mrbc') }
13
- .find { |f| File.executable?(f) }
14
-
15
- found || raise('mrbc not found. Install mruby: brew install mruby')
17
+ (path_candidates + rbenv_candidates).first ||
18
+ raise('mrbc not found. Install mruby 4.x: brew install mruby')
16
19
  end
17
20
 
18
21
  def self.version
@@ -21,5 +24,35 @@ module Prremote
21
24
  rescue RuntimeError
22
25
  '(mrbc not found)'
23
26
  end
27
+
28
+ def self.major_version
29
+ version[/\bmruby (\d+)\./, 1]&.to_i
30
+ end
31
+
32
+ def self.check_version!
33
+ return if @version_ok
34
+
35
+ major = major_version
36
+ unless major && major >= REQUIRED_MAJOR
37
+ raise "mrbc is mruby #{major || '?'}.x but mruby #{REQUIRED_MAJOR}.x or newer is required.\n" \
38
+ "Installed: #{version}\n" \
39
+ "Install mruby 4.x: brew install mruby\n" \
40
+ "On Linux: build from source (https://github.com/mruby/mruby/releases)"
41
+ end
42
+
43
+ @version_ok = true
44
+ end
45
+
46
+ private_class_method def self.path_candidates
47
+ ENV['PATH'].split(File::PATH_SEPARATOR)
48
+ .grep_v(SHIMS_RE)
49
+ .map { |d| File.join(d, 'mrbc') }
50
+ .select { |f| File.executable?(f) }
51
+ end
52
+
53
+ private_class_method def self.rbenv_candidates
54
+ Dir.glob(File.expand_path('~/.rbenv/versions/mruby-*/bin/mrbc'))
55
+ .select { |f| File.executable?(f) }
56
+ end
24
57
  end
25
58
  end
@@ -1,4 +1,4 @@
1
1
  module Prremote
2
- VERSION = '0.1.1'.freeze
3
- RUNTIME_VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.2'
3
+ RUNTIME_VERSION = '0.1.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prremote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITO Yosei