sbsm 1.5.8 → 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/lib/sbsm/lookandfeel.rb +5 -5
- data/lib/sbsm/session.rb +1 -2
- data/lib/sbsm/session_store.rb +1 -1
- data/lib/sbsm/state.rb +2 -1
- data/lib/sbsm/version.rb +1 -1
- data/test/simple_sbsm.rb +9 -4
- data/test/test_customized_app.rb +13 -4
- data/test/test_lookandfeel.rb +10 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f2ae1755e50072d0307ecbe9c57c67c1b4a891a
|
4
|
+
data.tar.gz: 1b2e7d58d1b60cc487248e1123a8422cf051fd4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e092d40cc433c228137788cbc01e79a2e31cb03d3c84ae51d6ad0c3c686241aead506e2baeabe841c58dc0b226616ab444324961e7607ab8e5034eb66157924
|
7
|
+
data.tar.gz: a430f249b35eed0d1b7514f352a8b4dfe27cd7f1d60efec3d4ca856884eb8756f7e28b81184b392707247f156923431d9b9a6d671935b60453cef4cba4591383
|
data/History.txt
CHANGED
data/lib/sbsm/lookandfeel.rb
CHANGED
@@ -54,7 +54,8 @@ module SBSM
|
|
54
54
|
self::class::HTML_ATTRIBUTES.fetch(key.to_sym, {}).dup rescue {}
|
55
55
|
end
|
56
56
|
def base_url
|
57
|
-
|
57
|
+
maybe_port = @session.server_port ? (":" + @session.server_port ) : ''
|
58
|
+
[@session.http_protocol + ':/', @session.server_name + maybe_port, @language, @flavor].compact.join("/")
|
58
59
|
end
|
59
60
|
def direct_event
|
60
61
|
@session.direct_event
|
@@ -88,7 +89,7 @@ module SBSM
|
|
88
89
|
@languages ||= self::class::DICTIONARIES.keys.sort
|
89
90
|
end
|
90
91
|
def language_url(language)
|
91
|
-
|
92
|
+
base_url
|
92
93
|
end
|
93
94
|
def lookup(key, *args, &block)
|
94
95
|
_lookup(key, *args) || (block.call if block)
|
@@ -166,9 +167,8 @@ module SBSM
|
|
166
167
|
end
|
167
168
|
end
|
168
169
|
def _collect_resource(base, part, rstr)
|
169
|
-
|
170
|
-
|
171
|
-
base, part, rstr].flatten.compact.join('/')
|
170
|
+
maybe_port = @session.server_port ? (":" + @session.server_port ) : ''
|
171
|
+
[ @session.http_protocol + ':/', @session.server_name + maybe_port, base, part, rstr].flatten.compact.join('/')
|
172
172
|
end
|
173
173
|
def set_dictionary(language)
|
174
174
|
@dictionary = self::class::DICTIONARIES[language] || {}
|
data/lib/sbsm/session.rb
CHANGED
@@ -213,7 +213,6 @@ module SBSM
|
|
213
213
|
@rack_request = rack_request
|
214
214
|
@request_path ||= rack_request.path
|
215
215
|
@post_content = nil
|
216
|
-
|
217
216
|
if rack_request.request_method.eql?('POST')
|
218
217
|
rack_request.params.each do |k, v|
|
219
218
|
# needed to test POST requests generated by curl (first parameter) or ARC (second parameter)
|
@@ -463,7 +462,7 @@ module SBSM
|
|
463
462
|
{'Content-Type' => 'text/plain'}
|
464
463
|
end
|
465
464
|
def http_protocol
|
466
|
-
@http_protocol ||= if(@server_port && @server_port == 443) || ENV['SERVER_PORT']
|
465
|
+
@http_protocol ||= if(@server_port && @server_port.to_i == 443) || ENV['SERVER_PORT']
|
467
466
|
'https'
|
468
467
|
else
|
469
468
|
'http'
|
data/lib/sbsm/session_store.rb
CHANGED
@@ -112,7 +112,7 @@ module SBSM
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
seconds = (Time.now.to_i - now.to_i)
|
115
|
-
SBSM.warn sprintf("Cleaned #{old_size - @@sessions.size} sessions. Took %d seconds", seconds)
|
115
|
+
# SBSM.warn sprintf("Cleaned #{old_size - @@sessions.size} sessions. Took %d seconds", seconds)
|
116
116
|
end
|
117
117
|
def SessionStore.sessions
|
118
118
|
@@sessions
|
data/lib/sbsm/state.rb
CHANGED
data/lib/sbsm/version.rb
CHANGED
data/test/simple_sbsm.rb
CHANGED
@@ -69,15 +69,20 @@ module Demo
|
|
69
69
|
info.join("\n")
|
70
70
|
end
|
71
71
|
end
|
72
|
+
class AboutView
|
73
|
+
def initialize(model, session)
|
74
|
+
end
|
75
|
+
def to_html(cgi)
|
76
|
+
'About SBSM: TDD ist great!'
|
77
|
+
end
|
78
|
+
end
|
72
79
|
class AboutState < GlobalState
|
73
80
|
DIRECT_EVENT = :about
|
81
|
+
VIEW = AboutView
|
74
82
|
def initialize(session, user)
|
75
83
|
SBSM.info "AboutState #{session}"
|
76
84
|
super(session, user)
|
77
85
|
end
|
78
|
-
def to_html(cgi)
|
79
|
-
'About SBSM: TDD ist great!'
|
80
|
-
end
|
81
86
|
end
|
82
87
|
class RedirectState < GlobalState
|
83
88
|
DIRECT_EVENT = :redirect
|
@@ -239,4 +244,4 @@ module Demo
|
|
239
244
|
session_class: session_class)
|
240
245
|
end
|
241
246
|
end
|
242
|
-
end
|
247
|
+
end
|
data/test/test_customized_app.rb
CHANGED
@@ -16,19 +16,27 @@ RUN_ALL_TESTS=true unless defined?(RUN_ALL_TESTS)
|
|
16
16
|
|
17
17
|
# Overriding some stuff from the simple_sbsm
|
18
18
|
module Demo
|
19
|
+
class View_AboutState
|
20
|
+
def initialize(model, session)
|
21
|
+
end
|
22
|
+
def http_headers
|
23
|
+
{ "foo" => "bar" }
|
24
|
+
end
|
25
|
+
def to_html(cgi)
|
26
|
+
"<br>customized to_html<br>"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
19
30
|
class AboutState < GlobalState
|
20
31
|
DIRECT_EVENT = :about
|
32
|
+
VIEW = View_AboutState
|
21
33
|
def initialize(session, user)
|
22
34
|
SBSM.info "AboutState #{session}"
|
23
35
|
super(session, user)
|
24
36
|
session.login
|
25
37
|
end
|
26
|
-
def http_headers
|
27
|
-
{ "foo" => "bar" }
|
28
|
-
end
|
29
38
|
end
|
30
39
|
|
31
|
-
|
32
40
|
DEMO_PERSISTENT_COOKIE_NAME = 'demo-simple-sbsm'
|
33
41
|
class Demo::CustomizedSBSM_COOKIE < SBSM::App
|
34
42
|
PERSISTENT_COOKIE_NAME = DEMO_PERSISTENT_COOKIE_NAME
|
@@ -201,6 +209,7 @@ class CustomizedAppSessionValidatorLnf < Minitest::Test
|
|
201
209
|
end
|
202
210
|
assert last_response.ok?
|
203
211
|
assert_equal 'bar', last_response.headers['foo']
|
212
|
+
assert_equal '<br>customized to_html<br>', last_response.body
|
204
213
|
end
|
205
214
|
|
206
215
|
def test_process_state
|
data/test/test_lookandfeel.rb
CHANGED
@@ -69,6 +69,9 @@ class StubLookandfeelSession
|
|
69
69
|
def flavor
|
70
70
|
"gcc"
|
71
71
|
end
|
72
|
+
def server_port
|
73
|
+
"1234"
|
74
|
+
end
|
72
75
|
def server_name
|
73
76
|
"test.com"
|
74
77
|
end
|
@@ -127,7 +130,7 @@ class TestLookandfeel < Minitest::Test
|
|
127
130
|
assert_equal({}, @lookandfeel.attributes(:undefined))
|
128
131
|
end
|
129
132
|
def test_resource
|
130
|
-
assert_equal('http://test.com/resources/gcc/bar', @lookandfeel.resource(:foo))
|
133
|
+
assert_equal('http://test.com:1234/resources/gcc/bar', @lookandfeel.resource(:foo))
|
131
134
|
end
|
132
135
|
def test_lookup
|
133
136
|
assert_equal('dictbar', @lookandfeel.lookup(:foo))
|
@@ -161,18 +164,18 @@ class TestLookandfeel < Minitest::Test
|
|
161
164
|
assert_equal(expected, time.rfc1123)
|
162
165
|
end
|
163
166
|
def test_base_url
|
164
|
-
assert_equal("http://test.com/de/gcc", @lookandfeel.base_url)
|
167
|
+
assert_equal("http://test.com:1234/de/gcc", @lookandfeel.base_url)
|
165
168
|
end
|
166
169
|
def test_event_url
|
167
|
-
assert_match(/http:\/\/test.com\/de\/gcc\/foo\/state_id\/\d\/bar\/baz/,@lookandfeel.event_url(:foo, {:bar => 'baz'}))
|
170
|
+
assert_match(/http:\/\/test.com:1234\/de\/gcc\/foo\/state_id\/\d\/bar\/baz/,@lookandfeel.event_url(:foo, {:bar => 'baz'}))
|
168
171
|
end
|
169
172
|
def test_event_url__crawler
|
170
173
|
@session.is_crawler = true
|
171
|
-
assert_equal("http://test.com/de/gcc/foo/bar/baz",
|
174
|
+
assert_equal("http://test.com:1234/de/gcc/foo/bar/baz",
|
172
175
|
@lookandfeel.event_url(:foo, {:bar => 'baz'}))
|
173
176
|
end
|
174
177
|
def test_event_url__state_id_given
|
175
|
-
assert_equal("http://test.com/de/gcc/foo/bar/baz/state_id/mine",
|
178
|
+
assert_equal("http://test.com:1234/de/gcc/foo/bar/baz/state_id/mine",
|
176
179
|
@lookandfeel.event_url(:foo, [:bar, 'baz', :state_id, 'mine']))
|
177
180
|
end
|
178
181
|
def test_format_price
|
@@ -214,10 +217,10 @@ class TestLookandfeelWrapper < Minitest::Test
|
|
214
217
|
end
|
215
218
|
def test_resource1
|
216
219
|
lnf = SBSM::LookandfeelWrapper.new(@lookandfeel)
|
217
|
-
assert_equal('http://test.com/resources/gcc/bar', lnf.resource(:foo))
|
220
|
+
assert_equal('http://test.com:1234/resources/gcc/bar', lnf.resource(:foo))
|
218
221
|
end
|
219
222
|
def test_resource2
|
220
|
-
assert_equal('http://test.com/resources/gcc/foo', @wrapped.resource(:foo))
|
223
|
+
assert_equal('http://test.com:1234/resources/gcc/foo', @wrapped.resource(:foo))
|
221
224
|
end
|
222
225
|
def test_attributes1
|
223
226
|
lnf = SBSM::LookandfeelWrapper.new(@lookandfeel)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|