Sha256: 139619b49f60b30bb48c0e5373c0ee70653c5f63a816430adff2107cf6e6ed0c

Contents?: true

Size: 1.9 KB

Versions: 11

Compression:

Stored size: 1.9 KB

Contents

require 'rbconfig'

##
# Hoe allows bundling of pre-compiled extensions in the +package+ task.
#
# To create a package for your current platform:
#
#   rake package INLINE=1
#
# This will force Hoe analize your +Inline+ already compiled
# extensions and include them in your gem.
#
# If somehow you need to force a specific platform:
#
#   rake package INLINE=1 FORCE_PLATFORM=mswin32
#
# This will set the +Gem::Specification+ platform to the one indicated in
# +FORCE_PLATFORM+ (instead of default Gem::Platform::CURRENT)

module Hoe::Inline
  def initialize_inline
    dependency "RubyInline", "~> 3.9"

    clean_globs << File.expand_path("~/.ruby_inline")
  end

  ##
  # Define tasks for plugin.

  def define_inline_tasks
    task :test => :clean

    if ENV['INLINE'] then
      s.platform = ENV['FORCE_PLATFORM'] || Gem::Platform::CURRENT

      # Try collecting Inline extensions for +name+
      if defined?(Inline) then
        directory 'lib/inline'

        dlext = RbConfig::CONFIG['DLEXT']

        Inline.registered_inline_classes.each do |cls|
          name = cls.name.gsub(/::/, '')
          # name of the extension is CamelCase
          alternate_name = if name =~ /[A-Z]/ then
                             name.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
                           elsif name =~ /_/ then
                             name.capitalize.gsub(/_([a-z])/) { $1.upcase }
                           end
          extensions = Dir.chdir(Inline::directory) {
            Dir["Inline_{#{name},#{alternate_name}}_*.#{dlext}"]
          }

          extensions.each do |ext|
            # add the inlined extension to the spec files
            s.files += ["lib/inline/#{ext}"]

            # include the file in the tasks
            file "lib/inline/#{ext}" => ["lib/inline"] do
              cp File.join(Inline::directory, ext), "lib/inline"
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hoe-2.16.1 lib/hoe/inline.rb
hoe-2.16.0 lib/hoe/inline.rb
hoe-2.15.0 lib/hoe/inline.rb
hoe-2.14.0 lib/hoe/inline.rb
hoe-2.13.1 lib/hoe/inline.rb
hoe-2.13.0 lib/hoe/inline.rb
hoe-2.12.5 lib/hoe/inline.rb
hoe-2.12.4 lib/hoe/inline.rb
hoe-2.12.3 lib/hoe/inline.rb
hoe-2.12.2 lib/hoe/inline.rb
hoe-2.12.1 lib/hoe/inline.rb