poxy_client 0.0.1.pre

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.
data/.gems ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .idea
6
+ .yardoc
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ Gemfile.lock
11
+ InstalledFiles
12
+ lib/bundler/man
13
+ pkg
14
+ poxy.sublime-project
15
+ poxy.sublime-workspace
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ vendor
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ -
2
+ lib/**/*.rb
3
+ bin/poxyd.rb
4
+ README.md
5
+ LICENSE.md
6
+ poxy.conf
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in poxy_client.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ guard :yard do
2
+ watch(%r{app/.+\.rb})
3
+ watch(%r{bin/.+})
4
+ watch(%r{ext/.+\.c})
5
+ watch(%r{lib/.+\.rb})
6
+ watch(%r{test/.+\.rb})
7
+ watch("README.md")
8
+ watch("poxy.conf")
9
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Julián Porta (julian@porta.sh)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # poxy_client
2
+
3
+ Poxy (http://poxy.porta.sh) is a web application that captures web requests and let's you do fun stuff with them.
4
+
5
+ Fun things like forwarding, emailing and some sort of processing (soon!).
6
+
7
+ In order to use it, first you'll need to [register](http://poxy.porta.sh/users/sign_up) into the site.
8
+
9
+
10
+ ## Installation
11
+
12
+ ### Bundler
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'poxy_client'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ ### Manual
23
+
24
+ $ gem install poxy_client
25
+
26
+ ## Usage
27
+
28
+ There are a few different ways to use the client.
29
+
30
+ The distribution includes a executable file that you can use just providing a .config file.
31
+
32
+ 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
+
34
+
35
+ ### Executable
36
+
37
+ 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.
38
+
39
+ It requires a mandatory config file (included in the distribution you'll find a sample one, here {file:poxy.conf ./poxy.conf}).
40
+
41
+ You can use that as a start (it points to a test endpoint in the poxy api).
42
+
43
+ Optionally, you can pass a -d parameter, and the executable will run as a daemon.
44
+
45
+ Sample run:
46
+
47
+ $ ruby poxyd.rb -c poxy.conf -d
48
+
49
+ Being poxy.conf a config file with your own API and Bucket keys.
50
+
51
+ ### Custom implementation
52
+
53
+ Though the code for {PoxyClient poxy_client} it's pretty straightforward, in case you want to take a look.
54
+
55
+ The {PoxyClient.perform perform} method encapsulates the 3 important operations the client performs.
56
+
57
+ #### Retrieve
58
+
59
+ #### Parse
60
+
61
+ #### Repeat
62
+
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 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 ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
11
+
data/bin/poxyd.rb ADDED
@@ -0,0 +1,66 @@
1
+ $:.unshift(*Dir[File.expand_path("../lib", File.dirname(__FILE__))])
2
+
3
+ # Dependencies
4
+
5
+ require 'clap'
6
+ require 'poxy_client'
7
+ require 'json'
8
+
9
+ @continue = true
10
+
11
+ trap(:INT) do
12
+ @continue = false
13
+ end
14
+
15
+ trap(0) do
16
+ puts "\nclosing up..."
17
+ end
18
+
19
+ opts = {}
20
+ config = {}
21
+
22
+ args = Clap.run ARGV,
23
+ "-c" => lambda { |file|
24
+ opts[:config_file] = file
25
+ },
26
+ "-d" => lambda {
27
+ opts[:daemonize] = true
28
+ }
29
+
30
+ $stdout.sync = true
31
+
32
+
33
+ if opts[:daemonize]
34
+ pid_path = File.expand_path("poxy.pid", File.dirname(__FILE__))
35
+ Process.daemon(true)
36
+ File.open(pid_path, File::RDWR|File::EXCL|File::CREAT, 0600) { |io| io.write(Process.pid) }
37
+ at_exit do
38
+ File.delete(pid_path) if File.exists?(pid_path)
39
+ end
40
+ end
41
+
42
+ if opts[:config_file]
43
+
44
+ File.read( opts[:config_file] ).scan(/(.*?)="?(.*)"?$/).each do |key, value|
45
+ config[key] ||= value
46
+ end
47
+
48
+ PoxyClient.configure do |c|
49
+ c.origin = config["origin"]
50
+ c.api_key = config["api"]
51
+ c.bucket_key = config["bucket"]
52
+ c.destination = config["destination"]
53
+ end
54
+
55
+ end
56
+
57
+
58
+
59
+ #run code here
60
+ while @continue do
61
+ #requests = PoxyClient.retriever.get(:all)
62
+ #parsed = PoxyClient.processor.parse(requests)
63
+ #result = PoxyClient.repeater.set(parsed)
64
+ PoxyClient.perform
65
+ sleep config["interval"].to_i
66
+ end
@@ -0,0 +1,9 @@
1
+ module HTTPI
2
+ class Request
3
+ attr_accessor :method
4
+
5
+ def method(value = :get)
6
+ @method ||= value.downcase
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ module PoxyClient
2
+ class Configuration
3
+ OPTIONS = [:api_key, :bucket_key, :origin, :destination, :method, :mode, :retriever_version].freeze
4
+
5
+ attr_accessor :api_key
6
+ attr_accessor :bucket_key
7
+ attr_accessor :origin
8
+ attr_accessor :destination
9
+ attr_accessor :method
10
+
11
+ attr_accessor :mode
12
+ attr_accessor :retriever_version
13
+
14
+ def initialize
15
+ @origin = 'http://poxy.porta.sh'
16
+ @destination = 'http://localhost'
17
+ @mode = 'development'
18
+ @method = "post"
19
+ @retriever_version = VERSION
20
+ end
21
+
22
+ def [](option)
23
+ send(option)
24
+ end
25
+
26
+ def to_hash
27
+ OPTIONS.inject({}) do |hash, option|
28
+ hash[option.to_sym] = self.send(option)
29
+ hash
30
+ end
31
+ end
32
+
33
+ def merge(hash)
34
+ to_hash.merge(hash)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ module PoxyClient
2
+ class Connector
3
+
4
+ def initialize(options = {})
5
+ HTTPI.adapter = :curb
6
+ end
7
+
8
+
9
+ def connect
10
+ yield(request)
11
+ end
12
+
13
+ def request
14
+ @request ||= HTTPI::Request.new
15
+ end
16
+
17
+ def method
18
+ @method ||= @request.method.downcase
19
+ end
20
+
21
+ def response
22
+ @response = HTTPI.send(method, @request)
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ module PoxyClient
2
+ class Processor
3
+
4
+ def initialize(options = {})
5
+
6
+ end
7
+
8
+ def parse(content)
9
+ @response = []
10
+ if ( content.respond_to?(:body) )
11
+ @response = JSON.parse(content.body)
12
+ else
13
+ @response = JSON.parse(content)
14
+ end
15
+ @response
16
+ end
17
+
18
+ def response
19
+ @response
20
+ end
21
+
22
+
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ module PoxyClient
2
+ class Repeater
3
+
4
+ attr_reader :destination
5
+
6
+ def initialize(options = {})
7
+ [ :destination
8
+ ].each do |option|
9
+ instance_variable_set("@#{option}", options[option])
10
+ end
11
+ end
12
+
13
+ def set(json_array)
14
+ @result = []
15
+ @connector = PoxyClient::Connector.new()
16
+ json_array.each do |params|
17
+ @connector.connect do |request|
18
+ request.method = params["method"]
19
+ request.url = @destination
20
+ request.headers = params["headers"]
21
+ request.body = params["params"]
22
+ end
23
+ @result << @connector.response
24
+ end
25
+ @result
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,55 @@
1
+ module PoxyClient
2
+ class Retriever
3
+
4
+
5
+ attr_reader :api_key
6
+ attr_reader :bucket_key
7
+ attr_reader :origin
8
+ attr_reader :mode
9
+ attr_reader :retriever_version
10
+
11
+ REQUESTS_URI = '/api/v1/requests/'.freeze
12
+
13
+ def initialize(options = {})
14
+ [ :api_key,
15
+ :bucket_key,
16
+ :origin,
17
+ :mode,
18
+ :retriever_version
19
+ ].each do |option|
20
+ instance_variable_set("@#{option}", options[option])
21
+ end
22
+
23
+ end
24
+
25
+
26
+ def get(how_many = "all")
27
+ #TODO: move to a factory
28
+ @connector = PoxyClient::Connector.new
29
+ @connector.connect do |request|
30
+ request.method = :post
31
+ request.url = build_url(how_many)
32
+ request.body = {:bucket_key => @bucket_key, :api_key => @api_key}
33
+ end
34
+ @connector.response
35
+ end
36
+
37
+
38
+ protected
39
+
40
+ def build_url(how_many)
41
+ @origin + REQUESTS_URI + how_many.to_s
42
+ end
43
+
44
+
45
+ end
46
+ 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
@@ -0,0 +1,3 @@
1
+ module PoxyClient
2
+ VERSION = "0.0.1.pre"
3
+ end
@@ -0,0 +1,57 @@
1
+ require "poxy_client/version.rb"
2
+ require "poxy_client/configuration.rb"
3
+ require "poxy_client/retriever.rb"
4
+ require "poxy_client/repeater.rb"
5
+ require "poxy_client/processor.rb"
6
+ require "poxy_client/connector.rb"
7
+ require "httpi"
8
+ require "httpi_request"
9
+
10
+ module PoxyClient
11
+
12
+ class << self
13
+
14
+ #attr_reader :configuration
15
+
16
+
17
+ def configure
18
+ yield(configuration)
19
+ end
20
+
21
+ def configuration
22
+ @configuration ||= PoxyClient::Configuration.new
23
+ end
24
+
25
+ def retriever
26
+ @retriever ||= PoxyClient::Retriever.new(configuration)
27
+ end
28
+
29
+ def repeater
30
+ @repeater ||= PoxyClient::Repeater.new(configuration)
31
+ end
32
+
33
+ def processor
34
+ @processor ||= PoxyClient::Processor.new(configuration)
35
+ end
36
+
37
+ def connector
38
+ @connector ||= PoxyClient::Connector.new(configuration)
39
+ end
40
+
41
+ # Encapsulates the three important operations. Retrieve, Process and Repeat
42
+ #
43
+ # @params [Symbol] which requests to retrieve from the API.
44
+ # Options are :all, :first, :last, :starred, :unstarred, :archived
45
+ # @result [Array] With the responses received in the destination server.
46
+ def perform(howmany = :all)
47
+ # Retrieve all the available requests from the site API
48
+ requests = PoxyClient.retriever.get(howmany)
49
+ # Parse those requests to JSON.
50
+ parsed = PoxyClient.processor.parse(requests)
51
+ # Repeat the retrieved and parsed requests to (usually) localhost.
52
+ # Check the sample poxy.conf file.
53
+ result = PoxyClient.repeater.set(parsed)
54
+ end
55
+
56
+ end
57
+ end
data/poxy.conf ADDED
@@ -0,0 +1,5 @@
1
+ api=test
2
+ bucket=test
3
+ origin=http://poxy.porta.sh
4
+ destination=http://localhost:9292
5
+ interval=10
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/poxy_client/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Julian Porta"]
6
+ gem.email = ["julian@porta.sh"]
7
+ gem.description = %q{Client for the Poxy website}
8
+ gem.summary = %q{Poxy is a website that captures requests and lets you do fun stuff with them}
9
+ gem.homepage = "http://poxy.porta.sh"
10
+
11
+ gem.add_runtime_dependency "httpi", [">= 1.0.0"]
12
+ gem.add_runtime_dependency "clap", [">= 0.0.2"]
13
+
14
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.name = "poxy_client"
18
+ gem.require_paths = ["lib"]
19
+ gem.version = PoxyClient::VERSION
20
+ end
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+ require 'poxy_client'
3
+ require 'json'
4
+
5
+ class PoxyBinTest < Test::Unit::TestCase
6
+
7
+ end
@@ -0,0 +1,40 @@
1
+ require 'test/unit'
2
+ require 'poxy_client'
3
+ require 'json'
4
+
5
+ class PoxyClientTest < Test::Unit::TestCase
6
+
7
+ def test_version
8
+ assert_equal PoxyClient::VERSION, '0.0.1.pre'
9
+ end
10
+
11
+ def test_config_version
12
+ @config = PoxyClient::Configuration.new
13
+ assert_equal @config.retriever_version, PoxyClient::VERSION
14
+ end
15
+
16
+ def test_config_block
17
+ PoxyClient.configure do |config|
18
+ config.api_key = "test"
19
+ config.bucket_key = "test"
20
+ end
21
+
22
+ @client = PoxyClient
23
+ #params passed for config
24
+ assert_equal @client.configuration.api_key, "test"
25
+ assert_equal @client.configuration.bucket_key, "test"
26
+ #params by default
27
+ assert_equal @client.configuration.destination, "http://localhost"
28
+ end
29
+
30
+ def test_whole_thing
31
+ PoxyClient.configure do |config|
32
+ config.origin = "http://poxy.porta.sh"
33
+ config.api_key = "test"
34
+ config.bucket_key = "test"
35
+ config.destination = "http://localhost:9292"
36
+ end
37
+ PoxyClient.perform(:all)
38
+ end
39
+
40
+ end
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+ require 'poxy_client'
3
+ require 'json'
4
+
5
+ class PoxyProcessorTest < Test::Unit::TestCase
6
+ def setup
7
+
8
+ PoxyClient.configure do |config|
9
+ config.destination = "http://postbin.heroku.com/56a0320c"
10
+ config.method = "post"
11
+ end
12
+ @raw_request = "{\"method\":\"POST\",\"headers\":{\"HOST\":\"localhost:9393\",\"CONNECTION\":\"keep-alive\",\"ORIGIN\":\"chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm\",\"X_REQUESTED_WITH\":\"sorongotronic\",\"X_CHUPALA\":\"dale\",\"USER_AGENT\":\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/11.10 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19\",\"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\":\"poxy=BAh7DEkiD3Nlc3Npb25faWQGOgZFRiJFMmI3ODc5OTA5YzhkNjFlMjkzMmRj%0AOTk0NTk4OGNjMmE2Njg4M2FiZDRmNzc4NTc5MzgyMDliY2NlM2JhNzUzYUka%0ADXRyYWNraW5nBjsARnsISSIUSFRUUF9VU0VSX0FHRU5UBjsARiItNTk4MjNl%0AZjU1YzI4N2NhYjEyNWFkNzk5ZTIyYTg3NTgzOGQ0NWJlYkkiGUhUVFBfQUND%0ARVBUX0VOQ09ESU5HBjsARiItZWQyYjNjYTkwYTRlNzIzNDAyMzY3YTFkMTdj%0AOGIyODM5Mjg0MjM5OEkiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsARiItY2M5%0AZjZmZWM2NTJhNDI1OGJjNmQyOTI4NzA1MjE3OWFiMWUwZDE0N0kiCWNzcmYG%0AOwBGIkVkN2Q1MmQwODhjOTZmYTMwMWE3OGNiYWRiYmU5Y2M4ZWYyNmIzYjll%0AYzdjMTFjNTM1OTkwMzk4ZDAwMDFiNDMwSSIRcmVtZW1iZXJfZm9yBjsARmkD%0AAHUSSSIJVXNlcgY7AEZJIgYxBjsARkkiDHN1Y2Nlc3MGOwBGSSIlWW91IGhh%0AdmUgc3VjY2Vzc2Z1bGx5IHNpZ25lZCB1cC4GOwBGSSIPZmxhc2hfa2luZAY7%0AAEZJIgdvawY7AEY%3D%0A--a86f16283e2e01cde59cffac507ca3f5319be642\",\"VERSION\":\"HTTP/1.1\"},\"query_string\":\"urlparam=1&url_param=2\",\"params\":{\"postparam\":\"uno\",\"post_param\":\"dos\"},\"body\":\"#<Rack::Lint::InputWrapper:0x00000002f87ad0>\"}"
13
+ @parsed_request = PoxyClient.processor.parse(@raw_request)
14
+ end
15
+
16
+
17
+
18
+ def test_parser
19
+ assert_equal JSON.parse(@raw_request), @parsed_request
20
+ end
21
+
22
+ end
@@ -0,0 +1,27 @@
1
+ require 'test/unit'
2
+ require 'poxy_client'
3
+ require 'json'
4
+
5
+ class PoxyRepeaterTest < Test::Unit::TestCase
6
+ def setup
7
+
8
+ PoxyClient.configure do |config|
9
+ config.destination = "http://postbin.heroku.com/56a0320c"
10
+ config.method = "post"
11
+ end
12
+ @repeater = PoxyClient.repeater
13
+ @raw_request = "[{\"method\":\"POST\",\"headers\":{\"HOST\":\"localhost:9393\",\"CONNECTION\":\"keep-alive\",\"ORIGIN\":\"chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm\",\"X_REQUESTED_WITH\":\"sorongotronic\",\"X_CHUPALA\":\"dale\",\"USER_AGENT\":\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/11.10 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19\",\"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\":\"poxy=BAh7DEkiD3Nlc3Npb25faWQGOgZFRiJFMmI3ODc5OTA5YzhkNjFlMjkzMmRj%0AOTk0NTk4OGNjMmE2Njg4M2FiZDRmNzc4NTc5MzgyMDliY2NlM2JhNzUzYUka%0ADXRyYWNraW5nBjsARnsISSIUSFRUUF9VU0VSX0FHRU5UBjsARiItNTk4MjNl%0AZjU1YzI4N2NhYjEyNWFkNzk5ZTIyYTg3NTgzOGQ0NWJlYkkiGUhUVFBfQUND%0ARVBUX0VOQ09ESU5HBjsARiItZWQyYjNjYTkwYTRlNzIzNDAyMzY3YTFkMTdj%0AOGIyODM5Mjg0MjM5OEkiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsARiItY2M5%0AZjZmZWM2NTJhNDI1OGJjNmQyOTI4NzA1MjE3OWFiMWUwZDE0N0kiCWNzcmYG%0AOwBGIkVkN2Q1MmQwODhjOTZmYTMwMWE3OGNiYWRiYmU5Y2M4ZWYyNmIzYjll%0AYzdjMTFjNTM1OTkwMzk4ZDAwMDFiNDMwSSIRcmVtZW1iZXJfZm9yBjsARmkD%0AAHUSSSIJVXNlcgY7AEZJIgYxBjsARkkiDHN1Y2Nlc3MGOwBGSSIlWW91IGhh%0AdmUgc3VjY2Vzc2Z1bGx5IHNpZ25lZCB1cC4GOwBGSSIPZmxhc2hfa2luZAY7%0AAEZJIgdvawY7AEY%3D%0A--a86f16283e2e01cde59cffac507ca3f5319be642\",\"VERSION\":\"HTTP/1.1\"},\"query_string\":\"urlparam=1&url_param=2\",\"params\":{\"postparam\":\"uno\",\"post_param\":\"dos\"},\"body\":\"#<Rack::Lint::InputWrapper:0x00000002f87ad0>\"}]"
14
+ @json_request = JSON.parse(@raw_request)
15
+ end
16
+
17
+
18
+ def test_repeater_config
19
+ #assert_equal @repeater.destination, "http://localhost:9393/debug"
20
+ end
21
+
22
+ def test_repeater_set
23
+ response = @repeater.set(@json_request)
24
+ assert_equal response[0].class, HTTPI::Response
25
+ end
26
+
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'test/unit'
2
+ require 'poxy_client'
3
+
4
+
5
+ class PoxyRetrieverTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ PoxyClient.configure do |config|
9
+ config.origin = "http://poxy.porta.sh"
10
+ config.api_key = "test"
11
+ config.bucket_key = "test"
12
+ end
13
+ @retriever = PoxyClient.retriever
14
+ end
15
+
16
+ def test_retriever_config
17
+ assert_equal @retriever.origin, "http://poxy.porta.sh"
18
+ assert_equal @retriever.mode, "development"
19
+ end
20
+
21
+ def test_retriever_get
22
+ response = @retriever.get(:all)
23
+ assert_equal response.class, HTTPI::Response
24
+ end
25
+
26
+
27
+
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: poxy_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Julian Porta
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httpi
16
+ requirement: &25883320 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *25883320
25
+ - !ruby/object:Gem::Dependency
26
+ name: clap
27
+ requirement: &25882800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *25882800
36
+ description: Client for the Poxy website
37
+ email:
38
+ - julian@porta.sh
39
+ executables:
40
+ - poxyd.rb
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gems
45
+ - .gitignore
46
+ - .yardopts
47
+ - Gemfile
48
+ - Guardfile
49
+ - LICENSE.md
50
+ - README.md
51
+ - Rakefile
52
+ - bin/poxyd.rb
53
+ - lib/httpi_request.rb
54
+ - lib/poxy_client.rb
55
+ - lib/poxy_client/configuration.rb
56
+ - lib/poxy_client/connector.rb
57
+ - lib/poxy_client/processor.rb
58
+ - lib/poxy_client/repeater.rb
59
+ - lib/poxy_client/retriever.rb
60
+ - lib/poxy_client/version.rb
61
+ - poxy.conf
62
+ - poxy_client.gemspec
63
+ - test/test_poxy_bin.rb
64
+ - test/test_poxy_client.rb
65
+ - test/test_poxy_processor.rb
66
+ - test/test_poxy_repeater.rb
67
+ - test/test_poxy_retriever.rb
68
+ homepage: http://poxy.porta.sh
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>'
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.1
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.11
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Poxy is a website that captures requests and lets you do fun stuff with them
92
+ test_files: []
93
+ has_rdoc: