
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
= WebTools Example, a demo for what a unified Ruby mirror API can offer you
The WebTools Sinatra application allows you to explore a Ruby application's Classes, Modules, Methods, Constants, and Ancestors in a web browser, as well as run and debug code, or explore VM statistics and other info.
If running on MagLev, it will also allow you to explore GemStone/S Smalltalk code, and to examine detailed statistics about all processes connected to GemStone/S.
=== Setup
$ rvm use [maglev-head|rbx|jruby|ruby-head]
$ bundle install
### Temporary workaround on MagLev for https://github.com/MagLev/maglev/issues/58 ###
$ maglev-gem pristine rack
== Viewing Ruby code
Run the WebTools Sinatra application
$ bundle exec rake
This will start WEBrick in your current window. Hit Ctl-C to stop.
Browse to http://localhost:9292/webtools, open a browser, click on a namespace, then click on a constant in that namespace. You will see instance methods. Select boxes show ancestors and implementors of the selected method in the hierarchy. To see class methods, switch to the "Class" tab.
Method source appears in the bottom pane, and time spent on the server/network/client in the status line. Depending on your Ruby, saving methods will work or not.
If you choose to open a workspace, you can run Ruby code. If the code has an error, a debugger will start. Depending on the capabilities of your Ruby, you can also inspect stack frames, trim the stack, step through methods and inspect arguments and locals. As a rule of thumb, almost nothing of this will work with MRI, because the MRI reflection is ad-hoc, infantile, and generally a prime example for an utter lack of -- or disgregard for -- engineering prinicples. Have a look at the Ruby mirrors project (https://github.com/timfel/rubymirrors) for more information.
== MagLev specific demos
=== Add classes and modules from ActiveModel
WARNING: If you already have an application loaded into MagLev, do not
run rake meta
since it persists RubyGems and ActiveModel.
Use WebTools to explore your application instead. If you run
rake meta
, run maglev force-reload
afterwards
to load an empty database.
$ rake meta
Open a new browser in WebTools. Note that AValidPerson now appears in the class list, as do a number of classes/modules from ActiveModel and ActiveSupport.
Click on the class AValidPerson and compare it with the source (meta_demo.rb). Some things to note:
initialize
method is unchanged from the code
in meta_demo.rb
_callback_before_1
generated from
$MAGLEV_HOME/lib/maglev/gems/1.8/gems/activesupport-3.0.5/lib/active_support/callbacks.rb
shows the actual method name _callback_before_1
instead of #{method_name}
.=== Modify meta_demo.rb and view new generated methods
Edit the file meta_demo.rb. Add :age to both validates_presence_of and attr_accessor. The changed lines should look like
validates_presence_of :first_name, :last_name, :age
attr_accessor :first_name, :last_name, :age
Then
$ rake meta
Click on "Refresh View" in WebTools. AValidPerson will now include the new instance methods age and age=.
=== Add some data
$ rake demodata
Click on "Refresh View" in WebTools. Note that AAADemo now appears in the class list. Click on the class AAADemo and compare it with the source (demo_data.rb).
== Viewing GemStone/S code, processes and statistics
The code for this example was inspired by the Smalltalk example found in $MAGLEV_HOME/gemstone/examples/www. The Smalltalk example code can be invoked from ruby (a demonstration of how to invoke Smalltalk from Ruby), via:
$ rake smalltalk
Then browse to http://localhost:8080/ and explore
Hit Ctl-C in the terminal window to stop.
== Known problems
Oh, so many problems...
== Contributing
MagLev Ruby code in this project is MIT licensed. See LICENSE.txt in this directory. By sending a pull request, you agree your contributed code is also MIT licensed.
This project includes a copy of CodeMirror, copyrighted by Marijn Haverbeke. See public/CodeMirror/LICENSE.
FAQs
Unknown package
We found that maglev-webtools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.