|
| 1 | +def extract_adapter_template_code(file_name, template_code_str) |
| 2 | + template_code_str << "module Daru" |
| 3 | + template_code_str << "\n module View" |
| 4 | + template_code_str << "\n module Adapter" |
| 5 | + template_code_str << "\n module #{file_name.capitalize}Adapter" |
| 6 | + template_code_str << "\n extend self # rubocop:disable Style/ModuleFunction" |
| 7 | + template_code_str << "\n def init(data, options, _user_options={})" |
| 8 | + template_code_str << "\n # TODO" |
| 9 | + template_code_str << "\n end" |
| 10 | + template_code_str << "\n" |
| 11 | + template_code_str << "\n def export_html_file(plot, path='./plot.html')" |
| 12 | + template_code_str << "\n # TODO" |
| 13 | + template_code_str << "\n end" |
| 14 | + template_code_str << "\n" |
| 15 | + template_code_str << "\n def show_in_iruby(plot)" |
| 16 | + template_code_str << "\n # TODO" |
| 17 | + template_code_str << "\n end" |
| 18 | + template_code_str << "\n" |
| 19 | + template_code_str << "\n def init_script" |
| 20 | + template_code_str << "\n # TODO" |
| 21 | + template_code_str << "\n end" |
| 22 | + template_code_str << "\n" |
| 23 | + template_code_str << "\n def init_iruby" |
| 24 | + template_code_str << "\n # TODO" |
| 25 | + template_code_str << "\n end" |
| 26 | + template_code_str << "\n end" |
| 27 | + template_code_str << "\n end" |
| 28 | + template_code_str << "\n end" |
| 29 | + template_code_str << "\nend" |
| 30 | + template_code_str << "\n" |
| 31 | +end |
| 32 | + |
| 33 | +namespace :new do |
| 34 | + desc "Generate a sample template for the new adapter" |
| 35 | + task :adapter do |
| 36 | + print "Creating new adapter..." |
| 37 | + ARGV.each { |a| task a.to_sym do ; end } |
| 38 | + file_name = ARGV[1].to_s |
| 39 | + path = File.expand_path( |
| 40 | + '../daru/view/adapters/' + file_name + '.rb', __dir__ |
| 41 | + ) |
| 42 | + template_code_str = '' |
| 43 | + extract_adapter_template_code(file_name, template_code_str) |
| 44 | + File.write(path, template_code_str) |
| 45 | + puts "Done." |
| 46 | + end |
| 47 | +end |
0 commit comments