ruby2js 2.0.2 → 2.0.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41b51a0b8a9e699a3940a9266d6ed450865c5d25
4
+ data.tar.gz: 9b8169f14d942efc013c22880fbc6999b3777197
5
+ SHA512:
6
+ metadata.gz: f22fa0762024fe374b7e57cac75114b58b0f9d26d6dd62a7da0ffa336c4f0fec738521579c136c328d10cdecee392ae78f36e4c7ad3b721ba88940ef2b500c7c
7
+ data.tar.gz: a104f444d257a72652349a8de2ab0c2cb3d816c922707a3450f90fffb77179aeeea3c5e2b2fbbe379c62297a3311b1b5b863984cda8ca9298c255694cc7f7d2b
@@ -12,8 +12,10 @@ module Ruby2JS
12
12
  if
13
13
  @state == :statement and args.children.length == 1 and
14
14
  call.children.first and call.children.first.type == :begin and
15
+ call.children[1] == :step and
15
16
  [:irange, :erange].include? call.children.first.children.first.type
16
17
  then
18
+ # convert combinations of range, step and block to a for loop
17
19
  var = args.children.first
18
20
  expression = call.children.first.children.first
19
21
  comp = (expression.type == :irange ? '<=' : '<')
@@ -22,7 +24,24 @@ module Ruby2JS
22
24
  put "; "; parse var; put " += "; parse call.children[2]; puts ") {"
23
25
  scope block
24
26
  sput "}"
27
+
28
+ elsif
29
+ call.children[0] == nil and call.children[1] == :function and
30
+ call.children[2..-1].all? do |child|
31
+ child.type == :lvar or (child.type == :send and
32
+ child.children.length == 2 and child.children[0] == nil and
33
+ Symbol === child.children[1])
34
+ end
35
+ then
36
+ # accommodate javascript style syntax: convert function blocks with
37
+ # simple arguments into an anonymous function
38
+ args = call.children[2..-1].map {|arg| s(:arg, arg.children.last)}
39
+ parse @ast.updated(:block, [s(:send, nil, :lambda),
40
+ s(:args, *args), block])
41
+
25
42
  else
43
+ # convert blocks into method calls with an additional argument
44
+ # consisting of an anonymous function
26
45
  block ||= s(:begin)
27
46
  function = @ast.updated(:def, [nil, args, block])
28
47
  parse s(:send, *call.children, function)
@@ -66,8 +66,8 @@ module Ruby2JS
66
66
  body.select {|child| child.type == :defs}.each do |child|
67
67
  parent, mname, args, *block = child.children
68
68
  if child.is_method?
69
- statics << s(:pair, s(:sym, mname), child.updated(:block,
70
- [s(:send, nil, :proc), args, s(:autoreturn, *block)]))
69
+ statics << s(:pair, s(:sym, mname), process(child.updated(:block,
70
+ [s(:send, nil, :proc), args, s(:autoreturn, *block)])))
71
71
  elsif
72
72
  block.length == 1 and
73
73
  Converter::EXPRESSIONS.include? block.first.type
@@ -314,10 +314,25 @@ module Ruby2JS
314
314
  pairs -= classes
315
315
  if expr
316
316
  if values.length > 1
317
- value = s(:send, s(:str, values.join(' ')), :+,
318
- s(:or, expr, s(:str, '')))
317
+ while expr.type == :begin and expr.children.length == 1
318
+ expr = expr.children.first
319
+ end
320
+
321
+ if
322
+ expr.type == :if and expr.children[1] and
323
+ expr.children[1].type == :str
324
+ then
325
+ left = expr.children[1]
326
+ right = expr.children[2] || s(:str, '')
327
+ right = s(:or, right, s(:str, '')) unless right.type == :str
328
+ expr = expr.updated(nil, [expr.children[0], left, right])
329
+ elsif expr.type != :str
330
+ expr = s(:or, expr, s(:str, ''))
331
+ end
332
+
333
+ value = s(:send, s(:str, values.join(' ')), :+, expr)
319
334
  else
320
- value = s(:or, expr, s(:str, ''))
335
+ value = expr
321
336
  end
322
337
  else
