startback-websocket 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/README.md +13 -0
- data/Rakefile +18 -0
- data/lib/startback/audit/prometheus.rb +87 -0
- data/lib/startback/audit/shared.rb +17 -0
- data/lib/startback/audit/trailer.rb +129 -0
- data/lib/startback/audit.rb +3 -0
- data/lib/startback/caching/entity_cache.rb +157 -0
- data/lib/startback/caching/no_store.rb +28 -0
- data/lib/startback/caching/store.rb +34 -0
- data/lib/startback/context/h_factory.rb +43 -0
- data/lib/startback/context/middleware.rb +53 -0
- data/lib/startback/context.rb +122 -0
- data/lib/startback/errors.rb +197 -0
- data/lib/startback/event/agent.rb +84 -0
- data/lib/startback/event/bus/bunny/async.rb +162 -0
- data/lib/startback/event/bus/bunny.rb +1 -0
- data/lib/startback/event/bus/memory/async.rb +45 -0
- data/lib/startback/event/bus/memory/sync.rb +35 -0
- data/lib/startback/event/bus/memory.rb +2 -0
- data/lib/startback/event/bus.rb +100 -0
- data/lib/startback/event/engine.rb +94 -0
- data/lib/startback/event/ext/context.rb +5 -0
- data/lib/startback/event/ext/operation.rb +13 -0
- data/lib/startback/event.rb +47 -0
- data/lib/startback/ext/date_time.rb +9 -0
- data/lib/startback/ext/time.rb +9 -0
- data/lib/startback/ext.rb +2 -0
- data/lib/startback/model.rb +6 -0
- data/lib/startback/operation/error_operation.rb +19 -0
- data/lib/startback/operation/multi_operation.rb +28 -0
- data/lib/startback/operation.rb +78 -0
- data/lib/startback/services.rb +11 -0
- data/lib/startback/support/data_object.rb +71 -0
- data/lib/startback/support/env.rb +41 -0
- data/lib/startback/support/fake_logger.rb +18 -0
- data/lib/startback/support/hooks.rb +48 -0
- data/lib/startback/support/log_formatter.rb +34 -0
- data/lib/startback/support/logger.rb +34 -0
- data/lib/startback/support/operation_runner.rb +150 -0
- data/lib/startback/support/robustness.rb +157 -0
- data/lib/startback/support/transaction_manager.rb +25 -0
- data/lib/startback/support/transaction_policy.rb +33 -0
- data/lib/startback/support/world.rb +54 -0
- data/lib/startback/support.rb +26 -0
- data/lib/startback/version.rb +8 -0
- data/lib/startback/web/api.rb +99 -0
- data/lib/startback/web/auto_caching.rb +85 -0
- data/lib/startback/web/catch_all.rb +52 -0
- data/lib/startback/web/cors_headers.rb +80 -0
- data/lib/startback/web/health_check.rb +49 -0
- data/lib/startback/web/magic_assets/ng_html_transformer.rb +80 -0
- data/lib/startback/web/magic_assets/rake_tasks.rb +64 -0
- data/lib/startback/web/magic_assets.rb +98 -0
- data/lib/startback/web/middleware.rb +13 -0
- data/lib/startback/web/prometheus.rb +16 -0
- data/lib/startback/web/shield.rb +58 -0
- data/lib/startback.rb +43 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/unit/audit/test_prometheus.rb +72 -0
- data/spec/unit/audit/test_trailer.rb +105 -0
- data/spec/unit/caching/test_entity_cache.rb +136 -0
- data/spec/unit/context/test_abstraction_factory.rb +64 -0
- data/spec/unit/context/test_dup.rb +42 -0
- data/spec/unit/context/test_fork.rb +37 -0
- data/spec/unit/context/test_h_factory.rb +31 -0
- data/spec/unit/context/test_middleware.rb +45 -0
- data/spec/unit/context/test_with_world.rb +20 -0
- data/spec/unit/context/test_world.rb +17 -0
- data/spec/unit/event/bus/memory/test_async.rb +43 -0
- data/spec/unit/event/bus/memory/test_sync.rb +43 -0
- data/spec/unit/support/hooks/test_after_hook.rb +54 -0
- data/spec/unit/support/hooks/test_before_hook.rb +54 -0
- data/spec/unit/support/operation_runner/test_around_run.rb +156 -0
- data/spec/unit/support/operation_runner/test_before_after_call.rb +48 -0
- data/spec/unit/support/test_data_object.rb +156 -0
- data/spec/unit/support/test_env.rb +75 -0
- data/spec/unit/support/test_robusteness.rb +229 -0
- data/spec/unit/support/test_transaction_manager.rb +64 -0
- data/spec/unit/support/test_world.rb +72 -0
- data/spec/unit/test_event.rb +62 -0
- data/spec/unit/test_operation.rb +55 -0
- data/spec/unit/test_support.rb +40 -0
- data/spec/unit/web/fixtures/assets/app/hello.es6 +4 -0
- data/spec/unit/web/fixtures/assets/app/hello.html +1 -0
- data/spec/unit/web/fixtures/assets/index.es6 +1 -0
- data/spec/unit/web/test_api.rb +82 -0
- data/spec/unit/web/test_auto_caching.rb +81 -0
- data/spec/unit/web/test_catch_all.rb +77 -0
- data/spec/unit/web/test_cors_headers.rb +88 -0
- data/spec/unit/web/test_healthcheck.rb +59 -0
- data/spec/unit/web/test_magic_assets.rb +82 -0
- data/tasks/test.rake +14 -0
- metadata +237 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'startback/web/magic_assets'
|
3
|
+
require 'startback/web/magic_assets/ng_html_transformer'
|
4
|
+
|
5
|
+
module Startback
|
6
|
+
module Web
|
7
|
+
describe MagicAssets do
|
8
|
+
include Rack::Test::Methods
|
9
|
+
|
10
|
+
context 'when used as an app' do
|
11
|
+
let(:app){
|
12
|
+
MagicAssets.new({
|
13
|
+
folder: Path.dir/"fixtures/assets"
|
14
|
+
})
|
15
|
+
}
|
16
|
+
|
17
|
+
it 'works as expected' do
|
18
|
+
get "/index.js"
|
19
|
+
expect(last_response.status).to eql(200)
|
20
|
+
expect(last_response.body).to match(/function test/)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'delegates a [] call to sprockets' do
|
24
|
+
result = app['index.js']
|
25
|
+
expect(result.to_s).to match(/function test/)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns a 404 on unknown' do
|
29
|
+
get '/nosuchone.js'
|
30
|
+
expect(last_response.status).to eql(404)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when used as a middleware' do
|
35
|
+
let(:app){
|
36
|
+
Rack::Builder.new do
|
37
|
+
use MagicAssets, {
|
38
|
+
folder: Path.dir/"fixtures/assets",
|
39
|
+
path: "/my-assets"
|
40
|
+
}
|
41
|
+
run ->(t){
|
42
|
+
[200, {}, ["Hello world"]]
|
43
|
+
}
|
44
|
+
end
|
45
|
+
}
|
46
|
+
|
47
|
+
it 'lets unrelated things pass' do
|
48
|
+
get "/hello"
|
49
|
+
expect(last_response.status).to eql(200)
|
50
|
+
expect(last_response.body).to eql("Hello world")
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'serves the assets under the chosen path' do
|
54
|
+
get "/my-assets/index.js"
|
55
|
+
expect(last_response.status).to eql(200)
|
56
|
+
expect(last_response.body).to match(/function test/)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when registering the NgHtmlTransformer' do
|
61
|
+
let(:app){
|
62
|
+
plugin = MagicAssets::NgHtmlTransformer.new({
|
63
|
+
ng_module: "test.templates"
|
64
|
+
})
|
65
|
+
MagicAssets.new({
|
66
|
+
folder: Path.dir/"fixtures/assets",
|
67
|
+
plugins: [plugin]
|
68
|
+
})
|
69
|
+
}
|
70
|
+
|
71
|
+
it 'works as expected' do
|
72
|
+
get "/index.js"
|
73
|
+
expect(last_response.status).to eql(200)
|
74
|
+
expect(last_response.body).to match(/function test/)
|
75
|
+
expect(last_response.body).to match(/Hello \{\{who\}\}/)
|
76
|
+
expect(last_response.body).to match(/angular.module\("test.templates"\)/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'path'
|
3
|
+
|
4
|
+
namespace :test do
|
5
|
+
|
6
|
+
desc "Run RSpec unit tests"
|
7
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
8
|
+
t.pattern = "spec/unit/**/test_*.rb"
|
9
|
+
t.rspec_opts = %{-Ilib -Ispec --color --backtrace --format progress --format RspecJunitFormatter --out spec/rspec-unit.xml}
|
10
|
+
end
|
11
|
+
|
12
|
+
task :all => [:unit]
|
13
|
+
end
|
14
|
+
task :test => :'test:all'
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: startback-websocket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.14.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bernard Lambeau
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: startback
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.14.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.14.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faye-websocket
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.11.0
|
34
|
+
- - "<="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.12.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.11.0
|
44
|
+
- - "<="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.12.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.6'
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '4.0'
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '3.6'
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '4.0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec_junit_formatter
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.4.1
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.5'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.4.1
|
84
|
+
- - "<"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.5'
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rake
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: rack-test
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
description: Websocket on top of the Startback framework
|
116
|
+
email: blambeau@gmail.com
|
117
|
+
executables: []
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- Gemfile
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/startback.rb
|
125
|
+
- lib/startback/audit.rb
|
126
|
+
- lib/startback/audit/prometheus.rb
|
127
|
+
- lib/startback/audit/shared.rb
|
128
|
+
- lib/startback/audit/trailer.rb
|
129
|
+
- lib/startback/caching/entity_cache.rb
|
130
|
+
- lib/startback/caching/no_store.rb
|
131
|
+
- lib/startback/caching/store.rb
|
132
|
+
- lib/startback/context.rb
|
133
|
+
- lib/startback/context/h_factory.rb
|
134
|
+
- lib/startback/context/middleware.rb
|
135
|
+
- lib/startback/errors.rb
|
136
|
+
- lib/startback/event.rb
|
137
|
+
- lib/startback/event/agent.rb
|
138
|
+
- lib/startback/event/bus.rb
|
139
|
+
- lib/startback/event/bus/bunny.rb
|
140
|
+
- lib/startback/event/bus/bunny/async.rb
|
141
|
+
- lib/startback/event/bus/memory.rb
|
142
|
+
- lib/startback/event/bus/memory/async.rb
|
143
|
+
- lib/startback/event/bus/memory/sync.rb
|
144
|
+
- lib/startback/event/engine.rb
|
145
|
+
- lib/startback/event/ext/context.rb
|
146
|
+
- lib/startback/event/ext/operation.rb
|
147
|
+
- lib/startback/ext.rb
|
148
|
+
- lib/startback/ext/date_time.rb
|
149
|
+
- lib/startback/ext/time.rb
|
150
|
+
- lib/startback/model.rb
|
151
|
+
- lib/startback/operation.rb
|
152
|
+
- lib/startback/operation/error_operation.rb
|
153
|
+
- lib/startback/operation/multi_operation.rb
|
154
|
+
- lib/startback/services.rb
|
155
|
+
- lib/startback/support.rb
|
156
|
+
- lib/startback/support/data_object.rb
|
157
|
+
- lib/startback/support/env.rb
|
158
|
+
- lib/startback/support/fake_logger.rb
|
159
|
+
- lib/startback/support/hooks.rb
|
160
|
+
- lib/startback/support/log_formatter.rb
|
161
|
+
- lib/startback/support/logger.rb
|
162
|
+
- lib/startback/support/operation_runner.rb
|
163
|
+
- lib/startback/support/robustness.rb
|
164
|
+
- lib/startback/support/transaction_manager.rb
|
165
|
+
- lib/startback/support/transaction_policy.rb
|
166
|
+
- lib/startback/support/world.rb
|
167
|
+
- lib/startback/version.rb
|
168
|
+
- lib/startback/web/api.rb
|
169
|
+
- lib/startback/web/auto_caching.rb
|
170
|
+
- lib/startback/web/catch_all.rb
|
171
|
+
- lib/startback/web/cors_headers.rb
|
172
|
+
- lib/startback/web/health_check.rb
|
173
|
+
- lib/startback/web/magic_assets.rb
|
174
|
+
- lib/startback/web/magic_assets/ng_html_transformer.rb
|
175
|
+
- lib/startback/web/magic_assets/rake_tasks.rb
|
176
|
+
- lib/startback/web/middleware.rb
|
177
|
+
- lib/startback/web/prometheus.rb
|
178
|
+
- lib/startback/web/shield.rb
|
179
|
+
- spec/spec_helper.rb
|
180
|
+
- spec/unit/audit/test_prometheus.rb
|
181
|
+
- spec/unit/audit/test_trailer.rb
|
182
|
+
- spec/unit/caching/test_entity_cache.rb
|
183
|
+
- spec/unit/context/test_abstraction_factory.rb
|
184
|
+
- spec/unit/context/test_dup.rb
|
185
|
+
- spec/unit/context/test_fork.rb
|
186
|
+
- spec/unit/context/test_h_factory.rb
|
187
|
+
- spec/unit/context/test_middleware.rb
|
188
|
+
- spec/unit/context/test_with_world.rb
|
189
|
+
- spec/unit/context/test_world.rb
|
190
|
+
- spec/unit/event/bus/memory/test_async.rb
|
191
|
+
- spec/unit/event/bus/memory/test_sync.rb
|
192
|
+
- spec/unit/support/hooks/test_after_hook.rb
|
193
|
+
- spec/unit/support/hooks/test_before_hook.rb
|
194
|
+
- spec/unit/support/operation_runner/test_around_run.rb
|
195
|
+
- spec/unit/support/operation_runner/test_before_after_call.rb
|
196
|
+
- spec/unit/support/test_data_object.rb
|
197
|
+
- spec/unit/support/test_env.rb
|
198
|
+
- spec/unit/support/test_robusteness.rb
|
199
|
+
- spec/unit/support/test_transaction_manager.rb
|
200
|
+
- spec/unit/support/test_world.rb
|
201
|
+
- spec/unit/test_event.rb
|
202
|
+
- spec/unit/test_operation.rb
|
203
|
+
- spec/unit/test_support.rb
|
204
|
+
- spec/unit/web/fixtures/assets/app/hello.es6
|
205
|
+
- spec/unit/web/fixtures/assets/app/hello.html
|
206
|
+
- spec/unit/web/fixtures/assets/index.es6
|
207
|
+
- spec/unit/web/test_api.rb
|
208
|
+
- spec/unit/web/test_auto_caching.rb
|
209
|
+
- spec/unit/web/test_catch_all.rb
|
210
|
+
- spec/unit/web/test_cors_headers.rb
|
211
|
+
- spec/unit/web/test_healthcheck.rb
|
212
|
+
- spec/unit/web/test_magic_assets.rb
|
213
|
+
- tasks/test.rake
|
214
|
+
homepage: https://www.enspirit.be
|
215
|
+
licenses:
|
216
|
+
- MIT
|
217
|
+
metadata: {}
|
218
|
+
post_install_message:
|
219
|
+
rdoc_options: []
|
220
|
+
require_paths:
|
221
|
+
- lib
|
222
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
223
|
+
requirements:
|
224
|
+
- - ">="
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: '0'
|
227
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
requirements: []
|
233
|
+
rubygems_version: 3.1.2
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
236
|
+
summary: Websocket on top of Startback
|
237
|
+
test_files: []
|