red 3.1.1 → 3.1.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.
- data/History.txt +6 -0
- data/Manifest.txt +1 -0
- data/bin/red +17 -27
- data/config/hoe.rb +5 -5
- data/lib/red/executable.rb +43 -55
- data/lib/red/messages.rb +49 -0
- data/lib/red/version.rb +1 -1
- data/lib/red.rb +0 -1
- data/website/index.html +1 -1
- metadata +24 -3
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/bin/red
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Red's command line transliterator executable.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
# Copyright (c) 2008. All rights reserved.
|
4
|
+
# Copyright (c) 2008 Jesse Sielaff.
|
6
5
|
|
7
6
|
begin
|
8
7
|
require 'rubygems'
|
@@ -11,42 +10,33 @@ rescue LoadError
|
|
11
10
|
end
|
12
11
|
|
13
12
|
require 'red'
|
13
|
+
require 'red/executable'
|
14
|
+
require 'red/messages'
|
15
|
+
require 'red/version'
|
14
16
|
require 'optparse'
|
15
17
|
|
16
|
-
include Red
|
17
|
-
|
18
|
-
OPTIONS = { :rails => false }
|
18
|
+
include Red
|
19
19
|
|
20
20
|
parser = OptionParser.new do |opts|
|
21
|
-
opts.banner =
|
22
|
-
Usage: red [filename] [options]
|
23
|
-
|
24
|
-
Description:
|
25
|
-
Red is a Ruby-to-JavaScript transliterator.
|
26
|
-
|
27
|
-
For more information see http://github.com/jessesielaff/red/wikis
|
28
|
-
|
29
|
-
Options are:
|
30
|
-
BANNER
|
21
|
+
opts.banner = RED_MESSAGES[:banner]
|
31
22
|
opts.separator ""
|
32
23
|
opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
|
33
|
-
opts.on("-r", "--rails", "
|
34
|
-
opts.on("-s", "--string=RUBY_STRING", "Translate a single string to JavaScript") { |string| direct_translate(string) }
|
24
|
+
opts.on("-r", "--rails", "Add Red plugin to ./vendor/plugins") { build_red_plugin_for_rails }
|
25
|
+
opts.on("-s", "--string=RUBY_STRING", "Translate a single string to JavaScript.") { |string| direct_translate(string) }
|
26
|
+
opts.on("-v", "--version", "Print version number.") { puts Red::VERSION::STRING; exit }
|
35
27
|
begin
|
36
28
|
opts.parse!(ARGV)
|
37
29
|
rescue OptionParser::InvalidOption => e
|
38
|
-
puts
|
39
|
-
|
40
|
-
exit
|
30
|
+
puts RED_MESSAGES[:invalid] % [e.message]; exit
|
31
|
+
rescue OptionParser::MissingArgument => e
|
32
|
+
puts RED_MESSAGES[:missing] % [e.message]; exit
|
41
33
|
end
|
42
34
|
end
|
43
35
|
|
44
|
-
if
|
45
|
-
|
36
|
+
if ARGV.empty?
|
37
|
+
puts RED_MESSAGES[:usage]; exit
|
46
38
|
else
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
Use red -h for help.
|
51
|
-
USAGE
|
39
|
+
class << Red
|
40
|
+
self.compile_red_to_js(ARGV[0])
|
41
|
+
end
|
52
42
|
end
|
data/config/hoe.rb
CHANGED
@@ -2,13 +2,13 @@ require 'red/version'
|
|
2
2
|
|
3
3
|
AUTHOR = 'Jesse Sielaff'
|
4
4
|
EMAIL = "jesse.sielaff@gmail.com"
|
5
|
-
DESCRIPTION = "
|
5
|
+
DESCRIPTION = "Red is a Ruby-to-JavaScript transliterator using ParseTree."
|
6
6
|
GEM_NAME = 'red'
|
7
7
|
RUBYFORGE_PROJECT = 'red-js'
|
8
8
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
9
|
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
10
|
EXTRA_DEPENDENCIES = [
|
11
|
-
['
|
11
|
+
['ParseTree', '>= 2.2.0'],
|
12
12
|
['rake', '>= 0.8.1']
|
13
13
|
]
|
14
14
|
|
@@ -62,10 +62,10 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
62
62
|
|
63
63
|
# == Optional
|
64
64
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
65
|
-
|
65
|
+
p.extra_deps = EXTRA_DEPENDENCIES
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
68
|
+
end
|
69
69
|
|
70
70
|
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
71
71
|
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
data/lib/red/executable.rb
CHANGED
@@ -1,66 +1,54 @@
|
|
1
|
-
module Red
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
puts "Directory vendor/plugins does not exist."
|
6
|
-
exit
|
7
|
-
end
|
8
|
-
|
9
|
-
begin
|
10
|
-
Dir.mkdir('vendor/plugins/red') unless File.exists?('vendor/plugins/red')
|
11
|
-
rescue SystemCallError
|
12
|
-
puts "Unable to create directory in vendor/plugins"
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
|
16
|
-
File.open('vendor/plugins/red/init.rb', 'w') { |f| f.write("require 'rubygems'\nrequire 'red'\n\n# Red is not yet supported for Rails projects.\n")} #Red.for_rails(binding)\n") }
|
17
|
-
|
18
|
-
puts "Red plugin added to project."
|
1
|
+
module Red # :nodoc:
|
2
|
+
def build_red_plugin_for_rails
|
3
|
+
unless File.exists?('vendor/plugins')
|
4
|
+
puts "Directory vendor/plugins does not exist."
|
19
5
|
exit
|
20
6
|
end
|
21
7
|
|
22
|
-
|
23
|
-
|
24
|
-
|
8
|
+
begin
|
9
|
+
Dir.mkdir('vendor/plugins/red') unless File.exists?('vendor/plugins/red')
|
10
|
+
rescue SystemCallError
|
11
|
+
puts "Unable to create directory in vendor/plugins"
|
25
12
|
exit
|
26
13
|
end
|
27
14
|
|
28
|
-
|
29
|
-
$stderr = File.open('spew', 'w')
|
30
|
-
output = yield
|
31
|
-
$stderr = $>
|
32
|
-
|
33
|
-
File.delete('spew')
|
34
|
-
|
35
|
-
return output
|
36
|
-
end
|
15
|
+
File.open('vendor/plugins/red/init.rb', 'w') { |f| f.write("require 'rubygems'\nrequire 'red'\n\n# Red is not yet supported for Rails projects.\n")} #Red.for_rails(binding)\n") }
|
37
16
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
17
|
+
puts "Red plugin added to project."
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
def direct_translate(string)
|
22
|
+
js_output = hush_warnings { string.string_to_node }.compile_node
|
23
|
+
print_js(js_output, 'test')
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
27
|
+
def hush_warnings
|
28
|
+
$stderr = File.open('spew', 'w')
|
29
|
+
output = yield
|
30
|
+
$stderr = $>
|
31
|
+
|
32
|
+
File.delete('spew')
|
51
33
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
File
|
62
|
-
|
63
|
-
print_js(js_output, filename)
|
34
|
+
return output
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_js(js_output, filename) # :nodoc:
|
38
|
+
puts RED_MESSAGES[:output] % [("- #{filename}.js" unless filename == 'test'), js_output, @@red_errors ||= '']
|
39
|
+
end
|
40
|
+
|
41
|
+
def compile_red_to_js(filename)
|
42
|
+
unless File.exists?(file = "%s.red" % [filename]) || File.exists?(file = "%sred/%s.red" % [(dir = "public/javascripts/"), filename])
|
43
|
+
puts "File #{filename}.red does not exist."
|
44
|
+
exit
|
64
45
|
end
|
46
|
+
|
47
|
+
source = File.read(file)
|
48
|
+
js_output = hush_warnings { source.string_to_node }.compile_node
|
49
|
+
|
50
|
+
File.open("%s%s.js" % [dir, filename], 'w') {|f| f.write(js_output)} unless filename == 'test'
|
51
|
+
|
52
|
+
print_js(js_output, filename)
|
65
53
|
end
|
66
54
|
end
|
data/lib/red/messages.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Red # :nodoc:
|
2
|
+
RED_MESSAGES = {}
|
3
|
+
RED_MESSAGES[:banner] = <<-MESSAGE
|
4
|
+
|
5
|
+
Description:
|
6
|
+
Red is a Ruby-to-JavaScript transliterator.
|
7
|
+
For more information see http://github.com/jessesielaff/red/wikis
|
8
|
+
|
9
|
+
Usage: red [filename] [options]
|
10
|
+
|
11
|
+
Options:
|
12
|
+
MESSAGE
|
13
|
+
|
14
|
+
RED_MESSAGES[:invalid] = <<-MESSAGE
|
15
|
+
|
16
|
+
You used an %s
|
17
|
+
|
18
|
+
Use red -h for help.
|
19
|
+
|
20
|
+
MESSAGE
|
21
|
+
|
22
|
+
RED_MESSAGES[:missing] = <<-MESSAGE
|
23
|
+
|
24
|
+
You had a %s <ruby-string>
|
25
|
+
|
26
|
+
Use red -h for help.
|
27
|
+
|
28
|
+
MESSAGE
|
29
|
+
|
30
|
+
RED_MESSAGES[:usage] = <<-MESSAGE
|
31
|
+
|
32
|
+
Usage: red [filename] [options]
|
33
|
+
|
34
|
+
Use red -h for help.
|
35
|
+
|
36
|
+
MESSAGE
|
37
|
+
|
38
|
+
RED_MESSAGES[:output] = <<-MESSAGE
|
39
|
+
|
40
|
+
%s
|
41
|
+
=================================
|
42
|
+
|
43
|
+
%s
|
44
|
+
|
45
|
+
=================================
|
46
|
+
%s
|
47
|
+
|
48
|
+
MESSAGE
|
49
|
+
end
|
data/lib/red/version.rb
CHANGED
data/lib/red.rb
CHANGED
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>foo</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/red"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/red" class="numbers">3.1.
|
36
|
+
<a href="http://rubyforge.org/projects/red" class="numbers">3.1.2</a>
|
37
37
|
</div>
|
38
38
|
<h1>&#x2192; ‘foo’</h1>
|
39
39
|
<h2>What</h2>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Sielaff
|
@@ -12,6 +12,26 @@ cert_chain: []
|
|
12
12
|
date: 2008-08-06 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ParseTree
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.2.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.1
|
34
|
+
version:
|
15
35
|
- !ruby/object:Gem::Dependency
|
16
36
|
name: hoe
|
17
37
|
type: :development
|
@@ -22,7 +42,7 @@ dependencies:
|
|
22
42
|
- !ruby/object:Gem::Version
|
23
43
|
version: 1.7.0
|
24
44
|
version:
|
25
|
-
description:
|
45
|
+
description: Red is a Ruby-to-JavaScript transliterator using ParseTree.
|
26
46
|
email:
|
27
47
|
- jesse.sielaff@gmail.com
|
28
48
|
executables:
|
@@ -59,6 +79,7 @@ files:
|
|
59
79
|
- lib/red/executable.rb
|
60
80
|
- lib/red/illegal_nodes.rb
|
61
81
|
- lib/red/literal_nodes.rb
|
82
|
+
- lib/red/messages.rb
|
62
83
|
- lib/red/variable_nodes.rb
|
63
84
|
- lib/red/version.rb
|
64
85
|
- lib/red/wrap_nodes.rb
|
@@ -108,6 +129,6 @@ rubyforge_project: red-js
|
|
108
129
|
rubygems_version: 1.2.0
|
109
130
|
signing_key:
|
110
131
|
specification_version: 2
|
111
|
-
summary:
|
132
|
+
summary: Red is a Ruby-to-JavaScript transliterator using ParseTree.
|
112
133
|
test_files: []
|
113
134
|
|