Sha256: 564d5749cc5caa693d044219ca5590eef81ee71fe351c7026ef13117831a694e

Contents?: true

Size: 827 Bytes

Versions: 4

Compression:

Stored size: 827 Bytes

Contents

module Puppet::Module::Tool

  module Applications

    class Searcher < Application

      def initialize(term, options = {})
        @term = term
        super(options)
      end

      def run
        header "Searching #{repository}"
        request = Net::HTTP::Get.new("/modules.json?q=#{URI.escape(@term)}")
        response = repository.contact(request)
        case response
        when Net::HTTPOK
          matches = PSON.parse(response.body)
          if matches.empty?
            subheader "0 found."
          else
            subheader "#{matches.size} found."
          end
          matches.each do |match|
            puts "#{match['full_name']} (#{match['version']})"
          end
        else
          say "Could not execute search (HTTP #{response.code})"
        end
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-module-0.3.4 lib/puppet/module/tool/applications/searcher.rb
puppet-module-0.3.3 lib/puppet/module/tool/applications/searcher.rb
puppet-module-0.3.2 lib/puppet/module/tool/applications/searcher.rb
puppet-module-0.3.0 lib/puppet/module/tool/applications/searcher.rb