323
338
  value = s(:str, values.join(' '))
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/ruby2js.gemspec CHANGED
@@ -2,23 +2,23 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ruby2js"
5
- s.version = "2.0.2"
5
+ s.version = "2.0.3"
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-10"
9
+ s.date = "2015-04-15"
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
- 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"]
12
+ s.files = ["ruby2js.gemspec", "README.md", "lib/ruby2js", "lib/ruby2js/cgi.rb", "lib/ruby2js/converter", "lib/ruby2js/converter/arg.rb", "lib/ruby2js/converter/args.rb", "lib/ruby2js/converter/array.rb", "lib/ruby2js/converter/begin.rb", "lib/ruby2js/converter/block.rb", "lib/ruby2js/converter/blockpass.rb", "lib/ruby2js/converter/boolean.rb", "lib/ruby2js/converter/break.rb", "lib/ruby2js/converter/case.rb", "lib/ruby2js/converter/casgn.rb", "lib/ruby2js/converter/class.rb", "lib/ruby2js/converter/const.rb", "lib/ruby2js/converter/cvar.rb", "lib/ruby2js/converter/cvasgn.rb", "lib/ruby2js/converter/def.rb", "lib/ruby2js/converter/defined.rb", "lib/ruby2js/converter/defs.rb", "lib/ruby2js/converter/dstr.rb", "lib/ruby2js/converter/for.rb", "lib/ruby2js/converter/hash.rb", "lib/ruby2js/converter/if.rb", "lib/ruby2js/converter/in.rb", "lib/ruby2js/converter/ivar.rb", "lib/ruby2js/converter/ivasgn.rb", "lib/ruby2js/converter/kwbegin.rb", "lib/ruby2js/converter/literal.rb", "lib/ruby2js/converter/logical.rb", "lib/ruby2js/converter/masgn.rb", "lib/ruby2js/converter/module.rb", "lib/ruby2js/converter/next.rb", "lib/ruby2js/converter/nil.rb", "lib/ruby2js/converter/nthref.rb", "lib/ruby2js/converter/opasgn.rb", "lib/ruby2js/converter/prototype.rb", "lib/ruby2js/converter/regexp.rb", "lib/ruby2js/converter/return.rb", "lib/ruby2js/converter/self.rb", "lib/ruby2js/converter/send.rb", "lib/ruby2js/converter/super.rb", "lib/ruby2js/converter/sym.rb", "lib/ruby2js/converter/undef.rb", "lib/ruby2js/converter/until.rb", "lib/ruby2js/converter/untilpost.rb", "lib/ruby2js/converter/var.rb", "lib/ruby2js/converter/vasgn.rb", "lib/ruby2js/converter/while.rb", "lib/ruby2js/converter/whilepost.rb", "lib/ruby2js/converter/xstr.rb", "lib/ruby2js/converter.rb", "lib/ruby2js/execjs.rb", "lib/ruby2js/filter", "lib/ruby2js/filter/angular-resource.rb", "lib/ruby2js/filter/angular-route.rb", "lib/ruby2js/filter/angularrb.rb", "lib/ruby2js/filter/camelCase.rb", "lib/ruby2js/filter/functions.rb", "lib/ruby2js/filter/jquery.rb", "lib/ruby2js/filter/minitest-jasmine.rb", "lib/ruby2js/filter/react.rb", "lib/ruby2js/filter/require.rb", "lib/ruby2js/filter/return.rb", "lib/ruby2js/filter/rubyjs.rb", "lib/ruby2js/filter/strict.rb", "lib/ruby2js/filter/underscore.rb", "lib/ruby2js/rails.rb", "lib/ruby2js/serializer.rb", "lib/ruby2js/sinatra.rb", "lib/ruby2js/version.rb", "lib/ruby2js.rb"]
13
13
  s.homepage = "http://github.com/rubys/ruby2js"
14
14
  s.licenses = ["MIT"]
15
15
  s.require_paths = ["lib"]
16
16
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
17
- s.rubygems_version = "1.8.23.2"
17
+ s.rubygems_version = "2.0.14"
18
18
  s.summary = "Minimal yet extensible Ruby to JavaScript conversion."
19
19
 
20
20
  if s.respond_to? :specification_version then
21
- s.specification_version = 3
21
+ s.specification_version = 4
22
22
 
23
23
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
24
24
  s.add_runtime_dependency(%q<parser>, [">= 0"])
metadata CHANGED
@@ -1,34 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2js
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 2.0.2
4
+ version: 2.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sam Ruby
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
14
+ name: parser
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- none: false
21
20
  type: :runtime
22
- name: parser
23
21
  prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
22
+ version_requirements: !ruby/object:Gem::Requirement
25
23
  requirements:
