-
Notifications
You must be signed in to change notification settings - Fork 44
/
Rakefile
59 lines (48 loc) · 1.43 KB
/
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# encoding: UTF-8
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
# For checking remote fancybox version.
require 'nokogiri'
require 'open-uri'
# Path to atom feed with fancybox updates.
$fancybox_feed = "http://code.google.com/feeds/p/fancybox/downloads/basic"
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :default => :test
namespace :fancybox do
desc "Get the local and remote fancybox versions."
task :version do
local = local_version
remote = remote_version
puts "local: v#{local}"
puts "remote: v#{remote}"
if local != remote
warn "\nthere is a newer remote version available"
end
end
end
# Get the current local version of the vendored fancybox library.
#
# Returns the String representing the local version.
def local_version
`grep ' * Version' vendor/assets/javascripts/jquery.fancybox.js | \
cut -d ' ' -f 4`.chomp
end
# Get the current version of the remote version of the library. Uses
# nokogiri and open-uri to grab the atom feed from google code, then
# parses the version out of the title.
#
# Returns the String representing the remote version.
def remote_version
doc = Nokogiri::HTML(open($fancybox_feed))
doc.css('entry:first title').text.match(/\d\.\d\.\d/)[0]
end