1 # Coquelicot: "one-click" file sharing with a focus on users' privacy.
2 # Copyright © 2010-2013 potager.org <jardiniers@potager.org>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as
6 # published by the Free Software Foundation, either version 3 of the
7 # License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Bundler.require(:default, :development)
22 require 'bundler/gem_tasks'
23 require 'gettext/tools/task'
24 require 'haml/magic_translations/xgettext/haml_parser'
25 require 'cucumber/rake/task'
26 require 'rspec/core/rake_task'
28 GetText::Tools::XGetText.add_parser(Haml::MagicTranslations::XGetText::HamlParser)
29 GetText::Tools::Task.define do |task|
30 task.spec = Gem::Specification.load('coquelicot.gemspec')
31 task.files = Dir.glob('views/**/*.{rb,haml}') + Dir.glob('lib/coquelicot/**/*.rb')
32 task.xgettext_options = ['--msgid-bugs-address=Coquelicot developers <coquelicot@potager.org>',
33 '--add-comments=TRANSLATORS']
36 task :create_archive do
37 spec = Gem::Specification.load('coquelicot.gemspec')
39 filename = "coquelicot-#{spec.version}.tar.gz"
41 File.open(filename, 'wb') do |archive|
42 Zlib::GzipWriter.wrap(archive) do |gzipped|
43 Gem::Package::TarWriter.new(gzipped) do |writer|
44 spec.files.each do |file|
45 next if File.directory? file
46 stat = File.stat(file)
47 mode = stat.mode & 0777
50 name, prefix = writer.split_name(file)
51 header = Gem::Package::TarHeader.new(:name => name, :mode => mode,
52 :size => size, :prefix => prefix,
55 gzipped.write(open(file, 'rb') { |f| f.read })
56 remainder = (512 - (size % 512)) % 512
57 gzipped.write("\0" * remainder)
59 # Add empty directories where there is place holders
60 Dir.glob('**/.placeholder') do |placeholder|
61 dir = File.dirname(placeholder)
62 name, prefix = writer.split_name(dir)
63 mtime = File.stat(dir).mtime
64 header = Gem::Package::TarHeader.new :name => name, :mode => 0700,
65 :typeflag => "5", :size => 0,
66 :prefix => prefix, :mtime => mtime
74 Cucumber::Rake::Task.new(:features) do |t|
75 t.cucumber_opts = "features --format pretty"
78 RSpec::Core::RakeTask.new(:spec)
80 task :test => [:spec, :features]