lib/warbler/jar.rb
def find_single_gem_files(config, gem_pattern, version = nil)
      if Gem::Specification === gem_pattern
        spec = gem_pattern
      else
        gem = case gem_pattern
              when Gem::Dependency
                gem_pattern
              else
                Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
              end

        # skip development dependencies
        return if gem.respond_to?(:type) and gem.type != :runtime

        # Deal with deprecated Gem.source_index and #search
        matched = gem.respond_to?(:to_spec) ? [gem.to_spec] : Gem.source_index.search(gem)
        fail "gem '#{gem}' not installed" if matched.empty?
        spec = matched.last
      end

      full_gem_path = Pathname.new(spec.full_gem_path)

      # skip gems whose full_gem_path does not exist
      ($stderr.puts "warning: skipping #{spec.name} (#{full_gem_path.to_s} does not exist)" ; return) unless full_gem_path.exist?

      @files[apply_pathmaps(config, "#{spec.full_name}.gemspec", :gemspecs)] = StringIO.new(spec.to_ruby)
      FileList["#{full_gem_path.to_s}/**/*"].each do |src|
        f = Pathname.new(src).relative_path_from(full_gem_path).to_s
        next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
        @files[apply_pathmaps(config, File.join(spec.full_name, f), :gems)] = src
      end

      spec.dependencies.each {|dep| find_single_gem_files(config, dep) } if config.gem_dependencies
    end
# Add a single gem to WEB-INF/gems
Add a single gem to WEB-INF/gems
Add a single gem to WEB - INF / gems
def find_single_gem_files(config, gem_pattern, version = nil)
      if Gem::Specification === gem_pattern
        spec = gem_pattern
      else
        gem = case gem_pattern
              when Gem::Dependency
                gem_pattern
              else
                Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
              end
        return if gem.respond_to?(:type) and gem.type != :runtime
        matched = gem.respond_to?(:to_spec) ? [gem.to_spec] : Gem.source_index.search(gem)
        fail "gem '#{gem}' not installed" if matched.empty?
        spec = matched.last
      end
      full_gem_path = Pathname.new(spec.full_gem_path)
      ($stderr.puts "warning: skipping #{spec.name} (#{full_gem_path.to_s} does not exist)" ; return) unless full_gem_path.exist?
      @files[apply_pathmaps(config, "#{spec.full_name}.gemspec", :gemspecs)] = StringIO.new(spec.to_ruby)
      FileList["#{full_gem_path.to_s}/**/*"].each do |src|
        f = Pathname.new(src).relative_path_from(full_gem_path).to_s
        next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
        @files[apply_pathmaps(config, File.join(spec.full_name, f), :gems)] = src
      end
      spec.dependencies.each {|dep| find_single_gem_files(config, dep) } if config.gem_dependencies
    end
def find_single_gem_files ( config , gem_pattern , version = nil ) if Gem :: Specification === gem_pattern spec = gem_pattern else gem = case gem_pattern when Gem :: Dependency gem_pattern else Gem :: Dependency . new ( gem_pattern , Gem :: Requirement . create ( version ) ) end return if gem . respond_to? ( :type ) and gem . type != :runtime matched = gem . respond_to? ( :to_spec ) ? [ gem . to_spec ] : Gem . source_index . search ( gem ) fail "gem '#{gem}' not installed" if matched . empty? spec = matched . last end full_gem_path = Pathname . new ( spec . full_gem_path ) ( $stderr . puts "warning: skipping #{spec.name} (#{full_gem_path.to_s} does not exist)" ; return ) unless full_gem_path . exist? @files [ apply_pathmaps ( config , "#{spec.full_name}.gemspec" , :gemspecs ) ] = StringIO . new ( spec . to_ruby ) FileList [ "#{full_gem_path.to_s}/**/*" ] . each do | src | f = Pathname . new ( src ) . relative_path_from ( full_gem_path ) . to_s next if config . gem_excludes && config . gem_excludes . any? { | rx | f =~ rx } @files [ apply_pathmaps ( config , File . join ( spec . full_name , f ) , :gems ) ] = src end spec . dependencies . each { | dep | find_single_gem_files ( config , dep ) } if config . gem_dependencies end
Add a single gem to WEB-INF/gems
Add a single gem to WEB - INF / gems
# skip development dependencies # Deal with deprecated Gem.source_index and #search # skip gems whose full_gem_path does not exist
config
gem_pattern
version