Class: Crate::GemIntegration
- Inherits:
-
Dependency
- Object
- Rake::TaskLib
- Dependency
- Crate::GemIntegration
- Defined in:
- lib/crate/gem_integration.rb
Instance Attribute Summary
Attributes inherited from Dependency
#build_commands, #install_commands, #name, #upstream_source, #version
Instance Method Summary collapse
-
#define ⇒ Object
Define all the tasks in the namespace of the
name
of this task. -
#define_integration ⇒ Object
Define how the gem integrates into the ruby installation.
-
#install_integration_files(info) ⇒ Object
each of the key value pairs indicates a matching path (the key) from the gemspec that should be installed into the designated destiation path (the value).
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!, #initialize, #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
This class inherits a constructor from Crate::Dependency
Instance Method Details
#define ⇒ Object
Define all the tasks in the namespace of the name
of this task.
The dependency chain is:
:integrate => :patch => :unpack => :verify => :download
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/crate/gem_integration.rb', line 13 def define logger.debug "Defining tasks for #{name} #{version}" namespace name do define_download define_verify define_unpack define_patch define_integration task :done => "#{name}:integrate" task :default => "#{name}:done" end desc "Build and Integrate #{name} #{version}" task name => "#{name}:default" end |
#define_integration ⇒ Object
Define how the gem integrates into the ruby installation
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 |
# File 'lib/crate/gem_integration.rb', line 34 def define_integration desc "Integrate #{name} into ruby's build tree" task :integration => [ "#{name}:patch", "ruby:patch" ] do |t| logger.info "Integrating #{name} into ruby's tree" format = Gem::Format.from_file_by_path( local_source ) require_paths = format.spec.require_paths.dup integration_info = {} format.spec.extensions.each do |ext| logger.info "integrating #{name} extension #{ext}" ext_dirname = File.dirname( ext ) + File::SEPARATOR dest_ext_dir = File.join( Crate.ruby.ext_dir, name ) integration_info[ ext_dirname ] = dest_ext_dir require_paths.delete( File.dirname( ext ) ) end require_paths.each do |rp| logger.info "integrating #{name} '#{rp}' files " integration_info[ rp + File::SEPARATOR ] = Crate.ruby.lib_dir end install_integration_files( integration_info ) setup_lines = IO.readlines( Crate.ruby.ext_setup_file ) if setup_lines.grep(/^#{name}/).empty? then File.open( Crate.ruby.ext_setup_file, "a+" ) do |f| logger.info "updating ext/Setup file to add #{name}" f.puts name end end end end |
#install_integration_files(info) ⇒ Object
each of the key value pairs indicates a matching path (the key) from the gemspec that should be installed into the designated destiation path (the value)
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/crate/gem_integration.rb', line 73 def install_integration_files( info ) format = Gem::Format.from_file_by_path( local_source ) info.each_pair do |from, to| Dir.chdir( File.join( pkg_dir, from ) ) do format.spec.files.each do |f| if f.index( from ) == 0 then src_file = f.sub( from, '' ) dest_file = File.join( to, src_file ) dest_dir = File.dirname( dest_file ) logger.debug "copy #{src_file} to #{dest_file}" FileUtils.mkdir_p dest_dir unless File.directory?( dest_dir ) FileUtils.cp src_file, dest_file end end end end end |