-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
monkstone
committed
Mar 2, 2016
1 parent
e6f7255
commit 613bbc6
Showing
8 changed files
with
157 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
*.jar | ||
MANIFEST.MF | ||
target | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require_relative 'lib/basic/version' | ||
|
||
def create_manifest | ||
title = 'Implementation-Title: rpextras (example JRuby Extension)' | ||
version = format('Implementation-Version: %s', BasicExample::VERSION) | ||
file = File.open('MANIFEST.MF', 'w') do |f| | ||
f.puts(title) | ||
f.puts(version) | ||
end | ||
end | ||
|
||
task default: [:init, :compile, :test] | ||
|
||
desc 'Create Manifest' | ||
task :init do | ||
create_manifest | ||
end | ||
|
||
desc 'Build gem' | ||
task :gem do | ||
sh 'gem build jruby_art.gemspec' | ||
end | ||
|
||
desc 'Compile' | ||
task :compile do | ||
sh 'mvn package' | ||
sh 'mv target/rpextras.jar lib' | ||
end | ||
|
||
desc 'Test' | ||
task :test do | ||
sh 'jruby test/deglut_spec_test.rb' | ||
sh 'jruby test/vecmath_spec_test.rb' | ||
sh 'jruby test/math_tool_test.rb' | ||
sh 'jruby test/helper_methods_test.rb' | ||
sh 'jruby test/aabb_spec_test.rb' | ||
home = File.expand_path('~') | ||
config = File.exist?(format('%s/.jruby_art/config.yml', home)) | ||
if config | ||
ruby 'test/k9_run_test.rb' | ||
else | ||
warn format('You should create %s/.jruby_art/config.yml to run sketch tests', home) | ||
end | ||
end | ||
|
||
desc 'clean' | ||
task :clean do | ||
Dir['./**/*.%w{jar gem}'].each do |path| | ||
puts 'Deleting #{path} ...' | ||
File.delete(path) | ||
end | ||
FileUtils.rm_rf('./target') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require_relative '../lib/basic/version' | ||
|
||
def create_manifest | ||
title = 'Implementation-Title: jruby-ext (example JRuby Extension)' | ||
version = format('Implementation-Version: %s', BasicExample::VERSION) | ||
file = File.open('MANIFEST.MF', 'w') do |f| | ||
f.puts(title) | ||
f.puts(version) | ||
end | ||
end | ||
|
||
task default: [:init, :compile] | ||
|
||
desc 'Create Manifest' | ||
task :init do | ||
create_manifest | ||
end | ||
|
||
desc 'Compile' | ||
task :compile do | ||
sh 'mvn package' | ||
sh 'mv target/jruby-ext.jar ../lib' | ||
end | ||
|
||
desc 'clean' | ||
task :clean do | ||
Dir['./**/*.%w{jar}'].each do |path| | ||
puts 'Deleting #{path} ...' | ||
File.delete(path) | ||
end | ||
FileUtils.rm_rf('./target') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
# A wrapper for version | ||
module BasicExample | ||
VERSION = '1.0.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "java" | ||
$CLASSPATH << File.join(File.dirname(__FILE__), "..", "jruby-ext", "target", "classes") | ||
|
||
require "com/purbon/basic" | ||
|
||
|
||
return if $0 != __FILE__ | ||
|
||
## | ||
# If executed directly this class runs a few methods comming out of the extensions | ||
# defined in this project. | ||
## | ||
|
||
## | ||
# Using a class created in the jruby side, this class has for example a method with aliases, etc. | ||
## | ||
bar = Bar.new | ||
|
||
## | ||
# Calling a method form the class that has two names, throw aliases. This method return a simple | ||
# string from the java side. | ||
## | ||
puts bar.say | ||
puts bar.shout | ||
|
||
puts bar.add(4, 4) | ||
|
||
## | ||
# Using a module defined in the extensione. | ||
# Foo is a module defined in jruby extension point. | ||
## | ||
class MyRubyClass | ||
include Foo | ||
end | ||
|
||
## | ||
# Using a method defined in the module, but form the created class. | ||
## | ||
puts MyRubyClass.new.build_string | ||
## | ||
# Using the same method but as static method defined in the module. | ||
## | ||
puts Foo.build_string |