Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 185 lines (152 sloc) 5.014 kb
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
$:.unshift 'extras'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/testtask'
require 'tempfile'
require 'open3'

task :default => :check

## Constants
NAME = "camping"
BRANCH = "1.9"
GIT = ENV['GIT'] || "git"
REV = `#{GIT} rev-list HEAD`.strip.split.length
VERS = ENV['VERSION'] || (REV.zero? ? BRANCH : [BRANCH, REV] * '.')

CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
RDOC_OPTS = ["--line-numbers", "--quiet", "--main", "README"]
    
## Packaging
spec =
  Gem::Specification.new do |s|
    s.name = NAME
    s.version = VERS
    s.platform = Gem::Platform::RUBY
    s.has_rdoc = true
    s.extra_rdoc_files = FileList["README", "CHANGELOG", "COPYING", "book/*"].to_a
    s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)\/', '--exclude', 'lib/camping.rb']
    s.summary = "minature rails for stay-at-home moms"
    s.author = "why the lucky stiff"
    s.email = 'why@ruby-lang.org'
    s.homepage = 'http://camping.rubyforge.org/'
    s.rubyforge_project = 'camping'
    s.executables = ['camping']

    s.add_dependency('rack', '>=1.0')
    s.required_ruby_version = '>= 1.8.2'

    s.files = %w(COPYING README Rakefile) +
    Dir.glob("{bin,doc,test,lib,extras,book}/**/*") +
    Dir.glob("ext/**/*.{h,c,rb}") +
    Dir.glob("examples/**/*.rb") +
    Dir.glob("tools/*.rb")

    s.require_path = "lib"
    s.bindir = "bin"
  end

omni =
  Gem::Specification.new do |s|
    s.name = "camping-omnibus"
    s.version = VERS
    s.platform = Gem::Platform::RUBY
    s.summary = "the camping meta-package for updating ActiveRecord, Mongrel and SQLite3 bindings"
    %w[author email homepage rubyforge_project].each { |x| s.__send__("#{x}=", spec.__send__(x)) }

    s.add_dependency('camping', "=#{VERS}")
    s.add_dependency('activerecord')
    s.add_dependency('sqlite3-ruby', '>=1.1.0.1')
    s.add_dependency('mongrel')
    s.add_dependency('acts_as_versioned')
    s.add_dependency('RedCloth')
  end
  
## RDoc

gem 'rdoc', '~> 2.4.0' rescue nil
require 'rdoc'

if defined?(RDoc::VERSION) && RDoc::VERSION[0,3] == "2.4"
  require 'rdoc/generator/singledarkfish'
  require 'rdoctask'
  
  Camping::RDocTask.new(:docs) do |rdoc|
    rdoc.before_running_rdoc do
      mv "lib/camping.rb", "lib/camping-mural.rb"
      mv "lib/camping-unabridged.rb", "lib/camping.rb"
    end
    
    rdoc.after_running_rdoc do
      mv "lib/camping.rb", "lib/camping-unabridged.rb"
      mv "lib/camping-mural.rb", "lib/camping.rb"
    end
    
    rdoc.rdoc_dir = 'doc'
    rdoc.options += ['-f', 'singledarkfish', *RDOC_OPTS]
    rdoc.template = "flipbook"
    rdoc.title = "Camping, a Microframework"
    rdoc.rdoc_files.add ['README', 'lib/camping.rb', 'lib/camping/**/*.rb', 'book/*']
  end
  
  task :rubygems_docs do
    require 'rubygems/doc_manager'
    
    def spec.installation_path; '.' end
    def spec.full_gem_path; '.' end
    manager = Gem::DocManager.new(spec)
    manager.generate_rdoc
  end
end

desc "Packages Camping."
task :package => :clean

Rake::GemPackageTask.new(spec) do |p|
  p.need_tar = true
  p.gem_spec = spec
end

Rake::GemPackageTask.new(omni) do |p|
  p.gem_spec = omni
end

task :install => :package do
  sh %{sudo gem install pkg/#{NAME}-#{VERS}}
end

task :uninstall => [:clean] do
  sh %{sudo gem uninstall #{NAME}}
end

## Tests
Rake::TestTask.new(:test) do |t|
  t.test_files = FileList['test/test_*.rb']
# t.warning = true
# t.verbose = true
end

## Diff
desc "Compare camping and camping-unabridged"
task :diff do
  require 'ruby2ruby'
  require 'ruby_parser'
  u = Tempfile.new('unabridged')
  m = Tempfile.new('mural')
  
  u << Ruby2Ruby.new.process(RubyParser.new.parse(File.read("lib/camping.rb")))
  m << Ruby2Ruby.new.process(RubyParser.new.parse(File.read("lib/camping-unabridged.rb")))
  
  sh "diff -u #{u.path} #{m.path} | less"
  
  u.delete
  m.delete
end

## Check
task :check => ["check:valid", "check:size", "check:lines"]
namespace :check do

  desc "Check source code validity"
  task :valid do
    require 'ruby_parser'
    u = RubyParser.new.parse(File.read("lib/camping-unabridged.rb"))
    m = RubyParser.new.parse(File.read("lib/camping.rb"))
    
    unless u == m
      STDERR.puts "camping.rb and camping-unabridged.rb are not synchronized."
    end
  end

  SIZE_LIMIT = 4096
  desc "Compare camping sizes to unabridged"
  task :size do
    FileList["lib/camping*.rb"].each do |path|
      s = File.size(path)
      puts "%21s : % 6d % 4d%" % [File.basename(path), s, (100 * s / SIZE_LIMIT)]
    end
    if File.size("lib/camping.rb") > SIZE_LIMIT
      STDERR.puts "lib/camping.rb: file is too big (> #{SIZE_LIMIT})"
    end
  end

  desc "Verify that line lenght doesn't exceed 80 chars for camping.rb"
  task :lines do
    i = 1
    File.open("lib/camping.rb").each_line do |line|
      if line.size > 81 # 1 added for \n
        STDERR.puts "lib/camping.rb:#{i}: line too long (#{line[-10..-1].inspect})"
      end
      i += 1
    end
  end

end
Something went wrong with that request. Please try again.