Skip to content
Newer
Older
100644 159 lines (135 sloc) 4.1 KB
03cb12a @mojombo convert to use rakegem
mojombo authored
1 require 'rubygems'
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
2 require 'rake'
03cb12a @mojombo convert to use rakegem
mojombo authored
3 require 'date'
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
4
03cb12a @mojombo convert to use rakegem
mojombo authored
5 #############################################################################
6 #
7 # Helper functions
8 #
9 #############################################################################
10
11 def name
12 @name ||= Dir['*.gemspec'].first.split('.').first
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
13 end
14
03cb12a @mojombo convert to use rakegem
mojombo authored
15 def version
16 line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17 line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
18 end
19
03cb12a @mojombo convert to use rakegem
mojombo authored
20 def date
21 Date.today.to_s
a426eb3 @JackDanger Getting the Rakefile configured to make this a working gem
JackDanger authored
22 end
d189e05 @mojombo first commit
mojombo authored
23
03cb12a @mojombo convert to use rakegem
mojombo authored
24 def rubyforge_project
25 name
26 end
27
28 def gemspec_file
29 "#{name}.gemspec"
30 end
31
32 def gem_file
33 "#{name}-#{version}.gem"
34 end
35
36 def replace_header(head, header_name)
37 head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
38 end
39
03cb12a @mojombo convert to use rakegem
mojombo authored
40 #############################################################################
41 #
42 # Standard tasks
43 #
44 #############################################################################
45
3c0bc3b @qrush Added features to default rake task, and post data feature all green
qrush authored
46 task :default => [:test, :features]
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
47
03cb12a @mojombo convert to use rakegem
mojombo authored
48 require 'rake/testtask'
49 Rake::TestTask.new(:test) do |test|
50 test.libs << 'lib' << 'test'
51 test.pattern = 'test/**/test_*.rb'
52 test.verbose = true
53 end
54
55 desc "Generate RCov test coverage and open in your browser"
56 task :coverage do
57 require 'rcov'
58 sh "rm -fr coverage"
59 sh "rcov test/test_*.rb"
60 sh "open coverage/index.html"
61 end
62
63 require 'rake/rdoctask'
64 Rake::RDocTask.new do |rdoc|
65 rdoc.rdoc_dir = 'rdoc'
66 rdoc.title = "#{name} #{version}"
67 rdoc.rdoc_files.include('README*')
68 rdoc.rdoc_files.include('lib/**/*.rb')
69 end
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
70
7dfe32a @mojombo read layout files into hash
mojombo authored
71 desc "Open an irb session preloaded with this library"
72 task :console do
03cb12a @mojombo convert to use rakegem
mojombo authored
73 sh "irb -rubygems -r ./lib/#{name}.rb"
a426eb3 @JackDanger Getting the Rakefile configured to make this a working gem
JackDanger authored
74 end
08bf7b1 Added a getto task to perform export from mephisto... this needs to b…
Chris Van Pelt authored
75
03cb12a @mojombo convert to use rakegem
mojombo authored
76 #############################################################################
77 #
78 # Custom tasks (add your own tasks here)
79 #
80 #############################################################################
2b820ae @mojombo switch to Jeweler for packaging
mojombo authored
81
03cb12a @mojombo convert to use rakegem
mojombo authored
82 namespace :migrate do
08bf7b1 Added a getto task to perform export from mephisto... this needs to b…
Chris Van Pelt authored
83 desc "Migrate from mephisto in the current directory"
84 task :mephisto do
03cb12a @mojombo convert to use rakegem
mojombo authored
85 sh %q(ruby -r './lib/jekyll/migrators/mephisto' -e 'Jekyll::Mephisto.postgres(:database => "#{ENV["DB"]}")')
08bf7b1 Added a getto task to perform export from mephisto... this needs to b…
Chris Van Pelt authored
86 end
4770882 @codeslinger added typo to manifest and Rakefile
codeslinger authored
87 desc "Migrate from Movable Type in the current directory"
8477cb5 @ngerakines Adding Movable Type migration library to lib/jekyll/converters/.
ngerakines authored
88 task :mt do
03cb12a @mojombo convert to use rakegem
mojombo authored
89 sh %q(ruby -r './lib/jekyll/migrators/mt' -e 'Jekyll::MT.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
8477cb5 @ngerakines Adding Movable Type migration library to lib/jekyll/converters/.
ngerakines authored
90 end
4770882 @codeslinger added typo to manifest and Rakefile
codeslinger authored
91 desc "Migrate from Typo in the current directory"
92 task :typo do
03cb12a @mojombo convert to use rakegem
mojombo authored
93 sh %q(ruby -r './lib/jekyll/migrators/typo' -e 'Jekyll::Typo.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
4770882 @codeslinger added typo to manifest and Rakefile
codeslinger authored
94 end
08bf7b1 Added a getto task to perform export from mephisto... this needs to b…
Chris Van Pelt authored
95 end
778894d @qrush Adding rake task for features, removing pipe for filters and starting…
qrush authored
96
97 begin
98 require 'cucumber/rake/task'
99 Cucumber::Rake::Task.new(:features) do |t|
921aee2 @qrush Removing topics for good
qrush authored
100 t.cucumber_opts = "--format progress"
778894d @qrush Adding rake task for features, removing pipe for filters and starting…
qrush authored
101 end
102 rescue LoadError
103 desc 'Cucumber rake task not available'
104 task :features do
105 abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
106 end
107 end
03cb12a @mojombo convert to use rakegem
mojombo authored
108
109 #############################################################################
110 #
111 # Packaging tasks
112 #
113 #############################################################################
114
115 task :release => :build do
116 unless `git branch` =~ /^\* master$/
117 puts "You must be on the master branch to release!"
118 exit!
119 end
120 sh "git commit --allow-empty -a -m 'Release #{version}'"
121 sh "git tag v#{version}"
122 sh "git push origin master"
123 sh "git push v#{version}"
124 sh "gem push pkg/#{name}-#{version}.gem"
125 end
126
127 task :build => :gemspec do
128 sh "mkdir -p pkg"
129 sh "gem build #{gemspec_file}"
130 sh "mv #{gem_file} pkg"
131 end
132
133 task :gemspec do
134 # read spec file and split out manifest section
135 spec = File.read(gemspec_file)
136 head, manifest, tail = spec.split(" # = MANIFEST =\n")
137
138 # replace name version and date
139 replace_header(head, :name)
140 replace_header(head, :version)
141 replace_header(head, :date)
142 #comment this out if your rubyforge_project has a different name
143 replace_header(head, :rubyforge_project)
144
145 # determine file list from git ls-files
146 files = `git ls-files`.
147 split("\n").
148 sort.
149 reject { |file| file =~ /^\./ }.
150 reject { |file| file =~ /^(rdoc|pkg|coverage)/ }.
151 map { |file| " #{file}" }.
152 join("\n")
153
154 # piece file back together and write
155 manifest = " s.files = %w[\n#{files}\n ]\n"
156 spec = [head, manifest, tail].join(" # = MANIFEST =\n")
157 File.open(gemspec_file, 'w') { |io| io.write(spec) }
158 puts "Updated #{gemspec_file}"
159 end
Something went wrong with that request. Please try again.