anatomy 0.2.16 → 0.3.0

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
  SHA1:
3
- metadata.gz: a9e27adc27d4ce9b9e27255abbfc61595a64dfaa
4
- data.tar.gz: d79a01d68b3b69f84ff9e485bb18ffec9ee7f43d
3
+ metadata.gz: 47f62f1faa26500750a8f1f6f0527b4be80ffae5
4
+ data.tar.gz: 932e0b655fa5ab2b23c8500ece2b3cd12907e9f2
5
5
  SHA512:
6
- metadata.gz: 336103723169c1c4e832b7bd840f7585baae69b7085305c40d11bd9eecba71bde1856b2bdd7d157c3003801796d5058007f7232326d58e5927428ff6af829d10
7
- data.tar.gz: 350aa961918fb5886cb70b46760ae73b7ffd5df83f077bb83b390a924173092e3097de3ae1c28cd1bd3c4e375432a63d57bdc137014d13a21b4c93c3960fb830
6
+ metadata.gz: 0edd0cec8340c5fcf51aabf9ad53670ce1df40c1c120b4a1b9744c935e89fa2e2d1a92d19430fc0a6c554d2b43beb7668f6fa903f8b45e32dc27ded34d7a5eea
7
+ data.tar.gz: 81ebee66c67b1448522854f5553b058109ad51c74a6ee8966c00a491a2f40254a741fb98328cc64e1ca1ba2821d4006c8cdeb8e0e539537514893120838aa5f4
@@ -1,6 +1,7 @@
1
1
  use(require("atomy"))
2
2
 
3
3
  require("webrick")
4
+ require("puma")
4
5
 
5
6
  -- shim in svg content-type support
6
7
  WEBrick HTTPUtils DefaultMimeTypes["svg"] = "image/svg+xml"
@@ -10,43 +11,47 @@ class(Server):
10
11
  @mutex = Mutex new
11
12
 
12
13
  def(Server serve(port)):
13
- server = WEBrick HTTPServer new(#{.Port -> port})
14
+ server = Puma Server new(
15
+ [env]:
16
+ relative-path = env["REQUEST_PATH"] sub(r"^\/", "")
17
+ local-abs-path = File absolute-path(relative-path, @destination)
14
18
 
15
- server mount-proc("/") [req, res]:
16
- relative-path = req path sub(r"^\/", "")
17
- local-abs-path = File absolute-path(relative-path, @destination)
19
+ if(relative-path == "favicon.ico")
20
+ then: respond-to-favicon
21
+ else: respond-to-path(relative-path, local-abs-path)
22
+ )
18
23
 
19
- if(relative-path == "favicon.ico")
20
- then: respond-to-favicon(res)
21
- else: respond-to-path(res, relative-path, local-abs-path)
24
+ server add-tcp-listener("0.0.0.0", port)
22
25
 
23
- trap("INT"): server shutdown
26
+ -- server mount-proc("/") [req, res]:
24
27
 
25
- server start
28
+ trap("INT"):
29
+ server stop
26
30
 
27
- def(Server respond-to-favicon(res)):
28
- res status = 404
31
+ puts(i"serving on port #{port}")
32
+ server run(false)
29
33
 
30
- def(Server respond-to-path(res, relative-path, local-abs-path)):
34
+ def(Server respond-to-favicon()):
35
+ [404, #{}, []]
36
+
37
+ def(Server respond-to-path(relative-path, local-abs-path)):
31
38
  do {
32
- rebuild-if-needed
39
+ rebuild-if-needed
33
40
 
34
41
  if(File directory?(local-abs-path))
35
- then: respond-to-file(res, File join(local-abs-path, "index.html"))
36
- else: respond-to-file(res, local-abs-path)
42
+ then: respond-to-file(File join(local-abs-path, "index.html"))
43
+ else: respond-to-file(local-abs-path)
37
44
  } rescue:
38
45
  e:
39
46
  message = i"#{e to-s}\n#{Rubinius Backtrace backtrace(e locations) show}"
40
47
  puts(message)
41
- respond-with-error(res, message)
48
+ respond-with-error(message)
42
49
 
43
- def(Server respond-with-error(res, message)):
44
- res content-type = "text/html"
45
- res body = i"<pre>#{message}</pre>"
50
+ def(Server respond-with-error(message)):
51
+ [500, #{"Content-Type" -> "text/html"}, [i"<pre>#{message}</pre>"]]
46
52
 
47
- def(Server respond-to-file(res, local-abs-path)):
48
- res body = File read(local-abs-path)
49
- res content-type = guess-content-type(local-abs-path)
53
+ def(Server respond-to-file(local-abs-path)):
54
+ [200, #{"Content-Type" -> guess-content-type(local-abs-path)}, [File read(local-abs-path)]]
50
55
 
51
56
  def(Server guess-content-type(path)):
52
57
  extension = File extname(path) sub(r"^\.", "")
@@ -54,7 +59,6 @@ def(Server guess-content-type(path)):
54
59
  "application/octet-stream"
55
60
 
56
61
  def(Server rebuild-if-needed):
57
- -- Webrick is multi-threaded; guard against concurrent builds
58
62
  @mutex synchronize:
59
63
  when(@last-disk-state == disk-state):
60
64
  return
@@ -1,3 +1,3 @@
1
1
  module Anatomy
2
- VERSION = "0.2.16"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,67 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anatomy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Suraci
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- prerelease: false
15
14
  name: atomy
15
+ prerelease: false
16
16
  type: :runtime
17
- version_requirements: !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.6.3
22
- requirement: !ruby/object:Gem::Requirement
22
+ version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.6.3
27
27
  - !ruby/object:Gem::Dependency
28
+ name: puma
28
29
  prerelease: false
29
- name: broomhlda
30
30
  type: :runtime
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '3.6'
31
36
  version_requirements: !ruby/object:Gem::Requirement
32
37
  requirements:
33
38
  - - "~>"
34
39
  - !ruby/object:Gem::Version
35
- version: 0.2.0
40
+ version: '3.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: broomhlda
43
+ prerelease: false
44
+ type: :runtime
36
45
  requirement: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - "~>"
39
48
  - !ruby/object:Gem::Version
40
49
  version: 0.2.0
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0
41
55
  - !ruby/object:Gem::Dependency
42
- prerelease: false
43
56
  name: json_pure
57
+ prerelease: false
44
58
  type: :runtime
45
- version_requirements: !ruby/object:Gem::Requirement
59
+ requirement: !ruby/object:Gem::Requirement
46
60
  requirements:
47
61
  - - "~>"
48
62
  - !ruby/object:Gem::Version
49
63
  version: '1.8'
50
- requirement: !ruby/object:Gem::Requirement
64
+ version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.8'
55
69
  - !ruby/object:Gem::Dependency
56
- prerelease: false
57
70
  name: rake
71
+ prerelease: false
58
72
  type: :development
59
- version_requirements: !ruby/object:Gem::Requirement
73
+ requirement: !ruby/object:Gem::Requirement
60
74
  requirements:
61
75
  - - "~>"
62
76
  - !ruby/object:Gem::Version
63
77
  version: '10.4'
64
- requirement: !ruby/object:Gem::Requirement
78
+ version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version