-
Notifications
You must be signed in to change notification settings - Fork 19
user support for updating JS #83
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
Changes from 9 commits
be233e1
c98ad03
063f6d3
593feb2
a05d261
ed81bff
38b7b4c
be08e6e
394916d
82cf48d
c018303
c6adbac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'optparse' | ||
require 'rake' | ||
|
||
path = File.expand_path('../lib/daru',__dir__) | ||
|
||
parser = OptionParser.new do |opts| | ||
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 the google developers website | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Line length can be reduced,right ? |
||
sh "curl -# http://www.gstatic.com/charts/loader.js -L --compressed -o #{path}/view/adapters/js/googlecharts_js/loader.js" | ||
end | ||
|
||
# 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 commentThe 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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Can't we make them in a loop ? |
||
sh "curl -# http://code.highcharts.com/highcharts-more.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/highcharts-more.js" | ||
sh "curl -# http://code.highcharts.com/highcharts-3d.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/highcharts-3d.js" | ||
|
||
# Modules | ||
sh "curl -# http://code.highcharts.com/modules/accessibility.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/accessibility.js" | ||
sh "curl -# http://code.highcharts.com/modules/annotations.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/annotations.js" | ||
sh "curl -# http://code.highcharts.com/modules/boost.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/boost.js" | ||
sh "curl -# http://code.highcharts.com/modules/broken-axis.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/broken-axis.js" | ||
sh "curl -# http://code.highcharts.com/modules/canvas-tools.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/canvas-tools.js" | ||
sh "curl -# http://code.highcharts.com/modules/data.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/data.js" | ||
sh "curl -# http://code.highcharts.com/modules/exporting.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/exporting.js" | ||
sh "curl -# http://code.highcharts.com/modules/drilldown.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/drilldown.js" | ||
sh "curl -# http://code.highcharts.com/modules/funnel.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/funnel.js" | ||
sh "curl -# http://code.highcharts.com/modules/heatmap.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/heatmap.js" | ||
sh "curl -# http://code.highcharts.com/modules/no-data-to-display.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/no-data-to-display.js" | ||
sh "curl -# http://code.highcharts.com/modules/offline-exporting.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/offline-exporting.js" | ||
sh "curl -# http://code.highcharts.com/modules/solid-gauge.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/solid-gauge.js" | ||
sh "curl -# http://code.highcharts.com/modules/treemap.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/modules/treemap.js" | ||
|
||
sh "curl -# http://code.highcharts.com/adapters/mootools-adapter.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/adapters/mootools-adapter.js" | ||
sh "curl -# http://code.highcharts.com/adapters/prototype-adapter.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/adapters/prototype-adapter.js" | ||
sh "mkdir -p #{path}/view/adapters/js/highcharts_js/stock/modules/" | ||
sh "mkdir -p #{path}/view/adapters/js/highcharts_js/stock/adapters/" | ||
|
||
sh "curl -# http://code.highcharts.com/stock/highstock.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/highstock.js" | ||
sh "curl -# http://code.highcharts.com/stock/highcharts-more.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/stock/highcharts-more.js" | ||
sh "curl -# http://code.highcharts.com/stock/modules/exporting.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/stock/modules/exporting.js" | ||
sh "curl -# http://code.highcharts.com/stock/modules/funnel.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/stock/modules/funnel.js" | ||
sh "curl -# http://code.highcharts.com/stock/adapters/mootools-adapter.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/stock/adapters/mootools-adapter.js" | ||
sh "curl -# http://code.highcharts.com/stock/adapters/prototype-adapter.js -L --compressed -o #{path}/view/adapters/js/highcharts_js/stock/adapters/prototype-adapter.js" | ||
end | ||
|
||
opts.on('-h', '--help', 'Displays Help') do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How it will handle if invalid option is given? |
||
puts opts | ||
exit | ||
end | ||
end | ||
|
||
parser.parse! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
describe Daru::View, "Update JS files" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the tab indent to 2 spaces. 😄 |
||
context "command usage" do | ||
it "shows the command usage description" do | ||
flag = system('daru-view -h') | ||
expect(flag).to eq(true) | ||
end | ||
end | ||
|
||
context "googlecharts" do | ||
it "updates google charts javascript dependent files" do | ||
flag = system('daru-view -g') | ||
expect(flag).to eq(true) | ||
end | ||
end | ||
|
||
context "highcharts" do | ||
it "updates high charts javascript dependent files" do | ||
flag = system('daru-view -H') | ||
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.
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.