inspect_request 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e7d6cffdcbcdc74f20cc4c28010c1a615f8abc13
4
+ data.tar.gz: ff4df94cc91353f4f512ba0c981cedd1c0c6b600
5
+ SHA512:
6
+ metadata.gz: 3d24c6f6e5ce5894dae93af6e076944efef6e3251770fb886b2ba6af98edb64e7bfc96315d8ddbf1b4d5cccae49710d9f276224cce5c1c0aeb8439489d0dae5c
7
+ data.tar.gz: afdd8be4b7f37bb1a627e861d0a7cf789ea82f513e521ffc42c890f16220e2a806516495fe775da24fe596318c9c341af20275d2f08cffb956ac8a64ac111556
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in umbrella.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ inspect_request (0.1.0)
5
+ ritm (~> 1.0.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (5.2.0)
11
+ activesupport (= 5.2.0)
12
+ activesupport (5.2.0)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ certificate_authority (0.1.6)
18
+ activemodel (>= 3.0.6)
19
+ concurrent-ruby (1.0.5)
20
+ diff-lcs (1.3)
21
+ domain_name (0.5.20180417)
22
+ unf (>= 0.0.5, < 1.0.0)
23
+ dot_hash (0.5.9)
24
+ faraday (0.14.0)
25
+ multipart-post (>= 1.2, < 3)
26
+ http-cookie (1.0.3)
27
+ domain_name (~> 0.5)
28
+ i18n (1.0.1)
29
+ concurrent-ruby (~> 1.0)
30
+ mime-types (3.1)
31
+ mime-types-data (~> 3.2015)
32
+ mime-types-data (3.2016.0521)
33
+ minitest (5.11.3)
34
+ multipart-post (2.0.0)
35
+ netrc (0.11.0)
36
+ rake (10.5.0)
37
+ rest-client (2.0.2)
38
+ http-cookie (>= 1.0.2, < 2.0)
39
+ mime-types (>= 1.16, < 4.0)
40
+ netrc (~> 0.8)
41
+ ritm (1.0.3)
42
+ certificate_authority (~> 0.1.6)
43
+ dot_hash (~> 0.5)
44
+ faraday (~> 0.13)
45
+ webrick (~> 1.3)
46
+ rspec (3.7.0)
47
+ rspec-core (~> 3.7.0)
48
+ rspec-expectations (~> 3.7.0)
49
+ rspec-mocks (~> 3.7.0)
50
+ rspec-core (3.7.1)
51
+ rspec-support (~> 3.7.0)
52
+ rspec-expectations (3.7.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.7.0)
55
+ rspec-mocks (3.7.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.7.0)
58
+ rspec-support (3.7.1)
59
+ thread_safe (0.3.6)
60
+ tzinfo (1.2.5)
61
+ thread_safe (~> 0.1)
62
+ unf (0.1.4)
63
+ unf_ext
64
+ unf_ext (0.0.7.5)
65
+ webrick (1.4.2)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bundler (~> 1.16)
72
+ inspect_request!
73
+ rake (~> 10.0)
74
+ rest-client (~> 2.0, >= 2.0.2)
75
+ rspec (~> 3.0)
76
+
77
+ BUNDLED WITH
78
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Akhmad Fathonih
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Umbrella
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/umbrella`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'inspect_request'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install inspect_request
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ require 'inspect_request'
27
+
28
+ foo = InspectRequest::Checker.new
29
+ foo.verify do |req|
30
+ req.host == 'example.org'
31
+ end
32
+
33
+ RestClient.get 'http://example.org'
34
+ sleep 1
35
+ expect(foo.fulfilled?).to be true
36
+ ```
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/umbrella.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "umbrella"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module InspectRequest
2
+ VERSION = "0.1.0"
3
+ end
data/lib/umbrella.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'umbrella/version'
2
+ require 'ritm'
3
+
4
+ module InspectRequest
5
+ @started = false
6
+ @session = nil
7
+
8
+ class Checker
9
+ def initialize
10
+ InspectRequest.start
11
+
12
+ InspectRequest.session.on_request do |req|
13
+ track_result @verifier_block.call req.clone
14
+ end
15
+
16
+ trap('INT') { InspectRequest.shutdown }
17
+ trap('TERM') { InspectRequest.shutdown }
18
+ @results = []
19
+ @verifier_block = proc {}
20
+ end
21
+
22
+ # block should return true/false given an `req` (webrick request instance)
23
+ def verify(&block)
24
+ @verifier_block = block
25
+ end
26
+
27
+ # automatically clear previous results
28
+ def fulfilled?
29
+ res = @results.any? # any true?
30
+ @results.clear
31
+ res
32
+ end
33
+
34
+ private
35
+
36
+ def track_result(result)
37
+ @results.push result
38
+ end
39
+ end
40
+
41
+ # Your code goes here...
42
+ def self.start
43
+ return if @started
44
+ @session = Ritm::Session.new
45
+ @session.configure do
46
+ proxy[:bind_address] = '0.0.0.0'
47
+ proxy[:bind_port] = 7777
48
+ end
49
+ @session.start
50
+ @started = true
51
+ end
52
+
53
+ def self.shutdown
54
+ @session.shutdown if @started
55
+ @started = false
56
+ end
57
+
58
+ def self.started?
59
+ @started
60
+ end
61
+
62
+ def self.session
63
+ @session
64
+ end
65
+ end
data/umbrella.gemspec ADDED
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'umbrella/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'inspect_request'
8
+ spec.version = InspectRequest::VERSION
9
+ spec.authors = ['Akhmad Fathonih']
10
+ spec.email = ['akhmadf@gmail.com']
11
+
12
+ spec.summary = 'Verify network traffic'
13
+ spec.description = 'Similar to mockserver, but simpler'
14
+ spec.homepage = 'http://google.com'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'ritm', '~> 1.0.3'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inspect_request
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Akhmad Fathonih
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ritm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.0.2
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.0'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ description: Similar to mockserver, but simpler
90
+ email:
91
+ - akhmadf@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - bin/console
105
+ - bin/setup
106
+ - lib/umbrella.rb
107
+ - lib/umbrella/version.rb
108
+ - umbrella.gemspec
109
+ homepage: http://google.com
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.5.1
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Verify network traffic
133
+ test_files: []