fakesite 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/fakesite/application.css +164 -164
- data/app/controllers/fakesite/fakesites_controller.rb +22 -22
- data/app/views/fakesite/fakesites/show.html.erb +55 -55
- data/config/routes.rb +7 -7
- data/config/spring.rb +1 -1
- data/lib/fakesite/action_controller.rb +13 -13
- data/lib/fakesite/base.rb +46 -46
- data/lib/fakesite/engine.rb +6 -6
- data/lib/fakesite/version.rb +3 -3
- data/lib/fakesite.rb +30 -30
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54816a25123fc376c75271babccc955ecf6ff541
|
4
|
+
data.tar.gz: b1e97eb01f3656df22658021a472d0e2518c2055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 429e6a8aaa6231acc3d66c735666fed3e49c524d517128a59e94c7862c29fd2197ff7370608e036c09f50a74be75001e65cd69f58deb51ec98f03cdf48890ef5
|
7
|
+
data.tar.gz: 40e75d3200c4e1fdc8616ea64ce35956bda61db8bcf84893b172e80c3c44def7973878de31e7cdc095ee87c0118c65f7baf63f738f9789fb10d001918f675463
|
@@ -1,165 +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;
|
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
165
|
}
|
@@ -1,22 +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
|
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
|
@@ -1,55 +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 => :post 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 %>
|
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 => :post 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 %>
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Fakesite::Engine.routes.draw do
|
2
|
-
resources :fakesites, :path => '/', :only => [:show] do
|
3
|
-
member do
|
4
|
-
post 'redirect'
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
Fakesite::Engine.routes.draw do
|
2
|
+
resources :fakesites, :path => '/', :only => [:show] do
|
3
|
+
member do
|
4
|
+
post 'redirect'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/config/spring.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Spring.application_root = './spec/dummy'
|
1
|
+
Spring.application_root = './spec/dummy'
|
@@ -1,14 +1,14 @@
|
|
1
|
-
if defined?(::Rails::Engine)
|
2
|
-
class ActionController::Base
|
3
|
-
alias_method :orig_redirect_to, :redirect_to
|
4
|
-
|
5
|
-
def redirect_to(options = {}, response_status = {})
|
6
|
-
id = Fakesite.match(options)
|
7
|
-
if id
|
8
|
-
orig_redirect_to Fakesite::Engine.routes.url_helpers.fakesite_path(id, :url => options)
|
9
|
-
else
|
10
|
-
orig_redirect_to(options, response_status)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
if defined?(::Rails::Engine)
|
2
|
+
class ActionController::Base
|
3
|
+
alias_method :orig_redirect_to, :redirect_to
|
4
|
+
|
5
|
+
def redirect_to(options = {}, response_status = {})
|
6
|
+
id = Fakesite.match(options)
|
7
|
+
if id
|
8
|
+
orig_redirect_to Fakesite::Engine.routes.url_helpers.fakesite_path(id, :url => options)
|
9
|
+
else
|
10
|
+
orig_redirect_to(options, response_status)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
data/lib/fakesite/base.rb
CHANGED
@@ -1,46 +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 ? Hash[CGI.parse(uri.query).map {|key,values| [key, values[0] || true]}] : {}
|
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
|
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 ? Hash[CGI.parse(uri.query).map {|key,values| [key, values[0] || true]}] : {}
|
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/engine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
if defined?(::Rails::Engine)
|
2
|
-
module Fakesite
|
3
|
-
class Engine < ::Rails::Engine
|
4
|
-
isolate_namespace Fakesite
|
5
|
-
end
|
6
|
-
end
|
1
|
+
if defined?(::Rails::Engine)
|
2
|
+
module Fakesite
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace Fakesite
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
data/lib/fakesite/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Fakesite
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
1
|
+
module Fakesite
|
2
|
+
VERSION = "0.1.3"
|
3
|
+
end
|
data/lib/fakesite.rb
CHANGED
@@ -1,30 +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
|
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakesite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chen Yi-Cyuan
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.4.
|
141
|
+
rubygems_version: 2.4.5
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: An rails plugin that provides a stub framework to stub 3-party redirect page
|