GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RubyNative/SwiftRuby: A Port of Ruby Core api to Swift for Scripting

BranchesTags
Open more actions menu

Latest commit

 

History

63 Commits
63 Commits

Folders and files

NameName
Last commit message
Last commit date
SwiftRuby.xcodeproj
SwiftRuby.xcodeproj
 
 
SwiftRuby
SwiftRuby
 
 
SwiftRubyTests
SwiftRubyTests
 
 
.gitignore
.gitignore
 
 
Array.swift
Array.swift
 
 
Data.swift
Data.swift
 
 
Dir.swift
Dir.swift
 
 
File.swift
File.swift
 
 
FileUtils.swift
FileUtils.swift
 
 
Float.swift
Float.swift
 
 
IO.swift
IO.swift
 
 
Info.plist
Info.plist
 
 
Integer.swift
Integer.swift
 
 
Kernel.swift
Kernel.swift
 
 
LICENSE
LICENSE
 
 
MISSING.md
MISSING.md
 
 
Object.swift
Object.swift
 
 
README.md
README.md
 
 
Rational.swift
Rational.swift
 
 
Regexp.swift
Regexp.swift
 
 
Stat.swift
Stat.swift
 
 
String.swift
String.swift
 
 
StringIO.swift
StringIO.swift
 
 
SwiftRuby.podspec
SwiftRuby.podspec
 
 
Time.swift
Time.swift
 
 
Utilities.h
Utilities.h
 
 
Utilities.m
Utilities.m
 
 
main.swift
main.swift
 
 

Repository files navigation

SwiftRuby

RubyNative is a port of the Ruby core api to Swift intended to be used with Diamond script interpreter or any Swift Program that would like simpler access to file i/o than is offered by Foundation kit. It also extends Swift's String and Array classes and will provide a well integrated Regexp class to take the burden off the programmer dealing with uncompromising Swift Strings.

Why port Ruby to Swift? Using a strictly typed and scoped language for scripting avoids may of the pitfalls of a dynamic language and allows for auto-completion when working in the editor. This makes your scripts run faster in terms of developer time and very much so at run time. The languages are also a good fit syntactically.

Seems like a lot of low level UNIX code? We chose to stay close to the metal and the Ruby apis seem based on the POSIX interface. It is also not clear Foundation will be available when Swift is released for Linux. For now the project has minimal dependencies on Foundation classes NSURL and NSRegularExpression for things that it would not be worth replicating until the smoke clears for Swift on Linux.

At this stage, Ruby's Dir, IO, File, StringIO, Time and Stat classes have been implemented. These classes follow the original documented functionality as closely as possible. Input arguments are generally protocols such as string_like or data_like to allow for automatic conversion between types. Return values are concrete types String Int, Float or Data or an instance.

A flavour of the common Ruby idioms implemented in Swift thus far is given below:

Icon

SwiftRuby has avoided using operator overloading as much as Ruby with one exception: subscripting when working with Strings. There are two general forms. Subscripting with integers to extract ranges from Strings and subscripting with Strings to provide a succinct syntax for Regular Expressions.

Subscripting Strings

At danger of unpicking the sterling work Swift has done to protect us all from String internals simple extensions have been defined to make scripting easier:

Icon

Subscripting Strings with a String as syntax for Regexp

If you think about it, the logical index into a string is a Regexp. Ruby toys with this idea but SwiftRuby takes this much further. This is best explained by the following examples:

Icon

License is MIT

SwiftRuby is also available as a CocoaPod for use without using the Diamond script interpreter and is available under an MIT License. If you have any comments or suggestions, the authors can be contacted on Twitter @Injection4Xcode.

About

A Port of Ruby Core api to Swift for Scripting

Resources

Readme
MIT license
Activity
Custom properties

Stars

93 stars

Watchers

6 watching

Forks

8 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.