irust 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7299b3ba179a2ee2d729520732435b5a5603f0cb
4
+ data.tar.gz: ce56c404994b4e122023085bedd32471ced47fe6
5
+ SHA512:
6
+ metadata.gz: dab18bfaa1e7b97d34f0488a0f60dff4b5cd8470f2ef295ec35d2bad6ae73f42eeee3d7eb92ffa0614373415be567ecfbf131139687140ce2659386425719344
7
+ data.tar.gz: e073b1c19c8b4dc40c14dc9f8de49348f65f49473fb6458115f678b44e7add4781f7c95966488b00be7a0b980ac63f76d5344782c0f60f1437145cfd9d8c93bd
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CHANGES.md ADDED
@@ -0,0 +1,3 @@
1
+ 1.0.0.pre (2013-12-22)
2
+ ----------------------
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in irust.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tony Arcieri
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # iRust: Interactive Rust REPL
2
+
3
+ Rust does not presently have a Read Eval Print Loop (REPL) that allows
4
+ interactive usage of the language on-the-fly without the need to write full
5
+ programs. Or rather, Rust does ship a REPL, but it's broken and won't be fixed
6
+ until Rust natively supports JIT compilation.
7
+
8
+ iRust is a Ruby-powered band-aid of a Rust REPL that shells out to the Rust
9
+ compiler for you and lets you use the language semi-interactively. It's not
10
+ great, but if you're looking for a way to play around with Rust quickly and
11
+ easily, it might get the job done.
12
+
13
+ ## Installation
14
+
15
+ To use iRust you must first install Rust. Please refer to the
16
+ [Rust README](https://github.com/mozilla/rust) for Rust installation directions.
17
+ Or if you're an impatient Mac user and you have
18
+ [Homebrew](https://github.com/homebrew/homebrew) installed, run:
19
+
20
+ $ brew install rust
21
+
22
+ After you've installed Rust, you'll need Ruby. You can find installers for Ruby
23
+ for various platforms here:
24
+
25
+ * **Windows**: [RubyInstaller](http://rubyinstaller.org/)
26
+ * **Mac or Linux**: [RVM](https://rvm.io/)
27
+ * **Mac or Linux**: [chruby](https://github.com/postmodern/chruby)
28
+ * **Java**: [JRuby](http://www.jruby.org/download)
29
+
30
+ Next, install the irust gem:
31
+
32
+ $ gem install irust
33
+
34
+ Congrats, it should be installed and working now!
35
+
36
+ ## Usage
37
+
38
+ Now that you have iRust installed, run:
39
+
40
+ $ irust
41
+
42
+ This should give you the following prompt:
43
+
44
+ irust>
45
+
46
+ Now type some fancy Rust expressions and watch them get magically evaluated
47
+ before your eyes!
48
+
49
+ irust> 2+2
50
+ 4
51
+ irust>
52
+
53
+ Technology!
54
+
55
+ ## Contributing
56
+
57
+ * Fork this repository on github
58
+ * Make your changes and send us a pull request
59
+ * If we like them we'll merge them
60
+
61
+ ## License
62
+
63
+ Copyright (c) 2013 Tony Arcieri. Distributed under the MIT License. See
64
+ LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/irust ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'irust'
4
+
5
+ IRust.run
data/irust.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'irust/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "irust"
8
+ spec.version = IRust::VERSION
9
+ spec.authors = ["Tony Arcieri"]
10
+ spec.email = ["bascule@gmail.com"]
11
+ spec.description = "iRust is an interactive REPL for Rust"
12
+ spec.summary = "Read, Eval, and Print Rust code to your heart's desire!"
13
+ spec.homepage = "https://github.com/tarcieri/irust"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,3 @@
1
+ module IRust
2
+ VERSION = "1.0.0.pre"
3
+ end
data/lib/irust.rb ADDED
@@ -0,0 +1,56 @@
1
+ require "readline"
2
+ require "tmpdir"
3
+ require "open3"
4
+
5
+ module IRust
6
+ module_function
7
+
8
+ def read
9
+ Readline.readline("irust> ", true)
10
+ end
11
+
12
+ def rust_program(line)
13
+ <<-RUST
14
+ #[feature(globs, macro_rules, struct_variant)];
15
+ extern mod extra;
16
+
17
+ fn main() {
18
+ let r = {
19
+ fn type_of<T>(_: &T) -> &'static str { unsafe {
20
+ (*std::unstable::intrinsics::get_tydesc::<T>()).name } } struct
21
+ Foo<T>(T);
22
+ #{line}
23
+ };
24
+ println!("{:?}", r)
25
+ }
26
+ RUST
27
+ end
28
+
29
+ def compile(tmpdir)
30
+ Dir.chdir(tmpdir) do
31
+ stdin, stderr, status = Open3.capture3("rustc irust.rs")
32
+
33
+ if status.success?
34
+ true
35
+ else
36
+ STDERR.puts stderr
37
+ false
38
+ end
39
+ end
40
+ end
41
+
42
+ def eval(line)
43
+ Dir.mktmpdir do |tmpdir|
44
+ input_src = File.join(tmpdir, "irust.rs")
45
+ File.write input_src, rust_program(line)
46
+
47
+ if compile(tmpdir)
48
+ system input_src.sub(/\.rs$/, '')
49
+ end
50
+ end
51
+ end
52
+
53
+ def run
54
+ loop { eval read }
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: irust
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - Tony Arcieri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: iRust is an interactive REPL for Rust
42
+ email:
43
+ - bascule@gmail.com
44
+ executables:
45
+ - irust
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - CHANGES.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/irust
56
+ - irust.gemspec
57
+ - lib/irust.rb
58
+ - lib/irust/version.rb
59
+ homepage: https://github.com/tarcieri/irust
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
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
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>'
75
+ - !ruby/object:Gem::Version
76
+ version: 1.3.1
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Read, Eval, and Print Rust code to your heart's desire!
83
+ test_files: []