httpalooza 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 374ae028d634e1fafe7d735fb4ee2c06b1a82ba0
4
- data.tar.gz: 1bd12e35c2ddfee45dbf1e67613240f97aad7f01
3
+ metadata.gz: 015fd22c665878d26dcb1513a726bbef678dd5a0
4
+ data.tar.gz: 96d5562f0f346c9b08b2459d07e93058caa34609
5
5
  SHA512:
6
- metadata.gz: 4e9bb8b68aed888612724d4fe23874da1ed9d7b28a80a529fbfaef653a65b903514f89bf215501ee10138107fbdd63ad962f7d00b2107d830910d6df3c804765
7
- data.tar.gz: ac36cf9de5924cb4b2bd4354d330f8ced3dcbd60ab0bff2169179bbbb244a706fb46661754fae3bb6391e3a352ce02bf5116904719d701a2886e1c8238cca861
6
+ metadata.gz: 5dacbfe38f88bbf6ceb9b725784a76b7fcaf04a1581e9dc7cf08a439babb29b3e541352292519e8e8dfd8d55e20b5fb717dad9a102479c45fe0dcc1954f7feef
7
+ data.tar.gz: 8360c36ddf32eb93dd13cd43e33bd70c74cc387a011ec01bb7a351bb382e13fc699ec6581d061efe244aaab4017cb82c04fc60beff115bd6f07a4246927c49cb
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.2.2
3
4
  - 2.0.0
5
+ - jruby-18mode # JRuby in 1.8 mode
6
+ - jruby-19mode # JRuby in 1.9 mode
7
+ - rbx-2.1.1
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -19,6 +19,9 @@ module HTTPalooza
19
19
  class Error < StandardError; end
20
20
  class NotImplementedError < Error; end
21
21
 
22
+ # Starts an HTTPalooza session.
23
+ #
24
+ # @return [HTTPalooza::Lineup] the new Lineup
22
25
  def self.invite
23
26
  Lineup.new
24
27
  end
@@ -1,21 +1,56 @@
1
1
  module HTTPalooza
2
2
  module API
3
+ # Peform an HTTP GET request with the assembled Lineup.
4
+ #
5
+ # @param [String] url the URL to request.
6
+ # options [Hash] the request options
7
+ # @option options [Hash] :headers request headers
8
+ # @option options [Hash] :params URL parameters
9
+ # @option options [String] :payload the request body
3
10
  def get(url, options = {}, &block)
4
11
  run! Request.new(url, :get, options.slice(:headers, :params, :payload), &block)
5
12
  end
6
13
 
14
+ # Peform an HTTP POST request with the assembled Lineup.
15
+ #
16
+ # @param [String] url the URL to request.
17
+ # options [Hash] the request options
18
+ # @option options [Hash] :headers request headers
19
+ # @option options [Hash] :params URL parameters
20
+ # @option options [String] :payload the request body
7
21
  def post(url, options = {}, &block)
8
22
  run! Request.new(url, :post, options.slice(:headers, :params, :payload), &block)
9
23
  end
10
24
 
25
+ # Peform an HTTP PUT request with the assembled Lineup.
26
+ #
27
+ # @param [String] url the URL to request.
28
+ # options [Hash] the request options
29
+ # @option options [Hash] :headers request headers
30
+ # @option options [Hash] :params URL parameters
31
+ # @option options [String] :payload the request body
11
32
  def put(url, options = {}, &block)
12
33
  run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)
13
34
  end
14
35
 
36
+ # Peform an HTTP DELETE request with the assembled Lineup.
37
+ #
38
+ # @param [String] url the URL to request.
39
+ # options [Hash] the request options
40
+ # @option options [Hash] :headers request headers
41
+ # @option options [Hash] :params URL parameters
42
+ # @option options [String] :payload the request body
15
43
  def delete(url, options = {}, &block)
16
44
  run! Request.new(url, :delete, options.slice(:headers, :params, :payload), &block)
17
45
  end
18
46
 
47
+ # Peform an HTTP HEAD request with the assembled Lineup.
48
+ #
49
+ # @param [String] url the URL to request.
50
+ # options [Hash] the request options
51
+ # @option options [Hash] :headers request headers
52
+ # @option options [Hash] :params URL parameters
53
+ # @option options [String] :payload the request body
19
54
  def head(url, options = {}, &block)
20
55
  run! Request.new(url, :head, options.slice(:headers, :params, :payload), &block)
21
56
  end
@@ -1,4 +1,16 @@
1
1
  module HTTPalooza
