0
+RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
0
+WIN = (PLATFORM =~ /mswin|cygwin/)
0
+SUDO = (WIN ? "" : "sudo")
0
-windows = (PLATFORM =~ /mswin|cygwin/)
0
-SUDO = windows ? "" : "sudo"
0
+Dir['tasks/**/*.rake'].each { |rake| load rake }
0
-RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
0
- RUBY_1_9 ? 'gem19' : 'gem'
0
-RAGEL_TARGET = "#{RAGEL_BASE}.c"
0
-RAGEL_FILE = "#{RAGEL_BASE}.rl"
0
-EXT_BASE = 'thin_parser'
0
-EXT_DIR = "ext/#{EXT_BASE}"
0
-EXT_BUNDLE = "#{EXT_DIR}/#{EXT_BASE}.#{Config::CONFIG['DLEXT']}"
0
-SO_FILE = "#{EXT_BASE}.so"
0
-Echoe.new(Thin::NAME) do |p|
0
- p.author = "Marc-Andre Cournoyer"
0
- p.email = "macournoyer@gmail.com"
0
- p.description = "Thin takes the http parser from Mongrel, the
0
- connection engine from EventMachine and the web server interface
0
- from Rack, creating a highly flexible, small, fast, and sexy
0
- web app server for Ruby."
0
- p.summary = "A thin and fast web server"
0
- p.url = "http://code.macournoyer.com/thin/"
0
- p.docs_host = "macournoyer.com:~/code.macournoyer.com/thin/doc/"
0
- p.clean_pattern = ['ext/thin_parser/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'lib/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/thin_parser/Makefile', 'pkg', 'lib/*.bundle', '*.gem', '*.gemspec', '.config', 'coverage']
0
- p.ignore_pattern = /^(.git|benchmark|site|tasks)|.gitignore/
0
- p.rdoc_pattern = ['README', 'LICENSE', 'changes.txt', 'lib/**/*.rb', 'doc/**/*.rdoc']
0
- p.ruby_version = '>= 1.8.6'
0
- p.dependencies = ['rack >= 0.2.0']
0
- p.extension_pattern = nil
0
- if RUBY_PLATFORM !~ /mswin/
0
- p.extension_pattern = ["ext/**/extconf.rb"]
0
- self.files += ['lib/thin_parser.so']
0
- add_dependency('eventmachine', '>= 0.8.1')
0
- add_dependency('daemons', '>= 1.0.9')
0
- add_dependency('eventmachine')
0
-task :clean => :clobber_package
0
- puts "Don't forget to tag the release:"
0
- puts " git tag -a v#{Thin::VERSION::STRING}"
0
-task :gem => [:compile,:tag_warn]
0
-desc "Compile the Ragel state machines"
0
- File.unlink RAGEL_TARGET if File.exist? RAGEL_TARGET
0
- sh "ragel #{RAGEL_FILE} | rlgen-cd -G2 -o #{RAGEL_TARGET}"
0
- raise "Failed to compile Ragel state machine" unless File.exist? RAGEL_TARGET
0
- FILENAME = "lib/#{SO_FILE}"
0
- desc "compile mswin32 extension"
0
- task :compile => [FILENAME]
0
- # task :compile defined by echoe due to defined extension_pattern
0
- task :site => %w(site:upload rdoc:upload)
0
- desc 'Deploy on code.macournoyer.com'
0
- task :alpha => %w(gem:upload deploy:site)
0
- desc 'Deploy on rubyforge'
0
- task :public => %w(gem:upload_rubyforge deploy:site)
0
-desc 'Deploy on all servers'
0
-task :deploy => %w(deploy:alpha deploy:public)
0
-def upload(file, to, options={})
0
- sh %{ssh macournoyer@macournoyer.com "rm -rf code.macournoyer.com/#{to}"} if options[:replace]
0
- sh %{scp -rq #{file} macournoyer@macournoyer.com:code.macournoyer.com/#{to}}
0
- mkdir_p 'tmp/site/images'
0
- sh "SITE_ROOT='/thin' ruby ../../site/thin.rb --dump"
0
- cp 'site/style.css', 'tmp/site'
0
- cp_r Dir['site/images/*'], 'tmp/site/images'
0
- desc 'Upload website to code.macournoyer.com'
0
- task :upload => 'site:build' do
0
- upload 'tmp/site/*', 'thin'
0
- warn 'RSpec not yet supporting Ruby 1.9, so cannot run the specs :('
0
- # RSpec not yet working w/ Ruby 1.9
0
- require 'spec/rake/spectask'
0
- desc "Run all examples"
0
- Spec::Rake::SpecTask.new('spec') do |t|
0
- t.spec_files = FileList['spec/**/*_spec.rb']
0
task :default => [:compile, :spec]
0
-desc 'Show some stats about the code'
0
- line_count = proc do |path|
0
- Dir[path].collect { |f| File.open(f).readlines.reject { |l| l =~ /(^\s*(\#|\/\*))|^\s*$/ }.size }.inject(0){ |sum,n| sum += n }
0
- lib = line_count['lib/**/*.rb']
0
- ext = line_count['ext/**/*.{c,h}']
0
- spec = line_count['spec/**/*.rb']
0
- ratio = '%1.2f' % (spec.to_f / lib.to_f)
0
- puts "#{lib.to_s.rjust(6)} LOC of lib"
0
- puts "#{ext.to_s.rjust(6)} LOC of ext"
0
- puts "#{spec.to_s.rjust(6)} LOC of spec"
0
- puts "#{ratio.to_s.rjust(6)} ratio lib/spec"
0
-task :thin_install => [:clean,:package] do
0
- sh %{#{SUDO} #{gem} install pkg/#{Thin::NAME}-#{Thin::VERSION::STRING}*.gem --no-update-sources}
0
-desc "uninstall the gem"
0
-task :thin_uninstall => :clean do
0
- sh %{#{SUDO} #{gem} uninstall #{Thin::NAME}}
Comments
No one has commented yet.