Sha256: e2610e0deb6cb5c848b84ef6cb972b1cf6a98bd727fc16e96209a6c679df41f5

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

require 'open-uri'

module SprocketsZeptojs
  class Updater
    FILES = %w[ajax assets data detect event form fx fx_methods gesture polyfill selector stack touch zepto]
    ASSET_PATH = File.expand_path("../../../vendor/assets/javascripts/zepto/", __FILE__)

    def initialize(version, repo = "madrobby/zepto")
      @repo    = repo
      @version = version
    end

    def update
      FILES.each do |file|
        update_file(file)
      end
    end

    private

    def update_file(file_name)
      source = open(remote_file_name(file_name))
      File.open(local_file_name(file_name), 'w') do |target|
        puts "#{file_name} -> #{local_file_name(file_name)}"
        target.puts(source.read)
      end
    end

    def remote_file_name(file_name)
      "https://raw.github.com/#{@repo}/#{@version}/src/#{file_name}.js"
    end

    def local_file_name(file_name)
      File.join(ASSET_PATH, "#{file_name}.js")
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sprockets_zeptojs-0.0.2 lib/sprockets_zeptojs/updater.rb
sprockets_zeptojs-0.0.1 lib/sprockets_zeptojs/updater.rb