2
+ # A Lineup assembles a set of Players to perform HTTP requests.
3
+ #
4
+ # @example Perform a request with curb
5
+ # lineup = HTTPalooza::Lineup.new.with_curb
6
+ # response = lineup.get('http://httpbin.org/')
7
+ # response[:curb] #=> Get the response from Curb
8
+ #
9
+ # @example Performing multiple requests
10
+ # lineup = HTTPalooza::Lineup.new.with_curb.and_unirest
11
+ # lineup.get('http://httpbin.org/')
12
+ # response[:curb] #=> Get the response from Curb
13
+ # response[:unirest] #=> Get the response from Unirest
2
14
  class Lineup
3
15
  include API
4
16
 
@@ -17,6 +29,7 @@ module HTTPalooza
17
29
  end
18
30
  end
19
31
 
32
+ # Return a Lineup with all available Players
20
33
  def everyone
21
34
  players.merge(Players.available)
22
35
  self
@@ -3,6 +3,9 @@ module HTTPalooza
3
3
  class << self
4
4
  attr_reader :available
5
5
 
6
+ # @!attribute [r] available
7
+ # @return [Set] the available Players
8
+
6
9
  def add(klass)
7
10
  @available ||= Set.new
8
11
 
@@ -1,9 +1,18 @@
1
1
  module HTTPalooza
2
2
  module Players
3
+ # Superclass for Player implementations
4
+ # @abstract
3
5
  class Base
4
6
  class << self
5
7
  attr_reader :name, :dependencies
6
8
 
9
+ # Create a new player and require any depenencies.
10
+ #
11
+ # @example
12
+ # introducing! :selenium, %w[ selenium-webdriver ]
13
+ #
14
+ # @param [Symbol] name the name of the player
15
+ # @param [Array] dependencies a list of dependencies require in order to use this player
7
16
  def introducing!(name, dependencies = [])
8
17
  @name = name.to_sym
9
18
  @dependencies = dependencies
@@ -1,9 +1,28 @@
1
1
  module HTTPalooza
2
+ # Request presents a standard interface for describing an HTTP request that Players can translate into the underlying library's representation.
2
3
  class Request
3
4
  STANDARD_METHODS = [:get, :post, :put, :patch, :delete, :options, :head]
4
5
 
5
6
  attr_reader :url, :method, :params, :payload, :headers
7
+ # @!attribute [r] url
8
+ # @return [String] the URL to request
9
+ # @!attribute [r] method
10
+ # @return [Symbol] the HTTP method
11
+ # @!attribute [r] params
12
+ # @return [Hash] the URL parameters
13
+ # @!attribute [r] payload
14
+ # @return [String] the request body
15
+ # @!attribute [r] headers
16
+ # @return [Hash] the request headers
6
17
 
18
+ # Instantiate a Request.
19
+ #
20
+ # @param [String] url the URL to request
21
+ # @param [Symbol] method the HTTP method
22
+ # @param [Hash] options additional options
23
+ # @option options [Hash] :params the URL parameters
24
+ # @option options [Hash] :headers the request headers
25
+ # @option options [String] :payload the request payload
7
26
  def initialize(url, method, options = {})
8
27
  @url = url
9
28
  @method = method
@@ -14,6 +33,7 @@ module HTTPalooza
14
33
  normalize_url!
15
34
  end
16
35
 
36
+ # @return [Boolean] whether or not the URL is SSL
17
37
  def ssl?
18
38
  !!(url.to_s =~ /^https/)
19
39
  end
@@ -1,18 +1,29 @@
1
1
  module HTTPalooza
2
+ # Response represents a unified interface for the various Player's responses.
2
3
  class Response
3
4
  AwesomeResponseCodes = 200..299
4
5
 
6
+ # @!attribute code
7
+ # @return [Fixnum] the HTTP status code
8
+ # @!attribute body
9
+ # @return [String] the HTTP response body
5
10
  attr_accessor :code, :body
6
11
 
12
+ # Create a new Response.
13
+ #
14
+ # @param [Fixnum] code the HTTP status code. Should be between 100 and 599.
15
+ # @param [String] body the HTTP response body.
7
16
  def initialize(code, body)
8
17
  @code = code.to_i
9
18
  @body = body
10
19
  end
11
20
 
21
+ # @return [Boolean] whether or not the response code was awesome.
12
22
  def awesome?
13
23
  AwesomeResponseCodes.include?(code)
14
24
  end
15
25
 
26
+ # @return [Boolean] whether or not the response code was not awesome.
16
27
  def not_awesome?
17
28
  !awesome?
18
29
  end
@@ -1,3 +1,3 @@
1
1
  module HTTPalooza
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpalooza
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quin Hoxie