File: actions.rb

package info (click to toggle)
ruby-typhoeus 1.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: ruby: 4,381; makefile: 6
file content (125 lines) | stat: -rw-r--r-- 3,613 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
module Typhoeus
  class Request

    # Module containing logic about shortcuts to
    # http methods. Like
    #   Typhoeus.get("www.example.com")
    module Actions

      # Make a get request.
      #
      # @example Make get request.
      #   Typhoeus.get("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option (see Typhoeus::Request#initialize)
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def get(base_url, options = {})
        Request.new(base_url, options.merge(:method => :get)).run
      end

      # Make a post request.
      #
      # @example Make post request.
      #   Typhoeus.post("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option (see Typhoeus::Request#initialize)
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def post(base_url, options = {})
        Request.new(base_url, options.merge(:method => :post)).run
      end

      # Make a put request.
      #
      # @example Make put request.
      #   Typhoeus.put("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option options :params [ Hash ] Params hash which
      #   is attached to the base_url.
      # @option options :body [ Hash ] Body hash which
      #   becomes a PUT request body.
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def put(base_url, options = {})
        Request.new(base_url, options.merge(:method => :put)).run
      end

      # Make a delete request.
      #
      # @example Make delete request.
      #   Typhoeus.delete("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option (see Typhoeus::Request#initialize)
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def delete(base_url, options = {})
        Request.new(base_url, options.merge(:method => :delete)).run
      end

      # Make a head request.
      #
      # @example Make head request.
      #   Typhoeus.head("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option (see Typhoeus::Request#initialize)
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def head(base_url, options = {})
        Request.new(base_url, options.merge(:method => :head)).run
      end

      # Make a patch request.
      #
      # @example Make patch request.
      #   Typhoeus.patch("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option (see Typhoeus::Request#initialize)
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def patch(base_url, options = {})
        Request.new(base_url, options.merge(:method => :patch)).run
      end

      # Make a options request.
      #
      # @example Make options request.
      #   Typhoeus.options("www.example.com")
      #
      # @param (see Typhoeus::Request#initialize)
      #
      # @option (see Typhoeus::Request#initialize)
      #
      # @return (see Typhoeus::Response#initialize)
      #
      # @note (see Typhoeus::Request#initialize)
      def options(base_url, options = {})
        Request.new(base_url, options.merge(:method => :options)).run
      end
    end
  end
end