0.0
No release in over 3 years
Load PicoRuby libraries from Steep
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0
 Project Readme

Steep::PicoRuby

A Steep extension to load RBS files for PicoRuby gems.

This gem supports introducing Steep into an application written in PicoRuby.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add steep-picoruby

If bundler is not being used to manage dependencies, install the gem by executing:

gem install steep-picoruby

Usage

This gem adds picoruby_library method for Steepfile.

It requires the picoruby/picoruby repository and a build config file that determines what gems your application depends on. Execute the following commands if you haven't downloaded the PicoRuby repository yet.

$ mkdir lib
$ git clone --recurse-submodules https://github.com/picoruby/picoruby lib/picoruby
# Steepfile

require 'steep/picoruby'

target :lib do
  picoruby_library(
    target: 'my_app',
    picoruby_root: 'path/to/picoruby/picoruby',
    build_config: 'path/to/your/build_config/my_app.rb',
  )

  # General type checking settings
  check 'mrblib'
  signature 'sig'
end

The arguments of picoruby_library:

name type description default
target String | Array[String] The build name defined in the build config file All existing targets
picoruby_root String | Pathname The file path of PicoRuby repository "lib/picoruby"
build_config String | Pathname | Array[String | Pathname] The file path of your build config Pathname.glob("build_config/*.rb")

Examples

These examples require that PicoRuby repository is cloned into lib/picoruby/.

For app on R2P2

# Steepfile

require 'steep/picoruby'

target :lib do
  picoruby_library(
    target: 'r2p2-picoruby-pico2',
    build_config: 'lib/picoruby/build_config/r2p2-picoruby-pico2.rb',
  )

  # General type checking settings
  check 'mrblib'
  signature 'sig'
end

You need to change the setting if your app assumes a different environment, such as FemtoRuby or Pico W.

Several targets

You can use several RBS environments. For example: application code and test code.

This example requires the following build_config files.

$ cat build_config/my-app.rb
MRuby::CrossBuild.new("my-app") do |conf|
  # ...
end

$ cat build_config/picotest-host.rb
MRuby::Build.new do |conf|
  # ...
end
# Steepfile

require 'steep/picoruby'

target :lib do
  # It only loads type signatures for application code
  picoruby_library target: 'my_app'

  signature "sig"
  check 'mrblib'
end

target :test do
  # It loads both dependencies of app and test.
  picoruby_library

  signature "sig"
  check 'test'
end

Note that if you specify picoruby_library target: 'host', it loads RBS files only for test dependencies. But it does not work well in most cases because RBS files under sig/ depend on gems that the test dependencies do not include.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pocke/steep-picoruby.

License

The gem is available as open source under the terms of the MIT License.