copy-cat 0.0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/copy-cat +6 -0
  3. data/lib/copy-cat.rb +50 -0
  4. metadata +86 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bfb690c88bb4e07c4d44b19e91ec5f9674546abeed9d7440c93108b5ed2cafc5
4
+ data.tar.gz: 4e5d945061df33d239352370ebcf97fb294a7d89fe890056e3b0d7a3d66846f3
5
+ SHA512:
6
+ metadata.gz: 8b860bd3c27f3ca623803c9cef8dfb236711a346205819475a152fdf1464d7a254fa4d94aa3acf5162b1d756be9f7f0cb93a36c1a0c9c8f18d909ed3282a7371
7
+ data.tar.gz: 5e8d0fc2dba984c1de5e8f003c4d4db2fec25e041a27aa93eb7f31f6c16dd1f2ded75af2fb5103ed13f4a7838e47f72adf25379a225459344290e172cc458d73
data/bin/copy-cat ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'copy-cat'
4
+
5
+ copy_cat = CopyCat.new :base_url => ARGV[0] || "http://localhost:8000"
6
+ copy_cat.start_server
data/lib/copy-cat.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'vcr'
3
+ require 'sinatra'
4
+
5
+ class CopyCatServer < Sinatra::Base
6
+
7
+ DEFAULT_HTTP_HEADERS = %w(Cookie x-csrftoken)
8
+
9
+ VCR.configure do |config|
10
+ config.cassette_library_dir = "fixtures/vcr_cassettes"
11
+ config.hook_into :webmock
12
+ end
13
+
14
+ get '*' do
15
+ content_type :json
16
+
17
+ url_string = settings.base_url + request.path_info + "?" + request.query_string
18
+ url = URI.parse(url_string)
19
+ headers = {}
20
+
21
+ http_headers = DEFAULT_HTTP_HEADERS + settings.custom_http_headers
22
+
23
+ http_headers.each do |h|
24
+ headers[h] = request.env["HTTP_#{h.upcase.gsub('-', '_')}"]
25
+ end
26
+
27
+ VCR.use_cassette(url) do
28
+ http = Net::HTTP.new(url.host, url.port)
29
+
30
+ resp = http.get(url.request_uri, headers)
31
+ resp.body
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+
39
+ class CopyCat
40
+
41
+ def initialize args
42
+ CopyCatServer.set :base_url, args[:base_url]
43
+ CopyCatServer.set :custom_http_headers, args[:custom_http_headers] || []
44
+ end
45
+
46
+ def start_server
47
+ CopyCatServer.run!
48
+ end
49
+
50
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: copy-cat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sudhir Shrestha
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-04-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vcr
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: sinatra
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.0.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.0.1
53
+ description: King cat
54
+ email: sudhirshresthaktm@gmail.com
55
+ executables:
56
+ - copy-cat
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - bin/copy-cat
61
+ - lib/copy-cat.rb
62
+ homepage: http://rubygems.org/gems/hola
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.7.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Meow !!!
86
+ test_files: []