B
Ben Giddings
In case you missed it, on RedHanded, I spotted was an interesting
snippet I didn't see on the list or anything:
It's a way of using ParseTree and RubyToC to add 'to_c' and 'to_ruby'
methods to any Method.
http://redhanded.hobix.com/cult/tooInterestingToPassUp.html
(it also kinda shows how difficult it would be to truly obfuscate Ruby
source)
A teaser:
class Example
def example(arg1)
return "Blah: " + arg1.to_s
end
end
quoting zenspider:
Source:
e = Example.new
puts "sexp:"
p e.methodexample).to_sexp
puts "C:"
puts e.methodexample).to_c
puts "Ruby:"
puts e.methodexample).to_ruby
Output:
sexp:
[:defn, :example, [:scope, [:block, [:args, :arg1], [:return, [:call,
[:str, "Blah: "], :+, [:array, [:call, [:lvar, :arg1], :to_s]]]]]]]
C:
str
example(long arg1) {
return strcat("Blah: ", to_s(arg1));
}
Ruby:
def example(arg1)
return "Blah: " + arg1.to_s
end
Ben
snippet I didn't see on the list or anything:
It's a way of using ParseTree and RubyToC to add 'to_c' and 'to_ruby'
methods to any Method.
http://redhanded.hobix.com/cult/tooInterestingToPassUp.html
(it also kinda shows how difficult it would be to truly obfuscate Ruby
source)
A teaser:
class Example
def example(arg1)
return "Blah: " + arg1.to_s
end
end
quoting zenspider:
Source:
e = Example.new
puts "sexp:"
p e.methodexample).to_sexp
puts "C:"
puts e.methodexample).to_c
puts "Ruby:"
puts e.methodexample).to_ruby
Output:
sexp:
[:defn, :example, [:scope, [:block, [:args, :arg1], [:return, [:call,
[:str, "Blah: "], :+, [:array, [:call, [:lvar, :arg1], :to_s]]]]]]]
C:
str
example(long arg1) {
return strcat("Blah: ", to_s(arg1));
}
Ruby:
def example(arg1)
return "Blah: " + arg1.to_s
end
Ben