hostrich 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/lib/hostrich.rb +4 -1
- data/lib/hostrich/version.rb +1 -1
- data/spec/hostrich_spec.rb +7 -0
- data/spec/spec_helper.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4e3e96a9692ca3bb53ce5408f139c9ed51f1a1
|
4
|
+
data.tar.gz: 170021e024e461c62dd02cf61039dfa3d73af6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a95b457cdde2b09f7bef015fd933e6751b23fcc787bcb53c22520b40f6ce7335b41ac70a2e7e8b2c172c50aa2e075e72e54ded9465722a7992a2dd5f2960b83d
|
7
|
+
data.tar.gz: 86ce4fc2137a9869261c939db61e6c81656f59f15a7a8c2f268a9135666463155ec95c5a6c4d4c54def716797fd191508586e961bcd7dff35fdc88548fd2ea96
|
data/.rspec
CHANGED
data/lib/hostrich.rb
CHANGED
@@ -38,9 +38,12 @@ class Hostrich
|
|
38
38
|
status, headers, body = @app.call(env)
|
39
39
|
body.close if body.respond_to? :close
|
40
40
|
|
41
|
+
chunks = []
|
42
|
+
body.each { |chunk| chunks << chunk.to_s }
|
43
|
+
body = chunks.join
|
44
|
+
|
41
45
|
# Add current host suffix in all response bodies, so that occurences of http://example.com
|
42
46
|
# appear as http://example.com.dev or http://example.com.127.0.0.1.xip.io in the browser.
|
43
|
-
body = Array(body.each(&:to_s)).join
|
44
47
|
body = [add_suffix(body, suffix)]
|
45
48
|
|
46
49
|
# Do the same in response headers. This is important for cookies and redirects.
|
data/lib/hostrich/version.rb
CHANGED
data/spec/hostrich_spec.rb
CHANGED
@@ -11,6 +11,8 @@ describe Hostrich do
|
|
11
11
|
[302, { 'Location' => 'http://foo.com/index.html' }, []]
|
12
12
|
when '/cookie'
|
13
13
|
[200, { 'Set-Cookie' => 'some_param=foo.com/index.html; Path=/; Domain=.foo.com' }, ['Cookie!']]
|
14
|
+
when '/version.rb'
|
15
|
+
Rack::File.new('lib/hostrich').call(env)
|
14
16
|
else
|
15
17
|
[200, {}, ['Welcome to foo.com or foo.com.dev, not foo.comzle, not ffoo.com and not bar.io']]
|
16
18
|
end
|
@@ -31,6 +33,11 @@ describe Hostrich do
|
|
31
33
|
response = request.get('/cookie', 'HTTP_HOST' => 'foo.com.dev')
|
32
34
|
expect(response.headers['Set-Cookie']).to eq 'some_param=foo.com.dev/index.html; Path=/; Domain=.foo.com.dev'
|
33
35
|
end
|
36
|
+
|
37
|
+
it 'works with Rack::File' do
|
38
|
+
response = request.get('/version.rb', 'HTTP_HOST' => 'foo.com.dev')
|
39
|
+
expect(response.body).to include "class Hostrich\n VERSION"
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
context 'passing host as a string' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hostrich
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafaël Blais Masson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.4.5
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Hostrich is a Rack middleware that eases multi-domain web app development.
|