raindeer 0.9.2 → 0.9.3
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/bin/rain +1 -0
- data/lib/cli/cli.rb +8 -3
- data/lib/cli/static.rb +45 -51
- data/lib/matrix/effects/color_effect.rb +1 -0
- data/lib/matrix/effects/leet_effect.rb +4 -4
- data/lib/matrix/stream.rb +2 -2
- data/lib/pages/pages.rb +6 -6
- data/lib/pages/raindown/lexemes/toc_lexeme.rb +2 -1
- data/lib/pages/raindown/nodes/toc_node.rb +3 -3
- data/lib/pages/raindown/raindown.rb +2 -2
- data/lib/raindeer/cli.rb +7 -8
- data/lib/raindeer/raindeer.rb +0 -2
- data/lib/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 41aa9563466af4e0a352cb288bf3af4dc340de96baa2417928f0807d745e7f4e
|
|
4
|
+
data.tar.gz: cf4ba9e858b140c6e3893814df02e04acc85a24320cf9e71580d2df5188aa615
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90762ce5864de9c7bdd5a69f6d30f5246388745d6bf2c44c85e01b661b48431210d6bc475cfe7b2d83f21de2305053292de4fbbfafc0b8922be5294761b36e5c
|
|
7
|
+
data.tar.gz: c63d7c49fedcbf168731510c4e5d07fdeeac7dfd27c81fdd099516f44a4940a8d700513b9cbfcab56eeea0aa46849774eae036aa1f5585cf4940cdae7a3b6395
|
data/bin/rain
CHANGED
data/lib/cli/cli.rb
CHANGED
|
@@ -7,13 +7,18 @@ module Rain
|
|
|
7
7
|
module CLI
|
|
8
8
|
extend Trees
|
|
9
9
|
|
|
10
|
+
TEMPLATE_URL = 'https://github.com/raindeer-rb/raindeer-template'
|
|
11
|
+
|
|
10
12
|
line('new :app_name') do |app_name|
|
|
11
|
-
summary {
|
|
12
|
-
execute
|
|
13
|
+
summary { 'Generates a Raindeer application with the specified name.' }
|
|
14
|
+
execute do
|
|
15
|
+
system("git clone #{TEMPLATE_URL} #{app_name}")
|
|
16
|
+
system("cd #{app_name}")
|
|
17
|
+
end
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
line('server') do
|
|
16
|
-
summary {
|
|
21
|
+
summary { 'Starts a Raindeer application. Once run visit http://127.0.0.1:4133' }
|
|
17
22
|
execute { system('bin/server') }
|
|
18
23
|
end
|
|
19
24
|
|
data/lib/cli/static.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
4
|
-
require 'lowload'
|
|
5
|
-
|
|
6
|
-
require 'async'
|
|
7
|
-
require 'async/http/internet'
|
|
3
|
+
require 'ruby-progressbar'
|
|
8
4
|
require 'fileutils'
|
|
9
5
|
|
|
6
|
+
require 'antlers' # Adds antlers support to lowload.
|
|
7
|
+
require 'lowload'
|
|
8
|
+
|
|
10
9
|
require_relative '../pages/pages'
|
|
11
10
|
|
|
12
11
|
module Rain
|
|
@@ -14,70 +13,65 @@ module Rain
|
|
|
14
13
|
module Static
|
|
15
14
|
extend self
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
FakeRequest = Data.define(:path)
|
|
17
|
+
RequestResult = Data.define(:path, :status, :html)
|
|
18
18
|
|
|
19
19
|
def build(application_path:)
|
|
20
|
-
metadata =
|
|
21
|
-
|
|
20
|
+
metadata = load_user_application(app_path: File.expand_path('app', application_path))
|
|
22
21
|
build_path = File.expand_path('build', application_path)
|
|
22
|
+
|
|
23
23
|
FileUtils.rm_rf(build_path)
|
|
24
24
|
FileUtils.mkdir_p(build_path)
|
|
25
25
|
FileUtils.cp_r(File.expand_path('public', application_path), File.expand_path('public', build_path))
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
FileUtils.mkdir_p(path)
|
|
30
|
-
File.write(File.expand_path('index.html', path), result.html)
|
|
27
|
+
Low::Events::RequestEvent.define do |observers|
|
|
28
|
+
observers << Providers['rain.router']
|
|
31
29
|
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def request_paths(metadata:, application_path:)
|
|
37
|
-
file_paths = metadata.file_types.values_at('md', 'rd', 'markdown', 'raindown').flat_map { it }.compact
|
|
38
|
-
url_paths = file_paths.map { |file_path| Rain::Pages.url_path(file_path:) }.compact
|
|
39
|
-
# Skip files that became solely metadata due to underscores hiding the entire file path.
|
|
40
|
-
url_paths.reject! { |url_path| url_path == '' }
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
request_path = request_path(application_path:, file_path:)
|
|
45
|
-
request_url = endpoint + request_path
|
|
31
|
+
request_results(metadata:).each do |request_result|
|
|
32
|
+
folder_path = File.join(build_path, request_result.path)
|
|
46
33
|
|
|
47
|
-
|
|
48
|
-
response_html = response.read
|
|
49
|
-
response.close
|
|
34
|
+
puts "#{folder_path} => #{request_result.status}"
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
FileUtils.mkdir_p(folder_path)
|
|
37
|
+
File.write(File.expand_path('index.html', folder_path), request_result.html)
|
|
53
38
|
end
|
|
54
|
-
|
|
55
|
-
tasks.map(&:result)
|
|
56
39
|
end
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
file_path.delete_prefix("#{application_path}/app/pages/")
|
|
60
|
-
end
|
|
41
|
+
private
|
|
61
42
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
end
|
|
43
|
+
def load_user_application(app_path:)
|
|
44
|
+
metadata = LowLoad.dirload(app_path)
|
|
65
45
|
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
if Dir.exist?(File.expand_path('pages', app_path))
|
|
47
|
+
Providers.define('rain.pages', eager: true) do
|
|
48
|
+
require_relative '../pages/pages'
|
|
49
|
+
Rain::Pages.new(metadata:)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
metadata
|
|
68
54
|
end
|
|
69
55
|
|
|
70
|
-
def
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
56
|
+
def request_results(metadata:)
|
|
57
|
+
file_paths = metadata.file_types.values_at('md', 'rd', 'markdown', 'raindown').flat_map { it }.compact
|
|
58
|
+
paths = file_paths.map { |file_path| Rain::Pages.url_path(file_path:) }.compact
|
|
59
|
+
paths << '/'
|
|
60
|
+
# Skip files that became solely metadata due to underscores hiding the entire file path.
|
|
61
|
+
paths.reject! { |url_path| url_path == '' }
|
|
62
|
+
|
|
63
|
+
progress_bar = ProgressBar.create(
|
|
64
|
+
total: paths.size,
|
|
65
|
+
format: "\e[0;34m%a |%B| %p%%\e[0m"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
paths.map do |path|
|
|
69
|
+
request = FakeRequest.new(path:)
|
|
70
|
+
response = Low::Events::RequestEvent.take(request:).response
|
|
71
|
+
result = RequestResult.new(path:, status: response.status, html: response.read)
|
|
72
|
+
progress_bar.increment
|
|
73
|
+
result
|
|
74
|
+
end
|
|
81
75
|
end
|
|
82
76
|
end
|
|
83
77
|
end
|
|
@@ -11,14 +11,14 @@ module Rain
|
|
|
11
11
|
@leet_letters = @leet_numbers.invert
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def render(output:,
|
|
15
|
-
output = filter(output:,
|
|
14
|
+
def render(output:, x:, y:, **)
|
|
15
|
+
output = filter(output:, x:, y:, **)
|
|
16
16
|
save(output:, x:, y:)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
private
|
|
20
20
|
|
|
21
|
-
def filter(output:,
|
|
21
|
+
def filter(output:, x:, y:, **)
|
|
22
22
|
return unless output
|
|
23
23
|
|
|
24
24
|
character = output.downcase
|
|
@@ -26,7 +26,7 @@ module Rain
|
|
|
26
26
|
|
|
27
27
|
return @leet_numbers[character] if @leet_letters.key?(last_character) && rand < 0.99
|
|
28
28
|
return @leet_numbers[character] if @leet_numbers.key?(character) && rand < 0.005
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
output
|
|
31
31
|
end
|
|
32
32
|
end
|
data/lib/matrix/stream.rb
CHANGED
|
@@ -75,8 +75,8 @@ module Rain
|
|
|
75
75
|
# └─────┴─────┴─────┘
|
|
76
76
|
def render(duration: nil)
|
|
77
77
|
@show_cursor.increment(delays:, inputs:, duration:) do |index|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
index.zero? ? @inputs.count - 1 : index - 1
|
|
79
|
+
index + 1 >= @inputs.count ? 0 : index + 1
|
|
80
80
|
|
|
81
81
|
if @inputs[index]
|
|
82
82
|
@outputs[index] = @inputs[index]
|
data/lib/pages/pages.rb
CHANGED
|
@@ -56,7 +56,7 @@ module Rain
|
|
|
56
56
|
metadata, * = parse_file(file_path:, parse_content: false)
|
|
57
57
|
metadata.each do |type, tag|
|
|
58
58
|
tag(type:, tag:, file_path:)
|
|
59
|
-
end
|
|
59
|
+
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -68,10 +68,10 @@ module Rain
|
|
|
68
68
|
|
|
69
69
|
def folders(file_path:)
|
|
70
70
|
File.dirname(file_path)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
.split(Regexp.union(['/', '&', '-']))
|
|
72
|
+
.filter { it.start_with?('_') }
|
|
73
|
+
.map { it.delete_prefix('_') }
|
|
74
|
+
.filter { !number?(it) }
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def order(file_path)
|
|
@@ -100,7 +100,7 @@ module Rain
|
|
|
100
100
|
data_lines = []
|
|
101
101
|
text_lines = []
|
|
102
102
|
|
|
103
|
-
File.foreach(file_path)
|
|
103
|
+
File.foreach(file_path) do |line|
|
|
104
104
|
if line.strip == '---' && dash_lines.count < 2
|
|
105
105
|
dash_lines << line
|
|
106
106
|
next
|
|
@@ -14,14 +14,14 @@ module Rain
|
|
|
14
14
|
def render(current_binding: nil, parent_binding: nil, slot_node: nil)
|
|
15
15
|
doc = Nokogiri::HTML(@template)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
<<~HTML
|
|
18
18
|
<div class="floating">
|
|
19
19
|
<details id="toc" open>
|
|
20
20
|
<summary>Table of contents</summary>
|
|
21
21
|
<ul>
|
|
22
|
-
#{doc.css('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]').map
|
|
22
|
+
#{doc.css('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]').map do |h|
|
|
23
23
|
"<li class='#{h.name}'><a href='\##{h['id']}'>#{h.text.strip}</a></li>"
|
|
24
|
-
|
|
24
|
+
end.join("\n")}
|
|
25
25
|
</ul>
|
|
26
26
|
</details>
|
|
27
27
|
</div>
|
|
@@ -6,14 +6,14 @@ require_relative 'elements'
|
|
|
6
6
|
|
|
7
7
|
module Rain
|
|
8
8
|
module Raindown
|
|
9
|
-
|
|
9
|
+
module_function
|
|
10
10
|
|
|
11
11
|
def render(markdown:)
|
|
12
12
|
template = markdown.gsub('<{', '<!-- ANTLERS').gsub('}>', 'ANTLERS -->')
|
|
13
13
|
|
|
14
14
|
doc = Commonmarker.parse(template)
|
|
15
15
|
doc.walk do |node|
|
|
16
|
-
if
|
|
16
|
+
if %i[code code_block].include?(node.type)
|
|
17
17
|
node.string_content = node.string_content.gsub('<!-- ANTLERS', '<{').gsub('ANTLERS -->', '}>')
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/raindeer/cli.rb
CHANGED
|
@@ -5,7 +5,12 @@ require 'low_type'
|
|
|
5
5
|
require 'observers'
|
|
6
6
|
require 'providers'
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# The CLI loads user application code and metadata, but doesn't start a server.
|
|
9
|
+
#
|
|
10
|
+
# Flow:
|
|
11
|
+
# 1. bin/rain - Located in raindeer or user application, loads "raindeer/cli" which is available on $PATH.
|
|
12
|
+
# 2. lib/raindeer/cli - Boots up a raindeer/user application that is suitable for use by the CLI. <-- YOU ARE HERE
|
|
13
|
+
# 3. lib/cli/cli - Defines and runs the CLI that responds to the ARGs given to bin/rain.
|
|
9
14
|
|
|
10
15
|
#################################################
|
|
11
16
|
# FRAMEWORK INTERNAL API
|
|
@@ -24,13 +29,7 @@ end
|
|
|
24
29
|
# FRAMEWORK EXTERNAL API
|
|
25
30
|
#################################################
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
class << self
|
|
29
|
-
def router(&block)
|
|
30
|
-
Providers['rain.router'].instance_eval(&block)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
32
|
+
require_relative 'raindeer'
|
|
34
33
|
|
|
35
34
|
#################################################
|
|
36
35
|
# CLI
|
data/lib/raindeer/raindeer.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raindeer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
@@ -10,7 +10,7 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: commonmarker
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
@@ -24,7 +24,7 @@ dependencies:
|
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: nokogiri
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
@@ -38,7 +38,21 @@ dependencies:
|
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
|
-
name:
|
|
41
|
+
name: ostruct
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: paint
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
43
57
|
requirements:
|
|
44
58
|
- - ">="
|
|
@@ -66,7 +80,7 @@ dependencies:
|
|
|
66
80
|
- !ruby/object:Gem::Version
|
|
67
81
|
version: '0'
|
|
68
82
|
- !ruby/object:Gem::Dependency
|
|
69
|
-
name:
|
|
83
|
+
name: ruby-progressbar
|
|
70
84
|
requirement: !ruby/object:Gem::Requirement
|
|
71
85
|
requirements:
|
|
72
86
|
- - ">="
|