Skip to content

Instantly share code, notes, and snippets.

@JakeCoxon
Created September 24, 2012 12:22
Show Gist options
  • Save JakeCoxon/3775689 to your computer and use it in GitHub Desktop.
Save JakeCoxon/3775689 to your computer and use it in GitHub Desktop.
Ruby + Java file
//;"
/*"
code = <<-CODE.chop
class AJavaClass {
public static void main(String[] args) {
System.out.println("#{Random.rand(100)}");
}
}
CODE
file = IO.read(__FILE__)
IO.write("#{__FILE__}.bak", file)
file.sub!(%r{(?<=^// BEGIN GEN\n)[\s\S]*(?=\n^// END GEN)}, code)
IO.write(__FILE__, file)
puts "Done"
=begin */
// BEGIN GEN
class AJavaClass {
public static void main(String[] args) {
System.out.println("38");
}
}
// END GEN
/*
=end
#*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment