Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rake task to add new adapter template #112

Merged
merged 3 commits into from
Aug 1, 2018

Conversation

Prakriti-nith
Copy link
Contributor

This PR aims to create a rake task to add a new adapter template.
Example:

rake new:adapter Charts

will create a new file charts.rb with all the necessary methods to add an adapter like init, init_script, init_ruby, show_in_iruby and export_html_file as TODO.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 632

  • 47 of 47 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.648%

Totals Coverage Status
Change from base Build 626: 0.04%
Covered Lines: 2616
Relevant Lines: 2679

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 24, 2018

Pull Request Test Coverage Report for Build 659

  • 51 of 51 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.908%

Totals Coverage Status
Change from base Build 648: 0.04%
Covered Lines: 2855
Relevant Lines: 2916

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 632

  • 47 of 47 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.648%

Totals Coverage Status
Change from base Build 626: 0.04%
Covered Lines: 2616
Relevant Lines: 2679

💛 - Coveralls

Copy link
Member

@Shekharrajak Shekharrajak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attach screenshot how it is generating the files and folder. Run some code in irb for this adapter in screenshot.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this raise not implemented exception.

template_code_str << "\n"
end

namespace :new do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document this feature in readme.md (and wiki page once it is completed) explaining about API and useage.

@Prakriti-nith
Copy link
Contributor Author

Running this command:
rake1

generates the following file in daru/view/adapters
rake3

Running some code for this adapter results in NotImplementedError:
rake2

@@ -0,0 +1,57 @@
def extract_adapter_template_code(file_name, template_code_str)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not good to have one single method that do all the things. We should have method to generate string for internal methods like init, export_html_file.

There are many ways to make it modular & extendable. Think/design good one.

Copy link
Member

@Shekharrajak Shekharrajak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine!

template_code_str << "\n module View"
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still prefer \t than spaces.

@Shekharrajak Shekharrajak merged commit f965fbb into SciRuby:master Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants