Skip to content

Commit

Permalink
Add tasks for updating main lib and mousetrap plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kugaevsky committed Nov 25, 2013
1 parent b9bc8df commit 8a6856c
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions Rakefile
Expand Up @@ -4,14 +4,43 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec

ORIGIN_URL = "https://raw.github.com/ccampbell/mousetrap/master"
BASE_FILE_PATH = "vendor/assets/javascripts"

namespace :mousetrap do
desc "Update Mousetrap javascript library from https://raw.github.com/ccampbell/mousetrap/master/mousetrap.js"
desc "Update main mousetrap javascript lib and its plugins"
task :update do
ORIGIN_URL = "https://raw.github.com/ccampbell/mousetrap/master/mousetrap.js"
FILE_PATH = "vendor/assets/javascripts/mousetrap.js"
puts "Updating Mousetrap.js library from origin"
puts "#{ORIGIN_URL} -> #{FILE_PATH}\n\n"
system 'wget', ORIGIN_URL, "-O", FILE_PATH
puts "Mousetrap.js updated!"
%w(main plugins).each do |task|
Rake::Task["mousetrap:update:#{task}"].invoke
end
end

namespace :update do
desc "Update main mousetrap javascript lib"
task :main do
origin_url = "#{ORIGIN_URL}/mousetrap.js"
file_path = "#{BASE_FILE_PATH}/mousetrap.js"
download origin_url, file_path
puts "\033[32m-> Main mousetrap lib updated!\033[0m\n\n"
end

desc "Update mousetrap javascript lib plugins"
task :plugins do
plugins = { dictionary: 'plugins/bind-dictionary/mousetrap-bind-dictionary.js',
global: 'plugins/global-bind/mousetrap-global-bind.js',
pause: 'plugins/pause/mousetrap-pause.js',
record: 'plugins/record/mousetrap-record.js'
}
plugins.each_pair do |name, file|
origin_url = "#{ORIGIN_URL}/#{file}"
file_path = "#{BASE_FILE_PATH}/mousetrap/#{name}.js"
download origin_url, file_path
puts "\033[32m-> #{name} mousetrap plugin updated!\033[0m\n\n"
end
end
end
end

def download(source, dest)
system 'wget', source, "-O", dest
end

0 comments on commit 8a6856c

Please sign in to comment.