crate 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +9 -0
- data/LICENSE +13 -0
- data/README +39 -0
- data/bin/crate +9 -0
- data/data/Makefile +5 -0
- data/data/Rakefile +77 -0
- data/data/application.rb +47 -0
- data/data/crate_boot.c +219 -0
- data/data/recipes/amalgalite/amalgalite.rake +7 -0
- data/data/recipes/arrayfields/arrayfields.rake +7 -0
- data/data/recipes/configuration/configuration.rake +7 -0
- data/data/recipes/openssl/openssl.rake +20 -0
- data/data/recipes/ruby/ext-extmk.rb.patch +33 -0
- data/data/recipes/ruby/ruby.rake +30 -0
- data/data/recipes/rubygems/rubygems.rake +19 -0
- data/data/recipes/zlib/zlib.rake +16 -0
- data/gemspec.rb +47 -0
- data/lib/crate.rb +85 -0
- data/lib/crate/dependency.rb +306 -0
- data/lib/crate/digest.rb +36 -0
- data/lib/crate/gem_integration.rb +91 -0
- data/lib/crate/main.rb +173 -0
- data/lib/crate/packing_list.rb +16 -0
- data/lib/crate/project.rb +255 -0
- data/lib/crate/ruby.rb +98 -0
- data/lib/crate/utils.rb +74 -0
- data/lib/crate/version.rb +26 -0
- data/spec/crate_spec.rb +16 -0
- data/spec/spec_helper.rb +5 -0
- data/tasks/announce.rake +38 -0
- data/tasks/config.rb +98 -0
- data/tasks/distribution.rake +46 -0
- data/tasks/documentation.rake +31 -0
- data/tasks/rspec.rake +29 -0
- data/tasks/rubyforge.rake +59 -0
- data/tasks/utils.rb +80 -0
- metadata +160 -0
data/lib/crate/ruby.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'crate/dependency'
|
2
|
+
require 'crate/gem_integration'
|
3
|
+
|
4
|
+
module Crate
|
5
|
+
class Ruby < Dependency
|
6
|
+
#
|
7
|
+
# Create a Crate Ruby with the given name and version
|
8
|
+
#
|
9
|
+
def initialize( name = nil, version = nil )
|
10
|
+
@name = name
|
11
|
+
@version = version
|
12
|
+
@install_commands = []
|
13
|
+
@build_commands = []
|
14
|
+
yield self if block_given?
|
15
|
+
@upstream_source = URI.parse( @upstream_source )
|
16
|
+
define unless name.nil? or version.nil?
|
17
|
+
::Crate.ruby = self
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
#
|
22
|
+
# Define all the tasks in the namespace of the +name+ of this task.
|
23
|
+
#
|
24
|
+
# The dependency chain is:
|
25
|
+
#
|
26
|
+
# :install => :build => :integration => :extensions => :patch => :unpack => :verify => :download
|
27
|
+
#
|
28
|
+
#
|
29
|
+
def define
|
30
|
+
logger.debug "Defining tasks for #{name} #{version}"
|
31
|
+
|
32
|
+
namespace name do
|
33
|
+
define_download
|
34
|
+
define_verify
|
35
|
+
define_unpack
|
36
|
+
define_patch
|
37
|
+
define_extensions
|
38
|
+
define_integration
|
39
|
+
|
40
|
+
desc "Integrate ruby modules into final source"
|
41
|
+
task :integration => "#{name}:patch"
|
42
|
+
file dotfile('build') => "#{name}:integration"
|
43
|
+
|
44
|
+
|
45
|
+
define_build
|
46
|
+
|
47
|
+
define_install
|
48
|
+
|
49
|
+
task :done => "#{name}:install"
|
50
|
+
task :default => "#{name}:done"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Build and Integrate #{name} #{version}"
|
54
|
+
task name => "#{name}:default"
|
55
|
+
end
|
56
|
+
|
57
|
+
def lib_dir
|
58
|
+
File.join( pkg_dir, "lib" )
|
59
|
+
end
|
60
|
+
|
61
|
+
def ext_dir
|
62
|
+
File.join( pkg_dir, "ext" )
|
63
|
+
end
|
64
|
+
|
65
|
+
def ext_setup_file
|
66
|
+
File.join( ext_dir, "Setup" )
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Define the task that overwrites the ext/Setup file
|
71
|
+
#
|
72
|
+
def define_extensions
|
73
|
+
desc "Overwrite the ext/Setup file"
|
74
|
+
task :extensions => "#{name}:patch" do
|
75
|
+
logger.info "Rewriting ext/Setup file"
|
76
|
+
File.open( ext_setup_file, "w") do |f|
|
77
|
+
f.puts "option nodynamic"
|
78
|
+
f.puts
|
79
|
+
::Crate.project.extensions.each do |e|
|
80
|
+
f.puts e
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Add in an integration task that depends on all the Integeration object's
|
88
|
+
# name:default task
|
89
|
+
#
|
90
|
+
def define_integration
|
91
|
+
end
|
92
|
+
|
93
|
+
def integrates( other )
|
94
|
+
task "#{name}:integration" => "#{other}:integration"
|
95
|
+
task "#{other}:integration" => "#{name}:extensions"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/crate/utils.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'archive/tar/minitar'
|
2
|
+
require 'zlib'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'progressbar'
|
6
|
+
require 'rubygems/installer'
|
7
|
+
|
8
|
+
module Crate
|
9
|
+
#
|
10
|
+
# Utiltiy methods useful for many items
|
11
|
+
module Utils
|
12
|
+
#
|
13
|
+
# Changes into a directory and unpacks the archive.
|
14
|
+
#
|
15
|
+
def unpack( archive, into = Dir.pwd )
|
16
|
+
Dir.chdir( into ) do
|
17
|
+
if archive.match( /\.tar\.gz\Z/ ) or archive.match(/\.tgz\Z/) then
|
18
|
+
tgz = ::Zlib::GzipReader.new( File.open( local_source, 'rb') )
|
19
|
+
::Archive::Tar::Minitar.unpack( tgz, into )
|
20
|
+
elsif archive.match( /\.gem\Z/ ) then
|
21
|
+
subdir = File.basename( archive, ".gem" )
|
22
|
+
Gem::Installer.new( archive ).unpack( subdir )
|
23
|
+
else
|
24
|
+
raise "Unable to extract files from #{File.basename( local_source)} -- unknown format"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Verify the given file against a digest value. If the digest value is nil
|
31
|
+
# then it is a no-op.
|
32
|
+
#
|
33
|
+
def verify( file, against = nil )
|
34
|
+
return ( against ? against.verify( file ) : true )
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# download the given URI to a specified location, show progress with a
|
39
|
+
# progress bar.
|
40
|
+
#
|
41
|
+
def download( uri, to )
|
42
|
+
to_dir = File.dirname( to )
|
43
|
+
FileUtils.mkdir_p( to_dir ) unless File.directory?( to_dir )
|
44
|
+
|
45
|
+
pbar = nil
|
46
|
+
File.open( to , "w" ) do |outf|
|
47
|
+
begin
|
48
|
+
uri.open( :content_length_proc => lambda { |t| pbar = ::ProgressBar.new( File.basename( local_source ), t ) if t && 0 < t },
|
49
|
+
:progress_proc => lambda { |s| pbar.set s if pbar } ) do |inf|
|
50
|
+
outf.write inf.read
|
51
|
+
end
|
52
|
+
rescue => e
|
53
|
+
puts
|
54
|
+
STDERR.puts "Error downloading #{uri.to_s} : #{e}"
|
55
|
+
exit 1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Apply the given patch file in a particular directory
|
62
|
+
#
|
63
|
+
def apply_patch( patch_file, location )
|
64
|
+
Dir.chdir( location ) do
|
65
|
+
%x[ patch -p0 < #{patch_file} ]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Wrap a command sending its output to the the Crate.project logger at the
|
71
|
+
# debug level
|
72
|
+
#
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2008 Jeremy Hinegardner
|
3
|
+
# All rights reserved. See LICENSE and/or COPYING for details
|
4
|
+
#++
|
5
|
+
|
6
|
+
module Crate
|
7
|
+
module Version
|
8
|
+
MAJOR = 0
|
9
|
+
MINOR = 1
|
10
|
+
BUILD = 1
|
11
|
+
|
12
|
+
def to_a
|
13
|
+
[MAJOR, MINOR, BUILD]
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
to_a.join(".")
|
18
|
+
end
|
19
|
+
|
20
|
+
module_function :to_a
|
21
|
+
module_function :to_s
|
22
|
+
|
23
|
+
STRING = Version.to_s
|
24
|
+
end
|
25
|
+
VERSION = Version.to_s
|
26
|
+
end
|
data/spec/crate_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
|
2
|
+
|
3
|
+
describe Crate do
|
4
|
+
before(:each) do
|
5
|
+
# some setup
|
6
|
+
end
|
7
|
+
|
8
|
+
after(:each) do
|
9
|
+
# some cleanup
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have some tests" do
|
13
|
+
violated("I just want to be tested... is that so wrong?")
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tasks/announce.rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
#-------------------------------------------------------------------------------
|
3
|
+
# announcement methods
|
4
|
+
#-------------------------------------------------------------------------------
|
5
|
+
|
6
|
+
proj_config = Configuration.for('project')
|
7
|
+
namespace :announce do
|
8
|
+
desc "create email for ruby-talk"
|
9
|
+
task :email do
|
10
|
+
info = Utils.announcement
|
11
|
+
|
12
|
+
File.open("email.txt", "w") do |mail|
|
13
|
+
mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
|
14
|
+
mail.puts "To: ruby-talk@ruby-lang.org"
|
15
|
+
mail.puts "Date: #{Time.now.rfc2822}"
|
16
|
+
mail.puts "Subject: [ANN] #{info[:subject]}"
|
17
|
+
mail.puts
|
18
|
+
mail.puts info[:title]
|
19
|
+
mail.puts
|
20
|
+
mail.puts info[:urls]
|
21
|
+
mail.puts
|
22
|
+
mail.puts info[:description]
|
23
|
+
mail.puts
|
24
|
+
mail.puts "{{ Release notes for Version #{Crate::VERSION} }}"
|
25
|
+
mail.puts
|
26
|
+
mail.puts info[:release_notes]
|
27
|
+
mail.puts
|
28
|
+
mail.puts info[:urls]
|
29
|
+
end
|
30
|
+
puts "Created the following as email.txt:"
|
31
|
+
puts "-" * 72
|
32
|
+
puts File.read("email.txt")
|
33
|
+
puts "-" * 72
|
34
|
+
end
|
35
|
+
|
36
|
+
CLOBBER << "email.txt"
|
37
|
+
end
|
38
|
+
|
data/tasks/config.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'configuration'
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'tasks/utils'
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------
|
7
|
+
# General project configuration
|
8
|
+
#-----------------------------------------------------------------------
|
9
|
+
Configuration.for('project') {
|
10
|
+
name "crate"
|
11
|
+
version "0.1.0"
|
12
|
+
author "Jeremy Hinegardner"
|
13
|
+
email "jeremy@copiousfreetime.org"
|
14
|
+
homepage "http://copiousfreetime.rubyforge.org/crate"
|
15
|
+
description Utils.section_of("README", "description")
|
16
|
+
summary description.split(".").first
|
17
|
+
history "HISTORY"
|
18
|
+
license FileList["LICENSE", ]
|
19
|
+
readme "README"
|
20
|
+
}
|
21
|
+
|
22
|
+
#-----------------------------------------------------------------------
|
23
|
+
# Packaging
|
24
|
+
#-----------------------------------------------------------------------
|
25
|
+
Configuration.for('packaging') {
|
26
|
+
# files in the project
|
27
|
+
proj_conf = Configuration.for('project')
|
28
|
+
files {
|
29
|
+
bin FileList["bin/*"]
|
30
|
+
lib FileList["lib/**/*.rb"]
|
31
|
+
test FileList["spec/**/*.rb", "test/**/*.rb"]
|
32
|
+
data FileList["data/**/*"]
|
33
|
+
tasks FileList["tasks/**/*.r{ake,b}"]
|
34
|
+
rdoc FileList[proj_conf.readme, proj_conf.history,
|
35
|
+
proj_conf.license] + lib
|
36
|
+
all bin + lib + test + data + rdoc + tasks
|
37
|
+
}
|
38
|
+
|
39
|
+
# ways to package the results
|
40
|
+
formats {
|
41
|
+
tgz true
|
42
|
+
zip true
|
43
|
+
rubygem Configuration::Table.has_key?('rubygem')
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
#-----------------------------------------------------------------------
|
48
|
+
# Gem packaging
|
49
|
+
#-----------------------------------------------------------------------
|
50
|
+
Configuration.for("rubygem") {
|
51
|
+
spec "gemspec.rb"
|
52
|
+
Configuration.for('packaging').files.all << spec
|
53
|
+
}
|
54
|
+
|
55
|
+
#-----------------------------------------------------------------------
|
56
|
+
# Testing
|
57
|
+
# - change mode to 'testunit' to use unit testing
|
58
|
+
#-----------------------------------------------------------------------
|
59
|
+
Configuration.for('test') {
|
60
|
+
mode "spec"
|
61
|
+
files Configuration.for("packaging").files.test
|
62
|
+
options %w[ --format specdoc --color ]
|
63
|
+
ruby_opts %w[ ]
|
64
|
+
}
|
65
|
+
|
66
|
+
#-----------------------------------------------------------------------
|
67
|
+
# Rcov
|
68
|
+
#-----------------------------------------------------------------------
|
69
|
+
Configuration.for('rcov') {
|
70
|
+
output_dir "coverage"
|
71
|
+
libs %w[ lib ]
|
72
|
+
rcov_opts %w[ --html ]
|
73
|
+
ruby_opts %w[ ]
|
74
|
+
test_files Configuration.for('packaging').files.test
|
75
|
+
}
|
76
|
+
|
77
|
+
#-----------------------------------------------------------------------
|
78
|
+
# Rdoc
|
79
|
+
#-----------------------------------------------------------------------
|
80
|
+
Configuration.for('rdoc') {
|
81
|
+
files Configuration.for('packaging').files.rdoc
|
82
|
+
main_page files.first
|
83
|
+
title Configuration.for('project').name
|
84
|
+
options %w[ --line-numbers --inline-source ]
|
85
|
+
output_dir "doc"
|
86
|
+
}
|
87
|
+
|
88
|
+
#-----------------------------------------------------------------------
|
89
|
+
# Rubyforge
|
90
|
+
#-----------------------------------------------------------------------
|
91
|
+
Configuration.for('rubyforge') {
|
92
|
+
project "copiousfreetime"
|
93
|
+
user "jjh"
|
94
|
+
host "rubyforge.org"
|
95
|
+
rdoc_location "#{user}@#{host}:/var/www/gforge-projects/#{project}/crate"
|
96
|
+
}
|
97
|
+
|
98
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------------
|
4
|
+
# Distribution and Packaging
|
5
|
+
#-------------------------------------------------------------------------------
|
6
|
+
if pkg_config = Configuration.for_if_exist?("packaging") then
|
7
|
+
|
8
|
+
require 'gemspec'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/contrib/sshpublisher'
|
11
|
+
|
12
|
+
namespace :dist do
|
13
|
+
|
14
|
+
Rake::GemPackageTask.new(Crate::GEM_SPEC) do |pkg|
|
15
|
+
pkg.need_tar = pkg_config.formats.tgz
|
16
|
+
pkg.need_zip = pkg_config.formats.zip
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Install as a gem"
|
20
|
+
task :install => [:clobber, :package] do
|
21
|
+
sh "sudo gem install pkg/#{Crate::GEM_SPEC.full_name}.gem"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Uninstall gem"
|
25
|
+
task :uninstall do
|
26
|
+
sh "sudo gem uninstall -x #{Crate::GEM_SPEC.name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "dump gemspec"
|
30
|
+
task :gemspec do
|
31
|
+
puts Crate::GEM_SPEC.to_ruby
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "reinstall gem"
|
35
|
+
task :reinstall => [:uninstall, :repackage, :install]
|
36
|
+
|
37
|
+
|
38
|
+
desc "distribute copiously"
|
39
|
+
task :copious => [ :package ] do
|
40
|
+
Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
|
41
|
+
'/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
|
42
|
+
'pkg' ,"#{Crate::GEM_SPEC.full_name}.gem").upload
|
43
|
+
sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
|
3
|
+
#-----------------------------------------------------------------------
|
4
|
+
# Documentation
|
5
|
+
#-----------------------------------------------------------------------
|
6
|
+
|
7
|
+
if rdoc_config = Configuration.for_if_exist?('rdoc') then
|
8
|
+
|
9
|
+
namespace :doc do
|
10
|
+
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
|
13
|
+
# generating documentation locally
|
14
|
+
Rake::RDocTask.new do |rdoc|
|
15
|
+
rdoc.rdoc_dir = rdoc_config.output_dir
|
16
|
+
rdoc.options = rdoc_config.options
|
17
|
+
rdoc.rdoc_files = rdoc_config.files
|
18
|
+
rdoc.title = rdoc_config.title
|
19
|
+
rdoc.main = rdoc_config.main_page
|
20
|
+
end
|
21
|
+
|
22
|
+
if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
|
23
|
+
desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
|
24
|
+
task :deploy => :rerdoc do
|
25
|
+
sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require 'tasks/config'
|
3
|
+
|
4
|
+
#--------------------------------------------------------------------------------
|
5
|
+
# configuration for running rspec. This shows up as the test:default task
|
6
|
+
#--------------------------------------------------------------------------------
|
7
|
+
if spec_config = Configuration.for_if_exist?("test") then
|
8
|
+
if spec_config.mode == "spec" then
|
9
|
+
namespace :test do
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
|
13
|
+
require 'spec/rake/spectask'
|
14
|
+
Spec::Rake::SpecTask.new do |r|
|
15
|
+
r.ruby_opts = spec_config.ruby_opts
|
16
|
+
r.libs = [ Crate.lib_path,
|
17
|
+
Crate.root_dir ]
|
18
|
+
r.spec_files = spec_config.files
|
19
|
+
r.spec_opts = spec_config.options
|
20
|
+
|
21
|
+
if rcov_config = Configuration.for_if_exist?('rcov') then
|
22
|
+
r.rcov = true
|
23
|
+
r.rcov_dir = rcov_config.output_dir
|
24
|
+
r.rcov_opts = rcov_config.rcov_opts
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|