runch 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +15 -0
- data/README.md +8 -1
- data/lib/runch/command.rb +2 -9
- data/lib/runch/language.rb +12 -0
- data/lib/runch/language/base.rb +36 -0
- data/lib/runch/language/c.rb +18 -0
- data/lib/runch/language/java.rb +24 -0
- data/lib/runch/version.rb +1 -1
- data/runch.gemspec +2 -2
- data/sample/Hello.java +5 -0
- data/sample/hello.c +2 -1
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9442b5886d11aec6f51dd01cb13d352bdf1f57d2
|
4
|
+
data.tar.gz: a6212bb16c16effa9468b97faad1089b937ee941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9af738a8a6db99a6e2e9bb95f0f61f948fb33d5ecec1596338a7500677540971f403fba1c44bc13b4e0bc415517c95ff42be6ff2d2abcd7ab3680431959bcdab
|
7
|
+
data.tar.gz: b0abbccf2d26edfc0c8f0804a297fa5eeb755b67219bf9eae465e39618f1cc6730a81ca347d75c07b4655b7479745b51fad8af2fca0f6b6913c813d87d713d24
|
data/NEWS.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Runch
|
2
2
|
|
3
|
-
A launcher as interpreter.
|
3
|
+
A launcher for source code as interpreter.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -9,11 +9,18 @@ A launcher as interpreter.
|
|
9
9
|
## Support Languages
|
10
10
|
|
11
11
|
* C
|
12
|
+
* Java
|
12
13
|
|
13
14
|
## Usage
|
14
15
|
|
16
|
+
### C
|
17
|
+
|
15
18
|
runch hello.c
|
16
19
|
|
20
|
+
### Java
|
21
|
+
|
22
|
+
runch Hello.java
|
23
|
+
|
17
24
|
## Contributing
|
18
25
|
|
19
26
|
1. Fork it
|
data/lib/runch/command.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "runch/language"
|
2
2
|
|
3
3
|
module Runch
|
4
4
|
class Command
|
@@ -12,14 +12,7 @@ module Runch
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run(arguments)
|
15
|
-
|
16
|
-
arguments.each do |file|
|
17
|
-
FileUtils.cp(file, dir)
|
18
|
-
basename = File.basename(file, ".*")
|
19
|
-
system("gcc", "-o", "#{dir}/#{basename}", file)
|
20
|
-
system("#{dir}/#{basename}")
|
21
|
-
end
|
22
|
-
end
|
15
|
+
Language.create(arguments[0], arguments[1..-1]).run
|
23
16
|
end
|
24
17
|
end
|
25
18
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "runch/language/c"
|
2
|
+
require "runch/language/java"
|
3
|
+
|
4
|
+
module Runch
|
5
|
+
module Language
|
6
|
+
module_function
|
7
|
+
def create(main_source, *files)
|
8
|
+
extname = File.extname(main_source)[1..-1]
|
9
|
+
const_get(extname.capitalize).new(main_source, files)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "tmpdir"
|
2
|
+
|
3
|
+
module Runch
|
4
|
+
module Language
|
5
|
+
module Base
|
6
|
+
def initialize(main_source, files)
|
7
|
+
@main_source = main_source
|
8
|
+
@files = files
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
Dir.mktmpdir("runch") do |tmpdir|
|
13
|
+
copy(tmpdir)
|
14
|
+
executable = compile(tmpdir)
|
15
|
+
execute(executable)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def copy(tmpdir)
|
21
|
+
FileUtils.cp(@main_source, tmpdir)
|
22
|
+
@files.each do |file|
|
23
|
+
FileUtils.cp_r(file, tmpdir)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def compile(tmpdir)
|
28
|
+
@main_source
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute(executable)
|
32
|
+
system(executable)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "runch/language/base"
|
2
|
+
|
3
|
+
module Runch
|
4
|
+
module Language
|
5
|
+
class C
|
6
|
+
include Base
|
7
|
+
|
8
|
+
def compile(tmpdir)
|
9
|
+
basename = File.basename(@main_source, ".*")
|
10
|
+
filename = File.basename(@main_source)
|
11
|
+
main_source = File.join(tmpdir, filename)
|
12
|
+
executable = File.join(tmpdir, basename)
|
13
|
+
system("gcc", "-o", executable, main_source)
|
14
|
+
executable
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "runch/language/base"
|
2
|
+
|
3
|
+
module Runch
|
4
|
+
module Language
|
5
|
+
class Java
|
6
|
+
include Base
|
7
|
+
|
8
|
+
def compile(tmpdir)
|
9
|
+
basename = File.basename(@main_source, ".*")
|
10
|
+
filename = File.basename(@main_source)
|
11
|
+
main_source = File.join(tmpdir, filename)
|
12
|
+
executable = File.join(tmpdir, basename)
|
13
|
+
system("javac", main_source)
|
14
|
+
executable
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute(executable)
|
18
|
+
dirname = File.dirname(executable)
|
19
|
+
classname = File.basename(executable)
|
20
|
+
system("java", "-classpath", dirname, classname)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/runch/version.rb
CHANGED
data/runch.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Runch::VERSION
|
9
9
|
spec.authors = ["Masafumi Yokoyama"]
|
10
10
|
spec.email = ["myokoym@gmail.com"]
|
11
|
-
spec.description = %q{A launcher as interpreter.}
|
12
|
-
spec.summary = %q{A launcher as interpreter.}
|
11
|
+
spec.description = %q{A launcher for source code as interpreter.}
|
12
|
+
spec.summary = %q{A launcher for source code as interpreter.}
|
13
13
|
spec.homepage = "https://github.com/myokoym/runch"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/sample/Hello.java
ADDED
data/sample/hello.c
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: A launcher as interpreter.
|
41
|
+
description: A launcher for source code as interpreter.
|
42
42
|
email:
|
43
43
|
- myokoym@gmail.com
|
44
44
|
executables:
|
@@ -49,13 +49,19 @@ files:
|
|
49
49
|
- .gitignore
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE.txt
|
52
|
+
- NEWS.md
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
54
55
|
- bin/runch
|
55
56
|
- lib/runch.rb
|
56
57
|
- lib/runch/command.rb
|
58
|
+
- lib/runch/language.rb
|
59
|
+
- lib/runch/language/base.rb
|
60
|
+
- lib/runch/language/c.rb
|
61
|
+
- lib/runch/language/java.rb
|
57
62
|
- lib/runch/version.rb
|
58
63
|
- runch.gemspec
|
64
|
+
- sample/Hello.java
|
59
65
|
- sample/hello.c
|
60
66
|
homepage: https://github.com/myokoym/runch
|
61
67
|
licenses:
|
@@ -80,5 +86,6 @@ rubyforge_project:
|
|
80
86
|
rubygems_version: 2.0.3
|
81
87
|
signing_key:
|
82
88
|
specification_version: 4
|
83
|
-
summary: A launcher as interpreter.
|
89
|
+
summary: A launcher for source code as interpreter.
|
84
90
|
test_files: []
|
91
|
+
has_rdoc:
|