Skip to content

Commit

Permalink
Added method append_method
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakriti-nith committed Jul 29, 2018
1 parent 3ddea09 commit 2033c64
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions lib/tasks/new_adapter.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,36 @@ def extract_adapter_template_code(file_name, template_code_str)
template_code_str << "\n module Adapter"
template_code_str << "\n module #{file_name.capitalize}Adapter"
template_code_str << "\n extend self # rubocop:disable Style/ModuleFunction"
template_code_str << "\n def init(data, options, _user_options={})"
template_code_str << "\n # TODO"
template_code_str << "\n raise NotImplementedError, 'Not yet implemented'"
template_code_str << "\n end"
template_code_str << append_method('init', ['data', 'options', '_user_options'])
template_code_str << "\n"
template_code_str << "\n def export_html_file(plot, path='./plot.html')"
template_code_str << "\n # TODO"
template_code_str << "\n raise NotImplementedError, 'Not yet implemented'"
template_code_str << "\n end"
template_code_str << append_method('export_html_file', ['plot', "path='./plot.html'"])
template_code_str << "\n"
template_code_str << "\n def show_in_iruby(plot)"
template_code_str << "\n # TODO"
template_code_str << "\n raise NotImplementedError, 'Not yet implemented'"
template_code_str << "\n end"
template_code_str << append_method('show_in_iruby', ['plot'])
template_code_str << "\n"
template_code_str << "\n def init_script"
template_code_str << "\n # TODO"
template_code_str << "\n raise NotImplementedError, 'Not yet implemented'"
template_code_str << "\n end"
template_code_str << append_method('init_script')
template_code_str << "\n"
template_code_str << "\n def generate_body(plot)"
template_code_str << "\n # TODO"
template_code_str << "\n raise NotImplementedError, 'Not yet implemented'"
template_code_str << "\n end"
template_code_str << append_method('generate_body', ['plot'])
template_code_str << "\n"
template_code_str << "\n def init_iruby"
template_code_str << "\n # TODO"
template_code_str << "\n raise NotImplementedError, 'Not yet implemented'"
template_code_str << "\n end"
template_code_str << append_method('init_iruby')
template_code_str << "\n end"
template_code_str << "\n end"
template_code_str << "\n end"
template_code_str << "\nend"
template_code_str << "\n"
end

def append_method(method_name, params=nil)
method_str = "\n def #{method_name}"
if params
method_str << '('
method_str << params.join(', ')
method_str << ')'
end
method_str << "\n # TODO"
method_str << "\n raise NotImplementedError, 'Not yet implemented'"
method_str << "\n end"
end

namespace :new do
desc "Generate a sample template for the new adapter"
task :adapter do
Expand Down

0 comments on commit 2033c64

Please sign in to comment.