diff --git a/Manifest.txt b/Manifest.txt new file mode 100644 index 0000000..dff2dec --- /dev/null +++ b/Manifest.txt @@ -0,0 +1,21 @@ +History.txt +Manifest.txt +PostInstall.txt +README +README.rdoc +Rakefile +bin/jhc_builder.sh +foo.hs +lib/Hubris.rb +sample/Makefile +sample/Test.hs +sample/hsload.rb +script/console +script/destroy +script/generate +spec/Hubris_spec.rb +spec/spec.opts +spec/spec_helper.rb +tasks/rspec.rake +test/test_Hubris.rb +test/test_helper.rb diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..363d482 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,61 @@ += Hubris + +* http://github.com/mwotton/Hubris + +== DESCRIPTION: + + This is a quick and dirty way to call haskell functions from ruby. + +== FEATURES/PROBLEMS: + + Hubris will wash your car, lie to your boss, and salvage your love life. + If you are very, very lucky, it might also let you get some uber-fast + functional goodness into your ruby programs through the back door. + +== SYNOPSIS: + + Eventually, we'll integrate with RubyInline or something similar, + so we can write inline Haskell. Until that happy day: + + write a haskell file (say sample/foo.hs) with some ccall exports declared + call "jhc_builder.sh foo.hs". This will build "libfoo.so". + write a ruby file similar to sample/hsload.rb in order to call the functions from ruby + +if all else fails, mail mwotton@gmail.com with tales of woe. + +== REQUIREMENTS: + + - jhc + - gcc < ... oh, come on. don't tell me you don't have it. > + - ruby 1.8.6 or higher + - linux (mostly because jhc doesn't seem to be working on Mac at the moment.) + - bash + +== INSTALL: + +* sudo gem install Hubris + +== LICENSE: + +(The MIT License) + +Copyright (c) 2009 Mark Wotton + +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. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..6df9eff --- /dev/null +++ b/Rakefile @@ -0,0 +1,26 @@ +require 'rubygems' +gem 'hoe', '>= 2.1.0' +require 'hoe' +require 'fileutils' +require './lib/Hubris' + +Hoe.plugin :newgem +# Hoe.plugin :website +# Hoe.plugin :cucumberfeatures + +# Generate all the Rake tasks +# Run 'rake -T' to see list of generated tasks (from gem root directory) +$hoe = Hoe.spec 'Hubris' do + self.developer 'FIXME full name', 'FIXME email' + self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required + self.rubyforge_name = self.name # TODO this is default value + # self.extra_deps = [['activesupport','>= 2.0.2']] + +end + +require 'newgem/tasks' +Dir['tasks/**/*.rake'].each { |t| load t } + +# TODO - want other tests/tasks run by default? Add them to the list +# remove_task :default +# task :default => [:spec, :features] diff --git a/lib/Hubris.rb b/lib/Hubris.rb new file mode 100644 index 0000000..7fc6dae --- /dev/null +++ b/lib/Hubris.rb @@ -0,0 +1,6 @@ +$:.unshift(File.dirname(__FILE__)) unless + $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) + +module Hubris + VERSION = '0.0.1' +end \ No newline at end of file diff --git a/script/console b/script/console new file mode 100755 index 0000000..ff73518 --- /dev/null +++ b/script/console @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# File: script/console +irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' + +libs = " -r irb/completion" +# Perhaps use a console_lib to store any extra methods I may want available in the cosole +# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}" +libs << " -r #{File.dirname(__FILE__) + '/../lib/Hubris.rb'}" +puts "Loading Hubris gem" +exec "#{irb} #{libs} --simple-prompt" \ No newline at end of file diff --git a/script/destroy b/script/destroy new file mode 100755 index 0000000..e48464d --- /dev/null +++ b/script/destroy @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) + +begin + require 'rubigen' +rescue LoadError + require 'rubygems' + require 'rubigen' +end +require 'rubigen/scripts/destroy' + +ARGV.shift if ['--help', '-h'].include?(ARGV[0]) +RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] +RubiGen::Scripts::Destroy.new.run(ARGV) diff --git a/script/generate b/script/generate new file mode 100755 index 0000000..c27f655 --- /dev/null +++ b/script/generate @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) + +begin + require 'rubigen' +rescue LoadError + require 'rubygems' + require 'rubigen' +end +require 'rubigen/scripts/generate' + +ARGV.shift if ['--help', '-h'].include?(ARGV[0]) +RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] +RubiGen::Scripts::Generate.new.run(ARGV) diff --git a/spec/Hubris_spec.rb b/spec/Hubris_spec.rb new file mode 100644 index 0000000..afdb080 --- /dev/null +++ b/spec/Hubris_spec.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/spec_helper.rb' + +# Time to add your specs! +# http://rspec.info/ +describe "Place your specs here" do + + it "find this spec in spec directory" do + # violated "Be sure to write your specs" + end + +end diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..cf6add7 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1 @@ +--colour \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..ef45d92 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,10 @@ +begin + require 'spec' +rescue LoadError + require 'rubygems' unless ENV['NO_RUBYGEMS'] + gem 'rspec' + require 'spec' +end + +$:.unshift(File.dirname(__FILE__) + '/../lib') +require 'Hubris' diff --git a/tasks/rspec.rake b/tasks/rspec.rake new file mode 100644 index 0000000..31a99b0 --- /dev/null +++ b/tasks/rspec.rake @@ -0,0 +1,21 @@ +begin + require 'spec' +rescue LoadError + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'spec' +end +begin + require 'spec/rake/spectask' +rescue LoadError + puts <<-EOS +To use rspec for testing you must install rspec gem: + gem install rspec +EOS + exit(0) +end + +desc "Run the specs under spec/models" +Spec::Rake::SpecTask.new do |t| + t.spec_opts = ['--options', "spec/spec.opts"] + t.spec_files = FileList['spec/**/*_spec.rb'] +end