impression 0.12 → 0.13

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: e9b79a3bb3823fad2c5c7ad2ed7f187c2c398dea84c62d9d0fdbd481238f499a
4
- data.tar.gz: 6cd1d41db73b992ee6f2027220440871d6512811f23b810ba064733a0538e7d4
3
+ metadata.gz: 7dff68cd22a426ae305742591ca09a3aa737cf453af1f186a54170671170f250
4
+ data.tar.gz: 920c5ca0698212f318dcc967cc09405e0b2f25e8d8521580c2fce331a4bfe982
5
5
  SHA512:
6
- metadata.gz: 734ab33bb5056e06076403fc774a13851953edec042b915826577aaa810c8e9d39c1a242b95836b5b6dcb61404d0fd1e8ab3afaf0cd095105a14d5ccd1bab9ea
7
- data.tar.gz: df49438b49021b4d42de855f72b2342ecfe9416a2ea118feb8d09580d8ac4c0bb3f10b87d25edc020cdf37be8a91a5d0d4f85119b3a7bf3e3d3186b917477594
6
+ metadata.gz: 98d8b4da9955eb4ac433cb74c45b9edeae759850e3a2b28cb4933f4445d554c25a360f968323f1a7a6db0bd9e748a2570048efc698a88803ac86920d77452757
7
+ data.tar.gz: e9e91a9fb0e9754fef82946f6a26368e53eb6c131d1e5d2ac0fe6e46274b75787cd2c47ee352a4dd015fd402ee2895fbfef2be1b7b01d84b8e3327ff91d18010
@@ -16,7 +16,7 @@ jobs:
16
16
  runs-on: ${{matrix.os}}
17
17
 
18
18
  env:
19
- POLYPHONY_USE_LIBEV: "1"
19
+ POLYPHONY_LIBEV: "1"
20
20
 
21
21
  steps:
22
22
  - name: Setup machine
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.13 2022-04-05
2
+
3
+ - Prevent race condiution on loading Ruby modules
4
+
1
5
  ## 0.12 2022-02-16
2
6
 
3
7
  - Implement `RackApp` resource class (#16)
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- impression (0.12)
4
+ impression (0.13)
5
5
  modulation (~> 1.1)
6
6
  papercraft (~> 0.23)
7
- polyphony (~> 0.77)
7
+ polyphony (~> 0.93)
8
8
  qeweney (~> 0.18)
9
- tipi (~> 0.50)
9
+ tipi (~> 0.52)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
@@ -16,8 +16,8 @@ GEM
16
16
  docile (1.4.0)
17
17
  escape_utils (1.2.1)
18
18
  ever (0.1)
19
- extralite (1.12)
20
- faraday (1.9.3)
19
+ extralite (1.14)
20
+ faraday (1.10.0)
21
21
  faraday-em_http (~> 1.0)
22
22
  faraday-em_synchrony (~> 1.0)
23
23
  faraday-excon (~> 1.1)
@@ -40,10 +40,10 @@ GEM
40
40
  faraday-patron (1.0.0)
41
41
  faraday-rack (1.0.0)
42
42
  faraday-retry (1.0.3)
43
- h1p (0.3)
43
+ h1p (0.5)
44
44
  http-2 (0.11.0)
45
45
  json (2.6.1)
46
- kramdown (2.3.1)
46
+ kramdown (2.3.2)
47
47
  rexml
48
48
  kramdown-parser-gfm (1.1.0)
49
49
  kramdown (~> 2.0)
@@ -52,12 +52,12 @@ GEM
52
52
  modulation (1.1)
53
53
  msgpack (1.4.5)
54
54
  multipart-post (2.1.1)
55
- papercraft (0.23)
55
+ papercraft (0.24)
56
56
  escape_utils (~> 1.2.1)
57
57
  kramdown (~> 2.3.1)
58
58
  kramdown-parser-gfm (~> 1.1.0)
59
59
  rouge (~> 3.27.0)
60
- polyphony (0.77)
60
+ polyphony (0.93)
61
61
  qeweney (0.18)
62
62
  escape_utils (~> 1.2.1)
63
63
  rack (2.2.3)
@@ -70,16 +70,16 @@ GEM
70
70
  json (>= 1.8, < 3)
71
71
  simplecov-html (~> 0.10.0)
72
72
  simplecov-html (0.10.2)
73
- tipi (0.50)
73
+ tipi (0.52)
74
74
  acme-client (~> 2.0.9)
75
75
  ever (~> 0.1)
76
- extralite (~> 1.2)
77
- h1p (~> 0.3)
76
+ extralite (~> 1.14)
77
+ h1p (~> 0.4)
78
78
  http-2 (~> 0.11)
79
79
  localhost (~> 1.1.4)
80
80
  msgpack (~> 1.4.2)
81
- polyphony (~> 0.77)
82
- qeweney (~> 0.17)
81
+ polyphony (~> 0.80)
82
+ qeweney (~> 0.18)
83
83
  rack (>= 2.0.8, < 2.3.0)
84
84
  websocket (~> 1.2.8)
85
85
  websocket (1.2.9)
data/impression.gemspec CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
  s.required_ruby_version = '>= 2.6'
22
22
 
23
- s.add_runtime_dependency 'polyphony', '~>0.77'
24
- s.add_runtime_dependency 'tipi', '~>0.50'
23
+ s.add_runtime_dependency 'polyphony', '~>0.93'
24
+ s.add_runtime_dependency 'tipi', '~>0.52'
25
25
  s.add_runtime_dependency 'qeweney', '~>0.18'
26
26
 
27
27
  s.add_runtime_dependency 'papercraft', '~>0.23'
@@ -16,6 +16,7 @@ module Impression
16
16
  def initialize(**props)
17
17
  super
18
18
  @layouts = {}
19
+ @file_info_loader = spin { run_file_info_loader }
19
20
  end
20
21
 
21
22
  # Returns a list of pages found in the given directory (relative to the base
@@ -46,6 +47,65 @@ module Impression
46
47
  symbolize_names: true
47
48
  }.freeze
