Class Boson::Commands::WebCore::Get

  1. lib/boson/commands/web_core.rb
Parent: Object

Used by the get command to make get requests and optionally parse json and yaml. Ruby 1.8.x is dependent on json gem for parsing json. See Get.request for options a request can take.


public class

  1. new

public instance

  1. request

Public class methods

new (url, options={})
[show source]
# File lib/boson/commands/web_core.rb, line 94
    def initialize(url, options={})
      @url, @options = url, options

Public instance methods

request (options={})

Returns the response body string or a parsed data structure. Returns nil if request fails. By default expects response to be 200.


Returns body string for any response code. Default is false.
Parse the body into either json or yaml. Expects a valid format or if true autodetects one. Default is false.
Raises any original errors when parsing or fetching url instead of handling errors silently.
[show source]
# File lib/boson/commands/web_core.rb, line 105
    def request(options={})
      @options.merge! options
      body = get_body
      body && @options[:parse] ? parse_body(body) : body