Sha256: 0d6b30405c914019145d65ed54d5163df9dec8f90786849078fc203b418defcc

Contents?: true

Size: 1.83 KB

Versions: 29

Compression:

Stored size: 1.83 KB

Contents

# encoding: utf-8
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
windows = RUBY_PLATFORM =~ /mswin|mingw/

desc "run specs"
task(:spec) { ruby "-S rspec spec#{" -c" unless windows}" }

desc "generate gemspec, update readme"
task :update => :completion do
  require 'travis/version'
  content = File.read('travis.gemspec')

  # fetch data
  fields = {
    :authors => `git shortlog -sn`.b.scan(/[^\d\s].*/).map { |a| a == 'petems' ? 'Peter Souter' : a },
    :email   => `git shortlog -sne`.b.scan(/[^<]+@[^>]+/),
    :files   => `git ls-files`.b.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
  }

  # :(
  fields[:email].delete("konstantin.haase@gmail.com")
  fields[:authors]

  # insert data
  fields.each do |field, values|
    updated = "  s.#{field} = ["
    updated << values.map { |v| "\n    %p" % v }.join(',')
    updated << "\n  ]"
    content.sub!(/  s\.#{field} = \[\n(    .*\n)*  \]/, updated)
  end

  # set version
  content.sub! /(s\.version.*=\s+).*/, "\\1\"#{Travis::VERSION}\""

  # escape unicode
  content.gsub!(/./) { |c| c.bytesize > 1 ? "\\u{#{c.codepoints.first.to_s(16)}}" : c }

  File.open('travis.gemspec', 'w') { |f| f << content }

  readme = File.read('README.md').b
  readme.gsub! /^(\s+\$ travis version\n\s+).*$/, "\\1#{Travis::VERSION}"
  readme.gsub! /(gem install travis -v )\S+/, "\\1#{Travis::VERSION}"
  File.write('README.md', readme)
end

task :completion do
  require 'travis/cli'
  require 'erb'
  commands = Travis::CLI.commands.sort_by { |c| c.command_name }
  template = File.read('completion/travis.sh.erb')
  source   = ERB.new(template).result(binding).gsub(/^ +\n/, '')
  File.write('completion/travis.sh', source)
end

task 'travis.gemspec' => :update
task 'README.md'      => :update

task :gemspec => :update
task :default => :spec
task :default => :gemspec unless windows or ENV['CI']
task :test    => :spec

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
travis-1.5.7.travis.345.4 Rakefile
travis-1.5.7.travis.341.4 Rakefile
travis-1.5.7.travis.338.4 Rakefile
travis-1.5.6 Rakefile
travis-1.5.6.travis.337.4 Rakefile
travis-1.5.6.travis.336.4 Rakefile
travis-1.5.6.travis.333.4 Rakefile
travis-1.5.6.travis.332.4 Rakefile
travis-1.5.6.travis.330.4 Rakefile
travis-1.5.6.travis.329.4 Rakefile
travis-1.5.6.travis.326.4 Rakefile
travis-1.5.6.travis.324.4 Rakefile
travis-1.5.6.travis.323.4 Rakefile
travis-1.5.6.travis.320.4 Rakefile
travis-1.5.6.travis.319.4 Rakefile
travis-1.5.6.travis.317.4 Rakefile
travis-1.5.6.travis.315.4 Rakefile
travis-1.5.6.travis.314.4 Rakefile
travis-1.5.6.travis.312.4 Rakefile
travis-1.5.6.travis.307.4 Rakefile