ruby2js 1.1.4 → 1.1.5
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/lib/ruby2js.rb +2 -0
- data/lib/ruby2js/converter.rb +5 -0
- data/lib/ruby2js/converter/array.rb +1 -1
- data/lib/ruby2js/converter/hash.rb +1 -1
- data/lib/ruby2js/converter/if.rb +1 -1
- data/lib/ruby2js/converter/send.rb +1 -1
- data/lib/ruby2js/filter/jquery.rb +6 -1
- data/lib/ruby2js/version.rb +1 -1
- data/ruby2js.gemspec +5 -5
- metadata +55 -56
- checksums.yaml +0 -15
data/lib/ruby2js.rb
CHANGED
data/lib/ruby2js/converter.rb
CHANGED
@@ -14,6 +14,7 @@ module Ruby2JS
|
|
14
14
|
@nl = ''
|
15
15
|
@ws = ' '
|
16
16
|
@varstack = []
|
17
|
+
@width = 80
|
17
18
|
|
18
19
|
@handlers = {}
|
19
20
|
@@handlers.each do |name|
|
@@ -31,6 +32,10 @@ module Ruby2JS
|
|
31
32
|
@binding = binding
|
32
33
|
end
|
33
34
|
|
35
|
+
def width=(width)
|
36
|
+
@width = width
|
37
|
+
end
|
38
|
+
|
34
39
|
def to_js
|
35
40
|
parse( @ast, :statement )
|
36
41
|
end
|
@@ -22,7 +22,7 @@ module Ruby2JS
|
|
22
22
|
end
|
23
23
|
else
|
24
24
|
items.map! { |item| parse item }
|
25
|
-
if items.map {|item| item.length+2}.reduce(&:+).to_i <
|
25
|
+
if items.map {|item| item.length+2}.reduce(&:+).to_i < @width-8
|
26
26
|
"[#{ items.join(', ') }]"
|
27
27
|
else
|
28
28
|
"[#@nl#{ items.join(",#@ws") }#@nl]"
|
data/lib/ruby2js/converter/if.rb
CHANGED
@@ -24,7 +24,7 @@ module Ruby2JS
|
|
24
24
|
output << " else {#@nl#{ scope else_block }#@nl}" if else_block
|
25
25
|
|
26
26
|
# use short form when appropriate
|
27
|
-
unless output.length
|
27
|
+
unless output.length>@width-8 or else_block or then_block.type == :begin
|
28
28
|
output = "if (#{ parse condition }) #{ scope then_block }"
|
29
29
|
end
|
30
30
|
|
@@ -103,7 +103,7 @@ module Ruby2JS
|
|
103
103
|
args = args.map {|a| parse a}
|
104
104
|
if args.any? {|arg| arg.to_s.include? "\n"}
|
105
105
|
"#{ call }(#{ args.join(', ') })"
|
106
|
-
elsif args.map {|arg| arg.length+2}.reduce(&:+).to_i <
|
106
|
+
elsif args.map {|arg| arg.length+2}.reduce(&:+).to_i < @width-10
|
107
107
|
"#{ call }(#{ args.join(', ') })"
|
108
108
|
else
|
109
109
|
"#{ call }(#@nl#{ args.join(",#@ws") }#@nl)"
|
@@ -11,6 +11,8 @@ require 'ruby2js'
|
|
11
11
|
# So as a second accomodation, the rarely used binary one's complement unary
|
12
12
|
# operator (namely, ~) is usurped, and the AST is rewritten to provide the
|
13
13
|
# effect of this operator being of a higher precedence than method calls.
|
14
|
+
# Passing multiple parameters can be accomplished by using array index
|
15
|
+
# syntax (e.g., ~['a', self])
|
14
16
|
#
|
15
17
|
# As a part of this rewriting, calls to getters and setters are rewritten
|
16
18
|
# to match jQuery's convention for getters and setters:
|
@@ -141,8 +143,11 @@ module Ruby2JS
|
|
141
143
|
# method call with a block parameter
|
142
144
|
node.updated nil, [rewrite_tilda[node.children[0]],
|
143
145
|
*process_all(node.children[1..-1])]
|
146
|
+
elsif node.type == :array
|
147
|
+
# innermost expression is an array
|
148
|
+
s(:send, nil, '$', *process(node))
|
144
149
|
else
|
145
|
-
# innermost expression
|
150
|
+
# innermost expression is a scalar
|
146
151
|
s(:send, nil, '$', process(node))
|
147
152
|
end
|
148
153
|
end
|
data/lib/ruby2js/version.rb
CHANGED
data/ruby2js.gemspec
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "ruby2js"
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.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 = "2013-12-
|
9
|
+
s.date = "2013-12-07"
|
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/
|
12
|
+
s.files = ["ruby2js.gemspec", "README.md", "lib/ruby2js", "lib/ruby2js/sinatra.rb", "lib/ruby2js/converter.rb", "lib/ruby2js/filter", "lib/ruby2js/filter/angular-route.rb", "lib/ruby2js/filter/jquery.rb", "lib/ruby2js/filter/return.rb", "lib/ruby2js/filter/angularrb.rb", "lib/ruby2js/filter/strict.rb", "lib/ruby2js/filter/functions.rb", "lib/ruby2js/filter/angular-resource.rb", "lib/ruby2js/converter", "lib/ruby2js/converter/ivasgn.rb", "lib/ruby2js/converter/self.rb", "lib/ruby2js/converter/undef.rb", "lib/ruby2js/converter/casgn.rb", "lib/ruby2js/converter/nil.rb", "lib/ruby2js/converter/logical.rb", "lib/ruby2js/converter/ivar.rb", "lib/ruby2js/converter/class.rb", "lib/ruby2js/converter/for.rb", "lib/ruby2js/converter/arg.rb", "lib/ruby2js/converter/literal.rb", "lib/ruby2js/converter/dstr.rb", "lib/ruby2js/converter/return.rb", "lib/ruby2js/converter/defined.rb", "lib/ruby2js/converter/boolean.rb", "lib/ruby2js/converter/next.rb", "lib/ruby2js/converter/array.rb", "lib/ruby2js/converter/def.rb", "lib/ruby2js/converter/args.rb", "lib/ruby2js/converter/regexp.rb", "lib/ruby2js/converter/var.rb", "lib/ruby2js/converter/defs.rb", "lib/ruby2js/converter/if.rb", "lib/ruby2js/converter/orasgn.rb", "lib/ruby2js/converter/masgn.rb", "lib/ruby2js/converter/hash.rb", "lib/ruby2js/converter/whilepost.rb", "lib/ruby2js/converter/break.rb", "lib/ruby2js/converter/opasgn.rb", "lib/ruby2js/converter/begin.rb", "lib/ruby2js/converter/xstr.rb", "lib/ruby2js/converter/vasgn.rb", "lib/ruby2js/converter/block.rb", "lib/ruby2js/converter/send.rb", "lib/ruby2js/converter/sym.rb", "lib/ruby2js/converter/case.rb", "lib/ruby2js/converter/kwbegin.rb", "lib/ruby2js/converter/const.rb", "lib/ruby2js/converter/module.rb", "lib/ruby2js/converter/until.rb", "lib/ruby2js/converter/untilpost.rb", "lib/ruby2js/converter/andasgn.rb", "lib/ruby2js/converter/blockpass.rb", "lib/ruby2js/converter/while.rb", "lib/ruby2js/cgi.rb", "lib/ruby2js/version.rb", "lib/ruby2js/rails.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
|
-
s.rubygems_version = "
|
16
|
+
s.rubygems_version = "1.8.11"
|
17
17
|
s.summary = "Minimal yet extensible Ruby to JavaScript conversion."
|
18
18
|
|
19
19
|
if s.respond_to? :specification_version then
|
20
|
-
s.specification_version =
|
20
|
+
s.specification_version = 3
|
21
21
|
|
22
22
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
23
23
|
s.add_runtime_dependency(%q<parser>, [">= 0"])
|
metadata
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Sam Ruby
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: parser
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &15295760 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
|
-
version_requirements:
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
24
|
+
version_requirements: *15295760
|
27
25
|
description: ! " The base package maps Ruby syntax to JavaScript semantics.\n Filters
|
28
26
|
may be provided to add Ruby-specific or framework specific\n behavior.\n"
|
29
27
|
email: rubys@intertwingly.net
|
@@ -33,85 +31,86 @@ extra_rdoc_files: []
|
|
33
31
|
files:
|
34
32
|
- ruby2js.gemspec
|
35
33
|
- README.md
|
36
|
-
- lib/ruby2js/
|
37
|
-
- lib/ruby2js/
|
38
|
-
- lib/ruby2js/
|
39
|
-
- lib/ruby2js/
|
40
|
-
- lib/ruby2js/
|
41
|
-
- lib/ruby2js/
|
42
|
-
- lib/ruby2js/
|
43
|
-
- lib/ruby2js/
|
44
|
-
- lib/ruby2js/
|
45
|
-
- lib/ruby2js/converter/
|
46
|
-
- lib/ruby2js/converter/
|
47
|
-
- lib/ruby2js/converter/
|
48
|
-
- lib/ruby2js/converter/
|
34
|
+
- lib/ruby2js/sinatra.rb
|
35
|
+
- lib/ruby2js/converter.rb
|
36
|
+
- lib/ruby2js/filter/angular-route.rb
|
37
|
+
- lib/ruby2js/filter/jquery.rb
|
38
|
+
- lib/ruby2js/filter/return.rb
|
39
|
+
- lib/ruby2js/filter/angularrb.rb
|
40
|
+
- lib/ruby2js/filter/strict.rb
|
41
|
+
- lib/ruby2js/filter/functions.rb
|
42
|
+
- lib/ruby2js/filter/angular-resource.rb
|
43
|
+
- lib/ruby2js/converter/ivasgn.rb
|
44
|
+
- lib/ruby2js/converter/self.rb
|
45
|
+
- lib/ruby2js/converter/undef.rb
|
46
|
+
- lib/ruby2js/converter/casgn.rb
|
49
47
|
- lib/ruby2js/converter/nil.rb
|
50
48
|
- lib/ruby2js/converter/logical.rb
|
51
|
-
- lib/ruby2js/converter/
|
52
|
-
- lib/ruby2js/converter/
|
53
|
-
- lib/ruby2js/converter/whilepost.rb
|
54
|
-
- lib/ruby2js/converter/arg.rb
|
55
|
-
- lib/ruby2js/converter/case.rb
|
56
|
-
- lib/ruby2js/converter/break.rb
|
57
|
-
- lib/ruby2js/converter/hash.rb
|
49
|
+
- lib/ruby2js/converter/ivar.rb
|
50
|
+
- lib/ruby2js/converter/class.rb
|
58
51
|
- lib/ruby2js/converter/for.rb
|
52
|
+
- lib/ruby2js/converter/arg.rb
|
53
|
+
- lib/ruby2js/converter/literal.rb
|
54
|
+
- lib/ruby2js/converter/dstr.rb
|
55
|
+
- lib/ruby2js/converter/return.rb
|
56
|
+
- lib/ruby2js/converter/defined.rb
|
59
57
|
- lib/ruby2js/converter/boolean.rb
|
60
|
-
- lib/ruby2js/converter/
|
61
|
-
- lib/ruby2js/converter/
|
62
|
-
- lib/ruby2js/converter/
|
63
|
-
- lib/ruby2js/converter/
|
64
|
-
- lib/ruby2js/converter/until.rb
|
58
|
+
- lib/ruby2js/converter/next.rb
|
59
|
+
- lib/ruby2js/converter/array.rb
|
60
|
+
- lib/ruby2js/converter/def.rb
|
61
|
+
- lib/ruby2js/converter/args.rb
|
65
62
|
- lib/ruby2js/converter/regexp.rb
|
66
|
-
- lib/ruby2js/converter/
|
63
|
+
- lib/ruby2js/converter/var.rb
|
64
|
+
- lib/ruby2js/converter/defs.rb
|
65
|
+
- lib/ruby2js/converter/if.rb
|
66
|
+
- lib/ruby2js/converter/orasgn.rb
|
67
67
|
- lib/ruby2js/converter/masgn.rb
|
68
|
+
- lib/ruby2js/converter/hash.rb
|
69
|
+
- lib/ruby2js/converter/whilepost.rb
|
70
|
+
- lib/ruby2js/converter/break.rb
|
71
|
+
- lib/ruby2js/converter/opasgn.rb
|
72
|
+
- lib/ruby2js/converter/begin.rb
|
73
|
+
- lib/ruby2js/converter/xstr.rb
|
74
|
+
- lib/ruby2js/converter/vasgn.rb
|
68
75
|
- lib/ruby2js/converter/block.rb
|
69
|
-
- lib/ruby2js/converter/ivar.rb
|
70
76
|
- lib/ruby2js/converter/send.rb
|
71
|
-
- lib/ruby2js/converter/vasgn.rb
|
72
|
-
- lib/ruby2js/converter/defined.rb
|
73
|
-
- lib/ruby2js/converter/def.rb
|
74
77
|
- lib/ruby2js/converter/sym.rb
|
75
|
-
- lib/ruby2js/converter/
|
76
|
-
- lib/ruby2js/converter/
|
77
|
-
- lib/ruby2js/converter/
|
78
|
+
- lib/ruby2js/converter/case.rb
|
79
|
+
- lib/ruby2js/converter/kwbegin.rb
|
80
|
+
- lib/ruby2js/converter/const.rb
|
81
|
+
- lib/ruby2js/converter/module.rb
|
82
|
+
- lib/ruby2js/converter/until.rb
|
83
|
+
- lib/ruby2js/converter/untilpost.rb
|
78
84
|
- lib/ruby2js/converter/andasgn.rb
|
79
|
-
- lib/ruby2js/converter/
|
80
|
-
- lib/ruby2js/converter/
|
81
|
-
- lib/ruby2js/converter/class.rb
|
85
|
+
- lib/ruby2js/converter/blockpass.rb
|
86
|
+
- lib/ruby2js/converter/while.rb
|
82
87
|
- lib/ruby2js/cgi.rb
|
83
|
-
- lib/ruby2js/
|
84
|
-
- lib/ruby2js/
|
85
|
-
- lib/ruby2js/filter/strict.rb
|
86
|
-
- lib/ruby2js/filter/angularrb.rb
|
87
|
-
- lib/ruby2js/filter/angular-resource.rb
|
88
|
-
- lib/ruby2js/filter/functions.rb
|
89
|
-
- lib/ruby2js/filter/jquery.rb
|
90
|
-
- lib/ruby2js/filter/angular-route.rb
|
91
|
-
- lib/ruby2js/sinatra.rb
|
88
|
+
- lib/ruby2js/version.rb
|
89
|
+
- lib/ruby2js/rails.rb
|
92
90
|
- lib/ruby2js.rb
|
93
91
|
homepage: http://github.com/rubys/ruby2js
|
94
92
|
licenses:
|
95
93
|
- MIT
|
96
|
-
metadata: {}
|
97
94
|
post_install_message:
|
98
95
|
rdoc_options: []
|
99
96
|
require_paths:
|
100
97
|
- lib
|
101
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
102
100
|
requirements:
|
103
101
|
- - ! '>='
|
104
102
|
- !ruby/object:Gem::Version
|
105
103
|
version: '0'
|
106
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
107
106
|
requirements:
|
108
107
|
- - ! '>='
|
109
108
|
- !ruby/object:Gem::Version
|
110
109
|
version: '0'
|
111
110
|
requirements: []
|
112
111
|
rubyforge_project:
|
113
|
-
rubygems_version:
|
112
|
+
rubygems_version: 1.8.11
|
114
113
|
signing_key:
|
115
|
-
specification_version:
|
114
|
+
specification_version: 3
|
116
115
|
summary: Minimal yet extensible Ruby to JavaScript conversion.
|
117
116
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MDMxNmI2YjUyMTk4MDExOWY5Mzc4NGE0YTYzOGVkYTc3YTE2YmE3OA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NGIzN2ZlMGM0MjJhNmJlYTZlZDc1MGJiMzVhNTQ0NmUzMjcwY2QwMA==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
N2QyMmJlN2IwZmNhY2NkZmI4ZGQzYzkwNThhMmUyMjRmOTY1NThjZDQzMGYx
|
10
|
-
ZjljMmZkODE0YzNjM2YxMzE3NzcyOWVmM2YyOWZiMTAzODVhYzg4ZjgyNTU5
|
11
|
-
YjVlNjJiNzg0OWZiOWQ0MzM2OGY1Zjc2ZmFhMTQ3YzhmN2IxNjA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTA2NzdiYThhYWRmOTYzYzg0OGNhNjRmNmU3OGJhMDg4ZWJmMWNhYTY0YmMy
|
14
|
-
YjM2MDdkNGUyMmRlZjNiOWFlZjJkOGQzY2FmMzJhNmE5NzIwNDcwM2ZjZDlk
|
15
|
-
ZGZlNGUwMjFkNmY3MGZmNDYzZjExZDI0ZTljNTAzMzBkNDVjNGY=
|