poxy_client 0.0.1.pre.2 → 0.0.1
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 +7 -0
- data/Gemfile +0 -1
- data/README.html +167 -0
- data/README.md +15 -28
- data/Rakefile +7 -0
- data/bin/poxyd.rb +15 -6
- data/lib/poxy_client.rb +6 -6
- data/lib/poxy_client/configuration.rb +3 -7
- data/lib/poxy_client/processor.rb +14 -5
- data/lib/poxy_client/repeater.rb +5 -2
- data/lib/poxy_client/retriever.rb +37 -17
- data/lib/poxy_client/version.rb +1 -1
- data/poxy.conf +4 -5
- data/poxy_client.gemspec +5 -3
- data/test/test_poxy_bin.rb +179 -5
- data/test/test_poxy_client.rb +35 -6
- data/test/test_poxy_processor.rb +149 -7
- data/test/test_poxy_repeater.rb +10 -7
- data/test/test_poxy_retriever.rb +19 -7
- metadata +61 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a2d95e8f4d82de16c409ca25d31189de6936ea5
|
4
|
+
data.tar.gz: ec9b55d164d4ddbe83b9f76c9bb07c621b40c440
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d00729245b8e84baaf42f6c2e49dc36dbfa1fa1de3ba56a3e143c5c95286cb1aa6d0bf78679cffef6aedd2ba78be0e0e1f7dd9788eabf3e87fc8f8335590125d
|
7
|
+
data.tar.gz: d4eabdcdd002f778ce863ee8ce98855a57dc1075f04180f4059921f6f80bab145b7e68ad5913e3ec177932b01cee66537aa413f7085ddc60ca2aa53d2d3a9af0
|
data/Gemfile
CHANGED
data/README.html
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><style>html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
|
2
|
+
|
3
|
+
body{
|
4
|
+
color:#444;
|
5
|
+
font-family:Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman',
|
6
|
+
"Hiragino Sans GB", "STXihei", "微软雅黑", serif;
|
7
|
+
font-size:12px;
|
8
|
+
line-height:1.5em;
|
9
|
+
background:#fefefe;
|
10
|
+
width: 45em;
|
11
|
+
margin: 10px auto;
|
12
|
+
padding: 1em;
|
13
|
+
outline: 1300px solid #FAFAFA;
|
14
|
+
}
|
15
|
+
|
16
|
+
a{ color: #0645ad; text-decoration:none;}
|
17
|
+
a:visited{ color: #0b0080; }
|
18
|
+
a:hover{ color: #06e; }
|
19
|
+
a:active{ color:#faa700; }
|
20
|
+
a:focus{ outline: thin dotted; }
|
21
|
+
a:hover, a:active{ outline: 0; }
|
22
|
+
|
23
|
+
span.backtick {
|
24
|
+
border:1px solid #EAEAEA;
|
25
|
+
border-radius:3px;
|
26
|
+
background:#F8F8F8;
|
27
|
+
padding:0 3px 0 3px;
|
28
|
+
}
|
29
|
+
|
30
|
+
::-moz-selection{background:rgba(255,255,0,0.3);color:#000}
|
31
|
+
::selection{background:rgba(255,255,0,0.3);color:#000}
|
32
|
+
|
33
|
+
a::-moz-selection{background:rgba(255,255,0,0.3);color:#0645ad}
|
34
|
+
a::selection{background:rgba(255,255,0,0.3);color:#0645ad}
|
35
|
+
|
36
|
+
p{
|
37
|
+
margin:1em 0;
|
38
|
+
}
|
39
|
+
|
40
|
+
img{
|
41
|
+
max-width:100%;
|
42
|
+
}
|
43
|
+
|
44
|
+
h1,h2,h3,h4,h5,h6{
|
45
|
+
font-weight:normal;
|
46
|
+
color:#111;
|
47
|
+
line-height:1em;
|
48
|
+
}
|
49
|
+
h4,h5,h6{ font-weight: bold; }
|
50
|
+
h1{ font-size:2.5em; }
|
51
|
+
h2{ font-size:2em; border-bottom:1px solid silver; padding-bottom: 5px; }
|
52
|
+
h3{ font-size:1.5em; }
|
53
|
+
h4{ font-size:1.2em; }
|
54
|
+
h5{ font-size:1em; }
|
55
|
+
h6{ font-size:0.9em; }
|
56
|
+
|
57
|
+
blockquote{
|
58
|
+
color:#666666;
|
59
|
+
margin:0;
|
60
|
+
padding-left: 3em;
|
61
|
+
border-left: 0.5em #EEE solid;
|
62
|
+
}
|
63
|
+
hr { display: block; height: 2px; border: 0; border-top: 1px solid #aaa;border-bottom: 1px solid #eee; margin: 1em 0; padding: 0; }
|
64
|
+
|
65
|
+
|
66
|
+
pre , code, kbd, samp {
|
67
|
+
color: #000;
|
68
|
+
font-family: monospace;
|
69
|
+
font-size: 0.88em;
|
70
|
+
border-radius:3px;
|
71
|
+
background-color: #F8F8F8;
|
72
|
+
border: 1px solid #CCC;
|
73
|
+
}
|
74
|
+
pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; padding: 5px 12px;}
|
75
|
+
pre code { border: 0px !important; padding: 0;}
|
76
|
+
code { padding: 0 3px 0 3px; }
|
77
|
+
|
78
|
+
b, strong { font-weight: bold; }
|
79
|
+
|
80
|
+
dfn { font-style: italic; }
|
81
|
+
|
82
|
+
ins { background: #ff9; color: #000; text-decoration: none; }
|
83
|
+
|
84
|
+
mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
|
85
|
+
|
86
|
+
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
|
87
|
+
sup { top: -0.5em; }
|
88
|
+
sub { bottom: -0.25em; }
|
89
|
+
|
90
|
+
ul, ol { margin: 1em 0; padding: 0 0 0 2em; }
|
91
|
+
li p:last-child { margin:0 }
|
92
|
+
dd { margin: 0 0 0 2em; }
|
93
|
+
|
94
|
+
img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
|
95
|
+
|
96
|
+
table { border-collapse: collapse; border-spacing: 0; }
|
97
|
+
td { vertical-align: top; }
|
98
|
+
|
99
|
+
@media only screen and (min-width: 480px) {
|
100
|
+
body{font-size:14px;}
|
101
|
+
}
|
102
|
+
|
103
|
+
@media only screen and (min-width: 768px) {
|
104
|
+
body{font-size:16px;}
|
105
|
+
}
|
106
|
+
|
107
|
+
@media print {
|
108
|
+
* { background: transparent !important; color: black !important; filter:none !important; -ms-filter: none !important; }
|
109
|
+
body{font-size:12pt; max-width:100%; outline:none;}
|
110
|
+
a, a:visited { text-decoration: underline; }
|
111
|
+
hr { height: 1px; border:0; border-bottom:1px solid black; }
|
112
|
+
a[href]:after { content: " (" attr(href) ")"; }
|
113
|
+
abbr[title]:after { content: " (" attr(title) ")"; }
|
114
|
+
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
|
115
|
+
pre, blockquote { border: 1px solid #999; padding-right: 1em; page-break-inside: avoid; }
|
116
|
+
tr, img { page-break-inside: avoid; }
|
117
|
+
img { max-width: 100% !important; }
|
118
|
+
@page :left { margin: 15mm 20mm 15mm 10mm; }
|
119
|
+
@page :right { margin: 15mm 10mm 15mm 20mm; }
|
120
|
+
p, h2, h3 { orphans: 3; widows: 3; }
|
121
|
+
h2, h3 { page-break-after: avoid; }
|
122
|
+
}
|
123
|
+
</style><title>README</title></head><body><h1 id="poxy_client">poxy_client</h1>
|
124
|
+
<p>Poxy (http://poxy.ws) is a web application that captures web requests to let you do fun stuff with them.</p>
|
125
|
+
<p>Fun things like proxying, forwarding, emailing and some sort of processing (soon!).</p>
|
126
|
+
<p>In order to use it first you'll need to <a href="http://poxy.porta.sh/users/sign_up">create an account</a> into the site.</p>
|
127
|
+
<h2 id="installation">Installation</h2>
|
128
|
+
<h3 id="bundler">Bundler</h3>
|
129
|
+
<p>Add this line to your application's Gemfile:</p>
|
130
|
+
<pre><code>gem 'poxy_client'
|
131
|
+
</code></pre>
|
132
|
+
<p>And then execute:</p>
|
133
|
+
<pre><code>$ bundle
|
134
|
+
</code></pre>
|
135
|
+
<h3 id="manual">Manual</h3>
|
136
|
+
<pre><code>$ gem install poxy_client
|
137
|
+
</code></pre>
|
138
|
+
<h2 id="usage">Usage</h2>
|
139
|
+
<p>There are a few different ways to use the client.</p>
|
140
|
+
<p>The distribution includes an executable file that you can use. It requires a .config file.</p>
|
141
|
+
<p>Or, you can implement your own client suited to your particular needs. Take a look at the executable file, or check the code documentation.</p>
|
142
|
+
<h2 id="api-blueprint">API Blueprint</h2>
|
143
|
+
<p>Courtesy of the great service <a href="http://apiary.io/">Apiary.io</a>, here it is:
|
144
|
+
(http://docs.poxy.apiary.io/)</p>
|
145
|
+
<h3 id="executable">Executable</h3>
|
146
|
+
<p>In the /lib folder of the distribution, there's a file named {file:bin/poxyd.rb poxyd.rb} which you can run from the commandline.</p>
|
147
|
+
<p>It requires a mandatory config file (included in the distribution you'll find a sample one, here {file:poxy.conf ./poxy.conf}).</p>
|
148
|
+
<p>You can use that as a start (it points to a test endpoint in the poxy api).</p>
|
149
|
+
<p>Optionally, you can pass a -d parameter, and the executable will run as a daemon.</p>
|
150
|
+
<p>Sample run:</p>
|
151
|
+
<pre><code>$ ruby poxyd.rb -c poxy.conf -d
|
152
|
+
</code></pre>
|
153
|
+
<p>Being poxy.conf a config file with your own API and Bucket keys.</p>
|
154
|
+
<h3 id="custom-implementation">Custom implementation</h3>
|
155
|
+
<p>The code for {PoxyClient poxy_client} it's pretty straightforward.</p>
|
156
|
+
<p>The {PoxyClient.perform perform} method encapsulates the 3 important operations the client does.</p>
|
157
|
+
<h4 id="retrieve">Retrieve</h4>
|
158
|
+
<h4 id="parse">Parse</h4>
|
159
|
+
<h4 id="repeat">Repeat</h4>
|
160
|
+
<h2 id="contributing">Contributing</h2>
|
161
|
+
<ol>
|
162
|
+
<li>Fork it</li>
|
163
|
+
<li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
|
164
|
+
<li>Commit your changes (<code>git commit -am 'Added some feature'</code>)</li>
|
165
|
+
<li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
|
166
|
+
<li>Create new Pull Request</li>
|
167
|
+
</ol></body></html>
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# poxy_client
|
2
2
|
|
3
|
-
Poxy
|
3
|
+
[Poxy](http://poxy.ws) is a web application that captures HTTP requests to let you do fun stuff with them.
|
4
4
|
|
5
|
-
Fun things like forwarding, emailing and some sort of processing (soon!).
|
5
|
+
Fun things like proxying, forwarding, emailing and some sort of processing (soon!).
|
6
6
|
|
7
|
-
In order to use it
|
7
|
+
In order to use it first you'll need to [create an account](http://poxy.ws/register) into the site.
|
8
8
|
|
9
9
|
|
10
10
|
## Installation
|
@@ -23,20 +23,26 @@ And then execute:
|
|
23
23
|
|
24
24
|
$ gem install poxy_client
|
25
25
|
|
26
|
+
## API Blueprint and Documentation
|
27
|
+
|
28
|
+
Courtesy of the great service [Apiary.io](http://apiary.io/), here it is:
|
29
|
+
[http://docs.poxy.apiary.io/](http://docs.poxy.apiary.io/)
|
30
|
+
|
26
31
|
## Usage
|
27
32
|
|
28
33
|
There are a few different ways to use the client.
|
29
34
|
|
30
|
-
The distribution includes
|
35
|
+
The distribution includes an executable file that you can use. It requires a .config file.
|
31
36
|
|
32
37
|
Or, you can implement your own client suited to your particular needs. Take a look at the executable file, or check the code documentation.
|
33
38
|
|
34
39
|
|
40
|
+
|
35
41
|
### Executable
|
36
42
|
|
37
|
-
In the /lib folder of the distribution, there's a file named
|
43
|
+
In the /lib folder of the distribution, there's a file named [poxyd.rb](bin/poxyd.rb) which you can run from the commandline.
|
38
44
|
|
39
|
-
It requires a mandatory config file (included in the distribution you'll find a sample one, here
|
45
|
+
It requires a mandatory config file (included in the distribution you'll find a sample one, here [poxy.conf](./poxy.conf).
|
40
46
|
|
41
47
|
You can use that as a start (it points to a test endpoint in the poxy api).
|
42
48
|
|
@@ -46,13 +52,13 @@ Sample run:
|
|
46
52
|
|
47
53
|
$ ruby poxyd.rb -c poxy.conf -d
|
48
54
|
|
49
|
-
Being poxy.conf a config file with your own API
|
55
|
+
Being poxy.conf a config file with your own API key.
|
50
56
|
|
51
57
|
### Custom implementation
|
52
58
|
|
53
|
-
|
59
|
+
The code for PoxyClient it's pretty straightforward.
|
54
60
|
|
55
|
-
The
|
61
|
+
The [PoxyClient#perform](lib/poxy_client.rb#L43) method encapsulates the 3 operations the client performs in order to retrieve, process and repeat a request.
|
56
62
|
|
57
63
|
#### Retrieve
|
58
64
|
|
@@ -68,22 +74,3 @@ The {PoxyClient.perform perform} method encapsulates the 3 important operations
|
|
68
74
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
69
75
|
4. Push to the branch (`git push origin my-new-feature`)
|
70
76
|
5. Create new Pull Request
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
data/Rakefile
CHANGED
data/bin/poxyd.rb
CHANGED
@@ -25,11 +25,19 @@ args = Clap.run ARGV,
|
|
25
25
|
},
|
26
26
|
"-d" => lambda {
|
27
27
|
opts[:daemonize] = true
|
28
|
+
},
|
29
|
+
"-v" => lambda {
|
30
|
+
opts[:version] = true
|
28
31
|
}
|
29
32
|
|
30
33
|
$stdout.sync = true
|
31
34
|
|
32
35
|
|
36
|
+
if opts[:version]
|
37
|
+
puts "PoxyClient daemon, version: #{PoxyClient::VERSION}"
|
38
|
+
@continue = false
|
39
|
+
end
|
40
|
+
|
33
41
|
if opts[:daemonize]
|
34
42
|
pid_path = File.expand_path("poxy.pid", File.dirname(__FILE__))
|
35
43
|
Process.daemon(true)
|
@@ -47,20 +55,21 @@ if opts[:config_file]
|
|
47
55
|
|
48
56
|
PoxyClient.configure do |c|
|
49
57
|
c.origin = config["origin"]
|
50
|
-
c.api_key = config["
|
51
|
-
c.bucket_key = config["bucket"]
|
58
|
+
c.api_key = config["api_key"]
|
52
59
|
c.destination = config["destination"]
|
53
60
|
end
|
54
61
|
|
62
|
+
else
|
63
|
+
@continue = false
|
55
64
|
end
|
56
65
|
|
57
66
|
|
58
67
|
|
59
68
|
#run code here
|
60
69
|
while @continue do
|
61
|
-
#requests = PoxyClient.retriever.get(:
|
62
|
-
#parsed = PoxyClient.processor.parse(requests)
|
63
|
-
#result = PoxyClient.repeater.set(parsed)
|
64
|
-
PoxyClient.perform
|
70
|
+
# requests = PoxyClient.retriever.get(:starred => true)
|
71
|
+
# parsed = PoxyClient.processor.parse(requests)
|
72
|
+
# result = PoxyClient.repeater.set(parsed)
|
73
|
+
PoxyClient.perform(:starred => true)
|
65
74
|
sleep config["interval"].to_i
|
66
75
|
end
|
data/lib/poxy_client.rb
CHANGED
@@ -37,17 +37,17 @@ module PoxyClient
|
|
37
37
|
|
38
38
|
# Encapsulates the three important operations. Retrieve, Process and Repeat
|
39
39
|
#
|
40
|
-
# @param [
|
41
|
-
# Options are :
|
40
|
+
# @param [Hash] which kind of requests we should get from the API
|
41
|
+
# Options are :
|
42
42
|
# @return [Array] With the responses received in the destination server.
|
43
|
-
def perform(
|
43
|
+
def perform(options = {}) #TODO: FIX DOCS
|
44
44
|
# Retrieve all the available requests from the site API
|
45
|
-
requests = PoxyClient.retriever.get(
|
45
|
+
requests = PoxyClient.retriever.get( options )
|
46
46
|
# Parse those requests to JSON.
|
47
|
-
parsed = PoxyClient.processor.parse(requests)
|
47
|
+
parsed = PoxyClient.processor.parse( requests )
|
48
48
|
# Repeat the retrieved and parsed requests to (usually) localhost.
|
49
49
|
# Check the sample poxy.conf file.
|
50
|
-
result = PoxyClient.repeater.set(parsed)
|
50
|
+
result = PoxyClient.repeater.set( parsed )
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
module PoxyClient
|
2
2
|
class Configuration
|
3
|
-
OPTIONS = [:api_key, :
|
3
|
+
OPTIONS = [:api_key, :origin, :destination, :mode, :retriever_version].freeze
|
4
4
|
|
5
5
|
attr_accessor :api_key
|
6
|
-
attr_accessor :bucket_key
|
7
6
|
attr_accessor :origin
|
8
7
|
attr_accessor :destination
|
9
|
-
attr_accessor :method
|
10
|
-
|
11
8
|
attr_accessor :mode
|
12
9
|
attr_accessor :retriever_version
|
13
10
|
|
14
11
|
def initialize
|
15
|
-
@origin = 'http://poxy.
|
16
|
-
@destination = 'http://
|
12
|
+
@origin = 'http://poxy.ws'
|
13
|
+
@destination = 'http://home.herokuapp.com/'
|
17
14
|
@mode = 'development'
|
18
|
-
@method = 'post'
|
19
15
|
@retriever_version = VERSION
|
20
16
|
end
|
21
17
|
|
@@ -5,23 +5,32 @@ module PoxyClient
|
|
5
5
|
|
6
6
|
end
|
7
7
|
|
8
|
+
# Parse the JSON encoded string from the retriever and generates an Object
|
9
|
+
#
|
10
|
+
# @param [String] content The JSON encoded string from the retriever.
|
11
|
+
# @return [Array] The list of items retrieved
|
8
12
|
def parse(content)
|
9
|
-
@response =
|
13
|
+
@response = []
|
10
14
|
if ( content.respond_to?(:body) )
|
11
15
|
@response = JSON.parse(content.body)
|
12
16
|
else
|
13
17
|
@response = JSON.parse(content)
|
14
18
|
end
|
15
|
-
@
|
16
|
-
|
17
|
-
end
|
18
|
-
@response
|
19
|
+
@complete_items = @response["items"]
|
20
|
+
@raw_items = @response["items"].map{|i| i['raw']}
|
19
21
|
end
|
20
22
|
|
21
23
|
def response
|
22
24
|
@response
|
23
25
|
end
|
24
26
|
|
27
|
+
def complete_items
|
28
|
+
@complete_items
|
29
|
+
end
|
30
|
+
|
31
|
+
def raw_items
|
32
|
+
@raw_items
|
33
|
+
end
|
25
34
|
|
26
35
|
end
|
27
36
|
end
|
data/lib/poxy_client/repeater.rb
CHANGED
@@ -10,13 +10,17 @@ module PoxyClient
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
# Generates and send requests retrieved from the API
|
14
|
+
#
|
15
|
+
# @param [Array] json_array with parsed requests
|
16
|
+
# @return [Array] responses from server to each request
|
13
17
|
def set(json_array)
|
14
18
|
@result = []
|
15
19
|
@connector = PoxyClient::Connector.new()
|
16
20
|
json_array.each do |params|
|
17
21
|
@connector.connect do |request|
|
18
22
|
request.method = params["method"]
|
19
|
-
request.url = @destination
|
23
|
+
request.url = @destination + '?' + params["query_string"].to_s
|
20
24
|
request.headers = params["headers"]
|
21
25
|
request.body = params["params"]
|
22
26
|
end
|
@@ -24,6 +28,5 @@ module PoxyClient
|
|
24
28
|
end
|
25
29
|
@result
|
26
30
|
end
|
27
|
-
|
28
31
|
end
|
29
32
|
end
|
@@ -8,28 +8,57 @@ module PoxyClient
|
|
8
8
|
attr_reader :mode
|
9
9
|
attr_reader :retriever_version
|
10
10
|
|
11
|
-
REQUESTS_URI = '/api/
|
11
|
+
REQUESTS_URI = '/api/requests?'.freeze
|
12
12
|
|
13
13
|
def initialize(options = {})
|
14
14
|
[ :api_key,
|
15
|
-
:bucket_key,
|
16
15
|
:origin,
|
17
16
|
:mode,
|
18
17
|
:retriever_version
|
19
18
|
].each do |option|
|
20
19
|
instance_variable_set("@#{option}", options[option])
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
24
22
|
|
25
23
|
|
26
|
-
|
24
|
+
#Retrieves requests from API.
|
25
|
+
# @param [Symbol] how_many which requests to retrieve from the API.
|
26
|
+
# Options are :new, :all, :first, :last, :starred, :unstarred, :archived
|
27
|
+
# @return [String] A JSON encoded array of requests.
|
28
|
+
def get(options = {})
|
27
29
|
#TODO: move to a factory
|
30
|
+
copy = {}
|
31
|
+
|
32
|
+
if options.has_key? :starred
|
33
|
+
copy[:starred] = options[:starred].to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
if options.has_key? :archived
|
37
|
+
copy[:archived] = options[:archived].to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
if options.has_key? :bucket_ids
|
41
|
+
copy[:bucket_ids] = options[:bucket_ids]
|
42
|
+
end
|
43
|
+
if options.has_key? :search
|
44
|
+
copy[:search] = options[:search].downcase
|
45
|
+
end
|
46
|
+
|
47
|
+
if options.has_key? :page
|
48
|
+
copy[:page] = options[:page]
|
49
|
+
end
|
50
|
+
|
51
|
+
if options.has_key? :per_page
|
52
|
+
copy[:per_page] = options[:per_page]
|
53
|
+
end
|
54
|
+
|
55
|
+
query = Rack::Utils.build_nested_query(copy)
|
56
|
+
|
28
57
|
@connector = PoxyClient::Connector.new
|
29
58
|
@connector.connect do |request|
|
30
|
-
request.method = :
|
31
|
-
request.url =
|
32
|
-
request.
|
59
|
+
request.method = :get
|
60
|
+
request.url = build_url(query)
|
61
|
+
request.auth.basic(@api_key, "")
|
33
62
|
end
|
34
63
|
@connector.response
|
35
64
|
end
|
@@ -38,18 +67,9 @@ module PoxyClient
|
|
38
67
|
protected
|
39
68
|
|
40
69
|
def build_url(how_many)
|
41
|
-
@origin + REQUESTS_URI + how_many
|
70
|
+
@origin + REQUESTS_URI + how_many
|
42
71
|
end
|
43
72
|
|
44
73
|
|
45
74
|
end
|
46
75
|
end
|
47
|
-
|
48
|
-
__END__
|
49
|
-
require 'json'
|
50
|
-
|
51
|
-
requests = JSON.parse(response.body)
|
52
|
-
requests.each do |r|
|
53
|
-
rp = JSON.parse(r)
|
54
|
-
puts rp['body']
|
55
|
-
end
|
data/lib/poxy_client/version.rb
CHANGED
data/poxy.conf
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
interval=10
|
1
|
+
api_key=3acb90c157c9f
|
2
|
+
origin=http://poxy.ws
|
3
|
+
destination=http://localhost:9292/
|
4
|
+
interval=10
|
data/poxy_client.gemspec
CHANGED
@@ -4,14 +4,16 @@ require File.expand_path('../lib/poxy_client/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Julian Porta"]
|
6
6
|
gem.email = ["julian@porta.sh"]
|
7
|
-
gem.description = %q{Client for Poxy (the
|
7
|
+
gem.description = %q{Client for Poxy (the http inbox)}
|
8
8
|
gem.summary = %q{Poxy is a website that captures requests and lets you do fun stuff with them}
|
9
|
-
gem.homepage = "
|
10
|
-
gem.post_install_message = %q{Thanks for installing poxy_client. Make sure to create an account at http://poxy.
|
9
|
+
gem.homepage = "https://github.com/Porta/poxy_client"
|
10
|
+
gem.post_install_message = %q{Thanks for installing poxy_client. Make sure to create an account at http://poxy.ws}
|
11
11
|
|
12
12
|
gem.add_runtime_dependency "httpi", [">= 1.0.0"]
|
13
13
|
gem.add_runtime_dependency "clap", [">= 0.0.2"]
|
14
14
|
gem.add_development_dependency "test-unit"
|
15
|
+
gem.add_development_dependency "rake"
|
16
|
+
gem.add_development_dependency "curb"
|
15
17
|
|
16
18
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
19
|
gem.files = `git ls-files`.split("\n")
|
data/test/test_poxy_bin.rb
CHANGED
@@ -1,7 +1,181 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require 'json'
|
1
|
+
# require "cutest"
|
2
|
+
# require "redis"
|
4
3
|
|
5
|
-
|
4
|
+
# at_exit {
|
5
|
+
# Process.waitall
|
6
|
+
# }
|
6
7
|
|
7
|
-
|
8
|
+
# def wait_for_pid(pid)
|
9
|
+
# running = true
|
10
|
+
|
11
|
+
# while running
|
12
|
+
# begin
|
13
|
+
# Process.kill(0, pid)
|
14
|
+
# rescue Errno::ESRCH
|
15
|
+
# running = false
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
|
20
|
+
# def root(path)
|
21
|
+
# File.expand_path("../#{path}", File.dirname(__FILE__))
|
22
|
+
# end
|
23
|
+
|
24
|
+
# redis = Redis.connect
|
25
|
+
|
26
|
+
# test "daemon, implicit start" do
|
27
|
+
# r, w = IO.pipe
|
28
|
+
# pid = nil
|
29
|
+
|
30
|
+
# begin
|
31
|
+
# redis.flushdb
|
32
|
+
|
33
|
+
# pid = spawn("#{root("bin/ost")} echo", out: w, chdir: "test")
|
34
|
+
|
35
|
+
# redis.rpush("ost:echo", 1)
|
36
|
+
|
37
|
+
# assert_equal "1\n", r.gets
|
38
|
+
# ensure
|
39
|
+
# Process.kill(:INT, pid) if pid
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# test "daemon, explicit start" do
|
44
|
+
# r, w = IO.pipe
|
45
|
+
# pid = nil
|
46
|
+
|
47
|
+
# begin
|
48
|
+
# redis.flushdb
|
49
|
+
|
50
|
+
# pid = spawn("#{root("bin/ost")} start echo", out: w, chdir: "test")
|
51
|
+
|
52
|
+
# redis.rpush("ost:echo", 2)
|
53
|
+
|
54
|
+
# assert_equal "2\n", r.gets
|
55
|
+
# ensure
|
56
|
+
# Process.kill(:INT, pid) if pid
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
|
60
|
+
# test "daemonizes" do
|
61
|
+
# r, w = IO.pipe
|
62
|
+
# pid, detached_pid = nil
|
63
|
+
|
64
|
+
# redis.flushdb
|
65
|
+
|
66
|
+
# begin
|
67
|
+
# pid = spawn("#{root("bin/ost")} -d echo", out: w, chdir: "test")
|
68
|
+
|
69
|
+
# sleep 1
|
70
|
+
|
71
|
+
# state = `ps -p #{pid} -o state`.lines.to_a.last[/(\w+)/, 1]
|
72
|
+
|
73
|
+
# assert_equal "Z", state
|
74
|
+
|
75
|
+
# pid_path = "./test/workers/echo.pid"
|
76
|
+
|
77
|
+
# assert File.exist?(pid_path)
|
78
|
+
|
79
|
+
# detached_pid = File.read(pid_path).to_i
|
80
|
+
|
81
|
+
# ppid = `ps -p #{detached_pid} -o ppid`.lines.to_a.last[/(\d+)/, 1]
|
82
|
+
|
83
|
+
# assert_equal "1", ppid
|
84
|
+
# ensure
|
85
|
+
# Process.kill(:INT, pid) if pid
|
86
|
+
# Process.kill(:INT, detached_pid) if detached_pid
|
87
|
+
# end
|
88
|
+
|
89
|
+
# wait_for_pid(detached_pid)
|
90
|
+
|
91
|
+
# assert !File.exist?(pid_path)
|
92
|
+
# end
|
93
|
+
|
94
|
+
# test "gracefully handles TERM signals" do
|
95
|
+
# r, w = IO.pipe
|
96
|
+
# pid, detached_pid = nil
|
97
|
+
|
98
|
+
# redis.flushdb
|
99
|
+
|
100
|
+
# pid_path = "./test/workers/slow.pid"
|
101
|
+
|
102
|
+
# begin
|
103
|
+
# redis.rpush("ost:slow", 5)
|
104
|
+
|
105
|
+
# pid = spawn("#{root("bin/ost")} -d slow", out: w, chdir: "test")
|
106
|
+
|
107
|
+
# until File.exist?(pid_path)
|
108
|
+
# sleep 0.5
|
109
|
+
# end
|
110
|
+
|
111
|
+
# detached_pid = File.read(pid_path).to_i
|
112
|
+
|
113
|
+
# Process.kill(:TERM, detached_pid)
|
114
|
+
# ensure
|
115
|
+
# Process.kill(:INT, pid)
|
116
|
+
# end
|
117
|
+
|
118
|
+
# wait_for_pid(detached_pid)
|
119
|
+
|
120
|
+
# assert_equal "5", redis.get("slow")
|
121
|
+
# end
|
122
|
+
|
123
|
+
# test "stops worker from command line action" do
|
124
|
+
# r, w = IO.pipe
|
125
|
+
# pid, detached_pid = nil
|
126
|
+
|
127
|
+
# redis.flushdb
|
128
|
+
|
129
|
+
# pid_path = "./test/workers/killme.pid"
|
130
|
+
|
131
|
+
# pid = spawn("#{root("bin/ost")} start -d killme", out: w, err: w, chdir: "test")
|
132
|
+
|
133
|
+
# sleep 1
|
134
|
+
|
135
|
+
# until File.exist?(pid_path)
|
136
|
+
# sleep 0.5
|
137
|
+
# end
|
138
|
+
|
139
|
+
# detached_pid = File.read(pid_path).to_i
|
140
|
+
|
141
|
+
# spawn("#{root("bin/ost")} kill killme", chdir: "test")
|
142
|
+
|
143
|
+
# wait_for_pid(detached_pid)
|
144
|
+
|
145
|
+
# assert_equal "YES", redis.get("killme")
|
146
|
+
# end
|
147
|
+
|
148
|
+
# test "use a different dir for pids" do
|
149
|
+
# r, w = IO.pipe
|
150
|
+
# pid, detached_pid = nil
|
151
|
+
|
152
|
+
# redis.flushdb
|
153
|
+
|
154
|
+
# begin
|
155
|
+
# pid = spawn("#{root("bin/ost")} -d echo -p tmp", out: w, chdir: "test")
|
156
|
+
|
157
|
+
# sleep 1
|
158
|
+
|
159
|
+
# state = `ps -p #{pid} -o state`.lines.to_a.last[/(\w+)/, 1]
|
160
|
+
|
161
|
+
# assert_equal "Z", state
|
162
|
+
|
163
|
+
# pid_path = "./test/tmp/echo.pid"
|
164
|
+
|
165
|
+
# assert File.exist?(pid_path)
|
166
|
+
|
167
|
+
# detached_pid = File.read(pid_path).to_i
|
168
|
+
|
169
|
+
# ppid = `ps -p #{detached_pid} -o ppid`.lines.to_a.last[/(\d+)/, 1]
|
170
|
+
|
171
|
+
# assert_equal "1", ppid
|
172
|
+
# ensure
|
173
|
+
# Process.kill(:INT, pid) if pid
|
174
|
+
# Process.kill(:INT, detached_pid) if detached_pid
|
175
|
+
# end
|
176
|
+
|
177
|
+
# wait_for_pid(detached_pid)
|
178
|
+
|
179
|
+
# assert !File.exist?(pid_path)
|
180
|
+
|
181
|
+
# end
|
data/test/test_poxy_client.rb
CHANGED
@@ -5,7 +5,7 @@ require 'json'
|
|
5
5
|
class PoxyClientTest < Test::Unit::TestCase
|
6
6
|
|
7
7
|
def test_version
|
8
|
-
assert_equal PoxyClient::VERSION, '0.0.1
|
8
|
+
assert_equal PoxyClient::VERSION, '0.0.1'
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_config_version
|
@@ -15,16 +15,45 @@ class PoxyClientTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
def test_config_block
|
17
17
|
PoxyClient.configure do |config|
|
18
|
-
config.api_key = "
|
19
|
-
config.
|
18
|
+
config.api_key = "3acb90c157c9f"
|
19
|
+
config.destination = "http://home.herokuapp.com/"
|
20
20
|
end
|
21
21
|
|
22
22
|
@client = PoxyClient
|
23
23
|
#params passed for config
|
24
|
-
assert_equal @client.configuration.api_key, "
|
25
|
-
assert_equal @client.configuration.bucket_key, "test"
|
24
|
+
assert_equal @client.configuration.api_key, "3acb90c157c9f"
|
26
25
|
#params by default
|
27
|
-
assert_equal @client.configuration.destination, "http://
|
26
|
+
assert_equal @client.configuration.destination, "http://home.herokuapp.com/"
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_integration
|
30
|
+
PoxyClient.configure do |config|
|
31
|
+
config.origin = "https://poxy.apiary.io"
|
32
|
+
config.api_key = "3acb90c157c9f"
|
33
|
+
config.destination = "http://home.herokuapp.com/"
|
34
|
+
end
|
35
|
+
|
36
|
+
@client = PoxyClient
|
37
|
+
@retriever = PoxyClient.retriever
|
38
|
+
@repeater = PoxyClient.repeater
|
39
|
+
requests = @retriever.get
|
40
|
+
processed = PoxyClient.processor.parse(requests)
|
41
|
+
processed.each do |request|
|
42
|
+
responses = @repeater.set([request])
|
43
|
+
assert_not_nil responses.first.body.match('FooBar')
|
44
|
+
assert_equal responses.first.code, 200
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_client_perform
|
49
|
+
PoxyClient.configure do |config|
|
50
|
+
config.origin = "https://poxy.apiary.io"
|
51
|
+
config.api_key = "3acb90c157c9f"
|
52
|
+
config.destination = "http://home.herokuapp.com/"
|
53
|
+
end
|
54
|
+
|
55
|
+
result = PoxyClient.perform(:starred => true)
|
56
|
+
assert_not_nil result
|
28
57
|
end
|
29
58
|
|
30
59
|
|
data/test/test_poxy_processor.rb
CHANGED
@@ -4,16 +4,158 @@ require 'json'
|
|
4
4
|
|
5
5
|
class PoxyProcessorTest < Test::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
@raw_response = '{
|
8
|
+
"code": "200",
|
9
|
+
"message": "Access to Requests Granted",
|
10
|
+
"page": 1,
|
11
|
+
"per_page": 50,
|
12
|
+
"item_count": 3,
|
13
|
+
"item_class": "request",
|
14
|
+
"items": [
|
15
|
+
{
|
16
|
+
"id": 1,
|
17
|
+
"bucket_id": 1,
|
18
|
+
"starred": false,
|
19
|
+
"archived": false,
|
20
|
+
"processed": {
|
21
|
+
"method": "GET",
|
22
|
+
"origin": null,
|
23
|
+
"path": "/",
|
24
|
+
"params": {
|
25
|
+
},
|
26
|
+
"uploads": [ ]
|
27
|
+
},
|
28
|
+
"raw": {
|
29
|
+
"method": "GET",
|
30
|
+
"path": "/",
|
31
|
+
"headers": {
|
32
|
+
"HOST": "my-bucket-name.poxy.ws",
|
33
|
+
"CONNECTION": "keep-alive",
|
34
|
+
"CACHE_CONTROL": "no-cache",
|
35
|
+
"USER_AGENT": "FooBar",
|
36
|
+
"ACCEPT": "*/*",
|
37
|
+
"ACCEPT_ENCODING": "gzip,deflate,sdch",
|
38
|
+
"ACCEPT_LANGUAGE": "en-US,en;q=0.8,es;q=0.6"
|
39
|
+
},
|
40
|
+
"query_string": "",
|
41
|
+
"params": {},
|
42
|
+
"body": "",
|
43
|
+
"origin": null
|
44
|
+
}
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"id": 2,
|
48
|
+
"bucket_id": 1,
|
49
|
+
"starred": true,
|
50
|
+
"archived": false,
|
51
|
+
"processed": {
|
52
|
+
"method": "POST",
|
53
|
+
"origin": null,
|
54
|
+
"path": "/",
|
55
|
+
"params": {
|
56
|
+
"uno": "dos",
|
57
|
+
"dos": "tres"
|
58
|
+
},
|
59
|
+
"uploads": [ ]
|
60
|
+
},
|
61
|
+
"raw": {
|
62
|
+
"method": "POST",
|
63
|
+
"path": "/",
|
64
|
+
"headers": {
|
65
|
+
"ACCEPT_LANGUAGE": "en-US,en;q=0.8,es;q=0.6",
|
66
|
+
"CONNECTION": "keep-alive",
|
67
|
+
"ACCEPT_ENCODING": "gzip,deflate,sdch",
|
68
|
+
"ACCEPT": "*/*",
|
69
|
+
"CACHE_CONTROL": "no-cache",
|
70
|
+
"ORIGIN": "",
|
71
|
+
"USER_AGENT": "FooBar",
|
72
|
+
"HOST": "my-bucket-name.poxy.ws"
|
73
|
+
},
|
74
|
+
"query_string": "",
|
75
|
+
"params": {
|
76
|
+
"uno": "dos",
|
77
|
+
"dos": "tres"
|
78
|
+
},
|
79
|
+
"body": "------WebKitFormBoundaryJchAQzyXrTzJl9eq\r\nContent-Disposition: form-data; name=\"uno\"\r\n\r\ndos\r\n------WebKitFormBoundaryJchAQzyXrTzJl9eq\r\nContent-Disposition: form-data; name=\"dos\"\r\n\r\ntres\r\n------WebKitFormBoundaryJchAQzyXrTzJl9eq--\r\n",
|
80
|
+
"origin": ""
|
81
|
+
}
|
82
|
+
} ,
|
83
|
+
{
|
84
|
+
"id": 3,
|
85
|
+
"bucket_id": 2,
|
86
|
+
"starred": false,
|
87
|
+
"archived": true,
|
88
|
+
"processed": {
|
89
|
+
"method": "GET",
|
90
|
+
"origin": null,
|
91
|
+
"path": "/",
|
92
|
+
"params": {
|
93
|
+
},
|
94
|
+
"uploads": [ ]
|
95
|
+
},
|
96
|
+
"raw": {
|
97
|
+
"method": "GET",
|
98
|
+
"path": "/",
|
99
|
+
"headers": {
|
100
|
+
"HOST": "another-one.poxy.ws",
|
101
|
+
"CONNECTION": "keep-alive",
|
102
|
+
"CACHE_CONTROL": "no-cache",
|
103
|
+
"USER_AGENT": "FooBar",
|
104
|
+
"ACCEPT": "*/*",
|
105
|
+
"ACCEPT_ENCODING": "gzip,deflate,sdch",
|
106
|
+
"ACCEPT_LANGUAGE": "en-US,en;q=0.8,es;q=0.6"
|
107
|
+
},
|
108
|
+
"query_string": "",
|
109
|
+
"params": {},
|
110
|
+
"body": "",
|
111
|
+
"origin": null
|
112
|
+
}
|
113
|
+
}
|
114
|
+
]
|
115
|
+
}'
|
116
|
+
@raw_request = '{
|
117
|
+
"id": 1,
|
118
|
+
"bucket_id": 1,
|
119
|
+
"starred": false,
|
120
|
+
"archived": false,
|
121
|
+
"processed": {
|
122
|
+
"method": "GET",
|
123
|
+
"origin": null,
|
124
|
+
"path": "/",
|
125
|
+
"params": {
|
126
|
+
},
|
127
|
+
"uploads": [ ]
|
128
|
+
},
|
129
|
+
"raw": {
|
130
|
+
"method": "GET",
|
131
|
+
"path": "/",
|
132
|
+
"headers": {
|
133
|
+
"HOST": "my-bucket-name.poxy.ws",
|
134
|
+
"CONNECTION": "keep-alive",
|
135
|
+
"CACHE_CONTROL": "no-cache",
|
136
|
+
"USER_AGENT": "FooBar",
|
137
|
+
"ACCEPT": "*/*",
|
138
|
+
"ACCEPT_ENCODING": "gzip,deflate,sdch",
|
139
|
+
"ACCEPT_LANGUAGE": "en-US,en;q=0.8,es;q=0.6"
|
140
|
+
},
|
141
|
+
"query_string": "",
|
142
|
+
"params": {},
|
143
|
+
"body": "",
|
144
|
+
"origin": null
|
145
|
+
}
|
146
|
+
}'
|
12
147
|
|
13
|
-
|
14
|
-
|
148
|
+
@parsed_response = PoxyClient.processor.parse(@raw_response)
|
149
|
+
@complete_response = PoxyClient.processor.complete_items
|
150
|
+
@parsed_request = JSON.parse(@raw_request)
|
15
151
|
end
|
16
152
|
|
153
|
+
def test_request_process
|
154
|
+
assert_equal @parsed_request["raw"], @parsed_response[0]
|
155
|
+
end
|
17
156
|
|
157
|
+
def test_complete_request_process
|
158
|
+
assert_equal @parsed_request, @complete_response[0]
|
159
|
+
end
|
18
160
|
|
19
161
|
end
|
data/test/test_poxy_repeater.rb
CHANGED
@@ -6,24 +6,27 @@ class PoxyRepeaterTest < Test::Unit::TestCase
|
|
6
6
|
def setup
|
7
7
|
|
8
8
|
PoxyClient.configure do |config|
|
9
|
-
config.destination = "http://
|
9
|
+
config.destination = "http://home.herokuapp.com/"
|
10
10
|
end
|
11
11
|
@repeater = PoxyClient.repeater
|
12
12
|
|
13
13
|
#make sure the HOST header is set to the destination host, or the request willl be rejected
|
14
|
-
@raw_request = "[{\"method\":\"POST\",\"headers\":{\"HOST\":\"localhost:
|
14
|
+
@raw_request = "[{\"method\":\"POST\",\"headers\":{\"HOST\":\"localhost:9292\",\"CONNECTION\":\"keep-alive\",\"ORIGIN\":\"localhost:9292\",\"USER_AGENT\":\"Don Gato y su Pandilla\",\"ACCEPT\":\"*/*\",\"ACCEPT_ENCODING\":\"gzip,deflate,sdch\",\"ACCEPT_LANGUAGE\":\"en-US,en;q=0.8\",\"ACCEPT_CHARSET\":\"ISO-8859-1,utf-8;q=0.7,*;q=0.3\",\"COOKIE\":\"rumba\",\"VERSION\":\"HTTP/1.1\"},\"query_string\":\"urlparam=1&url_param=2\",\"params\":{\"postparam\":\"uno\",\"post_param\":\"dos\"},\"body\":\"\"}]"
|
15
15
|
@json_request = JSON.parse(@raw_request)
|
16
16
|
end
|
17
17
|
|
18
18
|
|
19
19
|
def test_repeater_config
|
20
|
-
|
20
|
+
assert_equal @repeater.destination, "http://home.herokuapp.com/"
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_repeater_set
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
responses = @repeater.set(@json_request)
|
25
|
+
|
26
|
+
#assert_equal response[0].class, HTTPI::Response
|
27
|
+
assert_equal responses.first.code, 200 #poxy will respond with a 200, since it's a "receive" bucket
|
28
|
+
assert responses.first.body.include?('Don Gato y su Pandilla'), "Don Gato not present"
|
29
|
+
|
27
30
|
end
|
28
31
|
|
29
|
-
end
|
32
|
+
end
|
data/test/test_poxy_retriever.rb
CHANGED
@@ -6,24 +6,36 @@ class PoxyRetrieverTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
PoxyClient.configure do |config|
|
9
|
-
config.origin = "
|
10
|
-
config.api_key = "
|
11
|
-
config.bucket_key = "test"
|
9
|
+
config.origin = "https://poxy.apiary.io"
|
10
|
+
config.api_key = "3acb90c157c9f968d4e7d8929fd5264cc2c9693fa67a83911412ef9b6bfa95f6"
|
12
11
|
end
|
13
12
|
@retriever = PoxyClient.retriever
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_retriever_config
|
17
|
-
assert_equal @retriever.origin, "
|
16
|
+
assert_equal @retriever.origin, "https://poxy.apiary.io"
|
18
17
|
assert_equal @retriever.mode, "development"
|
19
18
|
end
|
20
19
|
|
21
20
|
def test_retriever_get
|
22
|
-
response = @retriever.get
|
23
|
-
assert_equal response.
|
21
|
+
response = @retriever.get
|
22
|
+
assert_equal response.code, 200
|
23
|
+
parsed = JSON.parse(response.body)
|
24
|
+
expected = {"code" => "200"}
|
25
|
+
assert_equal parsed["code"], expected["code"]
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def test_a_few_requests
|
30
|
+
response = @retriever.get(:search => "bucket_id: 1", :page => 1, :per_page => 50)
|
31
|
+
parsed = JSON.parse(response.body)
|
32
|
+
expected = { "item_count" => 3, "item_class" => "request", "page" => 1, "per_page" => 50 }
|
33
|
+
assert_equal parsed["item_count"], expected["item_count"]
|
34
|
+
assert_equal parsed["item_class"], expected["item_class"]
|
35
|
+
assert_equal parsed["page"], expected["page"]
|
36
|
+
assert_equal parsed["per_page"], expected["per_page"]
|
24
37
|
end
|
25
38
|
|
26
|
-
|
27
39
|
|
28
40
|
|
29
41
|
end
|
metadata
CHANGED
@@ -1,50 +1,86 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poxy_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease: 6
|
4
|
+
version: 0.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Julian Porta
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: httpi
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: clap
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.0.2
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.2
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: test-unit
|
38
|
-
requirement:
|
39
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: curb
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
40
72
|
requirements:
|
41
|
-
- -
|
73
|
+
- - '>='
|
42
74
|
- !ruby/object:Gem::Version
|
43
75
|
version: '0'
|
44
76
|
type: :development
|
45
77
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Client for Poxy (the http inbox)
|
48
84
|
email:
|
49
85
|
- julian@porta.sh
|
50
86
|
executables:
|
@@ -58,6 +94,7 @@ files:
|
|
58
94
|
- Gemfile
|
59
95
|
- Guardfile
|
60
96
|
- LICENSE.md
|
97
|
+
- README.html
|
61
98
|
- README.md
|
62
99
|
- Rakefile
|
63
100
|
- bin/poxyd.rb
|
@@ -76,30 +113,28 @@ files:
|
|
76
113
|
- test/test_poxy_processor.rb
|
77
114
|
- test/test_poxy_repeater.rb
|
78
115
|
- test/test_poxy_retriever.rb
|
79
|
-
homepage:
|
116
|
+
homepage: https://github.com/Porta/poxy_client
|
80
117
|
licenses: []
|
118
|
+
metadata: {}
|
81
119
|
post_install_message: Thanks for installing poxy_client. Make sure to create an account
|
82
|
-
at http://poxy.
|
120
|
+
at http://poxy.ws
|
83
121
|
rdoc_options: []
|
84
122
|
require_paths:
|
85
123
|
- lib
|
86
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
125
|
requirements:
|
89
|
-
- -
|
126
|
+
- - '>='
|
90
127
|
- !ruby/object:Gem::Version
|
91
128
|
version: '0'
|
92
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
130
|
requirements:
|
95
|
-
- -
|
131
|
+
- - '>='
|
96
132
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
133
|
+
version: '0'
|
98
134
|
requirements: []
|
99
135
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
136
|
+
rubygems_version: 2.1.11
|
101
137
|
signing_key:
|
102
|
-
specification_version:
|
138
|
+
specification_version: 4
|
103
139
|
summary: Poxy is a website that captures requests and lets you do fun stuff with them
|
104
140
|
test_files: []
|
105
|
-
has_rdoc:
|