Sha256: 3709a95a9d80c4c93852d3a8e3c1b66451ce07e3fdfe24ca0215a3cbb8c2b928

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module Pod
  class Command
    class Browser < Command
      self.summary = 'Open the homepage'

      self.description = <<-DESC
        Opens the homepage on browser.
      DESC

      self.arguments = '[QUERY]'

      def initialize(argv)
        @query = argv.arguments! unless argv.arguments.empty?
        super
      end

      def validate!
        super
        help! "A search query is required." unless @query
      end

      extend Executable
      executable :open

      def run
        opened = false
        sets   = SourcesManager.search_by_name(@query.join(' ').strip)
        statistics_provider = Config.instance.spec_statistics_provider
        sets.each do |set|
          begin
            pod = Specification::Set::Presenter.new(set, statistics_provider)
            next unless @query.include?(pod.name)
            if url = pod.homepage
              UI.puts("Opening #{url}")
              open!(url)
              opened = true
            else
              UI.warn "Skipping `#{set.name}` because the homepage not found."
            end
          rescue DSLError
            UI.warn "Skipping `#{set.name}` because the podspec contains errors."
          end
        end
        UI.warn "The query(`#{@query.join('` or `')}`) not found pod." unless opened
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocoapods-browser-0.0.1 lib/pod/command/browser.rb