Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

keeping it classy Seattle

  • Loading branch information...
commit 1e4cae847c646415a69062a7b68cba8aa958d2fd 1 parent 63521fa
@tenderlove authored
View
16 lib/zomg/idl/visitors/ruby_sexp.rb
@@ -8,7 +8,7 @@ def visit_Specification(o)
def visit_Module(o)
[ :module,
- o.name.capitalize.to_sym,
+ classify(o.name),
[:scope, [:block] + o.children.map { |c| c.accept(self) }]
]
end
@@ -17,7 +17,7 @@ def visit_Interface(o)
header = o.header.accept(self)
header = header ? [:block, header] : [:block]
[ :module,
- o.header.name.capitalize.to_sym,
+ classify(o.header.name),
[:scope,
header +
o.children.map { |c| c.accept(self) }
@@ -29,7 +29,7 @@ def visit_InterfaceHeader(o)
if o.children.length > 0
[:fcall, :include,
[:array] + o.children.map { |c|
- [:const, c.accept(self).to_s.capitalize.to_sym]
+ [:const, classify(c.accept(self))]
} ]
else
nil
@@ -46,7 +46,7 @@ def visit_Exception(o)
}.flatten.map { |att| [:lit, att] }
]] : [:scope]
- [:class, o.name.capitalize.to_sym, [:const, :Exception], attributes]
+ [:class, classify(o.name), [:const, :Exception], attributes]
end
def visit_Attribute(o)
@@ -101,7 +101,7 @@ def visit_ValueBoxDcl(o)
def visit_Struct(o)
[ :cdecl,
- o.name.capitalize.to_sym,
+ classify(o.name),
[ :call, [:const, :Struct],
:new,
[:array] + o.children.map { |c|
@@ -156,6 +156,12 @@ def visit_ForwardDeclaration(o)
def accept(target)
target.accept(self)
end
+
+ private
+ def classify(string)
+ s = string.to_s
+ :"#{s.slice(0,1).upcase}#{s[1..-1]}"
+ end
end
end
end
View
2  test/conversions/test_exception.rb
@@ -17,7 +17,7 @@ def test_to_ruby_sexp
assert_nothing_raised {
sexp = @tree.to_ruby_sexp
}
- assert_equal([:block, [:class, :Not_implemented, [:const, :Exception], [:scope]], [:class, :Avocadoexcpt, [:const, :Exception], [:scope, [:fcall, :attr_accessor, [:array, [:lit, :ex1]]]]]], sexp)
+ assert_equal([:block, [:class, :Not_implemented, [:const, :Exception], [:scope]], [:class, :AvocadoExcpt, [:const, :Exception], [:scope, [:fcall, :attr_accessor, [:array, [:lit, :ex1]]]]]], sexp)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.