class EJStr
Constants
- JAVA_TEMPLATE_FILE
Public Class Methods
new(files, pkg_name, clz_name)
click to toggle source
Calls superclass method
CommonEnc::new
# File lib/ejstr.rb, line 10 def initialize(files, pkg_name, clz_name) super(files) @@package_name = pkg_name @@class_name = clz_name end
Public Instance Methods
_(str)
click to toggle source
# File lib/ejstr.rb, line 45 def _(str) id = add(str_to_id(str), str) return "#{getstr_funcname}(#{@@package_name}.#{@@class_name}._ENJSTR_IDS.#{id})" end
getstr_funcname()
click to toggle source
# File lib/ejstr.rb, line 6 def getstr_funcname "#{@@package_name}.#{@@class_name}._" end
run()
click to toggle source
# File lib/ejstr.rb, line 16 def run @dict = Hash.new b = binding @files.each do |infile| outfile = infile[0..-5] erbfile = ERB.new(File.read infile) File.write outfile, erbfile.result(b) print "#{infile} -> #{outfile}\n" end idx = 0 ids = "" #private class _ENJSTR_IDS { \n" strs = "" #private String enc_j_strs[] = { \n" @dict.each do |key, value| ids += " public static final int #{key} = #{idx};\n" idx += 1 strs += " \"#{encrypt value}\",\n" end ids += " public static final int ENCRYPTED_STR_TOTAL_NUM = #{idx};" strs += " null" str_src_file = "#{@@class_name}.java" erbfile = ERB.new(File.read File.join(gem_root_dir, "lib/#{JAVA_TEMPLATE_FILE}")) File.write str_src_file, erbfile.result(binding) end