-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
94 lines (85 loc) · 2.4 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
require "rubygems"
require "rake"
require "rspec/core/rake_task"
APP_NAME = "ZZZ"
AUTHORS = ["Hexa"]
HOMEPAGE = "http://github.com/Hexa/ZZZ"
SUMMARY = "ZZZ is a liblary for issuing a certificate."
DESCRIPTION = <<-EOF
ZZZ is a liblary for issuing a certificate.
EOF
MAIL = "[email protected]"
LIB = "lib"
LICENSE = "New BSD License"
task :files do
spec_files = FileList["spec/**/*"]
doc_files = FileList["doc/source/**/*", "doc/Makefile"]
lib_files = FileList["lib/**/*"]
rake_files = FileList["Rakefile"]
version_files = FileList["VERSION"]
license_files = FileList["LICENSE"]
readme_files = FileList["README*"]
RDOC_FILES = FileList.new do |f|
[license_files, "README.rdoc"].each do |files|
f.include(files)
end
end
TEST_FILES = spec_files
PKG_FILES = FileList.new do |f|
[spec_files, doc_files, lib_files, rake_files, version_files, license_files, readme_files].each do |files|
f.include(files)
end
end
end
desc "Generate gemspec"
task :gemspec => :files do |e|
PKG_VERSION = File.open("VERSION", "rb") {|file| file.read }.strip!
gemspec = <<-EOF
Gem::Specification.new do |s|
s.name = %q{#{APP_NAME}}
s.summary = %q{#{SUMMARY}}
s.version = %q{#{PKG_VERSION}}
s.homepage = %q{#{HOMEPAGE}}
s.require_path = "#{LIB}"
s.authors = #{AUTHORS.inspect}
s.email = %q{#{MAIL}}
s.files = #{PKG_FILES.inspect}
s.description = %q{#{DESCRIPTION}}
s.test_files = #{TEST_FILES.inspect}
s.rdoc_options << "--charset=UTF-8"
s.extra_rdoc_files = #{RDOC_FILES.inspect}
s.add_development_dependency('rspec')
s.add_development_dependency('simplecov')
s.required_ruby_version = ">= #{RUBY_VERSION}"
s.license = "#{LICENSE}"
end
EOF
File.open("#{APP_NAME}.gemspec", "wb") {|file| file.puts gemspec }
end
PKG = "pkg/"
directory PKG
desc "Generate package"
task :build => :gemspec do
sh "gem build #{APP_NAME}.gemspec"
mkdir PKG unless Dir.exists?(PKG)
mv "#{APP_NAME}-#{PKG_VERSION}.gem", PKG
end
desc "Install package"
task :install => :build do
sh "gem install #{PKG}/#{APP_NAME}-#{PKG_VERSION}.gem"
end
desc "Uninstall package"
task :uninstall do
sh "gem uninstall #{APP_NAME}"
end
#require 'rake/rdoctask'
require 'rdoc/task'
Rake::RDocTask.new(:rdoc) do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README*", "lib/**/*.rb")
rd.options << "-c UTF-8"
end
desc "run spec"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./spec/**/*_spec.rb"
end