Module Rufus::Verbs

  1. lib/rufus/verbs/conditional.rb
  2. lib/rufus/verbs/cookies.rb
  3. lib/rufus/verbs/digest.rb
  4. lib/rufus/verbs/verbose.rb
  5. lib/rufus/verbs/endpoint.rb
  6. lib/rufus/verbs/version.rb
  7. lib/rufus/verbs.rb
  8. show all

Methods

public instance

  1. delete
  2. fopen
  3. get
  4. head
  5. options
  6. post
  7. put

Constants

USER_AGENT = "Ruby rufus-verbs #{VERSION}"
VERSION = '1.0.0'   The version of this rufus-verbs [gem]

Public instance methods

delete (*args)

DELETE

[show source]
    # File lib/rufus/verbs.rb, line 60
60:   def delete (*args)
61: 
62:     EndPoint.request :delete, args
63:   end
fopen (uri, *args, &block)

Opens a file or a URI (GETs it and return the reply). Will tolerate a HTTP[S] URI or a file path.

It is not named open() in order not to collide with File.open and open-uri’s open.

[show source]
     # File lib/rufus/verbs.rb, line 88
 88:   def fopen (uri, *args, &block)
 89: 
 90:     # should I really care about blocks here ? ...
 91: 
 92:     u = URI.parse uri.to_s
 93: 
 94:     return File.open(uri.to_s, &block) \
 95:       if u.scheme == nil
 96: 
 97:     return File.open(uri.to_s[5..-1], &block) \
 98:       if u.scheme == 'file'
 99: 
100:     if u.scheme == 'http' or u.scheme == 'https'
101: 
102:       r = EndPoint.request(:get, [ uri ] + args) \
103: 
104:       if block
105:         block.call r
106:         return
107:       end
108: 
109:       class << r
110:         def read
111:           self.body
112:         end
113:       end unless r.respond_to?(:read)
114: 
115:       return r
116:     end
117: 
118:     raise "can't handle scheme '#{u.scheme}' for #{u.to_s}"
119:   end
get (*args)

GET

[show source]
    # File lib/rufus/verbs.rb, line 36
36:   def get (*args)
37: 
38:     EndPoint.request :get, args
39:   end
head (*args)

HEAD

[show source]
    # File lib/rufus/verbs.rb, line 68
68:   def head (*args)
69: 
70:     EndPoint.request :head, args
71:   end
options (*args)

OPTIONS

[show source]
    # File lib/rufus/verbs.rb, line 76
76:   def options (*args)
77: 
78:     EndPoint.request :options, args
79:   end
post (*args, &block)

POST

[show source]
    # File lib/rufus/verbs.rb, line 44
44:   def post (*args, &block)
45: 
46:     EndPoint.request :post, args, &block
47:   end
put (*args, &block)

PUT

[show source]
    # File lib/rufus/verbs.rb, line 52
52:   def put (*args, &block)
53: 
54:     EndPoint.request :put, args, &block
55:   end