6 if not $EMACS or $EMACS == 't'
11 File.read("yasnippet.el", :encoding => "UTF-8") =~ /;; Package-version: *([0-9.]+?) *$/
15 FileUtils.mkdir_p('pkg')
17 desc "run tests in batch mode"
19 sh "#{$EMACS} -Q -L . -l yasnippet-tests.el" +
20 " --batch -f ert-run-tests-batch-and-exit"
23 desc "create a release package"
25 release_dir = "pkg/yasnippet-#{$version}"
26 FileUtils.mkdir_p(release_dir)
27 files = ['snippets', 'yasnippet.el']
28 FileUtils.cp_r files, release_dir
29 File.open(File.join(release_dir,'yasnippet-pkg.el'), 'w') do |file|
31 (define-package "yasnippet"
33 "A template system for Emacs")
36 sh "git clean -f snippets"
38 sh "tar cf yasnippet-#{$version}.tar yasnippet-#{$version}"
42 desc "create a release package and upload it to google code"
43 task :release => [:package, 'doc:archive'] do
44 raise "Not implemented for github yet!"
47 desc "Generate document"
48 task :doc, [:htmlize] do |t, args|
51 load_path += " -L #{args[:htmlize]}"
53 sh "#{$EMACS} -Q #{load_path} --batch -l doc/yas-doc-helper.el" +
54 " -f yas--generate-html-batch"
59 release_dir = "pkg/yasnippet-#{$version}"
60 FileUtils.mkdir_p(release_dir)
61 sh "tar cjf pkg/yasnippet-doc-#{$version}.tar.bz2 " +
62 "--exclude=doc/.svn --exclude=doc/images/.svn doc/*.html doc/images"
66 if File.exists? 'doc/gh-pages'
67 Dir.chdir 'doc/gh-pages' do
68 sh "git checkout gh-pages"
70 Dir.glob("doc/*.{html,css}").each do |file|
71 FileUtils.cp file, 'doc/gh-pages'
73 Dir.glob("doc/images/*").each do |file|
74 FileUtils.cp file, 'doc/gh-pages/images'
76 Dir.glob("doc/stylesheets/*.css").each do |file|
77 FileUtils.cp file, 'doc/gh-pages/stylesheets'
79 curRev = `git rev-parse --verify HEAD`.chomp()
80 expRev = IO.read('doc/html-revision').chomp()
82 raise ("The HTML rev: #{expRev},\n" +
83 "current rev: #{curRev}!\n")
85 if !system "git diff-index --quiet HEAD"
86 system "git status --untracked-files=no"
87 raise "You have uncommitted changes!"
89 Dir.chdir 'doc/gh-pages' do
90 sh "git commit -a -m 'Automatic documentation update.\n\n" +
91 "From #{curRev.chomp()}'"
98 desc "Compile yasnippet.el into yasnippet.elc"
100 rule '.elc' => '.el' do |t|
101 sh "#{$EMACS} --batch -L . --eval \"(setq byte-compile-error-on-warn t)\"" +
102 " -f batch-byte-compile #{t.source}"
104 task :compile => FileList["yasnippet.el"].ext('elc')
106 task :default => :doc
108 desc "use yasmate to convert textmate bundles"
109 task :convert_bundles do
111 sh "rake convert_bundles"