red 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 3.1.2 2008-08-06
2
+
3
+ * 2 bug fixes:
4
+ * Added gem dependency for ParseTree.
5
+ * Rescued the error thrown when no argument is given for -s option flag.
6
+
1
7
  == 3.1.1 2008-08-06
2
8
 
3
9
  * 1 major enhancement:
data/Manifest.txt CHANGED
@@ -20,6 +20,7 @@ lib/red/errors.rb
20
20
  lib/red/executable.rb
21
21
  lib/red/illegal_nodes.rb
22
22
  lib/red/literal_nodes.rb
23
+ lib/red/messages.rb
23
24
  lib/red/variable_nodes.rb
24
25
  lib/red/version.rb
25
26
  lib/red/wrap_nodes.rb
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
- # Created on 2008-8-6.
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, Red::Executable
17
-
18
- OPTIONS = { :rails => false }
18
+ include Red
19
19
 
20
20
  parser = OptionParser.new do |opts|
21
- opts.banner = <<-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", "Adds Red plugin to ./vendor/plugins") { build_red_plugin_for_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 "You used an #{e.message}."
39
- puts "Use red -h for help."
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 filename = ARGV[0]
45
- self.compile_red_to_js(filename)
36
+ if ARGV.empty?
37
+ puts RED_MESSAGES[:usage]; exit
46
38
  else
47
- puts <<-USAGE
48
- Usage: red [filename] [options]
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 = "A Ruby-to-JavaScript transliterator using ParseTree."
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
- ['parse_tree', '>= 2.2.0'],
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
- #p.extra_deps = EXTRA_DEPENDENCIES
65
+ p.extra_deps = EXTRA_DEPENDENCIES
66
66
 
67
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
68
- end
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}"
@@ -1,66 +1,54 @@
1
- module Red
2
- module Executable # :nodoc:
3
- def build_red_plugin_for_rails
4
- unless File.exists?('vendor/plugins')
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
- def direct_translate(string)
23
- js_output = hush_warnings { string.string_to_node }.compile_node
24
- print_js(js_output, 'test')
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
- def hush_warnings
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
- def print_js(js_output, filename) # :nodoc:
39
- puts <<-OUTPUT.%([("- #{filename}.js" unless filename == 'test'), js_output, @@red_errors ||= ''])
40
-
41
- %s
42
- =================================
43
-
44
- %s
45
-
46
- =================================
47
- %s
48
-
49
- OUTPUT
50
- end
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
- def compile_red_to_js(filename)
53
- unless File.exists?(file = "%s.red" % [filename]) || File.exists?(file = "%sred/%s.red" % [(dir = "public/javascripts/"), filename])
54
- puts "File #{filename}.red does not exist."
55
- exit
56
- end
57
-
58
- source = File.read(file)
59
- js_output = hush_warnings { source.string_to_node }.compile_node
60
-
61
- File.open("%s%s.js" % [dir, filename], 'w') {|f| f.write(js_output)} unless filename == 'test'
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
@@ -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
@@ -2,7 +2,7 @@ module Red
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/red.rb CHANGED
@@ -11,7 +11,6 @@ require 'red/control_nodes'
11
11
  require 'red/data_nodes'
12
12
  require 'red/definition_nodes'
13
13
  require 'red/errors'
14
- require 'red/executable'
15
14
  require 'red/illegal_nodes'
16
15
  require 'red/literal_nodes'
17
16
  require 'red/variable_nodes'
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.1</a>
36
+ <a href="http://rubyforge.org/projects/red" class="numbers">3.1.2</a>
37
37
  </div>
38
38
  <h1>&amp;#x2192; &#8216;foo&#8217;</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.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: A Ruby-to-JavaScript transliterator using ParseTree.
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: A Ruby-to-JavaScript transliterator using ParseTree.
132
+ summary: Red is a Ruby-to-JavaScript transliterator using ParseTree.
112
133
  test_files: []
113
134