-
Notifications
You must be signed in to change notification settings - Fork 16
/
Rakefile
58 lines (52 loc) · 1.94 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
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'zip'
require 'pathname'
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
ENV['gem_push'] = 'off'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'src'
t.test_files = FileList['test/**/*_test.rb']
end
desc 'Builds a SketchUp Extension package (.rbz)'
task :build_rbz do
# Get the version
project_name = 'ae_console'
load(File.expand_path("../src/#{project_name}/version.rb", __FILE__))
version = AE::ConsolePlugin::VERSION
# Configuration
files_to_exclude = %w{
ae_console/images/icon_54.png
ae_console/images/icon_60.png
ae_console/images/icon_64.png
ae_console/images/icon_128.png
ae_console/images/icon.draft.svg
ae_console/images/redo.png
ae_console/images/redo.svg
ae_console/images/icon_alternative.draft.svg
ae_console/external/ace/worker-xquery.js
ae_console/external/bootstrap/css/theme.css.map
ae_console/external/bootstrap/css/bootstrap-theme.css.map
}
# Compressing
create_zip_archive("#{project_name}_#{version}.rbz", 'src', include: '**/*', exclude: files_to_exclude)
end
def create_zip_archive(zip_filename, root_dir, include: [], exclude: [])
root_dir = File.expand_path(root_dir)
files_to_include = Dir.glob(File.expand_path(File.join(root_dir, include)))
files_to_exclude = exclude.map{ |filename|
filename = File.expand_path(File.join(root_dir, filename))
(File.directory?(filename)) ? Dir.glob(filename+'/') : filename
}.flatten
Zip::File.open(zip_filename, Zip::File::CREATE) do |zip_file|
files_to_include.each{ |filename|
unless files_to_exclude.include?(filename)
zipped_filename = Pathname.new(filename).relative_path_from(Pathname.new(root_dir))
zip_file.add(zipped_filename, filename)
end
}
end
end
task :default => :test