From d675ef441f3c12884c97c5d8555bb7a65f27c0a3 Mon Sep 17 00:00:00 2001 From: Mike Williamson Date: Mon, 18 Jul 2016 19:19:45 -0400 Subject: [PATCH] Make add script check for github repos --- add | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/add b/add index e77317a..1956cab 100755 --- a/add +++ b/add @@ -95,12 +95,14 @@ begin } extract_url with: "[class~='up-and-out']", and_run: proc {|url| url.attr('href').value } extract_founding_year with: "li.founded", and_run: proc {|tds| tds.last ? tds.last.text[/(\d{4})/] : nil } + extract_code with: ".github", and_run: proc {|code| code.empty? ? nil : code.attr('href').value } end - raise StandardError 'No technologies were listed!' if raw_results[:technology_list].empty? + raise Exception.new 'No technologies were listed!' if raw_results[:technology_list].empty? organization[:name] = raw_results[:name] organization[:url] = raw_results[:url] + organization[:code] = raw_results[:code] organization[:founding_year] = raw_results[:founding_year] @@ -122,7 +124,9 @@ begin location[:address] = address elsif choice.to_i == 2 puts "Enter a comma separated lat/lng: " - location[:lat], location[:lng] = STDIN.gets.strip.split(',') + lat, lng = STDIN.gets.strip.split(',') + location[:lat] = lat.chomp.to_f + location[:lng] = lng.chomp.to_f location[:address] = loc end else @@ -146,11 +150,13 @@ begin name: "#{organization[:name]}" #{ " founding_year: " + organization[:founding_year] if organization[:founding_year]} url: "#{organization[:url]}" + #{ 'code: "' + organization[:code] + '"' if organization[:code]} locations: [#{organization[:locations].map(&:to_graphql).join(", ")}] technologies: [#{organization[:technologies].map(&:to_graphql).join(", ")}] ) { name founding_year + code url } }