Skip to content

Commit

Permalink
Merge branch 'master' of github.com:heroku/heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
will committed Apr 29, 2011
2 parents 3ead585 + 39ca9f3 commit 7a3445d
Show file tree
Hide file tree
Showing 81 changed files with 6,232 additions and 1,532 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ pkg
rdoc
.DS_Store
*.swp
*.rbc
10 changes: 10 additions & 0 deletions Gemfile
@@ -1,3 +1,13 @@
source "http://rubygems.org"

gemspec

group :development do
gem "fakefs"
gem "parka", ">= 0.6.2"
gem "rake", ">= 0.8.7"
gem "rspec", ">= 2.0"
gem "taps", ">= 0.3.23"
gem "webmock"
end

36 changes: 26 additions & 10 deletions Gemfile.lock
@@ -1,26 +1,39 @@
PATH
remote: .
specs:
heroku (1.20.1)
launchy (~> 0.3.2)
rest-client (< 1.7.0, >= 1.4.0)
heroku (2.0.4)
launchy (>= 0.3.2)
rest-client (>= 1.4.0, < 1.7.0)
term-ansicolor (~> 1.0.5)

GEM
remote: http://rubygems.org/
specs:
addressable (2.2.2)
configuration (1.2.0)
crack (0.1.8)
diff-lcs (1.1.2)
fakefs (0.3.1)
launchy (0.3.7)
launchy (0.4.0)
configuration (>= 0.0.5)
rake (>= 0.8.1)
mime-types (1.16)
parka (0.6.2)
crack
rest-client
thor
rack (1.2.2)
rake (0.8.7)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (1.3.1)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
sequel (3.20.0)
sinatra (1.0)
rack (>= 1.0)
Expand All @@ -33,6 +46,8 @@ GEM
sequel (~> 3.20.0)
sinatra (~> 1.0.0)
sqlite3-ruby (~> 1.2)
term-ansicolor (1.0.5)
thor (0.14.6)
webmock (1.5.0)
addressable (>= 2.2.2)
crack (>= 0.1.7)
Expand All @@ -41,9 +56,10 @@ PLATFORMS
ruby

DEPENDENCIES
fakefs (~> 0.3.1)
fakefs
heroku!
rake
rspec (~> 1.3.0)
taps (~> 0.3.23)
webmock (~> 1.5.0)
parka (>= 0.6.2)
rake (>= 0.8.7)
rspec (>= 2.0)
taps (>= 0.3.23)
webmock
131 changes: 33 additions & 98 deletions Rakefile
@@ -1,116 +1,51 @@
$:.unshift File.expand_path("../lib", __FILE__)
require "heroku/version"

require 'rake'
require 'spec/rake/spectask'

desc "Run all specs"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
t.spec_files = FileList['spec/**/*_spec.rb']
end
require "rubygems"
require "bundler/setup"

desc "Print specdocs"
Spec::Rake::SpecTask.new(:doc) do |t|
t.spec_opts = ["--format", "specdoc", "--dry-run"]
t.spec_files = FileList['spec/*_spec.rb']
end
PROJECT_ROOT = File.expand_path("..", __FILE__)
$:.unshift "#{PROJECT_ROOT}/lib"

desc "Generate RCov code coverage report"
Spec::Rake::SpecTask.new('rcov') do |t|
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'examples']
end
require "heroku/version"
require "rspec/core/rake_task"

