module RPCoder
Public Class Methods
api_class_name()
click to toggle source
# File lib/rpcoder.rb, line 21 def api_class_name @api_class_name end
api_class_name=(name)
click to toggle source
# File lib/rpcoder.rb, line 17 def api_class_name=(name) @api_class_name = name end
clear()
click to toggle source
# File lib/rpcoder.rb, line 97 def clear functions.clear types.clear end
dir_to_export_classes(dir)
click to toggle source
# File lib/rpcoder.rb, line 93 def dir_to_export_classes(dir) File.join(dir, *name_space.split('.')) end
export(dir)
click to toggle source
# File lib/rpcoder.rb, line 49 def export(dir) class_dir = dir_to_export_classes(dir) FileUtils.mkdir_p(class_dir) [ {:path => File.join(class_dir, api_class_name.split('.').last + "Interface.as"), :content => render_functions_interface}, {:path => File.join(class_dir, api_class_name.split('.').last + ".as"), :content => render_functions}, {:path => File.join(class_dir, api_class_name.split('.').last + "Dummy.as"), :content => render_functions_dummy}, ].each do |hash| puts "API: #{hash[:path]}" File.open(hash[:path], "w") { |file| file << hash[:content] } end types.each { |type| export_type(type, File.join(class_dir, "#{type.name}.as")) } end
export_type(type, path)
click to toggle source
# File lib/rpcoder.rb, line 76 def export_type(type, path) puts "Type: #{path}" File.open(path, "w") { |file| file << render_type(type) } end
function(name) { |func| ... }
click to toggle source
# File lib/rpcoder.rb, line 41 def function(name) func = Function.new func.name = name yield func functions << func func end
functions()
click to toggle source
# File lib/rpcoder.rb, line 37 def functions @functions ||= [] end
name_space()
click to toggle source
# File lib/rpcoder.rb, line 13 def name_space @name_space end
name_space=(name_space)
click to toggle source
# File lib/rpcoder.rb, line 9 def name_space=(name_space) @name_space = name_space end
render_erb(template, _binding)
click to toggle source
# File lib/rpcoder.rb, line 85 def render_erb(template, _binding) ERB.new(File.read(template_path(template)), nil, '-').result(_binding) end
render_functions()
click to toggle source
# File lib/rpcoder.rb, line 68 def render_functions render_erb('API.erb', binding) end
render_functions_dummy()
click to toggle source
# File lib/rpcoder.rb, line 72 def render_functions_dummy render_erb('APIDummy.erb', binding) end
render_functions_interface()
click to toggle source
# File lib/rpcoder.rb, line 64 def render_functions_interface render_erb('APIInterface.erb', binding) end
render_type(type)
click to toggle source
# File lib/rpcoder.rb, line 81 def render_type(type) render_erb('Type.erb', binding) end
template_path(name)
click to toggle source
# File lib/rpcoder.rb, line 89 def template_path(name) File.join File.dirname(__FILE__), 'templates', name end
type(name) { |type| ... }
click to toggle source
# File lib/rpcoder.rb, line 29 def type(name) type = Type.new type.name = name yield type types << type type end
types()
click to toggle source
# File lib/rpcoder.rb, line 25 def types @types ||= [] end