fakesite 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 +7 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/fakesite/application.js +13 -0
- data/app/assets/stylesheets/fakesite/application.css +165 -0
- data/app/controllers/fakesite/application_controller.rb +4 -0
- data/app/controllers/fakesite/fakesites_controller.rb +22 -0
- data/app/helpers/fakesite/application_helper.rb +4 -0
- data/app/views/fakesite/fakesites/show.html.erb +55 -0
- data/app/views/layouts/fakesite/application.html.erb +14 -0
- data/config/routes.rb +7 -0
- data/config/spring.rb +1 -0
- data/lib/fakesite/action_controller.rb +12 -0
- data/lib/fakesite/base.rb +46 -0
- data/lib/fakesite/engine.rb +5 -0
- data/lib/fakesite/version.rb +3 -0
- data/lib/fakesite.rb +30 -0
- data/lib/tasks/fakesite_tasks.rake +4 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7dfd5855290c9ff3940f0fe4751414fdc8bd49b3
|
4
|
+
data.tar.gz: 535483117c061693185593282f1ae0afbd32f881
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e12be8a07f8ad4697c92144a3dabe9191ea6c1feb7cf8ad57154789cdb2c09cc878db15093a0481421c0ba75fca1f7fea8d4032b8a8bfa2cb2c5dca333c87d3a
|
7
|
+
data.tar.gz: e0ea7c47149a0ab06f1e8bc049ed0f860fe8af2193fddd1a6b344822562a83bf784d1a6e939e2e911c3051443405248942648d17472136e661714a1badae8e87
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,165 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
16
|
+
|
17
|
+
/* http://meyerweb.com/eric/tools/css/reset/
|
18
|
+
v2.0 | 20110126
|
19
|
+
License: none (public domain)
|
20
|
+
*/
|
21
|
+
|
22
|
+
html, body, div, span, applet, object, iframe,
|
23
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
24
|
+
a, abbr, acronym, address, big, cite, code,
|
25
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
26
|
+
small, strike, strong, sub, sup, tt, var,
|
27
|
+
b, u, i, center,
|
28
|
+
dl, dt, dd, ol, ul, li,
|
29
|
+
fieldset, form, label, legend,
|
30
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
31
|
+
article, aside, canvas, details, embed,
|
32
|
+
figure, figcaption, footer, header, hgroup,
|
33
|
+
menu, nav, output, ruby, section, summary,
|
34
|
+
time, mark, audio, video {
|
35
|
+
margin: 0;
|
36
|
+
padding: 0;
|
37
|
+
border: 0;
|
38
|
+
font-size: 100%;
|
39
|
+
font: inherit;
|
40
|
+
vertical-align: baseline;
|
41
|
+
}
|
42
|
+
/* HTML5 display-role reset for older browsers */
|
43
|
+
article, aside, details, figcaption, figure,
|
44
|
+
footer, header, hgroup, menu, nav, section {
|
45
|
+
display: block;
|
46
|
+
}
|
47
|
+
body {
|
48
|
+
line-height: 1;
|
49
|
+
}
|
50
|
+
ol, ul {
|
51
|
+
list-style: none;
|
52
|
+
}
|
53
|
+
blockquote, q {
|
54
|
+
quotes: none;
|
55
|
+
}
|
56
|
+
blockquote:before, blockquote:after,
|
57
|
+
q:before, q:after {
|
58
|
+
content: '';
|
59
|
+
content: none;
|
60
|
+
}
|
61
|
+
table {
|
62
|
+
border-collapse: collapse;
|
63
|
+
border-spacing: 0;
|
64
|
+
}
|
65
|
+
|
66
|
+
body {
|
67
|
+
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
68
|
+
font-size: 14px;
|
69
|
+
line-height: 1.42857143;
|
70
|
+
color: #333;
|
71
|
+
margin: 0 20px;
|
72
|
+
}
|
73
|
+
|
74
|
+
h2 {
|
75
|
+
font-size: 30px;
|
76
|
+
margin-top: 20px;
|
77
|
+
margin-bottom: 10px;
|
78
|
+
font-family: inherit;
|
79
|
+
font-weight: 500;
|
80
|
+
line-height: 1.1;
|
81
|
+
}
|
82
|
+
|
83
|
+
h3 {
|
84
|
+
font-size: 24px;
|
85
|
+
margin-top: 20px;
|
86
|
+
margin-bottom: 10px;
|
87
|
+
font-family: inherit;
|
88
|
+
font-weight: 500;
|
89
|
+
line-height: 1.1;
|
90
|
+
}
|
91
|
+
|
92
|
+
table {
|
93
|
+
border: 1px solid #ddd;
|
94
|
+
width: 100%;
|
95
|
+
max-width: 100%;
|
96
|
+
border-spacing: 0;
|
97
|
+
border-collapse: collapse;
|
98
|
+
}
|
99
|
+
|
100
|
+
tr:nth-of-type(odd) {
|
101
|
+
background-color: #f9f9f9;
|
102
|
+
}
|
103
|
+
|
104
|
+
tr:first-child>th {
|
105
|
+
border-top: 0;
|
106
|
+
}
|
107
|
+
|
108
|
+
th, td {
|
109
|
+
border-bottom-width: 2px;
|
110
|
+
border: 1px solid #ddd;
|
111
|
+
vertical-align: bottom;
|
112
|
+
border-bottom: 2px solid #ddd;
|
113
|
+
padding: 8px;
|
114
|
+
line-height: 1.42857143;
|
115
|
+
vertical-align: top;
|
116
|
+
border-top: 1px solid #ddd;
|
117
|
+
}
|
118
|
+
|
119
|
+
a {
|
120
|
+
text-decoration: none;
|
121
|
+
color: #007CFF;
|
122
|
+
}
|
123
|
+
|
124
|
+
.btn {
|
125
|
+
display: inline-block;
|
126
|
+
padding: 6px 12px;
|
127
|
+
margin-bottom: 0;
|
128
|
+
font-size: 14px;
|
129
|
+
font-weight: 400;
|
130
|
+
line-height: 1.42857143;
|
131
|
+
text-align: center;
|
132
|
+
white-space: nowrap;
|
133
|
+
vertical-align: middle;
|
134
|
+
-ms-touch-action: manipulation;
|
135
|
+
touch-action: manipulation;
|
136
|
+
cursor: pointer;
|
137
|
+
-webkit-user-select: none;
|
138
|
+
-moz-user-select: none;
|
139
|
+
-ms-user-select: none;
|
140
|
+
user-select: none;
|
141
|
+
background-image: none;
|
142
|
+
border: 1px solid transparent;
|
143
|
+
border-radius: 4px;
|
144
|
+
}
|
145
|
+
|
146
|
+
.btn-default:hover {
|
147
|
+
color: #333;
|
148
|
+
background-color: #e6e6e6;
|
149
|
+
border-color: #adadad;
|
150
|
+
}
|
151
|
+
|
152
|
+
.btn.focus, .btn:focus, .btn:hover {
|
153
|
+
color: #333;
|
154
|
+
text-decoration: none;
|
155
|
+
}
|
156
|
+
|
157
|
+
.btn-default {
|
158
|
+
color: #333;
|
159
|
+
background-color: #fff;
|
160
|
+
border-color: #ccc;
|
161
|
+
}
|
162
|
+
|
163
|
+
.center {
|
164
|
+
text-align: center;
|
165
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fakesite
|
2
|
+
class FakesitesController < Fakesite::ApplicationController
|
3
|
+
before_action :find_fakesite
|
4
|
+
|
5
|
+
def show
|
6
|
+
@uri = URI.parse(params[:url])
|
7
|
+
@id = params[:id]
|
8
|
+
@parameters = @fakesite.parameters(params[:url])
|
9
|
+
end
|
10
|
+
|
11
|
+
def redirect
|
12
|
+
@uri = URI.parse(params[:url])
|
13
|
+
redirect_to @fakesite.redirect_url(@uri, params[:p])
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def find_fakesite
|
19
|
+
@fakesite = Fakesite.find(params[:id])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<h2>
|
2
|
+
Fakesite - <%=@id %>
|
3
|
+
</h2>
|
4
|
+
<h3>Request Host</h3>
|
5
|
+
<p><%= @uri.to_s.split('?')[0] %></p>
|
6
|
+
<h3>Request Parameters</h3>
|
7
|
+
<table>
|
8
|
+
<colgroup>
|
9
|
+
<col width="200px"></col>
|
10
|
+
<col></col>
|
11
|
+
</colgroup>
|
12
|
+
<tr>
|
13
|
+
<th>Key</th>
|
14
|
+
<th>Value</th>
|
15
|
+
</tr>
|
16
|
+
<% Rack::Utils.parse_nested_query(@uri.query).each do |key, value| %>
|
17
|
+
<tr>
|
18
|
+
<td>
|
19
|
+
<%= key %>
|
20
|
+
</td>
|
21
|
+
<td>
|
22
|
+
<%= value %>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</table>
|
27
|
+
<h3>Return Parameters</h3>
|
28
|
+
<%= form_tag redirect_fakesite_path(@id), :method => :get do %>
|
29
|
+
<table>
|
30
|
+
<colgroup>
|
31
|
+
<col width="200px"></col>
|
32
|
+
<col></col>
|
33
|
+
</colgroup>
|
34
|
+
<tr>
|
35
|
+
<th>Key</th>
|
36
|
+
<th>Value</th>
|
37
|
+
</tr>
|
38
|
+
<% @parameters.each do |key, value| %>
|
39
|
+
<tr>
|
40
|
+
<td>
|
41
|
+
<%= label_tag "p[#{key}]", key %>
|
42
|
+
</td>
|
43
|
+
<td>
|
44
|
+
<%= text_field_tag "p[#{key}]", value %>
|
45
|
+
</td>
|
46
|
+
</tr>
|
47
|
+
<% end %>
|
48
|
+
<tr>
|
49
|
+
<td colspan="2" class="center">
|
50
|
+
<%= hidden_field_tag :url, params[:url] %>
|
51
|
+
<button type="submit" class="btn btn-default">Return</button>
|
52
|
+
</td>
|
53
|
+
</tr>
|
54
|
+
</table>
|
55
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Fakesite</title>
|
5
|
+
<%= stylesheet_link_tag "fakesite/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "fakesite/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/config/spring.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Spring.application_root = './spec/dummy'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ActionController::Base
|
2
|
+
alias_method :orig_redirect_to, :redirect_to
|
3
|
+
|
4
|
+
def redirect_to(options = {}, response_status = {})
|
5
|
+
fakesite = Fakesite.match(options)
|
6
|
+
if fakesite
|
7
|
+
orig_redirect_to Fakesite::Engine.routes.url_helpers.fakesite_path(fakesite, :url => options)
|
8
|
+
else
|
9
|
+
orig_redirect_to(options, response_status)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Fakesite
|
2
|
+
class Base
|
3
|
+
def initialize(options = {})
|
4
|
+
@options = options
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
end
|
9
|
+
|
10
|
+
def match(external_uri)
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
def parameters(external_uri)
|
15
|
+
{}
|
16
|
+
end
|
17
|
+
|
18
|
+
def return_parameters(params)
|
19
|
+
params
|
20
|
+
end
|
21
|
+
|
22
|
+
def return_url(external_uri)
|
23
|
+
params = query_to_hash(external_uri)
|
24
|
+
params["return_url"] || '/'
|
25
|
+
end
|
26
|
+
|
27
|
+
def redirect_url(external_uri, params)
|
28
|
+
append_parameters(return_url(external_uri), return_parameters(params))
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def query_to_hash(uri)
|
34
|
+
uri.query ? Rack::Utils.parse_nested_query(uri.query) : {}
|
35
|
+
end
|
36
|
+
|
37
|
+
def append_parameters(url, params)
|
38
|
+
query_string = URI.encode_www_form(params)
|
39
|
+
if query_string == ""
|
40
|
+
return url
|
41
|
+
else
|
42
|
+
url + (url.include?('?') ? '&' : '?') + query_string
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/fakesite.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
require "fakesite/engine"
|
4
|
+
require "fakesite/base"
|
5
|
+
|
6
|
+
module Fakesite
|
7
|
+
@@initialized = false
|
8
|
+
@@fakesites = {}
|
9
|
+
|
10
|
+
def self.register(fakesite)
|
11
|
+
require "fakesite/action_controller" unless @@initialized
|
12
|
+
@@initialized = true
|
13
|
+
@@fakesites[fakesite.id] = fakesite
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.match(url)
|
17
|
+
return false unless url.is_a? String
|
18
|
+
begin
|
19
|
+
uri = URI.parse(url)
|
20
|
+
@@fakesites.each do |id, fakesite|
|
21
|
+
return id if fakesite.match(uri)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.find(id)
|
28
|
+
@@fakesites[id.to_sym]
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fakesite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chen Yi-Cyuan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-its
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: An rails plugin that provides a stub framework to stub 3-party redirect
|
98
|
+
page such as payment or oauth login.
|
99
|
+
email:
|
100
|
+
- emn178@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- Rakefile
|
106
|
+
- app/assets/javascripts/fakesite/application.js
|
107
|
+
- app/assets/stylesheets/fakesite/application.css
|
108
|
+
- app/controllers/fakesite/application_controller.rb
|
109
|
+
- app/controllers/fakesite/fakesites_controller.rb
|
110
|
+
- app/helpers/fakesite/application_helper.rb
|
111
|
+
- app/views/fakesite/fakesites/show.html.erb
|
112
|
+
- app/views/layouts/fakesite/application.html.erb
|
113
|
+
- config/routes.rb
|
114
|
+
- config/spring.rb
|
115
|
+
- lib/fakesite.rb
|
116
|
+
- lib/fakesite/action_controller.rb
|
117
|
+
- lib/fakesite/base.rb
|
118
|
+
- lib/fakesite/engine.rb
|
119
|
+
- lib/fakesite/version.rb
|
120
|
+
- lib/tasks/fakesite_tasks.rake
|
121
|
+
homepage: https://github.com/emn178/fakesite
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
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.4.8
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: An rails plugin that provides a stub framework to stub 3-party redirect page
|
145
|
+
such as payment or oauth login.
|
146
|
+
test_files: []
|