red 3.1.2 → 3.2.0
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 +8 -0
- data/Manifest.txt +1 -1
- data/bin/red +0 -1
- data/lib/red/data_nodes.rb +1 -1
- data/lib/red/executable.rb +49 -1
- data/lib/red/plugin.rb +54 -0
- data/lib/red/version.rb +2 -2
- data/lib/red.rb +7 -2
- data/website/index.html +1 -1
- metadata +3 -3
- data/lib/red/messages.rb +0 -49
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/bin/red
CHANGED
data/lib/red/data_nodes.rb
CHANGED
data/lib/red/executable.rb
CHANGED
@@ -12,7 +12,7 @@ module Red # :nodoc:
|
|
12
12
|
exit
|
13
13
|
end
|
14
14
|
|
15
|
-
File.open('vendor/plugins/red/init.rb', 'w') { |f| f.write("require 'rubygems'\nrequire 'red'\n\
|
15
|
+
File.open('vendor/plugins/red/init.rb', 'w') { |f| f.write("require 'rubygems'\nrequire 'red'\n\nRed.rails\n") }
|
16
16
|
|
17
17
|
puts "Red plugin added to project."
|
18
18
|
exit
|
@@ -51,4 +51,52 @@ module Red # :nodoc:
|
|
51
51
|
|
52
52
|
print_js(js_output, filename)
|
53
53
|
end
|
54
|
+
|
55
|
+
RED_MESSAGES = {}
|
56
|
+
RED_MESSAGES[:banner] = <<-MESSAGE
|
57
|
+
|
58
|
+
Description:
|
59
|
+
Red is a Ruby-to-JavaScript transliterator.
|
60
|
+
For more information see http://github.com/jessesielaff/red/wikis
|
61
|
+
|
62
|
+
Usage: red [filename] [options]
|
63
|
+
|
64
|
+
Options:
|
65
|
+
MESSAGE
|
66
|
+
|
67
|
+
RED_MESSAGES[:invalid] = <<-MESSAGE
|
68
|
+
|
69
|
+
You used an %s
|
70
|
+
|
71
|
+
Use red -h for help.
|
72
|
+
|
73
|
+
MESSAGE
|
74
|
+
|
75
|
+
RED_MESSAGES[:missing] = <<-MESSAGE
|
76
|
+
|
77
|
+
You had a %s <ruby-string>
|
78
|
+
|
79
|
+
Use red -h for help.
|
80
|
+
|
81
|
+
MESSAGE
|
82
|
+
|
83
|
+
RED_MESSAGES[:usage] = <<-MESSAGE
|
84
|
+
|
85
|
+
Usage: red [filename] [options]
|
86
|
+
|
87
|
+
Use red -h for help.
|
88
|
+
|
89
|
+
MESSAGE
|
90
|
+
|
91
|
+
RED_MESSAGES[:output] = <<-MESSAGE
|
92
|
+
|
93
|
+
%s
|
94
|
+
=================================
|
95
|
+
|
96
|
+
%s
|
97
|
+
|
98
|
+
=================================
|
99
|
+
%s
|
100
|
+
|
101
|
+
MESSAGE
|
54
102
|
end
|
data/lib/red/plugin.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module Red
|
2
|
+
class << self
|
3
|
+
def already_updated?
|
4
|
+
@@red_updated ||= false
|
5
|
+
end
|
6
|
+
|
7
|
+
def update_javascripts
|
8
|
+
@@red_updated = true
|
9
|
+
red_dir = 'public/javascripts/red/'
|
10
|
+
Dir.glob("#{red_dir}**/*[.rb|.red]").each do |filepath|
|
11
|
+
if self.update_javascripts?(filename = filepath.gsub(red_dir,'').gsub(/.[rb|red]+$/,'')) || RAILS_ENV != 'production'
|
12
|
+
js_output = (File.read(filepath).string_to_node.compile_node || '') << (@@red_errors ||= '')
|
13
|
+
|
14
|
+
filename.split('/')[0...-1].inject('public/javascripts') do |string,dir|
|
15
|
+
new_dir = string << '/' << dir
|
16
|
+
Dir.mkdir(new_dir) unless File.exists?(new_dir)
|
17
|
+
string
|
18
|
+
end
|
19
|
+
|
20
|
+
File.open("public/javascripts/#{filename}.js", 'w') { |f| f.write(js_output) }
|
21
|
+
|
22
|
+
@@red_errors = ''
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_javascripts?(filename)
|
28
|
+
if File.exists?("public/javascripts/#{filename}.js")
|
29
|
+
(File.mtime("public/javascripts/red/#{filename}.red") rescue File.mtime("public/javascripts/red/#{filename}.rb")) > File.mtime("public/javascripts/#{filename}.js")
|
30
|
+
else
|
31
|
+
return true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module RailsBase # :nodoc:
|
37
|
+
def self.included(base)
|
38
|
+
base.send('alias_method', :red_old_process, :process)
|
39
|
+
base.class_eval do
|
40
|
+
def process(*args)
|
41
|
+
Red.update_javascripts unless Red.already_updated?
|
42
|
+
red_old_process(*args)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
include Red
|
50
|
+
|
51
|
+
unless defined?(Red::RAILS_LOADED) || !defined?(ActionController)
|
52
|
+
Red::RAILS_LOADED = true
|
53
|
+
ActionController::Base.send(:include, Red::RailsBase)
|
54
|
+
end
|
data/lib/red/version.rb
CHANGED
data/lib/red.rb
CHANGED
@@ -13,6 +13,7 @@ require 'red/definition_nodes'
|
|
13
13
|
require 'red/errors'
|
14
14
|
require 'red/illegal_nodes'
|
15
15
|
require 'red/literal_nodes'
|
16
|
+
require 'red/plugin'
|
16
17
|
require 'red/variable_nodes'
|
17
18
|
require 'red/wrap_nodes'
|
18
19
|
|
@@ -154,8 +155,12 @@ module Red
|
|
154
155
|
end
|
155
156
|
|
156
157
|
def handle_red_error(error) # :nodoc:
|
157
|
-
@@red_errors ||= "\
|
158
|
-
@@red_errors << "\n%s: %s" % [@@exception_index += 1, error]
|
158
|
+
@@red_errors ||= "\n// Errors"
|
159
|
+
@@red_errors << "\n// %s: %s" % [@@exception_index += 1, error]
|
159
160
|
return DataNode::ErrorNode.new(@@exception_index)
|
160
161
|
end
|
162
|
+
|
163
|
+
def self.rails
|
164
|
+
require 'red/plugin'
|
165
|
+
end
|
161
166
|
end
|
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.
|
36
|
+
<a href="http://rubyforge.org/projects/red" class="numbers">3.2.0</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.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Sielaff
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-07 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -79,7 +79,7 @@ files:
|
|
79
79
|
- lib/red/executable.rb
|
80
80
|
- lib/red/illegal_nodes.rb
|
81
81
|
- lib/red/literal_nodes.rb
|
82
|
-
- lib/red/
|
82
|
+
- lib/red/plugin.rb
|
83
83
|
- lib/red/variable_nodes.rb
|
84
84
|
- lib/red/version.rb
|
85
85
|
- lib/red/wrap_nodes.rb
|
data/lib/red/messages.rb
DELETED
@@ -1,49 +0,0 @@
|
|
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
|