genki-rub 0.0.2

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.
Files changed (5) hide show
  1. data/LICENSE +0 -0
  2. data/README +17 -0
  3. data/bin/rub +3 -0
  4. data/lib/rub.rb +30 -0
  5. metadata +57 -0
data/LICENSE ADDED
File without changes
data/README ADDED
@@ -0,0 +1,17 @@
1
+ Rub is endless Ruby
2
+ ===================
3
+
4
+ You can write Ruby code without "end"
5
+
6
+ class Foo
7
+ def foo
8
+ puts "foo"
9
+
10
+ Foo.new.foo #=> "foo"
11
+
12
+ LIMITATIONS
13
+ -----------
14
+
15
+ - You can't use multiline condition for if, while, until and so on.
16
+
17
+ This version (0.0.1) would have various limitations.
data/bin/rub ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), %w[.. lib rub])
3
+ rub ARGV.shift
@@ -0,0 +1,30 @@
1
+ def rub(path)
2
+ @@rub_loaded_paths ||= {}
3
+ return false if @@rub_loaded_paths[path]
4
+ result = []
5
+ indents = [0]
6
+ ended = false
7
+ open(path).read.split("\n").each do |line|
8
+ if ended
9
+ result << line
10
+ elsif line == "__END__"
11
+ result << line
12
+ ended = true
13
+ else
14
+ indent = line.index(/\S|$/)
15
+ if indent > indents[-1]
16
+ indents << indent
17
+ end
18
+ while indent < indents[-1]
19
+ indents.pop
20
+ unless line =~ /^\s*end\b/
21
+ result << (" " * indents[-1]) + "end"
22
+ end
23
+ end
24
+ result << line
25
+ end
26
+ end
27
+ (indents.size - 1).times{result << "end"}
28
+ eval result.join("\n"), TOPLEVEL_BINDING, $0 = path
29
+ @@rub_loaded_paths[path] = true
30
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genki-rub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Genki Takiuchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-18 00:00:00 -07:00
13
+ default_executable: rub
14
+ dependencies: []
15
+
16
+ description: Rub is endless Ruby
17
+ email: genki@s21g.com
18
+ executables:
19
+ - rub
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - LICENSE
25
+ files:
26
+ - LICENSE
27
+ - README
28
+ - lib/rub.rb
29
+ - bin/rub
30
+ has_rdoc: true
31
+ homepage: http://blog.s21g.com/genki
32
+ post_install_message:
33
+ rdoc_options: []
34
+
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project: asakurarb
52
+ rubygems_version: 1.2.0
53
+ signing_key:
54
+ specification_version: 2
55
+ summary: Rub is endless Ruby
56
+ test_files: []
57
+