bogeyman 0.0.1 → 0.0.2

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: 2eb68c19d409fa417daab614f90096339619ed9b
4
- data.tar.gz: 8aed3ec07f6f3d7d6f48dd99871c97fb9ec34ffb
3
+ metadata.gz: 625872cca43376ec239d79f030d6c15413ca6202
4
+ data.tar.gz: b3442d45b21396e1cf0c14961a312569cbaff28b
5
5
  SHA512:
6
- metadata.gz: b6f7db6ecb1ad5d951d057076b3cf9859ce9388e4fbdd371bb86404bcf05d637767cc0fd56d2ef6c7a737f56b08d2caaac3f3949d77e9dc2e072b7275b49c96d
7
- data.tar.gz: 2bbfe74ea5558a53b9e63e2e039f37f61ef2901b523baf1b2909496f7a827d297c490f0186dea27b8710b40b4a1802be27f90375d8be30ef8d5d873a379fe3dc
6
+ metadata.gz: 0c211c9503823b24d6dc10c153f191d2f5a7692749c696d680ab5ba2e081c00f6893f5b7b854f0625b3305fe472784c883ad6abc9a39700c5b3e6b1fbdaa12af
7
+ data.tar.gz: 80df69a7256b3434d08dd92017ea71d8af0642a65a11f3f9342a41c740c14fc2ab9266c53404bb623f06ef73e486c2a17498c969ba79c16a175e390d7eb4591d
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Bogeyman Ruby Client
2
+
3
+ Bogeyman is Ruby client for
4
+ [Bogeyman.js](https://github.com/reneklacan/bogeyman.js)
5
+ which is server application providing headless **crawling
6
+ of heavy javascript web sites** via REST API.
7
+
8
+ ## Installation
9
+
10
+ You can install it via gem
11
+
12
+ ```bash
13
+ gem install bogeyman
14
+ ```
15
+
16
+ Or you can put it in your Gemfile
17
+
18
+ ```ruby
19
+ gem 'bogeyman', '~> 0.0.2'
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ At first make sure that your server is installed and running
25
+
26
+ ```bash
27
+ npm install -g bogeyman # install it
28
+ bogeyman # start it
29
+ ```
30
+
31
+ For more information about server follow [this
32
+ link](https://github.com/reneklacan/bogeyman.js)
33
+
34
+ So when your server is set up then you can do
35
+
36
+ ```ruby
37
+ require 'bogeyman'
38
+
39
+ client = Bogeyman::Client.new
40
+ client.post 'http://example.com', param1: 'abc'
41
+ client.get 'http://example.com'
42
+ ```
43
+
44
+ Or if you require advanced options
45
+
46
+ ```ruby
47
+ client = Bogeyman::Client.new(
48
+ host: 'bogeyman.com', # default: 'localhost'
49
+ port: 12345, # default: 12345
50
+ proxy: '127.0.0.1:41414', # default: nil
51
+ proxy_type: 'socks5', # default: 'http'
52
+ proxy_auth: 'user:passwd', # default: nil
53
+ disk_cache: true, # default: false
54
+ max_disk_cache_size: '1024', # default: nil
55
+ ssl_protocol: 'any', # default: 'sslv3'
56
+ ssl_certificates-path: '...', # default: system default
57
+ web_security: true, # default: false
58
+ )
59
+ ```
60
+
61
+ For more information you can take a look at
62
+ [Bogeyman.js](https://github.com/reneklacan/bogeyman.js) or [PhantomJS
63
+ API Reference](https://github.com/ariya/phantomjs/wiki/API-Reference).
64
+
65
+ ## License
66
+
67
+ This library is distributed under the Beerware license.
@@ -3,13 +3,27 @@
3
3
  module Bogeyman
4
4
  class Client
5
5
  def initialize params={}
6
+ host = params.delete(:host) || 'localhost'
7
+ port = params.delete(:port) || 31313
8
+
9
+ @server = "http://#{host}:#{port}"
6
10
  @params = params
7
- @server = 'http://localhost:31313'
8
11
  end
9
12
 
10
- def get url, params={}
11
- params = @params.dup.update(params)
12
- params.update(method: 'GET', url: url)
13
+ [:get, :post, :patch, :delete].each do |method|
14
+ define_method method do |url, data={}|
15
+ request(method, url, data)
16
+ end
17
+ end
18
+
19
+ protected
20
+
21
+ def request method, url, data
22
+ params = {
23
+ method: method,
24
+ url: url,
25
+ params: @params,
26
+ }
13
27
 
14
28
  Response.new(
15
29
  JSON.parse(
@@ -1,3 +1,3 @@
1
1
  module Bogeyman
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rene Klacan
@@ -62,6 +62,7 @@ files:
62
62
  - lib/bogeyman/client.rb
63
63
  - lib/bogeyman/version.rb
64
64
  - lib/bogeyman.rb
65
+ - README.md
65
66
  homepage: https://github.com/reneklacan/bogeyman
66
67
  licenses:
67
68
  - Beerware