forked from calebhearth/autosize-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
24 lines (21 loc) · 964 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "bundler/gem_tasks"
task :update do
require 'net/http'
require 'json'
tags_url = 'https://api.github.com/repos/jackmoore/autosize/tags'
tags = JSON.parse(Net::HTTP.get(URI(tags_url)))
latest_tag = tags.first
if latest_tag['name'] > Autosize::Rails::VERSION
upstream_location = "/jackmoore/autosize/#{latest_tag['commit']['sha']}/jquery.autosize.js"
file_location = File.join(File.dirname(File.absolute_path(__FILE__)), 'vendor', 'assets', 'javascripts', 'jquery.autosize.js')
puts "Downloading new version (#{latest_tag['name']}):"
puts upstream_location
Net::HTTP.start('raw2.github.com', use_ssl: true) do |http|
resp = http.get(upstream_location)
File.open(file_location, 'w') { |file| file.write(resp.body) }
end
puts "Please bump the version.rv, commit and open a pull request with the new version. (#{latest_tag['name']})"
else
puts "Already up to date. (#{latest_tag['name']})"
end
end