Class: Crate::Ruby

Inherits:
Dependency show all
Defined in:
lib/crate/ruby.rb

Instance Attribute Summary

Attributes inherited from Dependency

#build_commands, #install_commands, #name, #upstream_source, #version

Instance Method Summary collapse

Methods inherited from Dependency

#build, #build_dir, #cd_and_sh, #define_build, #define_download, #define_install, #define_patch, #define_unpack, #define_verify, #depends_on, #dotfile, #dotfile!, #install, #install_dir, #local_source, #logger, #patch_files, #pkg_dir, #pkg_dir=, #recipe_dir, #sh, #upstream_md5=, #upstream_sha1, #upstream_sha1=, #usptream_md5

Constructor Details

#initialize(name = nil, version = nil) {|_self| ... } ⇒ Ruby

Create a Crate Ruby with the given name and version

Yields:

  • (_self)

Yield Parameters:

  • _self (Crate::Ruby)

    the object that the method was called on



9
10
11
12
13
14
15
16
17
18
# File 'lib/crate/ruby.rb', line 9

def initialize( name = nil, version = nil )
  @name = name
  @version = version
  @install_commands = []
  @build_commands = []
  yield self if block_given?
  @upstream_source = URI.parse( @upstream_source )
  define unless name.nil? or version.nil?
  ::Crate.ruby = self
end

Instance Method Details

#defineObject

Define all the tasks in the namespace of the name of this task.

The dependency chain is:

:install => :build => :integration => :extensions => :patch => :unpack => :verify => :download


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
# File 'lib/crate/ruby.rb', line 29

def define
  logger.debug "Defining tasks for #{name} #{version}"

  namespace name do
    define_download
    define_verify
    define_unpack
    define_patch
    define_extensions
    define_integration

    desc "Integrate ruby modules into final source" 
    task :integration => "#{name}:patch"
    file dotfile('build') => "#{name}:integration"


    define_build

    define_install

    task :done    => "#{name}:install"
    task :default => "#{name}:done"
  end

  desc "Build and Integrate #{name} #{version}"
  task name => "#{name}:default"
end

#define_extensionsObject

Define the task that overwrites the ext/Setup file



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/crate/ruby.rb', line 72

def define_extensions
  desc "Overwrite the ext/Setup file"
  task :extensions => "#{name}:patch" do
    logger.info "Rewriting ext/Setup file"
    File.open( ext_setup_file, "w") do |f|
      f.puts "option nodynamic"
      f.puts
      ::Crate.project.extensions.each do |e|
        f.puts e
      end
    end
  end
end

#define_integrationObject

Add in an integration task that depends on all the Integeration object’s name:default task



90
91
# File 'lib/crate/ruby.rb', line 90

def define_integration
end

#ext_dirObject



61
62
63
# File 'lib/crate/ruby.rb', line 61

def ext_dir
  File.join( pkg_dir, "ext" )
end

#ext_setup_fileObject



65
66
67
# File 'lib/crate/ruby.rb', line 65

def ext_setup_file
  File.join( ext_dir, "Setup" )
end

#integrates(other) ⇒ Object



93
94
95
96
# File 'lib/crate/ruby.rb', line 93

def integrates( other )
  task "#{name}:integration" => "#{other}:integration"
  task "#{other}:integration" => "#{name}:extensions"
end

#lib_dirObject



57
58
59
# File 'lib/crate/ruby.rb', line 57

def lib_dir
  File.join( pkg_dir, "lib" )
end