Sha256: d12200c85a5dfcca0a8087cbbeaee0e3aa46bb525c13454465009d6aeaa98097

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

require 'tap/generator/base'

module Tap
  module Generator
    module Generators
      # :startdoc::generator make a faster tap
      class Tap < Tap::Generator::Base
        
        config :name, 'tap', &c.string            # sets the tap executable name
        config :profile, 'profile.sh', &c.string  # sets the profile script name
        
        def manifest(m)
          load_paths = load_paths('lazydoc', 'configurable', 'tap')
          bin_path = File.join(load_paths.last.chomp('lib'), 'bin/tapexe')
          
          m.template name, 'tap.erb', {
            :load_paths => load_paths,
            :bin_path => bin_path
          }
          
          m.on(:generate) do 
            log :chmod, "0755 #{name}"
            FileUtils.chmod(0755, name)
          end
          
          m.template profile, 'profile.erb', {
            :generator => self.class,
            :filename => profile
          }
        end
        
        def load_paths(*gem_names)
          gem_names.collect! do |gem_name|
            load_path = $LOAD_PATH.find do |path|
              path =~ /\/#{gem_name}[-\d\.]*\/lib$/
            end
            
            if load_path.nil?
              raise "could not determine load path for: #{gem_name}"
            end
            
            File.expand_path(load_path)
          end
        end
        
      end 
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tap-gen-0.8.0 lib/tap/generator/generators/tap.rb
tap-gen-0.7.1 lib/tap/generator/generators/tap.rb
tap-gen-0.7.0 lib/tap/generator/generators/tap.rb