fakesite 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7dfd5855290c9ff3940f0fe4751414fdc8bd49b3
4
- data.tar.gz: 535483117c061693185593282f1ae0afbd32f881
3
+ metadata.gz: 8160b4d5b77590fb9618862821dbe52746928517
4
+ data.tar.gz: 2bfe2721a55a6b1bfd63e2255ccf2ba9d69caf84
5
5
  SHA512:
6
- metadata.gz: e12be8a07f8ad4697c92144a3dabe9191ea6c1feb7cf8ad57154789cdb2c09cc878db15093a0481421c0ba75fca1f7fea8d4032b8a8bfa2cb2c5dca333c87d3a
7
- data.tar.gz: e0ea7c47149a0ab06f1e8bc049ed0f860fe8af2193fddd1a6b344822562a83bf784d1a6e939e2e911c3051443405248942648d17472136e661714a1badae8e87
6
+ metadata.gz: ee8f3d67713b1d410335d7af3a0583202f195e8e61e01f11675bbd8935d4614582bbc66e3834d8962d648dda5213eb7aa61c133481bcc12fdbea11c0e30ac566
7
+ data.tar.gz: f0b2a1b87f86170e9254181ca28b8f1632b613b69adee70bd33121d9efd8b3e4ce08aee466a9e8055f1d12b2e435cb9cdc6b407175cd16c7dd40375f79637454
@@ -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,5 +1,5 @@
1
1
  <h2>
2
- Fakesite - <%=@id %>
2
+ Fakesite - <%=@id %>
3
3
  </h2>
4
4
  <h3>Request Host</h3>
5
5
  <p><%= @uri.to_s.split('?')[0] %></p>
@@ -26,30 +26,30 @@
26
26
  </table>
27
27
  <h3>Return Parameters</h3>
28
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>
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
49
  <td colspan="2" class="center">
50
- <%= hidden_field_tag :url, params[:url] %>
50
+ <%= hidden_field_tag :url, params[:url] %>
51
51
  <button type="submit" class="btn btn-default">Return</button>
52
52
  </td>
53
53
  </tr>
54
- </table>
54
+ </table>
55
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
- get 'redirect'
5
- end
6
- end
7
- end
1
+ Fakesite::Engine.routes.draw do
2
+ resources :fakesites, :path => '/', :only => [:show] do
3
+ member do
4
+ get 'redirect'
5
+ end
6
+ end
7
+ end
@@ -1,12 +1,14 @@
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
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
+ end
data/lib/fakesite/base.rb CHANGED
@@ -1,46 +1,46 @@
1
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
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
46
  end
@@ -1,5 +1,7 @@
1
- module Fakesite
2
- class Engine < ::Rails::Engine
3
- isolate_namespace Fakesite
4
- end
5
- end
1
+ if defined?(::Rails::Engine)
2
+ module Fakesite
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Fakesite
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
- module Fakesite
2
- VERSION = "0.1.0"
3
- end
1
+ module Fakesite
2
+ VERSION = "0.1.1"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakesite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chen Yi-Cyuan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails