fpm-fry 0.5.0 → 0.5.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
  SHA256:
3
- metadata.gz: f7a586c439b3d55bc4f79e6b913e2b263738b0777070e031fc475c7581693e90
4
- data.tar.gz: 6dc98b7b8a5dba4bf15d3e6bb11c8c03cbd21a0bface5de566255aa75f966fe1
3
+ metadata.gz: 4911dfb40c91dd585e0ccbbad499a4d71eebadd4c00846b982ed100b186c963f
4
+ data.tar.gz: 7122bfa7728cb976d3b12010e63be177ccc23d00c360c4830317369f1d1012f1
5
5
  SHA512:
6
- metadata.gz: e560d5ca908265f246ea5017e918b83a41485282c269808a4ee2cb243ffeb51723b7d09aaad27652773e424c29f2012ea61a79b761bbece9f04cdfd96e5b1403
7
- data.tar.gz: 194b3169dedc54888baecd8a32e76ce830783219fc9814eef891cd760add2896242872f4e585a70552b27ec02e8ffc07a186c711edee07d2b4084e8518bc0dc3
6
+ metadata.gz: 9e1ef45f2c7b25b759e3f170b0a3a41d745e686a8a008da43494f6c53166f9695b241f3f2e45dab5fafacfd18a88ae5320e3e7831c4114d5a5e0cbbea08cf10c
7
+ data.tar.gz: fbe991bb53e481eab8293c0631079af94795f60dc6381635448fac81aaea0b879fe97e50860688654795a820d2813fab581bc06881223514c289bdd70b9dd42f
@@ -197,7 +197,7 @@ module FPM; module Fry
197
197
  )
198
198
 
199
199
  client.post(
200
- path: client.url('containers',container,'attach?stderr=1&stdout=1&stream=1'),
200
+ path: client.url('containers',container,'attach?stderr=1&stdout=1&stream=1&logs=1'),
201
201
  body: '',
202
202
  expects: [200],
203
203
  middlewares: [
@@ -10,11 +10,9 @@ module FPM::Fry::Plugin ; module Service
10
10
 
11
11
  def render(file)
12
12
  _erbout = ""
13
- erb = ERB.new(
14
- IO.read(File.join(File.dirname(__FILE__),'..','templates',file)),
15
- 0, "-"
16
- )
17
- eval(erb.src,nil,File.join(File.dirname(__FILE__),'..','templates',file))
13
+ path = File.join(File.dirname(__FILE__),'..','templates',file)
14
+ erb = ERB.new(IO.read(path), trim_mode: "-")
15
+ eval erb.src, nil, path
18
16
  return _erbout
19
17
  end
20
18
 
@@ -16,38 +16,56 @@ module FPM; module Fry
16
16
  if datum[:response]
17
17
  # probably mocked
18
18
  if datum[:response][:body]
19
- @parser.parse(StringIO.new(datum[:response][:body]))
19
+ headers = datum[:response][:headers]
20
+ fake_socket = StringIO.new(datum[:response][:body])
21
+ parse_response_data(fake_socket, headers)
20
22
  end
21
- return @stack.response_call(datum)
22
23
  else
23
- socket = datum[:connection].send(:socket)
24
- begin
25
- line = socket.readline
26
- match = /^HTTP\/\d+\.\d+\s(\d{3})\s/.match(line)
27
- end while !match
28
- status = match[1].to_i
29
-
30
- datum[:response] = {
31
- :body => '',
32
- :headers => Excon::Headers.new,
33
- :status => status,
34
- :remote_ip => socket.respond_to?(:remote_ip) && socket.remote_ip,
35
- }
36
- Excon::Response.parse_headers(socket, datum)
24
+ socket, headers = extract_socket_and_headers(datum)
25
+ parse_response_data(socket, headers)
26
+ end
27
+ @stack.response_call(datum)
28
+ end
29
+
30
+ private
31
+
32
+ def extract_socket_and_headers(datum)
33
+ socket = datum[:connection].send(:socket)
34
+ begin
35
+ line = socket.readline
36
+ match = /^HTTP\/\d+\.\d+\s(\d{3})\s/.match(line)
37
+ end while !match
38
+ status = match[1].to_i
39
+
40
+ headers = Excon::Headers.new
41
+ datum[:response] = {
42
+ :body => '',
43
+ :headers => headers,
44
+ :status => status,
45
+ :remote_ip => socket.respond_to?(:remote_ip) && socket.remote_ip,
46
+ }
47
+ Excon::Response.parse_headers(socket, datum)
48
+
49
+ [socket, headers]
50
+ end
37
51
 
52
+ def parse_response_data(socket, headers)
53
+ if headers["Transfer-Encoding"] == "chunked"
54
+ @parser.parse_chunked(socket)
55
+ else
38
56
  @parser.parse(socket)
39
- return @stack.response_call(datum)
40
57
  end
41
58
  end
42
59
 
43
60
  end
44
61
 
45
- attr :out, :err
62
+ attr :out, :err, :streams
46
63
 
47
64
  def initialize(out, err)
48
65
  @out, @err = out, err
49
66
  @state = :null
50
67
  @left = 0
68
+ @streams = { 1 => out, 2 => err }
51
69
  end
52
70
 
53
71
  def new(stack)
@@ -55,8 +73,6 @@ module FPM; module Fry
55
73
  end
56
74
 
57
75
  def parse(socket)
58
- left = 0
59
- streams = {1 => out, 2 => err}
60
76
  loop do
61
77
  type = read_exactly(socket,4){|part|
62
78
  if part.bytesize == 0
@@ -94,5 +110,16 @@ module FPM; module Fry
94
110
  return buf
95
111
  end
96
112
 
113
+ def parse_chunked(socket)
114
+ loop do
115
+ line = socket.readline
116
+ chunk_size = line.chomp.to_i(16)
117
+ break if chunk_size.zero?
118
+ chunk = socket.read(chunk_size)
119
+ parse(StringIO.new(chunk))
120
+ line = socket.readline
121
+ end
122
+ end
123
+
97
124
  end
98
125
  end ; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm-fry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Lagresle
@@ -95,28 +95,28 @@ dependencies:
95
95
  name: coveralls
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - "~>"
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: '0'
100
+ version: 0.8.23
101
101
  type: :development
102
102
  prerelease: false
103
103
  version_requirements: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - "~>"
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
- version: '0'
107
+ version: 0.8.23
108
108
  - !ruby/object:Gem::Dependency
109
109
  name: simplecov
110
110
  requirement: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - "~>"
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  type: :development
116
116
  prerelease: false
117
117
  version_requirements: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - "~>"
119
+ - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  description: deep-fried package builder