Sha256: c42392848c6a6b40805276b54a08b28d64d9cad99940b8eef05074e261b4f321

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

class ExtconfGenerator < RubiGen::Base

  default_options :author => nil

  attr_reader :name, :module_name, :test_module_name

  def initialize(runtime_args, runtime_options = {})
    super
    usage if args.empty?
    @name = args.shift
    @module_name = name.camelcase
    @test_module_name = @module_name + "Extn"
  end

  def manifest
    record do |m|
      # Ensure appropriate folder(s) exists
      m.directory "ext/#{name}"
      m.directory "tasks/extconf"

      # Create stubs
      m.template "ext/c_file.c.erb",    "ext/#{name}/#{name}.c"
      m.template "ext/extconf.rb.erb",  "ext/#{name}/extconf.rb"
      if using_rspec?
        m.directory "spec"
        m.template "spec/spec.rb.erb", "spec/#{name}_extn_spec.rb"
      else
        m.directory "test"
        m.template "test/test.rb.erb",    "test/test_#{name}_extn.rb"
      end
      
      m.file     "tasks/extconf.rake",  "tasks/extconf.rake"
      m.file     "tasks/extconf_name.rake",  "tasks/extconf/#{name}.rake"

      m.template "autotest.rb.erb",         ".autotest"
      m.readme   "README.txt"
    end
  end

  def using_rspec?
    !Dir[File.join(destination_root, 'spec')].empty?
  end

  protected
    def banner
      <<-EOS
Creates a C-extension via extconf.

The extension be automatically built before running tests,
and will be built when the RubyGem is installed by users.

USAGE: #{$0} #{spec.name} name
EOS
    end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
newgem-1.1.0 rubygems_generators/extconf/extconf_generator.rb
newgem-1.2.0 rubygems_generators/extconf/extconf_generator.rb
newgem-1.2.1 rubygems_generators/extconf/extconf_generator.rb
newgem-1.2.2 rubygems_generators/extconf/extconf_generator.rb
newgem-1.2.3 rubygems_generators/extconf/extconf_generator.rb
newgem-1.3.0 rubygems_generators/extconf/extconf_generator.rb