48
49
 
50
+ # Runs a file info loader handling incoming requests for file info. This
51
+ # method is run in a fiber setup in #initialize.
52
+ #
53
+ # @return [void]
54
+ def run_file_info_loader
55
+ loop do
56
+ peer, path = receive
57
+ begin
58
+ info = calculate_path_info(path)
59
+ peer << info
60
+ rescue Polyphony::BaseException
61
+ raise
62
+ rescue => e
63
+ peer.raise(e)
64
+ end
65
+ end
66
+ end
67
+
68
+ def safe_calculate_path_info(path)
69
+ @file_info_loader << [Fiber.current, path]
70
+ receive
71
+ end
72
+
73
+ # Returns the path info for the given relative path.
74
+ #
75
+ # @param path [String] relative path
76
+ # @return [Hash] path info
77
+ def get_path_info(path)
78
+ @path_info_cache[path] ||= safe_calculate_path_info(path)
79
+ end
80
+
81
+ # Returns complete file info for Markdown files
82
+ #
83
+ # @param info [Hash] file info
84
+ # @param path [String] file path
85
+ # @return [Hash] file info
86
+ def file_info_md(info, path)
87
+ atts, content = parse_markdown_file(path)
88
+ info = info.merge(atts)
89
+ info[:html_content] = Papercraft.markdown(content)
90
+ info[:kind] = :markdown
91
+ if !info[:date] && (m = path.match(DATE_REGEXP))
92
+ info[:date] = Date.parse(m[1])
93
+ end
94
+ info
95
+ end
96
+
97
+ # Returns complete file info for Ruby files
98
+ #
99
+ # @param info [Hash] file info
100
+ # @param path [String] file path
101
+ # @return [Hash] file info
102
+ def file_info_rb(info, path)
103
+ info.merge(
104
+ kind: :module,
105
+ module: import(path)
106
+ )
107
+ end
108
+
49
109
  # Returns the path info for the given file path.
50
110
  #
51
111
  # @param path [String] file path
@@ -54,19 +114,12 @@ module Impression
54
114
  info = super
55
115
  case info[:ext]
56
116
  when '.md'
57
- atts, content = parse_markdown_file(path)
58
- info = info.merge(atts)
59
- info[:html_content] = Papercraft.markdown(content)
60
- info[:kind] = :markdown
117
+ file_info_md(info, path)
61
118
  when '.rb'
62
- info[:module] = import(path)
63
- info[:kind] = :module
64
- end
65
- if (m = path.match(DATE_REGEXP))
66
- info[:date] ||= Date.parse(m[1])
119
+ file_info_rb(info, path)
120
+ else
121
+ info
67
122
  end
68
-
69
- info
70
123
  end
71
124
 
72
125
  # Returns the pretty URL for the given relative path. For pages, the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Impression
4
- VERSION = '0.12'
4
+ VERSION = '0.13'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: impression
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.12'
4
+ version: '0.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2022-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: polyphony
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.77'
19
+ version: '0.93'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.77'
26
+ version: '0.93'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tipi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.50'
33
+ version: '0.52'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.50'
40
+ version: '0.52'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: qeweney
43
43
  requirement: !ruby/object:Gem::Requirement