Sha256: 6325a38c0ad1a79744feb4b754f9abb3588b4ba48887fdf5e4b843550285e236

Contents?: true

Size: 1.44 KB

Versions: 454

Compression:

Stored size: 1.44 KB

Contents

module Fastlane
  # Use the RubyGems API to get all fastlane plugins
  class PluginFetcher
    require 'fastlane_core'
    require 'fastlane/plugins/plugin_manager'

    # Returns an array of FastlanePlugin objects
    def self.fetch_gems(search_query: nil)
      require 'json'
      require 'open-uri'

      page = 1
      plugins = []
      loop do
        url = "https://rubygems.org/api/v1/search.json?query=#{PluginManager.plugin_prefix}#{search_query}&page=#{page}"
        FastlaneCore::UI.verbose("RubyGems API Request: #{url}")
        results = JSON.parse(open(url).read)
        break if results.count == 0

        plugins += results.collect do |current|
          FastlanePlugin.new(current)
        end
        page += 1
      end

      return plugins if search_query.to_s.length == 0
      plugins.keep_if do |current|
        current.full_name.include?(search_query)
      end

      return plugins
    end
  end

  class FastlanePlugin
    attr_accessor :full_name
    attr_accessor :name
    attr_accessor :downloads
    attr_accessor :info
    attr_accessor :homepage

    def initialize(hash)
      self.full_name = hash["name"]
      self.name = self.full_name.gsub(PluginManager.plugin_prefix, '')
      self.downloads = hash["downloads"]
      self.info = hash["info"]
      self.homepage = hash["homepage_uri"]
    end

    def linked_title
      return "`#{name}`" if homepage.to_s.length == 0
      return "[#{name}](#{homepage})"
    end
  end
end

Version data entries

454 entries across 454 versions & 1 rubygems

Version Path
fastlane-2.61.0.beta.20171007010004 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.61.0.beta.20171006010004 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.61.0.beta.20171005010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.61.0.beta.20171004010004 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.1 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20171003010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20171002010004 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20171001010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20170930010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20170929010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20170928010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20170927010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.60.0.beta.20170926010004 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.59.0 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.59.0.beta.20170925010002 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.59.0.beta.20170924010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.59.0.beta.20170923010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.59.0.beta.20170922010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb
fastlane-2.59.0.beta.20170921010003 fastlane/lib/fastlane/plugins/plugin_fetcher.rb