Class: SortedSearch::CocoapodsProvider

Inherits:
Provider
  • Object
show all
Defined in:
lib/sorted_search/providers/cocoapods_provider.rb

Overview

base class for printers

Instance Attribute Summary

Attributes inherited from Provider

#sorting_criteria

Instance Method Summary collapse

Methods inherited from Provider

#initialize, #pod_from_spec, #provide_sorted_specs

Constructor Details

This class inherits a constructor from SortedSearch::Provider

Instance Method Details

#fetch_dataObject



9
10
11
12
13
14
15
16
# File 'lib/sorted_search/providers/cocoapods_provider.rb', line 9

def fetch_data
  super
  @specs.each do |spec|
    pod = pod_from_spec(spec)
    pod.github_watchers # This will force statistics provider to fetch github info unless it is already cached
    @progress_bar.increment
  end
end

#sort_specsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sorted_search/providers/cocoapods_provider.rb', line 18

def sort_specs
  pods = @specs.map { |spec| pod_from_spec(spec) }

  pods.sort do |x, y|
    case @sorting_criteria

      when :stars
        x.github_watchers.to_i <=> y.github_watchers.to_i

      when :forks
        x.github_forks.to_i <=> y.github_forks.to_i

      when :activity
        x.statistics_provider.github_pushed_at(y.set).to_i <=> y.statistics_provider.github_pushed_at(x.set).to_i
      else
        nil
      end
  end
end