26
- - - ! '>='
24
+ - - ">="
27
25
  - !ruby/object:Gem::Version
28
26
  version: '0'
29
- none: false
30
- description: ! " The base package maps Ruby syntax to JavaScript semantics.\n Filters
31
- may be provided to add Ruby-specific or framework specific\n behavior.\n"
27
+ description: |2
28
+ The base package maps Ruby syntax to JavaScript semantics.
29
+ Filters may be provided to add Ruby-specific or framework specific
30
+ behavior.
32
31
  email: rubys@intertwingly.net
33
32
  executables: []
34
33
  extensions: []
@@ -36,98 +35,97 @@ extra_rdoc_files: []
36
35
  files:
37
36
  - ruby2js.gemspec
38
37
  - README.md
39
- - lib/ruby2js/execjs.rb
40
- - lib/ruby2js/converter.rb
41
- - lib/ruby2js/version.rb
42
- - lib/ruby2js/filter/jquery.rb
43
- - lib/ruby2js/filter/return.rb
44
- - lib/ruby2js/filter/underscore.rb
45
- - lib/ruby2js/filter/require.rb
46
- - lib/ruby2js/filter/angularrb.rb
47
- - lib/ruby2js/filter/minitest-jasmine.rb
48
- - lib/ruby2js/filter/camelCase.rb
49
- - lib/ruby2js/filter/rubyjs.rb
50
- - lib/ruby2js/filter/strict.rb
51
- - lib/ruby2js/filter/functions.rb
52
- - lib/ruby2js/filter/angular-resource.rb
53
- - lib/ruby2js/filter/react.rb
54
- - lib/ruby2js/filter/angular-route.rb
55
- - lib/ruby2js/sinatra.rb
56
- - lib/ruby2js/rails.rb
57
- - lib/ruby2js/serializer.rb
58
38
  - lib/ruby2js/cgi.rb
59
- - lib/ruby2js/converter/self.rb
60
39
  - lib/ruby2js/converter/arg.rb
61
- - lib/ruby2js/converter/dstr.rb
62
- - lib/ruby2js/converter/xstr.rb
63
- - lib/ruby2js/converter/sym.rb
64
- - lib/ruby2js/converter/return.rb
65
- - lib/ruby2js/converter/break.rb
66
- - lib/ruby2js/converter/for.rb
67
- - lib/ruby2js/converter/defined.rb
68
- - lib/ruby2js/converter/cvasgn.rb
69
- - lib/ruby2js/converter/whilepost.rb
70
- - lib/ruby2js/converter/logical.rb
71
- - lib/ruby2js/converter/in.rb
72
40
  - lib/ruby2js/converter/args.rb
73
- - lib/ruby2js/converter/def.rb
74
- - lib/ruby2js/converter/prototype.rb
75
- - lib/ruby2js/converter/class.rb
76
- - lib/ruby2js/converter/nthref.rb
77
- - lib/ruby2js/converter/opasgn.rb
78
- - lib/ruby2js/converter/module.rb
79
- - lib/ruby2js/converter/kwbegin.rb
80
- - lib/ruby2js/converter/send.rb
41
+ - lib/ruby2js/converter/array.rb
42
+ - lib/ruby2js/converter/begin.rb
43
+ - lib/ruby2js/converter/block.rb
44
+ - lib/ruby2js/converter/blockpass.rb
81
45
  - lib/ruby2js/converter/boolean.rb
82
- - lib/ruby2js/converter/masgn.rb
83
- - lib/ruby2js/converter/hash.rb
84
- - lib/ruby2js/converter/cvar.rb
85
- - lib/ruby2js/converter/ivasgn.rb
46
+ - lib/ruby2js/converter/break.rb
86
47
  - lib/ruby2js/converter/case.rb
48
+ - lib/ruby2js/converter/casgn.rb
49
+ - lib/ruby2js/converter/class.rb
87
50
  - lib/ruby2js/converter/const.rb
88
- - lib/ruby2js/converter/vasgn.rb
89
- - lib/ruby2js/converter/untilpost.rb
90
- - lib/ruby2js/converter/begin.rb
51
+ - lib/ruby2js/converter/cvar.rb
52
+ - lib/ruby2js/converter/cvasgn.rb
53
+ - lib/ruby2js/converter/def.rb
54
+ - lib/ruby2js/converter/defined.rb
55
+ - lib/ruby2js/converter/defs.rb
56
+ - lib/ruby2js/converter/dstr.rb
57
+ - lib/ruby2js/converter/for.rb
58
+ - lib/ruby2js/converter/hash.rb
59
+ - lib/ruby2js/converter/if.rb
60
+ - lib/ruby2js/converter/in.rb
91
61
  - lib/ruby2js/converter/ivar.rb
