File: Rakefile.rb

package info (click to toggle)
ruby-bluefeather 0.41-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 736 kB
  • sloc: ruby: 4,195; makefile: 9
file content (203 lines) | stat: -rw-r--r-- 4,822 bytes parent folder | download | duplicates (5)
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# encoding: us-ascii
#-----------------------------------------------------------
# BlueFeather rakefile
#
# Requirement:
#   Ruby (1.8.1 later)
#   Rake - <http://rake.rubyforge.org/> or `gem install rake` with RubyGems
#   Exerb - <http://exerb.sourceforge.jp/>
#   Info-Zip - If you use Windows, you can get it from GnuWin32
#                                  <http://gnuwin32.sourceforge.net/>
#   Rspec - `gem install rspec` with RubyGems
#-----------------------------------------------------------

require 'rake/testtask'
require 'rubygems/package_task'
require 'rake/clean'


# Adaptable to both RSpec 1 and 2
rspec_version = nil
begin
	# for RSpec 2
	require 'rspec/core/rake_task'
	rspec_version = 2
rescue LoadError
	begin
		# for RSpec 1
		require 'spec/rake/spectask'
		rspec_version = 1
	rescue LoadError
		puts "RSpec is not available."
	end
end


$KCODE = 'u' unless defined?(Encoding)
$LOAD_PATH.unshift './lib'
require 'bluefeather'

ZIP_NAME = "pkg/bluefeather-#{BlueFeather::VERSION}.zip"

CLOBBER.include 'sample/*.html'
CLOBBER.include 'doc/**/*.html'

# setup.rb
CLEAN.include('InstalledFiles', '.config', 'bin/bluefeather.bat')

PACKAGED = FileList.new
PACKAGED.include('readme*.txt')
PACKAGED.include('setup.rb')
PACKAGED.include('Rakefile.rb')
PACKAGED.include('bin/**/*')
PACKAGED.include('lib/bluefeather.rb')
PACKAGED.include('lib/bluefeather/*.rb')
PACKAGED.include('license/**/*')
PACKAGED.include('spec/**/*')
PACKAGED.include('original-tests/**/*')
PACKAGED.include('doc/**/*.*')
PACKAGED.exclude('doc/**/format-extension-spec.*')



task :default => :package

desc 'Package to zip.'
task :package => [:doc, ZIP_NAME]

desc 'Clobber and package.'
task :repackage => [:clobber, :package]

file ZIP_NAME => PACKAGED do |task|
	mkpath 'pkg'
	src_list = task.prerequisites.map{|x| %Q|"#{x}"|}.join(' ')
	sh "zip -q #{task.name} #{src_list}"
	puts "#{task.name} maked. (#{File.size(task.name) / 1024} KB)"
end




DOCS = []
Dir.glob('doc/**/*.bfdoc').each do |src|
	dest = src.sub(/\.bfdoc$/, '.html')
	DOCS << dest

	file dest => src do
		html = BlueFeather.parse_document_file(src)
		open(dest, 'w'){|f| f.write(html)}
		puts "#{src} => #{dest}"
	end
end

desc 'Convert documents, bfdoc -> html'
task :doc => DOCS

task :sample => 'sample/sample.html'

file 'sample/sample.html' => 'sample/sample.bfdoc' do |task|
	html = BlueFeather.parse_document_file(task.prerequisites.first)
	open(task.name, 'w'){|f| f.write(html)}
	puts "#{task.prerequisites.first} => #{task.name}"
end




GEM_PACKAGED = PACKAGED.dup
GEM_PACKAGED.exclude('setup.rb')

spec = Gem::Specification.new do |s|
	s.platform = Gem::Platform::RUBY
	s.summary = "Extend Markdown Converter"
	s.author = 'Dice'
	s.email = 'tetradice@gmail.com'
	s.homepage = 'http://ruby.morphball.net/bluefeather/'
	s.name = 'bluefeather'
	s.rubyforge_project = 'bluefeather'
	s.has_rdoc = false
	s.required_ruby_version = '>= 1.8.1'
	s.version = BlueFeather::VERSION
	s.files = GEM_PACKAGED
	s.executables = ['bluefeather']
	s.description = <<EOF
 BlueFeather is software for converting text written by extended Markdown to
html. It is pair of command-line tool and pure Ruby library.
EOF
end

Gem::PackageTask.new(spec) do |pkg|
end






desc 'Run tests of original BlueCloth.'
Rake::TestTask.new('original-test') do |tasklib|
	tasklib.test_files = FileList['original-tests/*.tests.rb']
end


if rspec_version then
	case rspec_version
	when 1
		task_cls = Spec::Rake::SpecTask
		rspec_opts_setting_proc = proc do |task|
			task.spec_opts << '-fs'
		end
	when 2
		task_cls = RSpec::Core::RakeTask
		rspec_opts_setting_proc = proc do |task|
			task.rspec_opts = ['-fs']
		end
	else
		raise 'unknown rspec version.'
	end
	
	# Proc for initializing each spec-tasks by common parameters
	setting = proc do |st|
		st.ruby_opts = %w(-Ku)
	end
	
	
	desc "Verify all spec files."
	task_cls.new do |st|
		setting.call(st)
		st.pattern = 'spec/*.rb'
	end
	
	desc "Verify all spec files with specdocs."
	task_cls.new(:specd) do |st|
		setting.call(st)
		rspec_opts_setting_proc.call(st)
		st.pattern = 'spec/*.rb'
	end
	
	
	
	namespace :spec do
		Dir.glob('spec/*.rb') do |path|
			desc "Verify '#{path}'"
			task_cls.new(File.basename(path, '.rb')) do |st|
				setting.call(st)
				st.pattern = path
			end
		end
	end
	
	namespace :specd do
		Dir.glob('spec/*.rb') do |path|
			desc "Verify '#{path}' with specdocs."
			task_cls.new(File.basename(path, '.rb')) do |st|
				setting.call(st)
				rspec_opts_setting_proc.call(st)
				st.pattern = path
			end
		end
	end
	
	desc '= spec + original-test'
	task 'test-all' => [:spec, 'original-test']
end