rackula 0.5.0 → 1.1.2
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/rackula +1 -6
- data/lib/rackula/command.rb +9 -10
- data/lib/rackula/command/generate.rb +36 -29
- data/lib/rackula/version.rb +1 -1
- metadata +50 -31
- data/.gitignore +0 -12
- data/.rspec +0 -4
- data/.travis.yml +0 -14
- data/Gemfile +0 -9
- data/README.md +0 -62
- data/Rakefile +0 -6
- data/rackula.gemspec +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55dbb62130ae7321355b3e20358524f0e8db29437e237b8f4c86a635517a213b
|
|
4
|
+
data.tar.gz: dd07bf18beb1836c1703b0d0b62cdc4949c3b63b9a84d3e26515c109e8e1bb13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89abd4f0aa5d931e69ab38126276bb46f6afe60dac68f85065c30c5731e2f9c258dfe33cddb194df60319b47c9d0ba25d3fb31b33ea0cd31e3143f911d974d48
|
|
7
|
+
data.tar.gz: 5351954b22340e243230cb638c06f8eaaeb2bd8b48832d0637ef0d265e93b93cb3d1fe906b39c7fd2f258b1a0b25012e3a990c9ee4f1f4a063b67f642e94b4ed
|
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,16 @@
|
|
|
21
21
|
require 'samovar'
|
|
22
22
|
|
|
23
23
|
require 'pathname'
|
|
24
|
+
require 'fileutils'
|
|
25
|
+
require 'rack'
|
|
24
26
|
|
|
25
27
|
require 'falcon/server'
|
|
28
|
+
|
|
26
29
|
require 'async/io'
|
|
27
30
|
require 'async/container'
|
|
31
|
+
require 'async/http'
|
|
28
32
|
|
|
29
|
-
require '
|
|
33
|
+
require 'variant'
|
|
30
34
|
|
|
31
35
|
module Rackula
|
|
32
36
|
module Command
|
|
@@ -35,13 +39,11 @@ module Rackula
|
|
|
35
39
|
self.description = "Start a local server and generate a static version of a site."
|
|
36
40
|
|
|
37
41
|
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'
|
|
42
|
+
option '-c/--config <path>', "Rackup configuration file to load.", default: 'config.ru'
|
|
43
|
+
option '-p/--public <path>', "The public path to copy initial files from.", default: 'public'
|
|
44
|
+
option '-o/--output-path <path>', "The output path to save static site.", default: 'static'
|
|
41
45
|
|
|
42
46
|
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
47
|
end
|
|
46
48
|
|
|
47
49
|
def copy_and_fetch(port, root)
|
|
@@ -56,7 +58,7 @@ module Rackula
|
|
|
56
58
|
raise Samovar::Failure.new("Output path already exists!")
|
|
57
59
|
end
|
|
58
60
|
end
|
|
59
|
-
|
|
61
|
+
|
|
60
62
|
# Create output directory
|
|
61
63
|
Dir.mkdir(output_path)
|
|
62
64
|
|
|
@@ -67,47 +69,52 @@ module Rackula
|
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
# Generate HTML pages:
|
|
70
|
-
system
|
|
72
|
+
system("wget", "--mirror", "--recursive", "--continue", "--convert-links", "--adjust-extension", "--no-host-directories", "--directory-prefix", output_path.to_s, "http://localhost:#{port}")
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
def serve(endpoint, root)
|
|
74
|
-
|
|
76
|
+
container = Async::Container.new
|
|
75
77
|
|
|
76
78
|
config_path = root + @options[:config]
|
|
77
|
-
rack_app, options = Rack::Builder.parse_file(config_path.to_s)
|
|
78
|
-
|
|
79
|
-
app = ::Falcon::Server.middleware(rack_app, verbose: @options[:verbose])
|
|
80
|
-
server = ::Falcon::Server.new(app, endpoint)
|
|
81
79
|
|
|
82
|
-
container
|
|
83
|
-
|
|
80
|
+
container.run do |instance|
|
|
81
|
+
Async do
|
|
82
|
+
rack_app, _ = Rack::Builder.parse_file(config_path.to_s)
|
|
83
|
+
app = ::Falcon::Server.middleware(rack_app, verbose: @options[:verbose])
|
|
84
|
+
server = ::Falcon::Server.new(app, endpoint)
|
|
85
|
+
|
|
86
|
+
instance.ready!
|
|
87
|
+
|
|
88
|
+
server.run
|
|
89
|
+
end
|
|
84
90
|
end
|
|
91
|
+
|
|
92
|
+
container.wait_until_ready
|
|
93
|
+
|
|
94
|
+
return container
|
|
85
95
|
end
|
|
86
96
|
|
|
87
97
|
def run(address, root)
|
|
88
|
-
endpoint = Async::
|
|
98
|
+
endpoint = Async::HTTP::Endpoint.parse("http://localhost", port: address.ip_port, reuse_port: true)
|
|
89
99
|
|
|
90
|
-
|
|
100
|
+
Async.logger.info(self) {"Setting up container to serve site on port #{address.ip_port}..."}
|
|
91
101
|
container = serve(endpoint, root)
|
|
92
102
|
|
|
93
103
|
# puts "Copy and fetch site to static..."
|
|
94
104
|
copy_and_fetch(address.ip_port, root)
|
|
95
105
|
ensure
|
|
96
|
-
container
|
|
106
|
+
container&.stop
|
|
97
107
|
end
|
|
98
108
|
|
|
99
|
-
def
|
|
100
|
-
|
|
101
|
-
ENV['RACK_ENV'] ||= 'static'
|
|
109
|
+
def call
|
|
110
|
+
Variant.force!('static')
|
|
102
111
|
|
|
103
|
-
Async::
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
end
|
|
110
|
-
end
|
|
112
|
+
endpoint = Async::IO::Endpoint.tcp("localhost", 0, reuse_port: true)
|
|
113
|
+
|
|
114
|
+
# We bind to a socket to generate a temporary port:
|
|
115
|
+
socket = Sync{endpoint.each.first.bind}
|
|
116
|
+
|
|
117
|
+
run(socket.local_address, Pathname.new(parent.root))
|
|
111
118
|
end
|
|
112
119
|
end
|
|
113
120
|
end
|
data/lib/rackula/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,71 +1,99 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rackula
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.2
|
|
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: 2021-04-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: falcon
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0.34'
|
|
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: '
|
|
26
|
+
version: '0.34'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: samovar
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: '2.1'
|
|
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:
|
|
40
|
+
version: '2.1'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: variant
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bake-bundler
|
|
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: covered
|
|
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,31 +108,23 @@ dependencies:
|
|
|
80
108
|
- - "~>"
|
|
81
109
|
- !ruby/object:Gem::Version
|
|
82
110
|
version: '3.0'
|
|
83
|
-
description:
|
|
111
|
+
description:
|
|
84
112
|
email:
|
|
85
|
-
- samuel.williams@oriontransfer.co.nz
|
|
86
113
|
executables:
|
|
87
114
|
- rackula
|
|
88
115
|
extensions: []
|
|
89
116
|
extra_rdoc_files: []
|
|
90
117
|
files:
|
|
91
|
-
- ".gitignore"
|
|
92
|
-
- ".rspec"
|
|
93
|
-
- ".travis.yml"
|
|
94
|
-
- Gemfile
|
|
95
|
-
- README.md
|
|
96
|
-
- Rakefile
|
|
97
118
|
- bin/rackula
|
|
98
119
|
- lib/rackula.rb
|
|
99
120
|
- lib/rackula/command.rb
|
|
100
121
|
- lib/rackula/command/generate.rb
|
|
101
122
|
- lib/rackula/version.rb
|
|
102
|
-
- rackula.gemspec
|
|
103
123
|
homepage: https://github.com/socketry/rackula
|
|
104
124
|
licenses:
|
|
105
125
|
- MIT
|
|
106
126
|
metadata: {}
|
|
107
|
-
post_install_message:
|
|
127
|
+
post_install_message:
|
|
108
128
|
rdoc_options: []
|
|
109
129
|
require_paths:
|
|
110
130
|
- lib
|
|
@@ -119,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
139
|
- !ruby/object:Gem::Version
|
|
120
140
|
version: '0'
|
|
121
141
|
requirements: []
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
signing_key:
|
|
142
|
+
rubygems_version: 3.2.3
|
|
143
|
+
signing_key:
|
|
125
144
|
specification_version: 4
|
|
126
145
|
summary: Generate a static site from any rackup compatible application.
|
|
127
146
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# Rackula
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
[](http://travis-ci.org/socketry/rackula)
|
|
6
|
-
[](https://coveralls.io/r/socketry/rackula)
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
Install the gem:
|
|
11
|
-
|
|
12
|
-
$ gem install rackula
|
|
13
|
-
|
|
14
|
-
Ensure that `wget` is installed and available.
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
### Rack Applications
|
|
19
|
-
|
|
20
|
-
In the root directory, simply run `rackula`. It will generate a static site in `static`. For more details about how to change the default behavior, run `rackula --help`.
|
|
21
|
-
|
|
22
|
-
### Rails Applications
|
|
23
|
-
|
|
24
|
-
Add a `config.ru` file to your rails app and follow the above instructions.
|
|
25
|
-
|
|
26
|
-
```ruby
|
|
27
|
-
# config.ru for rails app
|
|
28
|
-
require_relative 'config/environment'
|
|
29
|
-
run Rails.application
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Contributing
|
|
33
|
-
|
|
34
|
-
1. Fork it
|
|
35
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
36
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
37
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
38
|
-
5. Create new Pull Request
|
|
39
|
-
|
|
40
|
-
## License
|
|
41
|
-
|
|
42
|
-
Released under the MIT license.
|
|
43
|
-
|
|
44
|
-
Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
|
45
|
-
|
|
46
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
47
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
48
|
-
in the Software without restriction, including without limitation the rights
|
|
49
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
50
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
51
|
-
furnished to do so, subject to the following conditions:
|
|
52
|
-
|
|
53
|
-
The above copyright notice and this permission notice shall be included in
|
|
54
|
-
all copies or substantial portions of the Software.
|
|
55
|
-
|
|
56
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
57
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
58
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
59
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
60
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
61
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
62
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/rackula.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require_relative "lib/rackula/version"
|
|
3
|
-
|
|
4
|
-
Gem::Specification.new do |spec|
|
|
5
|
-
spec.name = "rackula"
|
|
6
|
-
spec.version = Rackula::VERSION
|
|
7
|
-
spec.authors = ["Samuel Williams"]
|
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
|
9
|
-
|
|
10
|
-
spec.summary = "Generate a static site from any rackup compatible application."
|
|
11
|
-
spec.homepage = "https://github.com/socketry/rackula"
|
|
12
|
-
spec.license = "MIT"
|
|
13
|
-
|
|
14
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
15
|
-
f.match(%r{^(test|spec|features)/})
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f)}
|
|
19
|
-
spec.require_paths = ["lib"]
|
|
20
|
-
|
|
21
|
-
spec.add_dependency "samovar", "~> 1.8"
|
|
22
|
-
spec.add_dependency "falcon", "~> 0.17.6"
|
|
23
|
-
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.15"
|
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
-
end
|