shvets-scriptlandia 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +7 -0
- data/README +42 -0
- data/Rakefile +96 -0
- data/TODO +3 -0
- data/bin/sl +22 -0
- data/bin/sl.bat +6 -0
- data/examples.zip +0 -0
- data/lib/buildfile +59 -0
- data/lib/configurer.rb +162 -0
- data/lib/language_installer.rb +47 -0
- data/lib/languages/ant/config.yaml +44 -0
- data/lib/languages/beanshell/config.yaml +6 -0
- data/lib/languages/clojure/config.yaml +7 -0
- data/lib/languages/extension_mapping.yaml +51 -0
- data/lib/languages/fan/config.yaml +8 -0
- data/lib/languages/fortress/config.yaml +11 -0
- data/lib/languages/groovy/config.yaml +7 -0
- data/lib/languages/jaskell/config.yaml +9 -0
- data/lib/languages/javascript/config.yaml +6 -0
- data/lib/languages/jawk/config.yaml +9 -0
- data/lib/languages/jruby/config.yaml +6 -0
- data/lib/languages/judo/config.yaml +7 -0
- data/lib/languages/jython/config.yaml +9 -0
- data/lib/languages/lolcode/config.yaml +6 -0
- data/lib/languages/pnuts/config.yaml +7 -0
- data/lib/languages/ptilde/config.yaml +8 -0
- data/lib/languages/scala/config.yaml +12 -0
- data/lib/languages/sleep/config.yaml +6 -0
- data/lib/languages/tcl/config.yaml +9 -0
- data/lib/languages/yoix/config.yaml +6 -0
- data/lib/launcher.rb +105 -0
- data/lib/settings.yaml +33 -0
- data/scriptlandia-r.gemspec +59 -0
- data/spec/rjb_spec.rb +28 -0
- data/spec/string_spec.rb +16 -0
- metadata +87 -0
data/CHANGES
ADDED
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= Scriptlandia-R -- Running scripts for Java VM
|
2
|
+
|
3
|
+
= Installing Scriptlandia-R
|
4
|
+
|
5
|
+
RubyGems is the preferred easy install method for Scriptlandia-R. However, you can install
|
6
|
+
Scriptlandia-R manually as described below.
|
7
|
+
|
8
|
+
== Installing the Gem
|
9
|
+
$ sudo gem sources -a http://gems.github.com
|
10
|
+
|
11
|
+
Scriptlandia-R is dependent on 2 plugins:
|
12
|
+
|
13
|
+
$ sudo gem install rjb
|
14
|
+
$ sudo gem install buildr
|
15
|
+
|
16
|
+
or
|
17
|
+
|
18
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install rjb
|
19
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
|
20
|
+
|
21
|
+
Scriptlandia-R is intended to be installed via the RubyGems [http://rubyforge.org/projects/rubygems/] system.
|
22
|
+
To get the latest version, simply enter the following into your command prompt:
|
23
|
+
|
24
|
+
$ sudo gem install shvets-scriptlandia
|
25
|
+
|
26
|
+
You must have RubyGems [http://rubyforge.org/projects/rubygems/] installed for the above to work.
|
27
|
+
|
28
|
+
After installation you have to configure the gem:
|
29
|
+
|
30
|
+
$ sudo sl --configure
|
31
|
+
|
32
|
+
You have to enter the location of Java Home and Jar Repository Location.
|
33
|
+
|
34
|
+
Now you can run scripts:
|
35
|
+
|
36
|
+
$ sl Hello.bsh
|
37
|
+
$ sl Test.scala
|
38
|
+
|
39
|
+
To install dependencies (jar files) for the language, run this command:
|
40
|
+
|
41
|
+
$ sl --install bsh
|
42
|
+
$ sl --install scala
|
data/Rakefile
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Rakefile for Scriptlandia-R
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rcov/rcovtask'
|
9
|
+
|
10
|
+
|
11
|
+
spec_name = 'scriptlandia-r.gemspec'
|
12
|
+
|
13
|
+
SPEC = Gem::Specification.load(spec_name)
|
14
|
+
|
15
|
+
Rake::GemPackageTask.new(SPEC) do |pkg|
|
16
|
+
# pkg.need_tar = true
|
17
|
+
# pkg.need_zip = true
|
18
|
+
end
|
19
|
+
|
20
|
+
Spec::Rake::SpecTask.new do |task|
|
21
|
+
task.libs << 'lib'
|
22
|
+
task.pattern = 'spec/**/*_spec.rb'
|
23
|
+
task.verbose = false
|
24
|
+
end
|
25
|
+
|
26
|
+
Rake::RDocTask.new do |rdoc|
|
27
|
+
rdoc.rdoc_dir = 'rdoc'
|
28
|
+
rdoc.title = 'teststuff'
|
29
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
30
|
+
rdoc.rdoc_files.include('README*')
|
31
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
|
+
end
|
33
|
+
|
34
|
+
Rcov::RcovTask.new do |task|
|
35
|
+
task.libs << 'test'
|
36
|
+
task.test_files = FileList['test/**/*_test.rb']
|
37
|
+
task.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "test gem compatibility with github"
|
41
|
+
task :"github:validate" do
|
42
|
+
SPEC.validate
|
43
|
+
|
44
|
+
puts SPEC
|
45
|
+
puts "OK"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "make zip file"
|
49
|
+
task :zip do
|
50
|
+
def create_zip_file dir
|
51
|
+
require 'zip/zip'
|
52
|
+
|
53
|
+
Zip::ZipOutputStream.open(dir + ".zip") do |zos|
|
54
|
+
zip zos, dir
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def zip zos, dir
|
60
|
+
Dir.new(dir).each do |filename|
|
61
|
+
if(filename != '.' and filename != '..')
|
62
|
+
full_name = dir + '/' + filename
|
63
|
+
|
64
|
+
if File.directory? full_name
|
65
|
+
zip(zos, full_name)
|
66
|
+
else
|
67
|
+
# Create a new entry with some arbitrary name
|
68
|
+
zos.put_next_entry(dir + '/' + filename)
|
69
|
+
# Add the contents of the file, don't read the stuff linewise if its binary, instead use direct IO
|
70
|
+
zos.print IO.read(dir + '/' + filename)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def files name
|
77
|
+
list = []
|
78
|
+
|
79
|
+
if File.directory? name
|
80
|
+
Dir.new(name).each do |filename|
|
81
|
+
if(filename != '.' and filename != '..')
|
82
|
+
list += files(name + '/' + filename)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
else
|
86
|
+
list << name
|
87
|
+
end
|
88
|
+
|
89
|
+
list
|
90
|
+
end
|
91
|
+
|
92
|
+
create_zip_file 'examples'
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
task :default => :rcov
|
data/bin/sl
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
require 'language_installer'
|
5
|
+
require 'configurer'
|
6
|
+
require 'launcher'
|
7
|
+
|
8
|
+
if(ARGV.size == 0)
|
9
|
+
puts "Please specify script file name."
|
10
|
+
else
|
11
|
+
if(ARGV[0] == '--install')
|
12
|
+
if(ARGV.size < 2)
|
13
|
+
puts "Please specify language name to be installed."
|
14
|
+
else
|
15
|
+
Scriptlandia::LanguageInstaller.new.install
|
16
|
+
end
|
17
|
+
elsif(ARGV[0] == '--configure')
|
18
|
+
Scriptlandia::Configurer.new.configure
|
19
|
+
else
|
20
|
+
Scriptlandia::Launcher.new.launch
|
21
|
+
end
|
22
|
+
end
|
data/bin/sl.bat
ADDED
data/examples.zip
ADDED
Binary file
|
data/lib/buildfile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# buildfile
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
settings = YAML::load File.open(File.dirname(__FILE__) + '/../settings.yaml')
|
6
|
+
|
7
|
+
ENV['JAVA_HOME'] = settings['java_home']
|
8
|
+
|
9
|
+
repositories.local = settings['repositories']['local']
|
10
|
+
|
11
|
+
settings['repositories']['remote'].each do |repository|
|
12
|
+
repositories.remote << repository
|
13
|
+
end
|
14
|
+
|
15
|
+
#options.proxy.http = ''
|
16
|
+
#options.proxy.exclude << '*.mycompany.com'
|
17
|
+
#options.proxy.exclude << 'localhost'
|
18
|
+
#ENV['http_proxy'] = ''
|
19
|
+
|
20
|
+
define 'buildr' do
|
21
|
+
def language_folder ext_mapping, ext
|
22
|
+
ext_mapping.each do |folder, extensions|
|
23
|
+
if folder == ext
|
24
|
+
return folder
|
25
|
+
end
|
26
|
+
|
27
|
+
if extensions.include?(ext)
|
28
|
+
return folder
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def build dep
|
34
|
+
extension = ENV['EXT']
|
35
|
+
|
36
|
+
if(extension == nil)
|
37
|
+
puts "Please specify language name or extension."
|
38
|
+
else
|
39
|
+
puts "ext: " + extension
|
40
|
+
|
41
|
+
ext_mapping = YAML::load File.open(File.dirname(__FILE__) + '/languages/extension_mapping.yaml')
|
42
|
+
|
43
|
+
language = language_folder(ext_mapping, extension)
|
44
|
+
|
45
|
+
puts "language: " + language.to_s
|
46
|
+
|
47
|
+
lang_config = YAML::load File.open(File.dirname(__FILE__) + '/languages/' + language + '/config.yaml')
|
48
|
+
|
49
|
+
puts 'Installing ' + language + ' language...'
|
50
|
+
|
51
|
+
lang_config['artifacts'].each do |name, a|
|
52
|
+
artifact(a).invoke
|
53
|
+
end
|
54
|
+
|
55
|
+
puts 'Language ' + language + ' installed.'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/configurer.rb
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
# installer.rb
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'find'
|
6
|
+
require 'ftools'
|
7
|
+
#require 'rake/gempackagetask'
|
8
|
+
|
9
|
+
module Scriptlandia
|
10
|
+
class Configurer
|
11
|
+
include Config
|
12
|
+
|
13
|
+
def configure
|
14
|
+
ARGV.shift
|
15
|
+
|
16
|
+
prepare()
|
17
|
+
|
18
|
+
install_settings(File.dirname(__FILE__) + "/../" + "lib/settings.yaml", $my_libdir + "/../settings.yaml")
|
19
|
+
|
20
|
+
settings = YAML::load File.open($my_libdir + "/../settings.yaml")
|
21
|
+
|
22
|
+
#install_file("bin/sl.bat", $my_bindir, "sl.bat", settings) if CONFIG['host_os'] =~ /mswin/
|
23
|
+
|
24
|
+
install_file_with_header($my_gem_path + "/bin/sl", $my_gem_path + "/bin/sl", settings)
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def prepare
|
30
|
+
$bindir = CONFIG["bindir"]
|
31
|
+
|
32
|
+
$my_bindir = CONFIG['bindir']
|
33
|
+
|
34
|
+
unless File.writable? $my_bindir
|
35
|
+
$my_bindir = [ENV['HOME'], '.gem', 'ruby', CONFIG["MAJOR"]+"."+CONFIG["MINOR"], 'bin'].join(File::SEPARATOR)
|
36
|
+
end
|
37
|
+
|
38
|
+
$libdir = CONFIG["libdir"]
|
39
|
+
|
40
|
+
my_gems_path = [CONFIG['libdir'], 'ruby', 'gems'].join(File::SEPARATOR)
|
41
|
+
|
42
|
+
# unless File.writable? my_gems_path
|
43
|
+
# my_gems_path = [ENV['HOME'], '.gem', 'ruby'].join(File::SEPARATOR)
|
44
|
+
# end
|
45
|
+
|
46
|
+
$ruby = CONFIG['ruby_install_name']
|
47
|
+
|
48
|
+
$spec = Gem::Specification.load(File.dirname(__FILE__) + "/../" + 'scriptlandia-r.gemspec')
|
49
|
+
|
50
|
+
$my_gem_path = File.join(my_gems_path, CONFIG["MAJOR"]+"."+CONFIG["MINOR"],
|
51
|
+
'gems', $spec.name + '-' + $spec.version.to_s)
|
52
|
+
|
53
|
+
$my_libdir = File.join($my_gem_path, 'lib')
|
54
|
+
end
|
55
|
+
|
56
|
+
def tmp_file
|
57
|
+
tmp_dir = nil
|
58
|
+
for t in [".", "/tmp", "c:/temp", $my_bindir]
|
59
|
+
stat = File.stat(t) rescue next
|
60
|
+
if stat.directory? and stat.writable?
|
61
|
+
tmp_dir = t
|
62
|
+
break
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
fail "Cannot find a temporary directory" unless tmp_dir
|
67
|
+
|
68
|
+
File.join(tmp_dir, "_tmp")
|
69
|
+
end
|
70
|
+
|
71
|
+
def install_file from_file, to_dir, to_file, settings
|
72
|
+
File.makedirs to_dir
|
73
|
+
|
74
|
+
#File::install(from_file, File.join(to_dir, to_file), 0755, true)
|
75
|
+
|
76
|
+
tmp = tmp_file()
|
77
|
+
|
78
|
+
File.open(from_file) do |ip|
|
79
|
+
File.open(tmp, "w") do |op|
|
80
|
+
|
81
|
+
op.write ip.read.gsub('C:/Ruby/ruby-1.8.7/bin/sl', $bindir + '/sl')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
File::install(tmp, to_file, 0755, true)
|
86
|
+
File::unlink(tmp)
|
87
|
+
end
|
88
|
+
|
89
|
+
def install_file_with_header(from_file, to_file, settings)
|
90
|
+
tmp = tmp_file()
|
91
|
+
|
92
|
+
File.open(from_file) do |ip|
|
93
|
+
File.open(tmp, "w") do |op|
|
94
|
+
ruby = File.join($bindir, $ruby)
|
95
|
+
op.puts "#!#{ruby} -w"
|
96
|
+
# op.puts "name = '" + $spec.name + "'"
|
97
|
+
# op.puts "version = '" + $spec.version.to_s + "'"
|
98
|
+
op.puts "ENV['JAVA_HOME'] = '" + settings['java_home'].chomp + "'"
|
99
|
+
|
100
|
+
op.write ip.read
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
File::install(tmp, to_file, 0755, true)
|
105
|
+
File::unlink(tmp)
|
106
|
+
end
|
107
|
+
|
108
|
+
def install_settings from_file, to_file
|
109
|
+
require 'yaml'
|
110
|
+
|
111
|
+
orig_settings_file_name = $my_libdir + "/settings.yaml"
|
112
|
+
|
113
|
+
if(File.exist? orig_settings_file_name)
|
114
|
+
settings = YAML::load File.open(orig_settings_file_name)
|
115
|
+
else
|
116
|
+
settings = YAML::load File.open(from_file)
|
117
|
+
end
|
118
|
+
|
119
|
+
orig_java_home = settings['java_home'].chomp
|
120
|
+
|
121
|
+
if orig_java_home[0..1] == 'c:' && CONFIG['host_os'] =~ /darwin/i
|
122
|
+
orig_java_home = '/Library/Java/Home'
|
123
|
+
end
|
124
|
+
|
125
|
+
orig_repository_home = settings['repositories']['local'].chomp
|
126
|
+
|
127
|
+
if orig_repository_home[0..1] == 'c:' && CONFIG['host_os'] =~ /darwin/i
|
128
|
+
orig_repository_home = '~/repository'
|
129
|
+
end
|
130
|
+
|
131
|
+
puts 'Enter Java Home (' + orig_java_home + "):"
|
132
|
+
|
133
|
+
java_home = gets
|
134
|
+
|
135
|
+
if(java_home.chomp.empty?)
|
136
|
+
java_home = orig_java_home
|
137
|
+
else
|
138
|
+
java_home = java_home.chomp
|
139
|
+
end
|
140
|
+
|
141
|
+
puts 'Enter Repository Home (' + orig_repository_home + "):"
|
142
|
+
|
143
|
+
repository_home = gets
|
144
|
+
|
145
|
+
if(repository_home.chomp.empty?)
|
146
|
+
repository_home = orig_repository_home
|
147
|
+
else
|
148
|
+
repository_home = repository_home.chomp
|
149
|
+
end
|
150
|
+
|
151
|
+
settings = YAML::load File.open(from_file)
|
152
|
+
settings['java_home'] = java_home
|
153
|
+
settings['repositories']['local'] = repository_home
|
154
|
+
|
155
|
+
File.open( to_file, 'w' ) do |out|
|
156
|
+
YAML.dump(settings, out)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# language_installer.rb
|
2
|
+
|
3
|
+
module Scriptlandia
|
4
|
+
class LanguageInstaller
|
5
|
+
include Config
|
6
|
+
|
7
|
+
def install
|
8
|
+
my_bindir = CONFIG['bindir']
|
9
|
+
|
10
|
+
unless File.writable? my_bindir
|
11
|
+
my_bindir = [ENV['HOME'], '.gem', 'ruby', CONFIG["MAJOR"]+"."+CONFIG["MINOR"], 'bin'].join(File::SEPARATOR)
|
12
|
+
end
|
13
|
+
|
14
|
+
my_gems_path = [CONFIG['libdir'], 'ruby', 'gems'].join(File::SEPARATOR)
|
15
|
+
|
16
|
+
unless File.writable? my_gems_path
|
17
|
+
my_gems_path = [ENV['HOME'], '.gem', 'ruby'].join(File::SEPARATOR)
|
18
|
+
end
|
19
|
+
|
20
|
+
buildr = File.join my_bindir, 'buildr'
|
21
|
+
|
22
|
+
buildr << '.bat' if CONFIG['host_os'] =~ /mswin/i
|
23
|
+
|
24
|
+
old_ext = ENV['EXT']
|
25
|
+
|
26
|
+
ENV['EXT'] = ARGV[1]
|
27
|
+
|
28
|
+
# buildfile = File.join(my_gems_path,
|
29
|
+
# CONFIG["MAJOR"]+"."+CONFIG["MINOR"],
|
30
|
+
# 'gems', name + '-' + version, 'lib', 'buildfile')
|
31
|
+
|
32
|
+
buildfile = File.join(File.dirname(__FILE__), 'buildfile')
|
33
|
+
|
34
|
+
ARGV.shift
|
35
|
+
ARGV.shift
|
36
|
+
|
37
|
+
ARGV.insert 0, buildfile
|
38
|
+
ARGV.insert 0, '-f'
|
39
|
+
|
40
|
+
require 'rubygems'
|
41
|
+
require 'buildr'
|
42
|
+
Buildr.application.run
|
43
|
+
|
44
|
+
ENV['EXT'] = old_ext
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
jvmargs:
|
2
|
+
|
3
|
+
artifacts:
|
4
|
+
bsh: bsh:bsh:jar:2.0b5
|
5
|
+
bcel: bcel:bcel:jar:5.1
|
6
|
+
bsf: bsf:bsf:jar:2.4.0
|
7
|
+
log4j: log4j:log4j:jar:1.2.13
|
8
|
+
oro: oro:oro:jar:2.0.8
|
9
|
+
regexp: regexp:regexp:jar:1.3
|
10
|
+
xml-resolver: xml-resolver:xml-resolver:jar:1.1
|
11
|
+
mail: javax.mail:mail:jar:1.4
|
12
|
+
activation: javax.activation:activation:jar:1.1
|
13
|
+
jdepend: jdepend:jdepend:jar:2.7
|
14
|
+
jsch: com.jcraft:jsch:jar:0.1.29
|
15
|
+
junit: junit:junit:jar:3.8.2
|
16
|
+
commons-logging-api: commons-logging:commons-logging-api:jar:1.0.4
|
17
|
+
commons-net: commons-net:commons-net:jar:1.4.0
|
18
|
+
|
19
|
+
ant: org.apache.ant:ant:jar:1.7.1
|
20
|
+
ant-apache-bcel: org.apache.ant:ant-apache-bcel:jar:1.7.1
|
21
|
+
ant-apache-bsf: org.apache.ant:ant-apache-bsf:jar:1.7.1
|
22
|
+
ant-apache-log4j: org.apache.ant:ant-apache-log4j:jar:1.7.1
|
23
|
+
ant-apache-oro: org.apache.ant:ant-apache-oro:jar:1.7.1
|
24
|
+
ant-apache-regexp: org.apache.ant:ant-apache-regexp:jar:1.7.1
|
25
|
+
ant-apache-resolver: org.apache.ant:ant-apache-resolver:jar:1.7.1
|
26
|
+
ant-commons-logging: org.apache.ant:ant-commons-logging:jar:1.7.1
|
27
|
+
ant-commons-net: org.apache.ant:ant-commons-net:jar:1.7.1
|
28
|
+
ant-javamail: org.apache.ant:ant-javamail:jar:1.7.1
|
29
|
+
ant-jdepend: org.apache.ant:ant-jdepend:jar:1.7.1
|
30
|
+
ant-jsch: org.apache.ant:ant-jsch:jar:1.7.1
|
31
|
+
ant-junit: org.apache.ant:ant-junit:jar:1.7.1
|
32
|
+
ant-launcher: org.apache.ant:ant-launcher:jar:1.7.1
|
33
|
+
ant-nodeps: org.apache.ant:ant-nodeps:jar:1.7.1
|
34
|
+
ant-swing: org.apache.ant:ant-swing:jar:1.7.1
|
35
|
+
ant-testutil: org.apache.ant:ant-testutil:jar:1.7.1
|
36
|
+
ant-trax: org.apache.ant:ant-trax:jar:1.7.1
|
37
|
+
ant-pack200: org.apache.ant:ant-pack200:jar:1.7.1
|
38
|
+
ant-apt: org.apache.ant:ant-apt:jar:1.7.1
|
39
|
+
ant-antlr: org.apache.ant:ant-antlr:jar:1.7.1
|
40
|
+
|
41
|
+
start_class: org.apache.tools.ant.Main
|
42
|
+
|
43
|
+
command_line:
|
44
|
+
['-f']
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# extension_mapping.yaml
|
2
|
+
|
3
|
+
ant: [ant, build.xml]
|
4
|
+
|
5
|
+
beanshell: [bsh]
|
6
|
+
|
7
|
+
class: [class]
|
8
|
+
|
9
|
+
clojure: [clj]
|
10
|
+
|
11
|
+
etl: [etl]
|
12
|
+
|
13
|
+
fan: [fan, pod]
|
14
|
+
|
15
|
+
fortress: [fss]
|
16
|
+
|
17
|
+
freemarker: [ftl, freemarker]
|
18
|
+
|
19
|
+
groovy: [groovy]
|
20
|
+
|
21
|
+
jaskell: [jsl, jaskell]
|
22
|
+
|
23
|
+
javascript: [js, javascript]
|
24
|
+
|
25
|
+
jawk: [jawk, awk]
|
26
|
+
|
27
|
+
jelly: [jelly]
|
28
|
+
|
29
|
+
judo: [judo]
|
30
|
+
|
31
|
+
jython: [py, python, jython]
|
32
|
+
|
33
|
+
lolcode: [lol, lcd]
|
34
|
+
|
35
|
+
maven: [mvn, maven, pom.xml]
|
36
|
+
|
37
|
+
pnuts: [pnut]
|
38
|
+
|
39
|
+
ptilde: [p7e, p7ei]
|
40
|
+
|
41
|
+
jruby: [rb, ruby]
|
42
|
+
|
43
|
+
scala: [scala]
|
44
|
+
|
45
|
+
sleep: [sl, sleep]
|
46
|
+
|
47
|
+
tcl: [tcl]
|
48
|
+
|
49
|
+
velocity: [vm, velocity]
|
50
|
+
|
51
|
+
yoix: [yx]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
jvmargs:
|
2
|
+
|
3
|
+
artifacts:
|
4
|
+
fortress: com.sun.fortress:fortress:jar:588
|
5
|
+
fortress-lib: com.sun.fortress:fortress-lib:jar:588
|
6
|
+
xtc: xtc:xtc:jar:1.10.0
|
7
|
+
concurrent: concurrent:concurrent:jar:1.3.4
|
8
|
+
bcel: bcel:bcel:jar:5.2
|
9
|
+
plt: edu.rice:plt:jar:20070717-1913
|
10
|
+
|
11
|
+
start_class: com.sun.fortress.interpreter.drivers.fs
|
@@ -0,0 +1,9 @@
|
|
1
|
+
jvmargs:
|
2
|
+
['-Dpython.home=#{repositories.local}/jython/jython/2.2.1',
|
3
|
+
'-Dpython.cachedir=#{repositories.local}/jython/jython/2.2.1/cachedir']
|
4
|
+
|
5
|
+
artifacts:
|
6
|
+
jython: jython:jython:jar:2.2.1
|
7
|
+
jython-lib: jython:jython-lib:jar:2.2.1
|
8
|
+
|
9
|
+
start_class: org.python.util.jython
|
@@ -0,0 +1,12 @@
|
|
1
|
+
jvmargs:
|
2
|
+
|
3
|
+
artifacts:
|
4
|
+
scala-lirary: org.scala-lang:scala-library:jar:2.7.1
|
5
|
+
scala-compiler: org.scala-lang:scala-compiler:jar:2.7.1
|
6
|
+
scala-dbc: org.scala-lang:scala-dbc:jar:2.7.1
|
7
|
+
scala-decoder: org.scala-lang:scala-decoder:jar:2.7.1
|
8
|
+
|
9
|
+
start_class: scala.tools.nsc.MainGenericRunner
|
10
|
+
|
11
|
+
command_line:
|
12
|
+
['-nocompdaemon', '-howtorun:script']
|
data/lib/launcher.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# scriptlandia.rb
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rjb'
|
6
|
+
|
7
|
+
class String
|
8
|
+
def interpolate vars
|
9
|
+
s_i = self.dup
|
10
|
+
|
11
|
+
vars.each do |key, value|
|
12
|
+
regexp = Regexp.new('#\{' + key + '\}')
|
13
|
+
|
14
|
+
s_i.gsub! regexp, value
|
15
|
+
end
|
16
|
+
|
17
|
+
s_i
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
module Scriptlandia
|
23
|
+
class Launcher
|
24
|
+
def initialize
|
25
|
+
@settings = YAML::load File.open(File.dirname(__FILE__) + '/settings.yaml')
|
26
|
+
@ext_mapping = YAML::load File.open(File.dirname(__FILE__) + '/languages/extension_mapping.yaml')
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.extension name
|
30
|
+
name[name.rindex('.')+1, name.length]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.language_folder ext_mapping, name
|
34
|
+
language_folder = nil
|
35
|
+
|
36
|
+
ext = extension(name)
|
37
|
+
|
38
|
+
ext_mapping.each do |folder, extensions|
|
39
|
+
if extensions.include?(ext) or extensions.include?(name)
|
40
|
+
language_folder = folder
|
41
|
+
break
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
language_folder
|
46
|
+
end
|
47
|
+
|
48
|
+
def launch
|
49
|
+
script_name = ARGV[0]
|
50
|
+
|
51
|
+
language = Launcher.language_folder(@ext_mapping, File.dirname(__FILE__) + "/" + script_name)
|
52
|
+
|
53
|
+
if(language == nil)
|
54
|
+
puts "Unsupported language/extension: " + Launcher.extension(File.dirname(__FILE__) + "/" + script_name)
|
55
|
+
else
|
56
|
+
lang_config = YAML::load File.open(File.dirname(__FILE__) + '/languages/' +
|
57
|
+
language + '/config.yaml')
|
58
|
+
|
59
|
+
ENV['JAVA_HOME'] = @settings['java_home']
|
60
|
+
local_repository = @settings['repositories']['local']
|
61
|
+
|
62
|
+
vars = {'repositories.local' => local_repository }
|
63
|
+
|
64
|
+
jvm_args = lang_config['jvmargs']
|
65
|
+
jvm_args = [] if jvm_args == nil
|
66
|
+
|
67
|
+
jvm_args = jvm_args.collect { |arg| arg.interpolate(vars) }
|
68
|
+
|
69
|
+
classpath = lang_config['classpath']
|
70
|
+
classpath = [] if classpath == nil
|
71
|
+
|
72
|
+
lang_config['artifacts'].each do |name, artifact|
|
73
|
+
group, id, type,version = artifact.split(':')
|
74
|
+
|
75
|
+
file_name = local_repository + '/' +
|
76
|
+
group.gsub('.', '/') + '/' +
|
77
|
+
id.gsub('.', '/') + '/' +
|
78
|
+
version + '/' +
|
79
|
+
id.gsub('.', '/') + '-' + version + '.' + type
|
80
|
+
|
81
|
+
unless File.exist? file_name
|
82
|
+
puts 'File ' + file_name + ' does not exists.'
|
83
|
+
else
|
84
|
+
classpath << file_name
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
pause = false
|
89
|
+
|
90
|
+
if(ARGV.include? '--wait')
|
91
|
+
ARGV.delete '--wait'
|
92
|
+
pause = true
|
93
|
+
end
|
94
|
+
|
95
|
+
Rjb::load(classpath.join(File::PATH_SEPARATOR), jvmargs = jvm_args)
|
96
|
+
|
97
|
+
ARGV[0, 0] = lang_config['command_line'] if lang_config['command_line']
|
98
|
+
|
99
|
+
Rjb::import(lang_config['start_class']).main(ARGV)
|
100
|
+
|
101
|
+
STDIN.gets if pause
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/settings.yaml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
java_home:
|
2
|
+
c:/Java/jdk1.5.0
|
3
|
+
|
4
|
+
repositories:
|
5
|
+
|
6
|
+
# customize user local maven2 repository location
|
7
|
+
local: c:/Work/maven-repository
|
8
|
+
|
9
|
+
# prefer the local or nearest mirrors
|
10
|
+
remote:
|
11
|
+
- file://c:/Work/maven-repository-accelerator
|
12
|
+
- http://scriptlandia-repository.googlecode.com/svn/trunk/languages
|
13
|
+
- http://scriptlandia-repository.googlecode.com/svn/trunk/tools
|
14
|
+
- http://repository.springsource.com/maven/bundles/release
|
15
|
+
- http://repository.springsource.com/maven/bundles/external
|
16
|
+
- http://repository.springsource.com/maven/libraries/release
|
17
|
+
- http://repository.springsource.com/maven/libraries/external
|
18
|
+
- http://repository.jboss.com/maven2
|
19
|
+
- http://repo.mergere.com/maven2
|
20
|
+
- http://repo1.maven.org/maven2
|
21
|
+
- http://repo1.maven.org/maven-spring
|
22
|
+
- http://dist.codehaus.org
|
23
|
+
- http://repository.codehaus.org
|
24
|
+
- http://download.java.net/maven/2
|
25
|
+
- https://maven-repository.dev.java.net/nonav/repository
|
26
|
+
- http://download.java.net/maven/2
|
27
|
+
- http://jyaml.sourceforge.net/m2-repo
|
28
|
+
- http://dist.codehaus.org/mule/dependencies/maven2
|
29
|
+
- http://scala-tools.org/repo-releases
|
30
|
+
|
31
|
+
#options:
|
32
|
+
# proxy:
|
33
|
+
# http: ''
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# scriptlandia-r.gemspec
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'scriptlandia'
|
7
|
+
spec.version = '0.5.6'
|
8
|
+
spec.required_rubygems_version = Gem::Requirement.new(">= 0") if spec.respond_to? :required_rubygems_version=
|
9
|
+
|
10
|
+
spec.authors = ["Alexander Shvets"]
|
11
|
+
spec.date = %q{2009-02-14}
|
12
|
+
spec.description = 'Scriptlandia Launcher in Ruby.'
|
13
|
+
spec.email = 'alexander.shvets@gmail.com'
|
14
|
+
|
15
|
+
spec.files = %w(CHANGES Rakefile README scriptlandia-r.gemspec TODO examples.zip) +
|
16
|
+
%w(bin/sl bin/sl.bat) +
|
17
|
+
%w(lib/buildfile lib/configurer.rb
|
18
|
+
lib/language_installer.rb lib/launcher.rb
|
19
|
+
lib/settings.yaml
|
20
|
+
lib/languages/ant/config.yaml
|
21
|
+
lib/languages/beanshell/config.yaml
|
22
|
+
lib/languages/clojure/config.yaml
|
23
|
+
lib/languages/fan/config.yaml
|
24
|
+
lib/languages/fortress/config.yaml
|
25
|
+
lib/languages/groovy/config.yaml
|
26
|
+
lib/languages/jaskell/config.yaml
|
27
|
+
lib/languages/javascript/config.yaml
|
28
|
+
lib/languages/jawk/config.yaml
|
29
|
+
lib/languages/jruby/config.yaml
|
30
|
+
lib/languages/judo/config.yaml
|
31
|
+
lib/languages/jython/config.yaml
|
32
|
+
lib/languages/lolcode/config.yaml
|
33
|
+
lib/languages/pnuts/config.yaml
|
34
|
+
lib/languages/ptilde/config.yaml
|
35
|
+
lib/languages/scala/config.yaml
|
36
|
+
lib/languages/sleep/config.yaml
|
37
|
+
lib/languages/tcl/config.yaml
|
38
|
+
lib/languages/yoix/config.yaml
|
39
|
+
lib/languages/extension_mapping.yaml) +
|
40
|
+
%w(spec/rjb_spec.rb spec/string_spec.rb)
|
41
|
+
spec.has_rdoc = false
|
42
|
+
spec.homepage = 'http://github.com/shvets/scriptlandia-r'
|
43
|
+
spec.require_paths = ["lib"]
|
44
|
+
spec.rubyforge_project = 'scriptlandia-r'
|
45
|
+
spec.rubygems_version = '1.3.1'
|
46
|
+
spec.summary = %q{.}
|
47
|
+
|
48
|
+
if spec.respond_to? :specification_version then
|
49
|
+
spec.specification_version = 2
|
50
|
+
end
|
51
|
+
|
52
|
+
spec.executables = ['sl']
|
53
|
+
spec.platform = Gem::Platform::RUBY
|
54
|
+
spec.requirements = ["none"]
|
55
|
+
spec.bindir = "bin"
|
56
|
+
|
57
|
+
#spec.add_dependency("rjb", ">= 1.1.6")
|
58
|
+
#spec.add_dependency("buildr", ">= 1.3.3")
|
59
|
+
end
|
data/spec/rjb_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rjb'
|
5
|
+
|
6
|
+
|
7
|
+
describe Rjb do
|
8
|
+
|
9
|
+
it "should load java String class" do
|
10
|
+
if RUBY_PLATFORM =~ /mswin32/
|
11
|
+
ENV['JAVA_HOME'] = 'c:/Java/jdk1.5.0'
|
12
|
+
else
|
13
|
+
ENV['JAVA_HOME'] = '/Library/Java/Home'
|
14
|
+
end
|
15
|
+
|
16
|
+
#ENV['LD_LIBRARY_PATH'] = "#{ENV['LD_LIBRARY_PATH']}:#{ENV['JAVA_HOME]}/jre/lib/i386:#{ENV['JAVA_HOME']}/jre/lib/i386/client"
|
17
|
+
|
18
|
+
Rjb::load(classpath = '.', jvmargs=[])
|
19
|
+
|
20
|
+
str = Rjb::import('java.lang.String')
|
21
|
+
|
22
|
+
instance = str.new "test"
|
23
|
+
|
24
|
+
instance.should_not be_nil
|
25
|
+
#assert_equal instance.to_s, 'test'
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/string_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require '../lib/scriptlandia'
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
|
7
|
+
it "should interpolate values" do
|
8
|
+
s = '-Dfan.home=#{repositories.local}/fan/fan-sys/1.0.29'
|
9
|
+
|
10
|
+
repositories_local = 'c:/maven-repository'
|
11
|
+
|
12
|
+
s_i = s.interpolate({'repositories.local' => repositories_local})
|
13
|
+
|
14
|
+
s_i.should eql('-Dfan.home=' + repositories_local + '/fan/fan-sys/1.0.29')
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shvets-scriptlandia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Shvets
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-14 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Scriptlandia Launcher in Ruby.
|
17
|
+
email: alexander.shvets@gmail.com
|
18
|
+
executables:
|
19
|
+
- sl
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- CHANGES
|
26
|
+
- Rakefile
|
27
|
+
- README
|
28
|
+
- scriptlandia-r.gemspec
|
29
|
+
- TODO
|
30
|
+
- examples.zip
|
31
|
+
- bin/sl
|
32
|
+
- bin/sl.bat
|
33
|
+
- lib/buildfile
|
34
|
+
- lib/configurer.rb
|
35
|
+
- lib/language_installer.rb
|
36
|
+
- lib/launcher.rb
|
37
|
+
- lib/settings.yaml
|
38
|
+
- lib/languages/ant/config.yaml
|
39
|
+
- lib/languages/beanshell/config.yaml
|
40
|
+
- lib/languages/clojure/config.yaml
|
41
|
+
- lib/languages/fan/config.yaml
|
42
|
+
- lib/languages/fortress/config.yaml
|
43
|
+
- lib/languages/groovy/config.yaml
|
44
|
+
- lib/languages/jaskell/config.yaml
|
45
|
+
- lib/languages/javascript/config.yaml
|
46
|
+
- lib/languages/jawk/config.yaml
|
47
|
+
- lib/languages/jruby/config.yaml
|
48
|
+
- lib/languages/judo/config.yaml
|
49
|
+
- lib/languages/jython/config.yaml
|
50
|
+
- lib/languages/lolcode/config.yaml
|
51
|
+
- lib/languages/pnuts/config.yaml
|
52
|
+
- lib/languages/ptilde/config.yaml
|
53
|
+
- lib/languages/scala/config.yaml
|
54
|
+
- lib/languages/sleep/config.yaml
|
55
|
+
- lib/languages/tcl/config.yaml
|
56
|
+
- lib/languages/yoix/config.yaml
|
57
|
+
- lib/languages/extension_mapping.yaml
|
58
|
+
- spec/rjb_spec.rb
|
59
|
+
- spec/string_spec.rb
|
60
|
+
has_rdoc: false
|
61
|
+
homepage: http://github.com/shvets/scriptlandia-r
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
requirements:
|
80
|
+
- none
|
81
|
+
rubyforge_project: scriptlandia-r
|
82
|
+
rubygems_version: 1.2.0
|
83
|
+
signing_key:
|
84
|
+
specification_version: 2
|
85
|
+
summary: .
|
86
|
+
test_files: []
|
87
|
+
|