rubysoftwareconservancy / conservancy-site

Website for the Ruby Software Conservancy
GNU General Public License v3.0
0 stars 1 forks source link

Discover gems to adopt through API calls #8

Open benjaminoakes opened 2 months ago

benjaminoakes commented 2 months ago

Goals

Spike

Query for homepage URLs using Fabio Rehm (who we adopted rake-notes from)

:information_source: I don't hold any of the names in this code closely. Feel free to change them as you like.

# query_gems.rb
class QueryGems
  def initialize(username:)
    @username = username
  end

  def results
    Gems.
      gems(@username).
      map { |gem| Gems.info(gem["name"])["homepage_uri"] }.
      sort
  end
end

Let's try using the default test framework for a bit and see how we like it:

# query_gems_test.rb
require "test_helper"

class QueryGemsTest < ActiveSupport::TestCase
  test "#gems" do
    query = QueryGems.new(username: "fgrehm")

    results = query.results

     assert_equal results, [
       "",
       "http://github.com/fgrehm/autotestforphp",
       "http://github.com/fgrehm/tiny-rails",
       "https://github.com/Helabs/jumpup-deis",
       "https://github.com/Helabs/jumpup-hipchat",
       "https://github.com/PetroFeed/actionpusher",
       "https://github.com/doximity/rsg",
       "https://github.com/fgrehm/bindler",
       "https://github.com/fgrehm/docker-provider",
       "https://github.com/fgrehm/letter_opener_web",
       "https://github.com/fgrehm/middleman-draft-articles",
       "https://github.com/fgrehm/rake-notes",
       "https://github.com/fgrehm/vagrant-boxen",
       "https://github.com/fgrehm/vagrant-cachier",
       "https://github.com/fgrehm/vagrant-global-status",
       "https://github.com/fgrehm/vagrant-lxc",
       "https://github.com/fgrehm/vagrant-notify",
       "https://github.com/fgrehm/vagrant-pristine",
       "https://github.com/fgrehm/ventriloquist",
       "https://github.com/fgrehm/vocker",
       "https://github.com/fgrehm/vundler",
     ]
  end
end