-
Notifications
You must be signed in to change notification settings - Fork 20
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
user support for updating JS #83
Conversation
Please write few examples/description/proper commit msg to understand how it will work along with PR. It will be better if we create different commands for updating the different library js files. i.e. (1 command for updating the highcharts related files another command for updating the googlecharts related files). Means I want it to be modular and extendable. The main command (which will update all the js files) will use these commands. Refer this One command must do only one thing. |
bin/daru-view
Outdated
opts.on('-u', '--update', 'Update js libraries') do | ||
path = `gem which daru/view`.split('/') | ||
path = path - [path[-1]] | ||
path = path.join('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path = `gem which daru/view`.split('/')[0...-1].join('/')
Usage
|
Should I add the following to prevent rubocop fail because replacing Style/ExpandPathArguments:
Enabled: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write test case for it. I hope there must be a way to test it.
I have managed to prevent failing build without altering the tests. Please check. |
@Shekharrajak can you review this change and see if its good enough for merging? |
I will review it by tonight. I was waiting for testcases . |
bin/daru-view
Outdated
opts.banner = "Usage: daru-view [options]" | ||
# Update google charts javascript dependent files, from latest Builds on google developers website | ||
opts.on('-g', '--update-googlecharts', 'Update googlecharts.js libraries') do | ||
sh "curl -# http://www.google.com/jsapi -L --compressed -o #{path}/view/adapters/js/googlecharts_js/google_visualr.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must create folder and file if it is not present, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if file is also not present or deleted to update it ? touch
can be useful here, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this too. curl
downloads the missing/deleted files. I have checked it by manually removing some js files. So it won't be a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even I tried deleting the files. But it was throwing error. I hope you can write testcases for it. Please write in comment the TODO part as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the travis script to run the executable and added the TODO.
bin/daru-view
Outdated
|
||
# Update highcharts.js from latest Builds on Highcharts codebase: http://code.highcharts.com/ | ||
opts.on('-H', '--update-highcharts', 'Update highcharts.js libraries') do | ||
sh "mkdir -p #{path}/view/adapters/js/highcharts_js/modules/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must have modularity , to update just modules or just adapters or just particular file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a doubt, why will someone using daru-view care about updating adapters and modules separately or a specific file? I think it is a different issue of having updates in a granular manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, if someone wants to use new features added in highcharts3d then user may just want to update the file highcharts-3d.js
. Let me know if it is little tricky task. We will add it as TODO task .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be better to add it as a TODO task in #47 as it will require a bit of restructuring. This PR will make it easy to atleast update the JS files for now.
The idea of the PR looks good, please have a look on comments . |
65c3481
to
e45721b
Compare
.travis.yml
Outdated
@@ -11,6 +11,8 @@ rvm: | |||
script: | |||
- bundle exec rspec | |||
- bundle exec rubocop | |||
- ./bin/daru-view -g | |||
- ./bin/daru-view -H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have testcases like this : https://github.com/bundler/bundler/blob/master/spec/commands/info_spec.rb ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have added tests in RSpec instead of Travis, please check.
@@ -0,0 +1,22 @@ | |||
describe Daru::View, "Update JS files" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the tab indent to 2 spaces. 😄
spec/update_spec.rb
Outdated
expect(flag).to eq(true) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line here.
bin/daru-view
Outdated
@@ -3,10 +3,12 @@ | |||
require 'optparse' | |||
require 'rake' | |||
|
|||
path = `gem which daru/view`.split('/')[0...-1].join('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your commit message is saying something else !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know why did you change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed to be an overkill for getting the path, So I just made it simpler by using the relative path. Pardon for the commit message. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested the command in isolated container and docker it is working fine.
I was waiting for the spec which will test the files (i.e. whether js file are created/updated or not). Also some modular way of doing the task.
Merging it for now. Thanks @rohitner !
@rohitner , Can you please document it ? |
bin/daru-view
Outdated
opts.banner = "Usage: daru-view [options]" | ||
# TODO add arguments to update only modules/adapters/a particular file | ||
|
||
# Update google charts javascript dependent files, from latest Builds on google developers website |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please maintain line length everywhere in the PR.
spec/update_spec.rb
Outdated
@@ -0,0 +1,22 @@ | |||
describe Daru::View, "Update JS files" do | |||
context "googlecharts" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context ?
end | ||
end | ||
|
||
context "googlecharts" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context ?
bin/daru-view
Outdated
opts.on('-g', '--update-googlecharts', 'Update googlecharts.js libraries') do | ||
sh "mkdir -p #{path}/view/adapters/js/googlecharts_js/" | ||
|
||
sh "curl -# http://www.google.com/jsapi -L --compressed -o #{path}/view/adapters/js/googlecharts_js/google_visualr.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line length can be reduced,right ?
bin/daru-view
Outdated
sh "mkdir -p #{path}/view/adapters/js/highcharts_js/modules/" | ||
sh "mkdir -p #{path}/view/adapters/js/highcharts_js/adapters/" | ||
|
||
sh "curl -# http://code.highcharts.com/highcharts.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/highcharts.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we make them in a loop ?
To keep everything DRY, I have replaced the code block with rake tasks. |
@rohitner , I will test it once more in isolated (docker) container. Let me know if you have tested all the commands properly in your system. |
Actually there's a problem, we always need a rakefile in current directory for this to work. I will revert back to previous commit if there aren't any ways to tackle this. |
@Shekharrajak , sorry for delay, please review |
ping! @Shekharrajak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work by using the already present rake task.
TBH, thor
is better if we want to test it properly, WDYT?
bin/daru-view
Outdated
# Update google charts javascript dependent files, from latest Builds | ||
# on the google developers website | ||
opts.on('-g', '--update-googlecharts', 'Update googlecharts.js libraries') do | ||
update(:googlecharts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a folder googlecharts_js
, if it is not present. Better place will be in rake task.
bin/daru-view
Outdated
update(:highcharts) | ||
end | ||
|
||
opts.on('-h', '--help', 'Displays Help') do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How it will handle if invalid option is given?
@rohitner , I just wanted to know your opinion. Let me know if you have checked it properly. This PR must be merged soon. Remaining thing we will do . |
Hey @Shekharrajak , I actually saw the need of |
Thanks @rohitner ! I had tested few commands in isolated container it worked fine. I still have few concerns :
I am putting these into TODO list. Let me know @rohitner , if you have any suggestions/opinions. I will merge it after that. |
IMO, we should stick to the conventional |
will be better I guess. Merging it for now. |
I have used the OptionParser as mentioned in #47