module Ruby2JS::Filter::CamelCase
Constants
- ALLOWLIST
- CAPS_EXCEPTIONS
Public Instance Methods
camelCase(symbol)
click to toggle source
# File lib/ruby2js/filter/camelCase.rb, line 33 def camelCase(symbol) return symbol if ALLOWLIST.include?(symbol.to_s) should_symbolize = symbol.is_a?(Symbol) symbol = symbol .to_s .gsub(/(?!^)_[a-z0-9]/) {|match| match[1].upcase} .gsub(/^(.*)$/) {|match| CAPS_EXCEPTIONS[match] || match } should_symbolize ? symbol.to_sym : symbol end
handle_generic_node(node, node_type)
click to toggle source
# File lib/ruby2js/filter/camelCase.rb, line 69 def handle_generic_node(node, node_type) return node if node.type != node_type if node.children[0].to_s =~ /_.*[?!\w]$/ and !ALLOWLIST.include?(node.children[0].to_s) S(node_type , camelCase(node.children[0]), *node.children[1..-1]) else node end end
on_arg(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 103 def on_arg(node) handle_generic_node(super, :arg) end
on_assign(node)
click to toggle source
# File lib/ruby2js/filter/camelCase.rb, line 135 def on_assign(node) S(:assign , node.children[0], *node.children[1..-1].map{ process _1 }) end
on_attr(node)
click to toggle source
# File lib/ruby2js/filter/camelCase.rb, line 65 def on_attr(node) on_send(node) end
on_csend(node)
click to toggle source
# File lib/ruby2js/filter/camelCase.rb, line 61 def on_csend(node) on_send(node) end
on_cvar(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 99 def on_cvar(node) handle_generic_node(super, :cvar) end
on_cvasgn(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 119 def on_cvasgn(node) handle_generic_node(super, :cvasgn) end
on_def(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 79 def on_def(node) handle_generic_node(super, :def) end
on_defs(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 139 def on_defs(node) node = super return node if node.type != :defs if node.children[1] =~ /_.*[?!\w]$/ S(:defs , node.children[0], camelCase(node.children[1]), *node.children[2..-1]) else node end end
on_ivar(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 95 def on_ivar(node) handle_generic_node(super, :ivar) end
on_ivasgn(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 115 def on_ivasgn(node) handle_generic_node(super, :ivasgn) end
on_kwarg(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 107 def on_kwarg(node) handle_generic_node(super, :kwarg) end
on_kwoptarg(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 87 def on_kwoptarg(node) handle_generic_node(super, :kwoptarg) end
on_lvar(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 91 def on_lvar(node) handle_generic_node(super, :lvar) end
on_lvasgn(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 111 def on_lvasgn(node) handle_generic_node(super, :lvasgn) end
on_match_pattern(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 123 def on_match_pattern(node) handle_generic_node(super, :match_pattern) end
on_match_var(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 127 def on_match_var(node) handle_generic_node(super, :match_var) end
on_optarg(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 83 def on_optarg(node) handle_generic_node(super, :optarg) end
on_send(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 44 def on_send(node) node = super return node unless [:send, :csend, :attr].include? node.type if node.children[0] == nil and ALLOWLIST.include? node.children[1].to_s node elsif node.children[0] && [:ivar, :cvar].include?(node.children[0].type) S(node.type, s(node.children[0].type, camelCase(node.children[0].children[0])), camelCase(node.children[1]), *node.children[2..-1]) elsif node.children[1] =~ /_.*\w[=!?]?$/ S(node.type, node.children[0], camelCase(node.children[1]), *node.children[2..-1]) else node end end
on_sym(node)
click to toggle source
Calls superclass method
# File lib/ruby2js/filter/camelCase.rb, line 131 def on_sym(node) handle_generic_node(super, :sym) end