92
- - lib/ruby2js/converter/while.rb
62
+ - lib/ruby2js/converter/ivasgn.rb
63
+ - lib/ruby2js/converter/kwbegin.rb
64
+ - lib/ruby2js/converter/literal.rb
65
+ - lib/ruby2js/converter/logical.rb
66
+ - lib/ruby2js/converter/masgn.rb
67
+ - lib/ruby2js/converter/module.rb
93
68
  - lib/ruby2js/converter/next.rb
94
69
  - lib/ruby2js/converter/nil.rb
95
- - lib/ruby2js/converter/blockpass.rb
96
- - lib/ruby2js/converter/super.rb
97
- - lib/ruby2js/converter/defs.rb
98
- - lib/ruby2js/converter/array.rb
99
- - lib/ruby2js/converter/block.rb
100
- - lib/ruby2js/converter/if.rb
101
- - lib/ruby2js/converter/until.rb
70
+ - lib/ruby2js/converter/nthref.rb
71
+ - lib/ruby2js/converter/opasgn.rb
72
+ - lib/ruby2js/converter/prototype.rb
102
73
  - lib/ruby2js/converter/regexp.rb
103
- - lib/ruby2js/converter/casgn.rb
74
+ - lib/ruby2js/converter/return.rb
75
+ - lib/ruby2js/converter/self.rb
76
+ - lib/ruby2js/converter/send.rb
77
+ - lib/ruby2js/converter/super.rb
78
+ - lib/ruby2js/converter/sym.rb
104
79
  - lib/ruby2js/converter/undef.rb
105
- - lib/ruby2js/converter/literal.rb
80
+ - lib/ruby2js/converter/until.rb
81
+ - lib/ruby2js/converter/untilpost.rb
106
82
  - lib/ruby2js/converter/var.rb
83
+ - lib/ruby2js/converter/vasgn.rb
84
+ - lib/ruby2js/converter/while.rb
85
+ - lib/ruby2js/converter/whilepost.rb
86
+ - lib/ruby2js/converter/xstr.rb
87
+ - lib/ruby2js/converter.rb
88
+ - lib/ruby2js/execjs.rb
89
+ - lib/ruby2js/filter/angular-resource.rb
90
+ - lib/ruby2js/filter/angular-route.rb
91
+ - lib/ruby2js/filter/angularrb.rb
92
+ - lib/ruby2js/filter/camelCase.rb
93
+ - lib/ruby2js/filter/functions.rb
94
+ - lib/ruby2js/filter/jquery.rb
95
+ - lib/ruby2js/filter/minitest-jasmine.rb
96
+ - lib/ruby2js/filter/react.rb
97
+ - lib/ruby2js/filter/require.rb
98
+ - lib/ruby2js/filter/return.rb
99
+ - lib/ruby2js/filter/rubyjs.rb
100
+ - lib/ruby2js/filter/strict.rb
101
+ - lib/ruby2js/filter/underscore.rb
102
+ - lib/ruby2js/rails.rb
103
+ - lib/ruby2js/serializer.rb
104
+ - lib/ruby2js/sinatra.rb
105
+ - lib/ruby2js/version.rb
107
106
  - lib/ruby2js.rb
108
107
  homepage: http://github.com/rubys/ruby2js
109
108
  licenses:
110
109
  - MIT
110
+ metadata: {}
111
111
  post_install_message:
112
112
  rdoc_options: []
113
113
  require_paths:
114
114
  - lib
115
115
  required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ! '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: 1.9.3
120
- none: false
121
120
  required_rubygems_version: !ruby/object:Gem::Requirement
122
121
  requirements:
123
- - - ! '>='
122
+ - - ">="
124
123
  - !ruby/object:Gem::Version
125
124
  version: '0'
126
- none: false
127
125
  requirements: []
128
126
  rubyforge_project:
129
- rubygems_version: 1.8.23.2
127
+ rubygems_version: 2.0.14
130
128
  signing_key:
131
- specification_version: 3
129
+ specification_version: 4
132
130
  summary: Minimal yet extensible Ruby to JavaScript conversion.
133
131
  test_files: []