Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/technohippy/sapphire

Sapphire is a ruby to perl compiler. Note that the purpose of Sapphire for now is not converting a ruby program into a perl program but writing a perl program in a rubyish manner.
https://github.com/technohippy/sapphire

Last synced: 3 months ago
JSON representation

Sapphire is a ruby to perl compiler. Note that the purpose of Sapphire for now is not converting a ruby program into a perl program but writing a perl program in a rubyish manner.

Awesome Lists containing this project

README

        

= sapphire

* Sapphire (http://github.com/technohippy/sapphire)

== DESCRIPTION:

Sapphire is a ruby to perl compiler. Note that the purpose of Sapphire for now is not converting a ruby program into a perl program but writing a perl program in a rubyish manner.

== FEATURES/PROBLEMS:

* FOR LIGHT PURPOSES ONLY. I'm developing this just for fun.

== SAMPLES:

https://github.com/technohippy/sapphire-sample

=== See code

$ cat misc/write_file.rb
# http://learn.perl.org/examples/read_write_file.html
require 'path/class'
require 'autodie'

dir = dir '/tmp'
file = dir.file 'file.txt'
file_handle = file.openw
list = %w(a list of lines)
list.each do |line|
file_handle.print "#{line}\n"
end

=== Convert

$ bin/sapphire misc/write_file.rb
use strict;
use warnings;
use Path::Class;
use Autodie;
my $dir = dir("/tmp");
my $file = $dir->file("file.txt");
my $file_handle = $file->openw();
my @list = ( "a", "list", "of", "lines" );
for my $line (@list) {
$file_handle->print( "" . $line . "\n" );
}

1;

=== Execute

$ bin/sapphire misc/write_file.rb | perl
$ cat /tmp/file.txt
a
list
of
lines

== REQUIREMENTS:

* ruby_parser
* Perl::Tidy (to prettify the result)

== INSTALL:

* sudo gem install sapphire

== LICENSE:

(The MIT License)

Copyright (c) 2012 ANDO Yasushi

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.