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

Projects
None yet
3 participants
@Prakriti-nith
Contributor

Prakriti-nith commented Jul 24, 2018

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.

@Prakriti-nith Prakriti-nith force-pushed the Prakriti-nith:rake_adapter branch from 008e73b to 6c69e2e Jul 24, 2018

@coveralls

This comment has been minimized.

coveralls commented Jul 24, 2018

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

This comment has been minimized.

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

This comment has been minimized.

coveralls commented Jul 24, 2018

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
@Shekharrajak

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"

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 26, 2018

Collaborator

After this raise not implemented exception.

template_code_str << "\n"
end

namespace :new do

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 26, 2018

Collaborator

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

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 26, 2018

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)

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 28, 2018

Collaborator

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.

@Prakriti-nith Prakriti-nith force-pushed the Prakriti-nith:rake_adapter branch from 2033c64 to f9d0acf Jul 29, 2018

@Shekharrajak

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"

This comment has been minimized.

@Shekharrajak

Shekharrajak Aug 1, 2018

Collaborator

I still prefer \t than spaces.

@Shekharrajak Shekharrajak merged commit f965fbb into SciRuby:master Aug 1, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.04%) to 97.908%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment