Class: PryGem::GemStat
- Inherits:
-
Pry::ClassCommand
- Object
- Pry::ClassCommand
- PryGem::GemStat
- Defined in:
- lib/pry-gem/gem_stat.rb
Overview
Constant Summary collapse
- STAT_HOST =
"rubygems.org".freeze
- STAT_PORT =
443- STAT_PATH =
"/api/v1/gems/%s.json".freeze
- FAIL_WHALE =
<<-FAILWHALE.freeze W W W W W W W '. W .-""-._ \ \.--| / "-..__) .-' | _ / \'-.__, .__.,' `'----'._\--' VVVVVVVVVVVVVVVVVVVVV FAILWHALE
Instance Method Summary collapse
Instance Method Details
#process(name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pry-gem/gem_stat.rb', line 32 def process(name) client = Net::HTTP.start STAT_HOST, STAT_PORT, use_ssl: true res = client.get STAT_PATH % URI.encode_www_form_component(name) case res when Net::HTTPOK _pry_.pager.page format_gem(JSON.parse(res.body)) when Net::HTTPServiceUnavailable _pry_.pager.page <<-FAILURE #{bright_blue(FAIL_WHALE)} #{bright_red('Ruby On Rails')} #{bright_red('Net::HTTPServiceUnavailable')} FAILURE else raise Pry::CommandError, "Bad response (#{res.class})" end ensure client.finish if client end |