forked from bterkuile/dm-paperclip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
107 lines (94 loc) · 3.04 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
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'rubygems/package_task'
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'dm-core'
require 'dm-validations'
require 'dm-paperclip'
desc 'Default: run unit tests.'
task :default => [:clean, :test]
# Test tasks
desc 'Test the DM-Paperclip library.'
Rake::TestTask.new(:test) do |t|
t.libs << 'dm-paperclip'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
# Console
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -r dm-validations -r dm-migrations -r ./lib/dm-paperclip.rb"
end
# Rdoc
desc 'Generate documentation for the paperclip plugin.'
Rake::RDocTask.new(:doc) do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = 'DM-Paperclip'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
# Code coverage
task :coverage do
system("rm -fr coverage")
system("rcov test/test_*.rb")
system("open coverage/index.html")
end
# Clean house
desc 'Clean up files.'
task :clean do |t|
FileUtils.rm_rf "doc"
FileUtils.rm_rf "coverage"
FileUtils.rm_rf "tmp"
FileUtils.rm_rf "pkg"
FileUtils.rm_rf "log"
end
spec = Gem::Specification.new do |s|
s.name = "dm-paperclip"
s.version = Paperclip::VERSION
s.author = "Jonas von Andrian"
s.email = "jvadev@gmail.com"
s.homepage = "https://github.com/johnny/dm-paperclip"
s.platform = Gem::Platform::RUBY
s.summary = "File attachments as attributes for DataMapper, based on the original Paperclip by Jon Yurek at Thoughtbot"
s.files = FileList["README.rdoc",
"LICENSE",
"Rakefile",
"dm-paperclip.gemspec",
"init.rb",
"{lib,tasks,test}/**/*"].to_a
s.require_path = "lib"
s.test_files = FileList["test/**/test_*.rb"].to_a
s.rubyforge_project = "dm-paperclip"
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc"]
s.rdoc_options << '--line-numbers' << '--inline-source'
s.requirements << "ImageMagick"
s.requirements << "dm-core"
s.requirements << "dm-validations"
end
Gem::PackageTask.new(spec) do |pkg|
pkg.need_tar = true
end
desc 'Generate gemspec'
task :gemspec do
File.open("#{spec.name}.gemspec", 'w') { |f| f.puts(spec.to_ruby) }
end
WIN32 = (PLATFORM =~ /win32|cygwin/) rescue nil
SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
desc "Install #{spec.name} #{spec.version}"
task :install => [ :package ] do
sh "#{SUDO} gem install pkg/#{spec.name}-#{spec.version} --no-update-sources", :verbose => false
end
desc "Release new version"
task :release => [:test, :gem] do
require 'rubygems'
require 'rubyforge'
r = RubyForge.new
r.login
r.add_release spec.rubyforge_project,
spec.name,
spec.version,
File.join("pkg", "#{spec.name}-#{spec.version}.gem")
end