brawne 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/brawne.rb +28 -0
- metadata +62 -0
data/lib/brawne.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require "net/https"
|
3
|
+
|
4
|
+
class Brawne
|
5
|
+
|
6
|
+
attr_accessor :host, :port, :ssl, :user, :token
|
7
|
+
|
8
|
+
def initialize(host, port, ssl, user, token)
|
9
|
+
@host, @port, @ssl, @user, @token = host, port, ssl, user, token
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(request)
|
13
|
+
http_r = Net::HTTP.new(@host, @port)
|
14
|
+
http_r.use_ssl = @ssl
|
15
|
+
response = nil
|
16
|
+
begin
|
17
|
+
http_r.start() do |http|
|
18
|
+
req = Net::HTTP::Get.new(request)
|
19
|
+
req.add_field("USERNAME", @user)
|
20
|
+
req.add_field("TOKEN", @token)
|
21
|
+
response = http.request(req)
|
22
|
+
end
|
23
|
+
return [response.code, response.body]
|
24
|
+
rescue Errno::ECONNREFUSED
|
25
|
+
return [503, "unavailable"]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brawne
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Joel AZEMAR
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-09-15 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Make request thrown Net::Http
|
22
|
+
email: joel.azemar@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/brawne.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://joelazemar.fr
|
33
|
+
licenses: []
|
34
|
+
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Brawne!
|
61
|
+
test_files: []
|
62
|
+
|