red 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/License.txt CHANGED
@@ -6,7 +6,7 @@ a copy of this software and associated documentation files (the
6
6
  without limitation the rights to use, copy, modify, merge, publish,
7
7
  distribute, sublicense, and/or sell copies of the Software, and to
8
8
  permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
9
+ the following conditions:
10
10
 
11
11
  The above copyright notice and this permission notice shall be
12
12
  included in all copies or substantial portions of the Software.
data/PostInstall.txt CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- For more information on red, see http://github.com/jessesielaff/red/wikis
2
+ For more information on Red, see http://github.com/jessesielaff/red/wikis
data/README.txt CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Red takes the Ruby you write and turns it into JavaScript for your browser.
4
4
 
5
- The all-new Red is a Ruby-to-JavaScript transliterator backed by a custom ruby.js library designed to let your code run in the browser exactly* the way Ruby would run on your machine. The JavaScript output is optimized to contain only the fraction of the ruby.js source library needed to run your code.
5
+ The all-new Red is a Ruby-to-JavaScript transliterator backed by a custom ruby.js library designed to let your code run in the browser exactly the way Ruby would run on your machine. The JavaScript output is optimized to contain only the fraction of the ruby.js source library needed to run your code.
6
6
 
7
- What does this mean for today’s Ruby developer? Simple. You dont need to learn JavaScript.
7
+ What does this mean for today’s Ruby developer? Simple. You don't need to learn JavaScript.
8
8
 
9
9
  === Installation
10
10
 
@@ -12,9 +12,13 @@ To get Red working, install the rubygem.
12
12
 
13
13
  sudo gem install red
14
14
 
15
+ === Tutorials
16
+
17
+ Find more info at Github on how to use Red: http://github.com/jessesielaff/red/wikis
18
+
15
19
  === Bugs / Issues
16
20
 
17
- Got a problem? Tell us about it. Submit a ticket to the project page at <a href=http://jessesielaff.lighthouseapp.com/projects/15182-red>Lighthouse</a>.
21
+ Got a problem? Tell us about it. Submit a ticket to the project page at Lighthouse: http://jessesielaff.lighthouseapp.com/projects/15182-red
18
22
 
19
23
  === MIT License
20
24
 
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
2
+ require 'config/hoe'
3
3
 
4
4
  Dir['tasks/**/*.rake'].each { |rake| load rake }
data/lib/red.rb CHANGED
@@ -183,8 +183,10 @@ module Red # :nodoc:
183
183
 
184
184
  INTERNAL_METHODS = %w{
185
185
  []
186
+ []=
186
187
  <=>
187
188
  ==
189
+ ===
188
190
  allocate
189
191
  append_features
190
192
  backtrace
@@ -213,6 +215,7 @@ module Red # :nodoc:
213
215
  @@red_constants = NATIVE_CONSTANTS
214
216
  @@red_methods = INTERNAL_METHODS
215
217
  @@red_function = nil
218
+ @@red_singleton = nil
216
219
  @@red_block_arg = nil
217
220
  @@red_import = false
218
221
  return true
data/lib/red/errors.rb CHANGED
@@ -4,8 +4,8 @@ module Red
4
4
  class NoArbitraryMatch < BuildError # :nodoc:
5
5
  end
6
6
 
7
- # Raised when a +BEGIN+ or +END+ block is used.
8
- class NoBEGINorEND < BuildError # :nodoc:
7
+ # Raised when an +END+ block is used.
8
+ class NoENDBlocks < BuildError # :nodoc:
9
9
  end
10
10
 
11
11
  # Raised when a +retry+ keyword is used.
@@ -21,11 +21,6 @@ module Red
21
21
  class NoRegexEvaluation < BuildError # :nodoc:
22
22
  end
23
23
 
24
- # Raised when the active JavaScript library has no special array
25
- # constructor.
26
- class NoSplatConstructor < BuildError # :nodoc:
27
- end
28
-
29
24
  # Raised when an unknown ParseTree sexp type is called to initialize.
30
25
  class UnknownNode < BuildError # :nodoc:
31
26
  end
@@ -53,6 +53,12 @@ module Red # :nodoc:
53
53
  exit
54
54
  end
55
55
 
56
+ def translate_to_string_including_ruby(string)
57
+ js_output = hush_warnings { string.translate_to_sexp_array }.red!
58
+ ruby_js = compile_ruby_js_source
59
+ return ruby_js + js_output
60
+ end
61
+
56
62
  def hush_warnings
57
63
  $stderr = File.open('spew', 'w')
58
64
  output = yield
@@ -14,7 +14,7 @@ module Red
14
14
  class Constant < AssignmentNode # :nodoc:
15
15
  # [:cdecl, :Foo, {expression}]
16
16
  def initialize(constant_name_sexp, expression_sexp, options)
17
- constant_name = (@@namespace_stack + ["c$%s" % constant_name_sexp.red!]).join(".")
17
+ constant_name = (@@namespace_stack + ["%s" % constant_name_sexp.red!]).join(".c$")
18
18
  @@red_constants |= [constant_name]
19
19
  expression = expression_sexp.red!(:as_assignment => true)
20
20
  self << "%s=%s" % [constant_name, expression]
@@ -81,7 +81,7 @@ module Red
81
81
  comma = arguments.empty? ? "" : ","
82
82
  method = (METHOD_ESCAPE[method_sexp] || method_sexp).red!
83
83
  expression = expression_sexp.red!(:as_argument => true)
84
- object = "%s.m$_brkt(%s)" % [receiver, arguments]
84
+ object = "%s.m$_brac(%s)" % [receiver, arguments]
85
85
  unless string = ((method == '||' && LogicNode::Conjunction::Or::STRING) || (method == '&&' && LogicNode::Conjunction::And::STRING))
86
86
  operation = "%s.m$%s(%s)" % [object, method, expression]
87
87
  else
@@ -119,6 +119,7 @@ module Red
119
119
  function = (METHOD_ESCAPE[function_name_sexp] || function_name_sexp).red!
120
120
  @@red_function = function
121
121
  object = object_sexp.is_sexp?(:self) ? @@namespace_stack.join(".") : object_sexp.red!
122
+ @@red_singleton = object
122
123
  singleton = "%s.m$%s" % [object, function]
123
124
  block_sexp = scope_sexp.assoc(:args) ? (scope_sexp << [:block, scope_sexp.delete(scope_sexp.assoc(:args)), [:nil]]).assoc(:block) : scope_sexp.assoc(:block)
124
125
  block_arg_sexp = block_sexp.delete(block_sexp.assoc(:block_arg)) || ([:block_arg, :_block] if block_sexp.flatten.include?(:yield))
@@ -138,6 +139,7 @@ module Red
138
139
  self << "%s=function(%s){%s;}" % [singleton, arguments, contents]
139
140
  @@red_block_arg = nil
140
141
  @@red_function = nil
142
+ @@red_singleton = nil
141
143
  end
142
144
  end
143
145
  end
@@ -14,7 +14,7 @@ module Red
14
14
 
15
15
  class PostexeNode < IllegalNode # :nodoc:
16
16
  def initialize(*args)
17
- raise(BuildError::NoBEGINorEND, "BEGIN and END blocks are not supported")
17
+ raise(BuildError::NoENDBlocks, "END blocks are not supported")
18
18
  end
19
19
  end
20
20
 
@@ -16,7 +16,7 @@ module Red
16
16
  def initialize(*element_sexps)
17
17
  options = element_sexps.pop
18
18
  elements = element_sexps.map {|element_sexp| element_sexp.red!(:as_argument => true)}.join(",")
19
- self << "c$Hash.m$_brkt(%s)" % [elements]
19
+ self << "c$Hash.m$_brac(%s)" % [elements]
20
20
  end
21
21
  end
22
22
 
@@ -51,7 +51,12 @@ module Red
51
51
  # [:nil]
52
52
  # [:self]
53
53
  def initialize(options)
54
- string = case self when Nil : "nil" when Self : "this" end
54
+ string = case self
55
+ when Nil
56
+ "nil"
57
+ when Self
58
+ @@red_singleton || "this"
59
+ end
55
60
  self << string
56
61
  end
57
62
 
data/lib/red/version.rb CHANGED
@@ -2,7 +2,7 @@ module Red
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/script/txt2html CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- GEM_NAME = 'red' # what ppl will type to install your gem
4
- RUBYFORGE_PROJECT = 'red'
3
+ GEM_NAME = 'red'
4
+ RUBYFORGE_PROJECT = 'red-js'
5
5
 
6
6
  require 'rubygems'
7
7
  begin
data/setup.rb CHANGED
@@ -313,7 +313,7 @@ class ConfigTable
313
313
  def value_config?(name)
314
314
  lookup(name).value?
315
315
  end
316
-
316
+
317
317
  class Item
318
318
  def initialize(name, template, default, desc)
319
319
  @name = name.freeze
@@ -322,41 +322,41 @@ class ConfigTable
322
322
  @default = default
323
323
  @description = desc
324
324
  end
325
-
325
+
326
326
  attr_reader :name
327
327
  attr_reader :description
328
-
328
+
329
329
  attr_accessor :default
330
330
  alias help_default default
331
-
331
+
332
332
  def help_opt
333
333
  "--#{@name}=#{@template}"
334
334
  end
335
-
335
+
336
336
  def value?
337
337
  true
338
338
  end
339
-
339
+
340
340
  def value
341
341
  @value
342
342
  end
343
-
343
+
344
344
  def resolve(table)
345
345
  @value.gsub(%r<\$([^/]+)>) { table[$1] }
346
346
  end
347
-
347
+
348
348
  def set(val)
349
349
  @value = check(val)
350
350
  end
351
-
351
+
352
352
  private
353
-
353
+
354
354
  def check(val)
355
355
  setup_rb_error "config: --#{name} requires argument" unless val
356
356
  val
357
357
  end
358
358
  end
359
-
359
+
360
360
  class BoolItem < Item
361
361
  def config_type
362
362
  'bool'
data/spec/red_spec.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- # Time to add your specs!
4
3
  # http://rspec.info/
5
4
  describe "Place your specs here" do
6
5
 
@@ -14,7 +14,7 @@ task :check_version do
14
14
  end
15
15
 
16
16
  desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
17
- task :install_gem_no_doc => [:clean, :package] do
17
+ task :ig => [:clean, :package] do
18
18
  sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
19
19
  end
20
20
 
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: 4.0.0
4
+ version: 4.0.1
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-10-12 00:00:00 -04:00
12
+ date: 2008-10-13 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -95,7 +95,7 @@ has_rdoc: true
95
95
  homepage: http://red-js.rubyforge.org
96
96
  post_install_message: |
97
97
 
98
- For more information on red, see http://github.com/jessesielaff/red/wikis
98
+ For more information on Red, see http://github.com/jessesielaff/red/wikis
99
99
 
100
100
  rdoc_options:
101
101
  - --main