Sha256: b694a847363599a64eeb41f2368afb17e283cf17f7a330d734b8e995672c704b

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

namespace :custom do
	task :generate, [:file] do |t, args|
		generate = lambda do |source, destination|
			Glyph.info "Generating #{destination}..."
			Glyph.compile Glyph::PROJECT/"text/#{source}.glyph", Glyph::PROJECT/"../#{destination}.textile"
		end
		files = {
			:AUTHORS => :acknowledgements, 
			:CHANGELOG => :changelog, 
			:LICENSE => :license, 
			:README => :introduction
		}
		arg = args[:file].upcase.to_sym
		raise RuntimeError, "Unknown file '#{arg}.glyph'" unless files.keys.include? arg
		generate.call files[arg], arg
		Glyph.info "Done."
	end
end

namespace :generate do
	desc "Create output for h3rald.com integration"
	task :h3rald => [:web] do
		dir = Glyph::PROJECT/'output/h3rald'
		(dir/"glyph/book").mkpath
		# Copy files in subdir
		(dir).find do |i|
			if i.file? then
				next if 
					i.to_s.match(Regexp.escape(dir/'glyph')) || 
					i.to_s.match(Regexp.escape(dir/'images')) || 
					i.to_s.match(Regexp.escape(dir/'styles'))
				dest = dir/"glyph/book/#{i.relative_path_from(Glyph::PROJECT/dir)}"
				src = i.to_s
				Pathname.new(dest).parent.mkpath
				file_copy src, dest
			end
		end
		# Remove files
		dir.children.each do |c|
			unless [dir/'glyph', dir/'images', dir/'styles'].include? c then
				c.directory? ? c.rmtree : c.unlink
			end
		end
		(dir/'images/glyph/glyph.eps').unlink 
		(dir/'images/glyph/glyph.svg').unlink
		# Create project page
		project = Glyph.filter %{layout:project[
				@contents[#{file_load(Glyph::PROJECT/'text/introduction.glyph')}]
			]}
		file_write dir/"glyph.textile", project
	end	
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glyph-0.4.0 book/lib/tasks/tasks.rake