ruby2js 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -182,6 +182,7 @@ the script.
182
182
  * `.replace` becomes `.length = 0; ...push.apply(*)`
183
183
  * `.respond_to?` becomes `right in left`
184
184
  * `.start_with?` becomes `.substring(0, arg.length) == arg`
185
+ * `.strip` becomes `.trim`
185
186
  * `.sub` becomes `.replace`
186
187
  * `.to_a` becomes `to_Array`
187
188
  * `.to_f` becomes `parseFloat`
@@ -192,6 +193,7 @@ the script.
192
193
  * `[n...m]` becomes `.slice(n,m)`
193
194
  * `[n..m]` becomes `.slice(n,m+1)`
194
195
  * `[/r/, n]` becomes `.match(/r/)[n]`
196
+ * `"string" * length` becomes `new Array(length + 1).join("string")`
195
197
  * `.sub!` and `.gsub!` become equivalent `x = x.replace` statements
196
198
  * `.map!`, `.reverse!`, and `.select` become equivalent
197
199
  `.splice(0, .length, *.method())` statements
@@ -7,10 +7,14 @@ module Ruby2JS
7
7
 
8
8
  handle :prototype do |expr|
9
9
  begin
10
+ @block_this, @block_depth = false, 0
10
11
  prototype, @prototype = @prototype, true
12
+ mark = output_location
11
13
  parse(expr)
14
+ insert mark, "var self = this#{@sep}" if @block_this
12
15
  ensure
13
16
  @prototype = prototype
17
+ @block_this, @block_depth = nil, nil
14
18
  end
15
19
  end
16
20
  end
@@ -127,6 +127,9 @@ module Ruby2JS
127
127
  elsif method == :upcase and args.length == 0
128
128
  process S(:send, target, :toUpperCase)
129
129
 
130
+ elsif method == :strip and args.length == 0
131
+ process S(:send, target, :trim)
132
+
130
133
  elsif node.children[0..1] == [nil, :puts]
131
134
  process S(:send, s(:attr, nil, :console), :log, *args)
132
135
 
@@ -210,6 +213,10 @@ module Ruby2JS
210
213
  elsif method == :inspect and args.length == 0
211
214
  S(:send, s(:const, nil, :JSON), :stringify, process(target))
212
215
 
216
+ elsif method == :* and target.type == :str
217
+ process S(:send, s(:send, s(:const, nil, :Array), :new,
218
+ s(:send, args.first, :+, s(:int, 1))), :join, target)
219
+
213
220
  else
214
221
  super
215
222
  end
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/ruby2js.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ruby2js"
5
- s.version = "2.0.4"
5
+ s.version = "2.0.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sam Ruby"]
9
- s.date = "2015-04-20"
9
+ s.date = "2015-04-30"
10
10
  s.description = " The base package maps Ruby syntax to JavaScript semantics.\n Filters may be provided to add Ruby-specific or framework specific\n behavior.\n"
11
11
  s.email = "rubys@intertwingly.net"
12
12
  s.files = ["ruby2js.gemspec", "README.md", "lib/ruby2js", "lib/ruby2js/execjs.rb", "lib/ruby2js/converter.rb", "lib/ruby2js/version.rb", "lib/ruby2js/filter", "lib/ruby2js/filter/jquery.rb", "lib/ruby2js/filter/return.rb", "lib/ruby2js/filter/underscore.rb", "lib/ruby2js/filter/require.rb", "lib/ruby2js/filter/angularrb.rb", "lib/ruby2js/filter/minitest-jasmine.rb", "lib/ruby2js/filter/camelCase.rb", "lib/ruby2js/filter/rubyjs.rb", "lib/ruby2js/filter/strict.rb", "lib/ruby2js/filter/functions.rb", "lib/ruby2js/filter/angular-resource.rb", "lib/ruby2js/filter/react.rb", "lib/ruby2js/filter/angular-route.rb", "lib/ruby2js/sinatra.rb", "lib/ruby2js/rails.rb", "lib/ruby2js/serializer.rb", "lib/ruby2js/cgi.rb", "lib/ruby2js/converter", "lib/ruby2js/converter/self.rb", "lib/ruby2js/converter/arg.rb", "lib/ruby2js/converter/dstr.rb", "lib/ruby2js/converter/xstr.rb", "lib/ruby2js/converter/sym.rb", "lib/ruby2js/converter/return.rb", "lib/ruby2js/converter/break.rb", "lib/ruby2js/converter/for.rb", "lib/ruby2js/converter/defined.rb", "lib/ruby2js/converter/cvasgn.rb", "lib/ruby2js/converter/whilepost.rb", "lib/ruby2js/converter/logical.rb", "lib/ruby2js/converter/in.rb", "lib/ruby2js/converter/args.rb", "lib/ruby2js/converter/def.rb", "lib/ruby2js/converter/prototype.rb", "lib/ruby2js/converter/class.rb", "lib/ruby2js/converter/nthref.rb", "lib/ruby2js/converter/opasgn.rb", "lib/ruby2js/converter/module.rb", "lib/ruby2js/converter/kwbegin.rb", "lib/ruby2js/converter/send.rb", "lib/ruby2js/converter/boolean.rb", "lib/ruby2js/converter/masgn.rb", "lib/ruby2js/converter/hash.rb", "lib/ruby2js/converter/cvar.rb", "lib/ruby2js/converter/ivasgn.rb", "lib/ruby2js/converter/case.rb", "lib/ruby2js/converter/const.rb", "lib/ruby2js/converter/vasgn.rb", "lib/ruby2js/converter/untilpost.rb", "lib/ruby2js/converter/begin.rb", "lib/ruby2js/converter/ivar.rb", "lib/ruby2js/converter/while.rb", "lib/ruby2js/converter/next.rb", "lib/ruby2js/converter/nil.rb", "lib/ruby2js/converter/blockpass.rb", "lib/ruby2js/converter/super.rb", "lib/ruby2js/converter/defs.rb", "lib/ruby2js/converter/array.rb", "lib/ruby2js/converter/block.rb", "lib/ruby2js/converter/if.rb", "lib/ruby2js/converter/until.rb", "lib/ruby2js/converter/regexp.rb", "lib/ruby2js/converter/casgn.rb", "lib/ruby2js/converter/undef.rb", "lib/ruby2js/converter/literal.rb", "lib/ruby2js/converter/var.rb", "lib/ruby2js.rb"]
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ruby2js
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.4
5
+ version: 2.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sam Ruby
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-20 00:00:00.000000000 Z
12
+ date: 2015-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement