Scarpe

Shoes in modern Ruby and Webview

View the Project on GitHub scarpe-team/scarpe

Scarpe/Shoes Incompatibilities

This document outlines known incompatibilities between Scarpe and classic Shoes3 (the original _why implementation and its successors).

Unsupported Shoes3 Widgets

These widgets exist only in Shoes3 and have no Scarpe equivalent:

Unsupported Shoes3 APIs

Global App Settings (Shoes. methods)

Event System

Decoration & Theming

Native Menus

Behavioral Differences

Scripts Without Shoes.app

Classic Shoes allowed calling ask(), alert(), and other builtins at the top level without wrapping in Shoes.app:

# This works in classic Shoes, NOT in Scarpe
guess = ask "What's your name?"
alert "Hello, #{guess}!"

Scarpe requires Shoes.app because builtins need a WebView context:

# Scarpe-compatible version
Shoes.app do
  guess = ask "What's your name?"
  alert "Hello, #{guess}!"
end

Method Definition Order

Methods defined AFTER Shoes.app are not available inside the block:

# This will FAIL - to_radians doesn't exist when Shoes.app runs
Shoes.app do
  angle = to_radians(45)  # NoMethodError!
end

def to_radians(deg)
  deg * Math::PI / 180
end

Solution: Define helper methods BEFORE Shoes.app:

# This WORKS
def to_radians(deg)
  deg * Math::PI / 180
end

Shoes.app do
  angle = to_radians(45)  # Works!
end

Widget Positioning

In classic Shoes, widgets knew their position after layout. In Scarpe, self.left and self.top inside Widget#initialize return nil because browser layout hasn’t occurred yet.

class MyWidget < Shoes::Widget
  def initialize
    @x = self.left  # nil in Scarpe, had value in classic Shoes
  end
end

ask() Cancel Behavior

Pre-app Dialogs

Calling confirm(), ask(), or alert() before Shoes.app exists doesn’t work in Scarpe:

# Works in classic Shoes, fails in Scarpe
if confirm("Continue?")
  Shoes.app { ... }
end

External Dependencies

Some Shoes3 examples require gems that are dead or incompatible with modern Ruby:

Migration Tips

  1. Wrap all code in Shoes.app - Don’t rely on top-level builtins
  2. Define helpers before Shoes.app - Method order matters in Ruby
  3. Use check instead of switch - Similar functionality
  4. Replace svghandle with image - SVG data URIs work well
  5. Use Nokogiri instead of hpricot - For HTML/XML parsing
  6. Test ask() cancel handling - Now returns "" not nil

What Works Well

Scarpe has excellent compatibility with core Shoes features:

The Hackety Hack samples are a good test suite - 9 of 12 run unmodified on Scarpe.