-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
107 lines (81 loc) · 2.26 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env rake
require 'filegen'
require 'fedux_org/stdlib/rake'
require 'active_support/core_ext/string/inflections'
require 'open3'
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
def software
gemspec.name
end
def gemspec
eval File.read(Dir.glob(File.join(File.expand_path('../', __FILE__), '*.gemspec')).first)
end
def version
require "#{software}/version"
"#{software.camelcase}::VERSION".constantize
end
def root_directory
::File.expand_path('../', __FILE__)
end
def tar_file
::File.join(pkg_directory, "#{software}-#{version}.tar.gz")
end
def tmp_directory
::File.join(root_directory, 'tmp', "#{software}-#{version}")
end
def archlinux_build_directory
::File.join(root_directory, 'share', 'archlinux')
end
def gem_file
::File.join(root_directory, 'pkg', "#{software}-#{version}.gem")
end
def pkg_directory
::File.join(root_directory, 'pkg')
end
def gem_directory
::File.join(root_directory, 'vendor', 'cache')
end
task :default => 'gem:build'
file gem_file => 'gem:build'
file tmp_directory do
FileUtils.mkdir_p tmp_directory
end
file archlinux_build_directory do
FileUtils.mkdir_p archlinux_build_directory
end
def extract_sha
%x[makepkg -g 2>/dev/null].split(/\n/).find { |l| l =~ /sha256/ }
end
namespace :package do
desc 'build arch linux package'
task :archlinux => [gem_file, archlinux_build_directory] do
#FileUtils.mv ::File.join(pkg_directory, "#{software}-#{version}.gem"), archlinux_build_directory
generator = Filegen::Rubygen.new
template = File.read(File.expand_path('../share/archlinux/PKGBUILD.sh.erb', __FILE__))
build_file = File.expand_path('../share/archlinux/PKGBUILD', __FILE__)
data = {
sha: nil,
version: version,
}
Dir.chdir(archlinux_build_directory) do
File.open(build_file, 'w') do |f|
f.write generator.run(template, data )
end
data = {
sha: extract_sha,
version: version,
}
File.open(build_file, 'w') do |f|
f.write generator.run(template, data)
end
sh "makepkg -f"
end
end
end
require 'coveralls/rake/task'
Coveralls::RakeTask.new
namespace :test do
desc 'Test with coveralls'
task :coveralls => ['test:rspec', 'test:cucumber', 'coveralls:push']
end