rackula 0.4.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +6 -0
- data/.github/workflows/development.yml +59 -0
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/bin/rackula +1 -6
- data/lib/rackula/command.rb +9 -10
- data/lib/rackula/command/generate.rb +35 -30
- data/lib/rackula/version.rb +1 -1
- data/rackula.gemspec +8 -5
- metadata +48 -21
- data/.travis.yml +0 -14
- data/Rakefile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5039707ba9bb39bbbfddfc7fc89340e4ac80035adbe7b1fd6384e31192c58fde
|
4
|
+
data.tar.gz: eb3c3ea58a63accd923ff265ceee6c92bd3cb075e853aa635378ba359e199181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec376d563599f830413d6f4a63c662cc3727651b42239d7d27ee3f999f72fe8774e23c7f972bd1f05bee9fa48e78c01f713598a3da9b613c1cab39bf57456121
|
7
|
+
data.tar.gz: b59920cbe6cc4d5260ce4c64a08e5c4e1b09d897aff4247d83d9ef8ccad4ceb8eb42ffed404c269e8bea8c01d48103fc69e3865ced9f6c911bf2807f8ab58179
|
data/.editorconfig
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
name: Development
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ${{matrix.os}}-latest
|
8
|
+
continue-on-error: ${{matrix.experimental}}
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
os:
|
13
|
+
- ubuntu
|
14
|
+
- macos
|
15
|
+
|
16
|
+
ruby:
|
17
|
+
- 2.5
|
18
|
+
- 2.6
|
19
|
+
- 2.7
|
20
|
+
|
21
|
+
experimental: [false]
|
22
|
+
env: [""]
|
23
|
+
|
24
|
+
include:
|
25
|
+
- os: ubuntu
|
26
|
+
ruby: truffleruby
|
27
|
+
experimental: true
|
28
|
+
env: JRUBY_OPTS="--debug -X+O"
|
29
|
+
- os: ubuntu
|
30
|
+
ruby: jruby
|
31
|
+
experimental: true
|
32
|
+
- os: ubuntu
|
33
|
+
ruby: head
|
34
|
+
experimental: true
|
35
|
+
- os: ubuntu
|
36
|
+
ruby: 2.6
|
37
|
+
experimental: false
|
38
|
+
env: COVERAGE=PartialSummary,Coveralls
|
39
|
+
|
40
|
+
steps:
|
41
|
+
- uses: actions/checkout@v1
|
42
|
+
- uses: ruby/setup-ruby@v1
|
43
|
+
with:
|
44
|
+
ruby-version: ${{matrix.ruby}}
|
45
|
+
|
46
|
+
- name: Install dependencies
|
47
|
+
run: ${{matrix.env}} bundle install
|
48
|
+
|
49
|
+
- name: Installing packages (ubuntu)
|
50
|
+
if: matrix.os == 'ubuntu'
|
51
|
+
run: sudo apt-get install wget
|
52
|
+
|
53
|
+
- name: Installing packages (macos)
|
54
|
+
if: matrix.os == 'macos'
|
55
|
+
run: brew install wget
|
56
|
+
|
57
|
+
- name: Run tests
|
58
|
+
timeout-minutes: 5
|
59
|
+
run: ${{matrix.env}} bundle exec rspec
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Rackula will immortalize your rackup web app by generating a static copy. It can be used to generate a static site from any rack-compatible middleware (e.g. rails, sinatra, utopia).
|
4
4
|
|
5
|
-
[![Build Status](https://
|
5
|
+
[![Build Status](https://travis-ci.com/socketry/rackula.svg)](https://travis-ci.com/socketry/rackula)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/socketry/rackula/badge.svg)](https://coveralls.io/r/socketry/rackula)
|
7
7
|
|
8
8
|
## Installation
|
data/bin/rackula
CHANGED
data/lib/rackula/command.rb
CHANGED
@@ -24,8 +24,8 @@ require_relative 'command/generate'
|
|
24
24
|
|
25
25
|
module Rackula
|
26
26
|
module Command
|
27
|
-
def self.
|
28
|
-
Top.
|
27
|
+
def self.call(*args)
|
28
|
+
Top.call(*args)
|
29
29
|
end
|
30
30
|
|
31
31
|
# The top level utopia command.
|
@@ -38,23 +38,22 @@ module Rackula
|
|
38
38
|
option '-v/--version', "Print out the application version."
|
39
39
|
end
|
40
40
|
|
41
|
-
nested
|
41
|
+
nested :command, {
|
42
42
|
'generate' => Generate
|
43
|
+
}, default: 'generate'
|
43
44
|
|
44
45
|
# The root directory for the site.
|
45
46
|
def root
|
46
47
|
File.expand_path(@options.fetch(:root, ''), Dir.getwd)
|
47
48
|
end
|
48
49
|
|
49
|
-
def
|
50
|
+
def call
|
50
51
|
if @options[:version]
|
51
|
-
puts "
|
52
|
-
elsif @options[:help]
|
53
|
-
print_usage(
|
52
|
+
puts "#{self.name} v#{VERSION}"
|
53
|
+
elsif @options[:help]
|
54
|
+
print_usage(output: $stdout)
|
54
55
|
else
|
55
|
-
|
56
|
-
@command.invoke(self)
|
57
|
-
end
|
56
|
+
@command.call
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
@@ -21,12 +21,15 @@
|
|
21
21
|
require 'samovar'
|
22
22
|
|
23
23
|
require 'pathname'
|
24
|
+
require 'rack'
|
24
25
|
|
25
26
|
require 'falcon/server'
|
27
|
+
|
26
28
|
require 'async/io'
|
27
29
|
require 'async/container'
|
30
|
+
require 'async/http'
|
28
31
|
|
29
|
-
require '
|
32
|
+
require 'variant'
|
30
33
|
|
31
34
|
module Rackula
|
32
35
|
module Command
|
@@ -35,13 +38,11 @@ module Rackula
|
|
35
38
|
self.description = "Start a local server and generate a static version of a site."
|
36
39
|
|
37
40
|
options do
|
38
|
-
option '-c/--config <path>', "Rackup configuration file to load", default: 'config.ru'
|
39
|
-
option '-p/--public <path>', "The public path to copy initial files from", default: 'public'
|
40
|
-
option '-o/--output-path <path>', "The output path to save static site", default: 'static'
|
41
|
+
option '-c/--config <path>', "Rackup configuration file to load.", default: 'config.ru'
|
42
|
+
option '-p/--public <path>', "The public path to copy initial files from.", default: 'public'
|
43
|
+
option '-o/--output-path <path>', "The output path to save static site.", default: 'static'
|
41
44
|
|
42
45
|
option '-f/--force', "If the output path exists, delete it.", default: false
|
43
|
-
|
44
|
-
option '--concurrency', "The concurrency of the server container", default: 4
|
45
46
|
end
|
46
47
|
|
47
48
|
def copy_and_fetch(port, root)
|
@@ -56,7 +57,7 @@ module Rackula
|
|
56
57
|
raise Samovar::Failure.new("Output path already exists!")
|
57
58
|
end
|
58
59
|
end
|
59
|
-
|
60
|
+
|
60
61
|
# Create output directory
|
61
62
|
Dir.mkdir(output_path)
|
62
63
|
|
@@ -67,48 +68,52 @@ module Rackula
|
|
67
68
|
end
|
68
69
|
|
69
70
|
# Generate HTML pages:
|
70
|
-
system
|
71
|
+
system("wget", "--mirror", "--recursive", "--continue", "--convert-links", "--adjust-extension", "--no-host-directories", "--directory-prefix", output_path.to_s, "http://localhost:#{port}")
|
71
72
|
end
|
72
73
|
|
73
74
|
def serve(endpoint, root)
|
74
|
-
|
75
|
+
container = Async::Container.new
|
75
76
|
|
76
77
|
config_path = root + @options[:config]
|
77
|
-
app, options = Rack::Builder.parse_file(config_path.to_s)
|
78
78
|
|
79
|
-
container
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
container.run do |instance|
|
80
|
+
Async do
|
81
|
+
rack_app, _ = Rack::Builder.parse_file(config_path.to_s)
|
82
|
+
app = ::Falcon::Server.middleware(rack_app, verbose: @options[:verbose])
|
83
|
+
server = ::Falcon::Server.new(app, endpoint)
|
84
|
+
|
85
|
+
instance.ready!
|
86
|
+
|
87
|
+
server.run
|
88
|
+
end
|
85
89
|
end
|
90
|
+
|
91
|
+
container.wait_until_ready
|
92
|
+
|
93
|
+
return container
|
86
94
|
end
|
87
95
|
|
88
96
|
def run(address, root)
|
89
|
-
endpoint = Async::
|
97
|
+
endpoint = Async::HTTP::Endpoint.parse("http://localhost", port: address.ip_port, reuse_port: true)
|
90
98
|
|
91
|
-
|
99
|
+
Async.logger.info(self) {"Setting up container to serve site on port #{address.ip_port}..."}
|
92
100
|
container = serve(endpoint, root)
|
93
101
|
|
94
102
|
# puts "Copy and fetch site to static..."
|
95
103
|
copy_and_fetch(address.ip_port, root)
|
96
104
|
ensure
|
97
|
-
container
|
105
|
+
container&.stop
|
98
106
|
end
|
99
107
|
|
100
|
-
def
|
101
|
-
|
102
|
-
ENV['RACK_ENV'] ||= 'static'
|
108
|
+
def call
|
109
|
+
Variant.force!('static')
|
103
110
|
|
104
|
-
Async::
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
end
|
111
|
+
endpoint = Async::IO::Endpoint.tcp("localhost", 0, reuse_port: true)
|
112
|
+
|
113
|
+
# We bind to a socket to generate a temporary port:
|
114
|
+
socket = Sync{endpoint.each.first.bind}
|
115
|
+
|
116
|
+
run(socket.local_address, Pathname.new(parent.root))
|
112
117
|
end
|
113
118
|
end
|
114
119
|
end
|
data/lib/rackula/version.rb
CHANGED
data/rackula.gemspec
CHANGED
@@ -18,10 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f)}
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "samovar", "~> 1
|
22
|
-
spec.add_dependency "falcon"
|
23
|
-
|
24
|
-
spec.
|
25
|
-
|
21
|
+
spec.add_dependency "samovar", "~> 2.1"
|
22
|
+
spec.add_dependency "falcon", "~> 0.34"
|
23
|
+
|
24
|
+
spec.add_dependency "variant"
|
25
|
+
|
26
|
+
spec.add_development_dependency "covered"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "bake-bundler"
|
26
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|
@@ -16,16 +16,30 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
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: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: falcon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.34'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.34'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: variant
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -38,34 +52,48 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: covered
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
|
-
- - "
|
73
|
+
- - ">="
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
75
|
+
version: '0'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- - "
|
80
|
+
- - ">="
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: bake-bundler
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- - "
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
89
|
+
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- - "
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rspec
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +108,7 @@ dependencies:
|
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '3.0'
|
83
|
-
description:
|
111
|
+
description:
|
84
112
|
email:
|
85
113
|
- samuel.williams@oriontransfer.co.nz
|
86
114
|
executables:
|
@@ -88,12 +116,12 @@ executables:
|
|
88
116
|
extensions: []
|
89
117
|
extra_rdoc_files: []
|
90
118
|
files:
|
119
|
+
- ".editorconfig"
|
120
|
+
- ".github/workflows/development.yml"
|
91
121
|
- ".gitignore"
|
92
122
|
- ".rspec"
|
93
|
-
- ".travis.yml"
|
94
123
|
- Gemfile
|
95
124
|
- README.md
|
96
|
-
- Rakefile
|
97
125
|
- bin/rackula
|
98
126
|
- lib/rackula.rb
|
99
127
|
- lib/rackula/command.rb
|
@@ -104,7 +132,7 @@ homepage: https://github.com/socketry/rackula
|
|
104
132
|
licenses:
|
105
133
|
- MIT
|
106
134
|
metadata: {}
|
107
|
-
post_install_message:
|
135
|
+
post_install_message:
|
108
136
|
rdoc_options: []
|
109
137
|
require_paths:
|
110
138
|
- lib
|
@@ -119,9 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
147
|
- !ruby/object:Gem::Version
|
120
148
|
version: '0'
|
121
149
|
requirements: []
|
122
|
-
|
123
|
-
|
124
|
-
signing_key:
|
150
|
+
rubygems_version: 3.1.2
|
151
|
+
signing_key:
|
125
152
|
specification_version: 4
|
126
153
|
summary: Generate a static site from any rackup compatible application.
|
127
154
|
test_files: []
|
data/.travis.yml
DELETED