def gem_paths
%x{ bundle show }.split("\n").map do |line|
if line =~ /^ \* (.*?) \((.*?)\)/
%x{ bundle show #{$1} }.strip
end
end.compact
desc "Run all specs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = true
end

GEM_BLACKLIST = %w( bundler heroku )

def copy_gems(package_gem_dir)
lines = %x{ bundle show }.strip.split("\n")
raise "error running bundler" unless $?.success?
task :default => :spec

%x{ env BUNDLE_WITHOUT="development:test" bundle show }.split("\n").each do |line|
if line =~ /^ \* (.*?) \((.*?)\)/
next if GEM_BLACKLIST.include?($1)
puts "vendoring: #{$1}-#{$2}"
gem_dir = %x{ bundle show #{$1} }.strip
%x{ cp -R #{gem_dir} #{package_gem_dir}/ }
end
end.compact
def builder(action, ext)
package_file = "pkg/heroku-#{Heroku::VERSION}.#{ext}"
puts "#{action}: #{package_file}"
system "build/#{ext}/#{action} #{PROJECT_ROOT} #{package_file}"
end

def package_path(path, stream)
puts "#{path}/**/*.rb"
Dir["#{path}/**/*"].each do |file|
next unless File.file?(file)
puts "finding file: #{file}"
relative = file.gsub(/^#{path}/, '')
relative.gsub!(/^\//, '')
stream.puts("__FILE__ #{relative}")
stream.puts(File.read(file))
stream.puts("__ENDFILE__")
namespace :package do
desc "package the gem version"
task :gem do
builder :package, :gem
end
end

desc "Package as a single file"
task :package do
base_dir = File.dirname(__FILE__)

require "tmpdir"
package_dir = "#{Dir.mktmpdir}/heroku-#{Heroku::VERSION}"
package_gem_dir = "#{package_dir}/vendor/gems"

puts "building in: #{package_dir}"
%x{ mkdir -p #{package_gem_dir} }
copy_gems package_gem_dir

%x{ cp -R #{base_dir}/lib #{package_dir} }

File.open("#{package_dir}/heroku", "w") do |file|
file.puts <<-PREAMBLE
#!/usr/bin/env ruby
gem_dir = File.expand_path("../vendor/gems", __FILE__)
Dir["\#{gem_dir}/**/lib"].each do |libdir|
$:.unshift libdir
desc "package the tgz version"
task :tgz do
builder :package, :tgz
end
end

$:.unshift File.expand_path("../lib", __FILE__)
desc "package all"
task :package => %w( package:gem package:tgz )

require 'heroku'
require 'heroku/command'
args = ARGV.dup
ARGV.clear
command = args.shift.strip rescue 'help'
Heroku::Command.run(command, args)
PREAMBLE
namespace :release do
desc "release the gem version"
task :gem => "package:gem" do
builder :release, :gem
end

%x{ chmod +x #{package_dir}/heroku }

if plugins = (ENV["PLUGINS"] || "").split(" ")
plugins.each do |plugin|
puts "plugin: #{plugin}"
%x{ mkdir -p #{package_dir}/plugins }
%x{ cd #{package_dir}/plugins && git clone #{plugin} 2>&1 }
%x{ rm -rf $(find #{package_dir}/plugins -name .git) }
end
desc "release the tgz version"
task :tgz => "package:tgz" do
builder :release, :tgz
end

%x{ mkdir -p #{base_dir}/pkg }
%x{ cd #{package_dir}/.. && tar czvpf #{base_dir}/pkg/heroku-#{Heroku::VERSION}.tgz * 2>&1 }

puts "package: pkg/heroku-#{Heroku::VERSION}.tgz"
end

task :default => :spec
desc "release all"
task :release => %w( release:gem release:tgz )
11 changes: 9 additions & 2 deletions autotest/discover.rb
@@ -1,4 +1,11 @@
begin
require "octotest"
rescue LoadError
puts "missing the 'octotest' gem"
exit 1
end

Autotest.add_discovery { "octotest" }
Autotest.add_discovery { "rspec" }
Autotest.add_discovery { "rspec2" }

ENV["OCTOTEST_RUBIES"] = "ruby-1.8.7@heroku-gem ruby-1.9.2@heroku-gem"
ENV["OCTOTEST_RUBIES"] ||= "ruby-1.8.7 ruby-1.9.2 rbx"
1 change: 1 addition & 0 deletions bin/heroku
Expand Up @@ -10,5 +10,6 @@ args = ARGV.dup
ARGV.clear
command = args.shift.strip rescue 'help'

Heroku::Command.load
Heroku::Command.run(command, args)

14 changes: 14 additions & 0 deletions build/gem/package
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

project_root = ARGV.shift
package_file = ARGV.shift

unless project_root && package_file
puts "usage: gem/package PROJECT_ROOT PACKAGE_FILE"
exit 1
end

Dir.chdir(project_root)

system "parka build -f #{project_root}/#{package_file}"

13 changes: 13 additions & 0 deletions build/gem/release
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby

package_file = ARGV.shift

unless package_file
puts "usage: gem/release PACKAGE_FILE"
exit 1
end

Dir.chdir(File.expand_path("../..", package_file))

system "parka push -f #{package_file}"

99 changes: 99 additions & 0 deletions build/tgz/package
@@ -0,0 +1,99 @@
#!/usr/bin/env ruby

project_root = ARGV.shift
package_file = ARGV.shift

unless project_root && package_file
puts "usage: tgz/package PROJECT_ROOT PACKAGE_FILE"
exit 1
end

GEM_BLACKLIST = %w( bundler heroku )

def gem_paths
%x{ bundle show }.split("\n").map do |line|
if line =~ /^ \* (.*?) \((.*?)\)/
%x{ bundle show #{$1} }.strip
end
end.compact
end

def copy_gems(package_gem_dir)
lines = %x{ bundle show }.strip.split("\n")
raise "error running bundler" unless $?.success?

%x{ env BUNDLE_WITHOUT="development:test" bundle show }.split("\n").each do |line|
if line =~ /^ \* (.*?) \((.*?)\)/
next if GEM_BLACKLIST.include?($1)
puts "vendoring: #{$1}-#{$2}"
gem_dir = %x{ bundle show #{$1} }.strip
%x{ cp -R #{gem_dir} #{package_gem_dir}/ }
end
end.compact
end

def package_path(path, stream)
puts "#{path}/**/*.rb"
Dir["#{path}/**/*"].each do |file|
next unless File.file?(file)
puts "finding file: #{file}"
relative = file.gsub(/^#{path}/, '')
relative.gsub!(/^\//, '')
stream.puts("__FILE__ #{relative}")
stream.puts(File.read(file))
stream.puts("__ENDFILE__")
end
end

Dir.chdir(project_root)

version = package_file.match(/heroku-([a-z0-9\.]+)\./)[1]

require "tmpdir"
package_dir = "#{Dir.mktmpdir}/heroku-#{version}"
package_gem_dir = "#{package_dir}/vendor/gems"

puts "building in: #{package_dir}"
%x{ mkdir -p #{package_gem_dir} }
copy_gems package_gem_dir

%x{ cd #{project_root} && find . -name "*.rbc" -delete }
%x{ cp -R #{project_root}/data #{package_dir} }
%x{ cp -R #{project_root}/lib #{package_dir} }

File.open("#{package_dir}/heroku", "w") do |file|
file.puts <<-PREAMBLE
#!/usr/bin/env ruby
gem_dir = File.expand_path("../vendor/gems", __FILE__)
Dir["\#{gem_dir}/**/lib"].each do |libdir|
$:.unshift libdir
end
$:.unshift File.expand_path("../lib", __FILE__)
require 'heroku'
require 'heroku/command'
args = ARGV.dup
ARGV.clear
command = args.shift.strip rescue 'help'
Heroku::Command.load
Heroku::Command.run(command, args)
PREAMBLE
end

%x{ chmod +x #{package_dir}/heroku }

if plugins = (ENV["PLUGINS"] || "").split(" ")
plugins.each do |plugin|
puts "plugin: #{plugin}"
%x{ mkdir -p #{package_dir}/plugins }
%x{ cd #{package_dir}/plugins && git clone #{plugin} 2>&1 }
%x{ rm -rf $(find #{package_dir}/plugins -name .git) }
end
end

%x{ mkdir -p #{project_root}/pkg }
%x{ cd #{package_dir}/.. && tar czvpf #{project_root}/#{package_file} * 2>&1 }

0 comments on commit 7a3445d

Please sign in to comment.