bogeyman 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -1
- data/lib/bogeyman/client.rb +7 -2
- data/lib/bogeyman/cookie.rb +33 -0
- data/lib/bogeyman/version.rb +1 -1
- data/lib/bogeyman.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df5166d0ba9731dba8780d2b9f0b37cebb2fd5e0
|
4
|
+
data.tar.gz: 6fc5a0c00d01fc76ca5c7a5437c5f23eee4847b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e7e76952f65db2fc2fca6975f0dbae2535801b0d1cbdd91abb0d9cb4297450f764c8bca7be72d01aac10a774d7bf2d0ddf3e15e160ba6eab33483e66be1812
|
7
|
+
data.tar.gz: b24cd3b2ce29ac4fd6aff1a92eab041170960330d861a149124bd46df5b9e426032ff117433c1f2002cedc9499abfe2efc87e258a340e4f2c23dc08e56864f09
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ gem install bogeyman
|
|
16
16
|
Or you can put it in your Gemfile
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'bogeyman', '~> 0.0.
|
19
|
+
gem 'bogeyman', '~> 0.0.3'
|
20
20
|
```
|
21
21
|
|
22
22
|
## Usage
|
@@ -41,6 +41,24 @@ client.post 'http://example.com', param1: 'abc'
|
|
41
41
|
client.get 'http://example.com'
|
42
42
|
```
|
43
43
|
|
44
|
+
Or if you want to use existing cookies
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
client = Bogeyman::Client.new(
|
48
|
+
cookies: [
|
49
|
+
{
|
50
|
+
name: "test",
|
51
|
+
value: "test",
|
52
|
+
domain: "yuna.sk",
|
53
|
+
path: "/path",
|
54
|
+
httponly: false,
|
55
|
+
secure: false,
|
56
|
+
expires: 1405164630,
|
57
|
+
},
|
58
|
+
]
|
59
|
+
)
|
60
|
+
```
|
61
|
+
|
44
62
|
Or if you require advanced options
|
45
63
|
|
46
64
|
```ruby
|
@@ -55,6 +73,7 @@ client = Bogeyman::Client.new(
|
|
55
73
|
ssl_protocol: 'any', # default: 'sslv3'
|
56
74
|
ssl_certificates-path: '...', # default: system default
|
57
75
|
web_security: true, # default: false
|
76
|
+
cookies: []
|
58
77
|
)
|
59
78
|
```
|
60
79
|
|
data/lib/bogeyman/client.rb
CHANGED
@@ -5,7 +5,7 @@ module Bogeyman
|
|
5
5
|
def initialize params={}
|
6
6
|
host = params.delete(:host) || 'localhost'
|
7
7
|
port = params.delete(:port) || 31313
|
8
|
-
|
8
|
+
@cookies = (params.delete(:cookies) || []).map{ |c| Cookie.new(c) }
|
9
9
|
@server = "http://#{host}:#{port}"
|
10
10
|
@params = params
|
11
11
|
end
|
@@ -20,9 +20,10 @@ module Bogeyman
|
|
20
20
|
|
21
21
|
def request method, url, data
|
22
22
|
params = {
|
23
|
-
method: method,
|
23
|
+
method: method.upcase,
|
24
24
|
url: url,
|
25
25
|
params: @params,
|
26
|
+
cookies: @cookies.map(&:to_hash),
|
26
27
|
}
|
27
28
|
|
28
29
|
Response.new(
|
@@ -34,6 +35,10 @@ module Bogeyman
|
|
34
35
|
)
|
35
36
|
)
|
36
37
|
)
|
38
|
+
rescue Errno::ECONNREFUSED
|
39
|
+
raise RuntimeError.new(
|
40
|
+
"Bogeyman.js server is not running at #{@server}"
|
41
|
+
)
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module Bogeyman
|
4
|
+
class Cookie
|
5
|
+
REQUIRED = [:name, :value, :domain]
|
6
|
+
|
7
|
+
def initialize params={}
|
8
|
+
@params = params
|
9
|
+
validate
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_hash
|
13
|
+
{
|
14
|
+
name: @params[:name],
|
15
|
+
value: @params[:value],
|
16
|
+
domain: @params[:domain],
|
17
|
+
path: @params[:path] || '/',
|
18
|
+
httponly: @params[:httponly] || false,
|
19
|
+
secure: @params[:secure] || false,
|
20
|
+
expires: (@params[:expires] || Time.now.to_i + 3600)*1000,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def validate
|
27
|
+
REQUIRED.each do |attr|
|
28
|
+
next if @params.include?(attr)
|
29
|
+
raise ArgumentError.new("#{attr} required in cookie hash")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bogeyman/version.rb
CHANGED
data/lib/bogeyman.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bogeyman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rene Klacan
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/bogeyman/response.rb
|
62
62
|
- lib/bogeyman/client.rb
|
63
63
|
- lib/bogeyman/version.rb
|
64
|
+
- lib/bogeyman/cookie.rb
|
64
65
|
- lib/bogeyman.rb
|
65
66
|
- README.md
|
66
67
|
homepage: https://github.com/reneklacan/bogeyman
|