sitehub 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +15 -1
- data/README.md +23 -0
- data/Rakefile +3 -9
- data/circle.yml +6 -0
- data/lib/sitehub/builder.rb +19 -19
- data/lib/sitehub/collection/route_collection.rb +7 -9
- data/lib/sitehub/collection/split_route_collection/split.rb +7 -5
- data/lib/sitehub/collection/split_route_collection.rb +13 -10
- data/lib/sitehub/collection.rb +26 -21
- data/lib/sitehub/constants/http_header_keys.rb +2 -6
- data/lib/sitehub/constants/rack_http_header_keys.rb +2 -2
- data/lib/sitehub/constants.rb +3 -3
- data/lib/sitehub/cookie/attribute.rb +4 -4
- data/lib/sitehub/cookie/flag.rb +4 -5
- data/lib/sitehub/cookie.rb +10 -14
- data/lib/sitehub/cookie_rewriting.rb +11 -13
- data/lib/sitehub/forward_proxies.rb +12 -13
- data/lib/sitehub/forward_proxy.rb +38 -24
- data/lib/sitehub/forward_proxy_builder.rb +38 -21
- data/lib/sitehub/http_headers.rb +39 -26
- data/lib/sitehub/logging/access_logger.rb +39 -35
- data/lib/sitehub/logging/error_logger.rb +7 -7
- data/lib/sitehub/logging/log_entry.rb +6 -5
- data/lib/sitehub/logging/log_stash.rb +2 -2
- data/lib/sitehub/logging/log_wrapper.rb +5 -5
- data/lib/sitehub/logging.rb +1 -1
- data/lib/sitehub/middleware.rb +2 -2
- data/lib/sitehub/path_directive.rb +10 -10
- data/lib/sitehub/path_directives.rb +5 -4
- data/lib/sitehub/request_mapping.rb +13 -11
- data/lib/sitehub/resolver.rb +5 -6
- data/lib/sitehub/reverse_proxy.rb +16 -12
- data/lib/sitehub/rules.rb +2 -2
- data/lib/sitehub/string_sanitiser.rb +1 -1
- data/lib/sitehub/transaction_id.rb +3 -3
- data/lib/sitehub/version.rb +1 -1
- data/lib/sitehub.rb +1 -1
- data/sitehub.gemspec +27 -29
- data/spec/sitehub/builder_spec.rb +18 -20
- data/spec/sitehub/collection/route_collection_spec.rb +16 -14
- data/spec/sitehub/collection/split_route_collection_spec.rb +8 -10
- data/spec/sitehub/collection_spec.rb +7 -7
- data/spec/sitehub/cookie/attribute_spec.rb +3 -3
- data/spec/sitehub/cookie/flag_spec.rb +2 -2
- data/spec/sitehub/cookie_rewriting_spec.rb +15 -12
- data/spec/sitehub/cookie_spec.rb +7 -18
- data/spec/sitehub/error_handling_spec.rb +2 -3
- data/spec/sitehub/forward_proxies_spec.rb +16 -12
- data/spec/sitehub/forward_proxy_builder_spec.rb +53 -30
- data/spec/sitehub/forward_proxy_spec.rb +26 -22
- data/spec/sitehub/http_headers_spec.rb +17 -18
- data/spec/sitehub/integration_spec.rb +4 -5
- data/spec/sitehub/logging/access_logger_spec.rb +25 -24
- data/spec/sitehub/logging/error_logger_spec.rb +5 -7
- data/spec/sitehub/logging/log_entry_spec.rb +2 -5
- data/spec/sitehub/logging/log_stash_spec.rb +1 -3
- data/spec/sitehub/logging/log_wrapper_spec.rb +0 -4
- data/spec/sitehub/middleware_spec.rb +1 -5
- data/spec/sitehub/path_directive_spec.rb +4 -7
- data/spec/sitehub/path_directives_spec.rb +6 -7
- data/spec/sitehub/request_mapping_spec.rb +2 -5
- data/spec/sitehub/resolver_spec.rb +1 -1
- data/spec/sitehub/reverse_proxy_spec.rb +37 -31
- data/spec/sitehub/transaction_id_spec.rb +3 -3
- data/spec/sitehub_spec.rb +2 -4
- data/spec/support/async/callback.rb +11 -0
- data/spec/support/async/middleware.rb +25 -0
- data/spec/support/async/response_handler.rb +16 -0
- data/spec/support/async.rb +4 -0
- data/spec/support/patch/rack/response.rb +13 -21
- data/spec/support/shared_contexts/async_context.rb +3 -58
- data/spec/support/shared_contexts/middleware_context.rb +15 -17
- data/spec/support/shared_contexts/rack_test_context.rb +3 -3
- data/spec/support/shared_contexts/sitehub_context.rb +9 -4
- data/spec/support/silent_warnings.rb +2 -3
- data/tasks/code_quality.rake +15 -0
- data/tasks/gem_tasks.rake +1 -0
- data/tasks/support/console.rb +7 -0
- data/tasks/testing.rake +4 -0
- data/tasks/util_tasks.rake +7 -0
- metadata +27 -3
- data/spec/basket_spec.rb +0 -30
@@ -1,17 +1,22 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
shared_context :site_hub do
|
3
|
-
|
4
|
-
let(:downstream_url){'http://localhost:12345'}
|
3
|
+
let(:downstream_url) { 'http://localhost:12345' }
|
5
4
|
|
6
5
|
before do
|
7
|
-
stub_request(:get, downstream_url).to_return(:
|
6
|
+
stub_request(:get, downstream_url).to_return(body: 'hello')
|
8
7
|
end
|
9
8
|
|
10
9
|
let(:builder) do
|
11
10
|
SiteHub::Builder.new.tap do |builder|
|
12
11
|
builder.access_logger StringIO.new
|
13
12
|
builder.error_logger StringIO.new
|
14
|
-
|
13
|
+
downstream_url = downstream_url()
|
14
|
+
builder.proxy '/endpoint' do
|
15
|
+
split(percentage: 100) do
|
16
|
+
split percentage: 50, label: 'experiment1', url: downstream_url
|
17
|
+
split percentage: 50, label: 'experiment2', url: downstream_url
|
18
|
+
end
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rubocop/rake_task'
|
3
|
+
$LOAD_PATH.unshift(__dir__)
|
4
|
+
require 'support/console'
|
5
|
+
|
6
|
+
RuboCop::RakeTask.new
|
7
|
+
|
8
|
+
task :coverage_check do
|
9
|
+
required_percentage = 100
|
10
|
+
percentage = JSON(File.read("#{__dir__}/../coverage/.last_run.json"))['result']['covered_percent']
|
11
|
+
unless percentage == required_percentage
|
12
|
+
Console.error "Expected coverage: #{required_percentage}% got: #{percentage}%"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/tasks/testing.rake
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitehub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ladtech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: rubocop
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: memory_profiler
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -257,11 +271,13 @@ extra_rdoc_files: []
|
|
257
271
|
files:
|
258
272
|
- ".gitignore"
|
259
273
|
- ".rspec"
|
274
|
+
- ".rubocop.yml"
|
260
275
|
- Gemfile
|
261
276
|
- Gemfile.lock
|
262
277
|
- LICENSE
|
263
278
|
- README.md
|
264
279
|
- Rakefile
|
280
|
+
- circle.yml
|
265
281
|
- lib/sitehub.rb
|
266
282
|
- lib/sitehub/builder.rb
|
267
283
|
- lib/sitehub/collection.rb
|
@@ -297,7 +313,6 @@ files:
|
|
297
313
|
- lib/sitehub/version.rb
|
298
314
|
- mem_usage.txt
|
299
315
|
- sitehub.gemspec
|
300
|
-
- spec/basket_spec.rb
|
301
316
|
- spec/sitehub/builder_spec.rb
|
302
317
|
- spec/sitehub/collection/route_collection_spec.rb
|
303
318
|
- spec/sitehub/collection/split_route_collection_spec.rb
|
@@ -326,12 +341,21 @@ files:
|
|
326
341
|
- spec/sitehub/transaction_id_spec.rb
|
327
342
|
- spec/sitehub_spec.rb
|
328
343
|
- spec/spec_helper.rb
|
344
|
+
- spec/support/async.rb
|
345
|
+
- spec/support/async/callback.rb
|
346
|
+
- spec/support/async/middleware.rb
|
347
|
+
- spec/support/async/response_handler.rb
|
329
348
|
- spec/support/patch/rack/response.rb
|
330
349
|
- spec/support/shared_contexts/async_context.rb
|
331
350
|
- spec/support/shared_contexts/middleware_context.rb
|
332
351
|
- spec/support/shared_contexts/rack_test_context.rb
|
333
352
|
- spec/support/shared_contexts/sitehub_context.rb
|
334
353
|
- spec/support/silent_warnings.rb
|
354
|
+
- tasks/code_quality.rake
|
355
|
+
- tasks/gem_tasks.rake
|
356
|
+
- tasks/support/console.rb
|
357
|
+
- tasks/testing.rake
|
358
|
+
- tasks/util_tasks.rake
|
335
359
|
homepage: ''
|
336
360
|
licenses:
|
337
361
|
- MIT
|
data/spec/basket_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
class Basket
|
2
|
-
|
3
|
-
attr_reader :items
|
4
|
-
def initialize shopping_list
|
5
|
-
@items = parse(shopping_list)
|
6
|
-
end
|
7
|
-
|
8
|
-
def parse shopping_list
|
9
|
-
shopping_list.lines[1..-1].collect { |item|
|
10
|
-
item.chomp.to_sym
|
11
|
-
}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe Basket do
|
16
|
-
|
17
|
-
describe '#initialize' do
|
18
|
-
it 'takes a shopping list' do
|
19
|
-
|
20
|
-
shopping_list=<<LIST
|
21
|
-
list
|
22
|
-
apple
|
23
|
-
carrot
|
24
|
-
LIST
|
25
|
-
|
26
|
-
basket = described_class.new(shopping_list)
|
27
|
-
expect(basket.items).to eq([:apple, :carrot])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|