Sha256: 2425aab99357d6acd07ca515b2ee7c1685d054a524a8238f0cec98deaac83370
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 KB
Contents
#!/usr/bin/env rake require "bundler/gem_tasks" desc "Update assets from Fotorama repo" task :update do require "json" require "httpclient" def github_tags(repo) http = HTTPClient.new body = http.get("https://api.github.com/repos/#{repo}/tags").body response = JSON.parse(body) response.map { |tag| Gem::Version.new(tag['name']) }.sort end def get(url, to) to.open('w') do |io| http = HTTPClient.new http.transparent_gzip_decompression = true io << http.get(url).body end end def asset(file) assets = Pathname(__FILE__).dirname.join('vendor/assets') if file.end_with? '.css' or file.end_with? '.scss' assets.join('stylesheets', file) elsif file.end_with? '.js' assets.join('javascripts', file) else assets.join('images', file) end end def fetch(tag) cdn = "http://fotorama.s3.amazonaws.com/#{tag}" %w(fotorama.js fotorama.css fotorama.png fotorama@2x.png).each do |file| from = "#{cdn}/#{file}".sub(/(.css|.js)$/, '.uncompressed\\1') get from, asset(file) end end def convert css = asset('fotorama.css') scss = asset('fotorama.css.scss') scss.open('w') do |io| io << css.read.gsub(/url\(/, 'image-url(') end css.delete end def update_version(tag) version_file = Pathname(__FILE__).dirname.join('lib/fotoramajs/version.rb') version_file.open('w') do |io| io << "module Fotoramajs\n VERSION = \"#{tag}\"\nend\n" end end puts "Fetching tags" tag = github_tags('artpolikarpov/fotorama').last puts "Load Fotorama #{tag}" fetch(tag) puts "Convert CSS to SCSS" convert puts "Update gem version" update_version(tag) puts "Done" end desc 'Delete all generated files' task :clobber do rm_r 'pkg' rescue nil end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fotoramajs-4.4.1 | Rakefile |
fotoramajs-4.3.4.1 | Rakefile |
fotoramajs-4.3.3 | Rakefile |