vcr-proxy 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 29c052670b0fab22771637984110350d9714a91fb48f1c504025447a3136fb1c
4
+ data.tar.gz: 38a4927bb52c8c556e7981664719172b03a400976fcf84e90d664a0d571554c1
5
+ SHA512:
6
+ metadata.gz: 35c24627b67bf523c2a3e8be977fb72fa82ca34a46955e7346f59114b57ec3358abb9844027061e005e2f9113faf63b07c585f32416babadb37829c2ca0d49a6
7
+ data.tar.gz: 0ae4a0545daf91a9902f071fd5d54b88dd6b4bb55e6b3396386fe8934dbf364b96c46140257d4b739ade19739b847c0bd1abbdf7bf99a8ad2f11af0c96ce36e0
@@ -0,0 +1,44 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ build:
13
+ name: Build + Publish
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@master
18
+ - name: Set up Ruby 2.6
19
+ uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.6.x
22
+
23
+ - name: Publish to GPR
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
+ gem build *.gemspec
30
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
31
+ env:
32
+ GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
33
+ OWNER: username
34
+
35
+ - name: Publish to RubyGems
36
+ run: |
37
+ mkdir -p $HOME/.gem
38
+ touch $HOME/.gem/credentials
39
+ chmod 0600 $HOME/.gem/credentials
40
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
41
+ gem build *.gemspec
42
+ gem push *.gem
43
+ env:
44
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ceritium@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in vcr-proxy.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vcr-proxy (0.1.0)
5
+ sinatra
6
+ vcr
7
+ webmock
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ hashdiff (1.0.0)
17
+ minitest (5.13.0)
18
+ mustermann (1.0.3)
19
+ public_suffix (4.0.1)
20
+ rack (2.0.7)
21
+ rack-protection (2.0.7)
22
+ rack
23
+ rake (10.5.0)
24
+ safe_yaml (1.0.5)
25
+ sinatra (2.0.7)
26
+ mustermann (~> 1.0)
27
+ rack (~> 2.0)
28
+ rack-protection (= 2.0.7)
29
+ tilt (~> 2.0)
30
+ tilt (2.0.10)
31
+ vcr (5.0.0)
32
+ webmock (3.7.6)
33
+ addressable (>= 2.3.6)
34
+ crack (>= 0.3.2)
35
+ hashdiff (>= 0.4.0, < 2.0.0)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bundler (~> 2.0)
42
+ minitest (~> 5.0)
43
+ rake (~> 10.0)
44
+ vcr-proxy!
45
+
46
+ BUNDLED WITH
47
+ 2.0.1
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Vcr::Proxy
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/vcr/proxy`. 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 'vcr-proxy'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install vcr-proxy
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vcr-proxy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Vcr::Proxy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vcr-proxy/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vcr/proxy"
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
data/bin/vcr-proxy ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'vcr'
6
+ require 'vcr/proxy'
7
+ require 'optparse'
8
+
9
+ ARGV << '-h' if ARGV.empty?
10
+
11
+ OptionParser.new do |opts|
12
+ opts.banner = 'Usage: vcr-proxy [options]'
13
+
14
+ opts.on('-e', '--endpoint=http://example.com', 'Proxy endpoint') do |n|
15
+ VCR::Proxy.config.endpoint = n
16
+ end
17
+
18
+ opts.on('-l', '--library-dir=fixtures/vcr_cassettes', 'Library directory') do |n|
19
+ VCR::Proxy.config.cassette_library_dir = n
20
+ end
21
+
22
+ opts.on('-p', '--port=8099', Integer, 'Listening port') do |n|
23
+ VCR::Proxy.config.port = n
24
+ end
25
+
26
+ opts.on('-b', '--bind=0.0.0.0', 'Bind IP') do |n|
27
+ VCR::Proxy.config.bind = n
28
+ end
29
+
30
+ opts.on_tail('-h', '--help', 'Show this message') do
31
+ puts opts
32
+ exit
33
+ end
34
+ end.parse!
35
+
36
+ VCR.configure do |config|
37
+ config.cassette_library_dir = VCR::Proxy.config.cassette_library_dir
38
+ config.hook_into :webmock
39
+ end
40
+
41
+ require 'vcr/proxy/app'
42
+ App.run!
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sinatra/base'
4
+
5
+ # Sinatra App which proxy calls caching the response with VCR
6
+ class App < Sinatra::Base
7
+ configure do
8
+ set :bind, VCR::Proxy.config.bind
9
+ set :port, VCR::Proxy.config.port
10
+ end
11
+
12
+ post '*' do
13
+ vcr_wrapper('post') do
14
+ uri = URI("#{VCR::Proxy.config}#{request.path}")
15
+ uri.query = URI.encode_www_form(request.params)
16
+ request = Net::HTTP::Post.new(uri)
17
+ request.body = request.body
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ response = http.request(request)
20
+ status response.code
21
+ response.body
22
+ end
23
+ end
24
+
25
+ get '*' do
26
+ vcr_wrapper('get') do
27
+ uri = URI("#{VCR::Proxy.config.endpoint}#{request.path}")
28
+ uri.query = URI.encode_www_form(request.params)
29
+ response = Net::HTTP.get_response(uri)
30
+ status response.code
31
+ response.body
32
+ end
33
+ end
34
+
35
+ def vcr_wrapper(verb)
36
+ key = "#{request.path}/#{verb}/#{request.params.to_json}"
37
+ VCR.use_cassette(key, match_requests_on: VCR::Proxy.config.match_requests_on) do
38
+ yield
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module VCR
2
+ module Proxy
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
data/lib/vcr/proxy.rb ADDED
@@ -0,0 +1,29 @@
1
+ require "singleton"
2
+ require "vcr/proxy/version"
3
+
4
+ module VCR
5
+ module Proxy
6
+
7
+ def self.config
8
+ Config.instance
9
+ end
10
+
11
+ class Config
12
+ include Singleton
13
+
14
+ attr_accessor :endpoint
15
+ attr_accessor :cassette_library_dir
16
+ attr_accessor :match_requests_on
17
+ attr_accessor :port
18
+ attr_accessor :bind
19
+
20
+ def initialize
21
+ @endpoint = 'https://example.com'
22
+ @cassette_library_dir = 'fixtures/vcr_cassettes'
23
+ @match_requests_on = %i[path query body method]
24
+ @port = 8099
25
+ @bind = '0.0.0.0'
26
+ end
27
+ end
28
+ end
29
+ end
data/vcr-proxy.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'vcr/proxy/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'vcr-proxy'
9
+ spec.version = VCR::Proxy::VERSION
10
+ spec.authors = ['José Galisteo']
11
+ spec.email = ['ceritium@gmail.com']
12
+
13
+ spec.summary = 'VCR web proxy'
14
+ # spec.description = %q{}
15
+ spec.homepage = "https://github.com/ceritium/vcr-proxy"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/ceritium/vcr-proxy"
22
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
23
+ else
24
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
25
+ 'public gem pushes.'
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+
34
+ spec.executables << 'vcr-proxy'
35
+ spec.require_paths = ['lib']
36
+
37
+ spec.add_dependency 'sinatra'
38
+ spec.add_dependency 'vcr'
39
+ spec.add_dependency 'webmock'
40
+ spec.add_development_dependency 'bundler', '~> 2.0'
41
+ spec.add_development_dependency 'minitest', '~> 5.0'
42
+ spec.add_development_dependency 'rake', '~> 10.0'
43
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vcr-proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - José Galisteo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: vcr
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ description:
98
+ email:
99
+ - ceritium@gmail.com
100
+ executables:
101
+ - vcr-proxy
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".github/workflows/gempush.yml"
106
+ - ".gitignore"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - Gemfile.lock
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - bin/vcr-proxy
116
+ - lib/vcr/proxy.rb
117
+ - lib/vcr/proxy/app.rb
118
+ - lib/vcr/proxy/version.rb
119
+ - vcr-proxy.gemspec
120
+ homepage: https://github.com/ceritium/vcr-proxy
121
+ licenses: []
122
+ metadata:
123
+ homepage_uri: https://github.com/ceritium/vcr-proxy
124
+ source_code_uri: https://github.com/ceritium/vcr-proxy
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.7.6
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: VCR web proxy
145
+ test_files: []