Class: Menu::Releases
- Inherits:
-
Array
- Object
- Array
- Menu::Releases
- Defined in:
- lib/menu/releases.rb
Constant Summary collapse
- @@con =
Faraday.new(:url => ENV['MENU_URL']) do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :json, :content_type => /\bjson$/ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.do(component) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/menu/releases.rb', line 5 def self.do component raise "Missing component" unless component response = @@con.get("/#{component}.json") if response.success? Releases.from_array response.body['releases'] else puts "New component, creating empty list" Releases.new end end |
Instance Method Details
#to_json ⇒ Object
22 23 24 25 26 |
# File 'lib/menu/releases.rb', line 22 def to_json { releases: sort_by {|o| o.version} }.to_json end |