/
Rakefile.rb
142 lines (122 loc) · 4.18 KB
/
Rakefile.rb
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
require 'jello'
require 'fileutils'
# =======================
# = Gem packaging tasks =
# =======================
begin
require 'echoe'
task :package => :'package:package'
task :install => :'package:install'
task :manifest => :'package:manifest'
namespace :package do
Echoe.new('jello', Jello::Version) do |g|
g.project = 'jello'
g.author = ['elliottcable']
g.email = ['Jello@elliottcable.com']
g.summary = 'A library to watch the OS X pasteboard, and process/modify incoming pastes.'
g.url = 'http://github.com/elliottcable/jello'
g.development_dependencies = ['echoe >= 3.0.2', 'rspec', 'rcov', 'yard', 'stringray']
g.manifest_name = '.manifest'
g.retain_gemspec = true
g.rakefile_name = 'Rakefile.rb'
g.ignore_pattern = /^\.git\/|^meta\/|\.gemspec/
end
desc 'tests packaged files to ensure they are all present'
task :verify => :package do
# An error message will be displayed if files are missing
if system %(ruby -e "require 'rubygems'; require 'pkg/jello-#{Jello::Version}/lib/jello'")
puts "\nThe library files are present"
end
end
end
rescue LoadError
desc 'You need the `echoe` gem to package Jello'
task :package
end
begin
require 'launchdr/task'
LaunchDr::Task.new :launchd, :bin => 'jello', :arguments => ['grabup', 'shortener']
rescue LoadError
desc 'You need the `elliottcable-launchdr` gem to generate a launchd property list'
task :launchd
end
# =======================
# = Spec/Coverage tasks =
# =======================
begin
require 'spec'
require 'rcov'
require 'spec/rake/spectask'
task :default => :'coverage:run'
task :coverage => :'coverage:run'
namespace :coverage do
Spec::Rake::SpecTask.new(:run) do |t|
t.spec_opts = ["--format", "specdoc"]
t.spec_opts << "--colour" unless ENV['CI']
t.spec_files = Dir['spec/**/*_spec.rb'].sort
t.libs = ['lib']
t.rcov = true
t.rcov_opts = [ '--include-file', '"^lib"', '--exclude-only', '".*"']
t.rcov_dir = File.join('meta', 'coverage')
end
begin
require 'spec/rake/verify_rcov'
# For the moment, this is the only way I know of to fix RCov. I may
# release the fix as it's own gem at some point in the near future.
require 'stringray/core_ext/spec/rake/verify_rcov'
RCov::VerifyTask.new(:verify) do |t|
t.threshold = 50.0
t.index_html = File.join('meta', 'coverage', 'index.html')
t.require_exact_threshold = false
end
rescue LoadError
desc 'You need the `stringray` gem to verify coverage'
task :verify
end
task :open do
system 'open ' + File.join('meta', 'coverage', 'index.html') if PLATFORM['darwin']
end
end
rescue LoadError
desc 'You need the `rcov` and `rspec` gems to run specs/coverage'
task :coverage
end
# =======================
# = Documentation tasks =
# =======================
begin
require 'yard'
require 'yard/rake/yardoc_task'
task :documentation => :'documentation:generate'
namespace :documentation do
YARD::Rake::YardocTask.new :generate do |t|
t.files = ['lib/**/*.rb']
t.options = ['--output-dir', File.join('meta', 'documentation'),
'--readme', 'README.markdown']
end
YARD::Rake::YardocTask.new :dotyardoc do |t|
t.files = ['lib/**/*.rb']
t.options = ['--no-output',
'--readme', 'README.markdown']
end
task :open do
system 'open ' + File.join('meta', 'documentation', 'index.html') if PLATFORM['darwin']
end
end
rescue LoadError
desc 'You need the `yard` gem to generate documentation'
task :documentation
end
# =========
# = Other =
# =========
desc 'Removes all meta producs'
task :clobber do
`rm -rf #{File.expand_path(File.join( File.dirname(__FILE__), 'meta' ))}`
end
desc 'Check everything over before commiting'
task :aok => [:'documentation:generate', :'documentation:open',
:'package:manifest', :'package:package',
:'coverage:run', :'coverage:verify', :'coverage:open']
task :ci => [:'documentation:generate', :'coverage:run', :'coverage:verify']