Sha256: 42e52d314df116328c08e6892669a19e54ec8fd70a6e6a39bf386bc14d0616bd

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'bundler/gem_tasks'
require 'fileutils'

desc 'Update the perfect-scrollbar Javascript and CSS files'
task :update do
  def working_dir
    'tmp'
  end

  def ensure_working_dir_exists!
    FileUtils.mkdir_p(working_dir)
  end

  def zip_path
    File.join(working_dir, 'perfect-scrollbar.zip')
  end

  def download(version)
    base_url = 'https://github.com/noraesae/perfect-scrollbar/releases/download'
    final_url = "#{base_url}/#{version}/perfect-scrollbar.zip"
    puts "Downlading perfect-scrollbar #{version} ..."
    `curl -Lfo #{zip_path} #{final_url}`
  end

  def extract
    puts "Extracting perfect-scrollbar archive ..."
    `unzip -d #{working_dir} #{zip_path}`
  end

  def move_files
    puts "Installating assets files ..."
    `mv #{working_dir}/js/perfect-scrollbar.jquery.js \
        vendor/assets/javascripts/perfect-scrollbar.js`
    `mv #{working_dir}/css/perfect-scrollbar.css vendor/assets/stylesheets`
  end

  def clean
    `rm -rf #{working_dir}`
  end

  FileUtils.mkdir_p('vendor/assets/javascripts')
  FileUtils.mkdir_p('vendor/assets/stylesheets')
  ensure_working_dir_exists!
  download(PerfectScrollbar::Rails::VERSION)
  extract
  move_files
  clean

  puts "\e[32mDone!\e[0m"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
perfect-scrollbar-rails-0.6.11 Rakefile
perfect-scrollbar-rails-0.6.10 Rakefile
perfect-scrollbar-rails-0.6.9 Rakefile
perfect-scrollbar-rails-0.6.8.1 Rakefile