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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be3e6c07efcd8165eb967e3c9d699a81c77ed447fea68fbfb1d65518f148225d
4
- data.tar.gz: e2bd53f12b5f7f5233b4d05c87c18b770d3743a47b947e339949fe4ddbdddd94
3
+ metadata.gz: 55dbb62130ae7321355b3e20358524f0e8db29437e237b8f4c86a635517a213b
4
+ data.tar.gz: dd07bf18beb1836c1703b0d0b62cdc4949c3b63b9a84d3e26515c109e8e1bb13
5
5
  SHA512:
6
- metadata.gz: a3ca96043d241b8ff75532088c5ff4da8583486ab61c25e4b714405c17b3fd9c29c336176d06ac8c03026b1090e8b02264be05bfcc2c2463c8e47e61e8159e25
7
- data.tar.gz: 9d1d142728bfc9da2e12b8b38c05a06858cbe13b014f8e0fb8065b53e13c84febef39d292b70b67cfd640d75aa2abc0138519bedb9c5b37f4b2f24fd86410fc0
6
+ metadata.gz: 89abd4f0aa5d931e69ab38126276bb46f6afe60dac68f85065c30c5731e2f9c258dfe33cddb194df60319b47c9d0ba25d3fb31b33ea0cd31e3143f911d974d48
7
+ data.tar.gz: 5351954b22340e243230cb638c06f8eaaeb2bd8b48832d0637ef0d265e93b93cb3d1fe906b39c7fd2f258b1a0b25012e3a990c9ee4f1f4a063b67f642e94b4ed
data/bin/rackula CHANGED
@@ -22,9 +22,4 @@
22
22
 
23
23
  require 'rackula/command'
24
24
 
25
- begin
26
- Rackula::Command.parse(ARGV).invoke
27
- rescue Samovar::Failure
28
- puts "Failed: #{$!.message}"
29
- exit 1
30
- end
25
+ Rackula::Command.call
@@ -24,8 +24,8 @@ require_relative 'command/generate'
24
24
 
25
25
  module Rackula
26
26
  module Command
27
- def self.parse(*args)
28
- Top.parse(*args)
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 '<command>',
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 invoke(program_name: File.basename($0))
50
+ def call
50
51
  if @options[:version]
51
- puts "utopia v#{VERSION}"
52
- elsif @options[:help] or @command.nil?
53
- print_usage(program_name)
52
+ puts "#{self.name} v#{VERSION}"
53
+ elsif @options[:help]
54
+ print_usage(output: $stdout)
54
55
  else
55
- track_time do
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 'falcon'
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!("wget", "--mirror", "--recursive", "--continue", "--convert-links", "--adjust-extension", "--no-host-directories", "--directory-prefix", output_path.to_s, "http://localhost:#{port}")
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
- container_class = Async::Container::Threaded
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 = container_class.new(concurrency: @options[:concurrency]) do
83
- server.run
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::IO::Endpoint.tcp("localhost", address.ip_port, reuse_port: true)
98
+ endpoint = Async::HTTP::Endpoint.parse("http://localhost", port: address.ip_port, reuse_port: true)
89
99
 
90
- puts "Setting up container to serve site on port #{address.ip_port}..."
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.stop if container
106
+ container&.stop
97
107
  end
98
108
 
99
- def invoke(parent)
100
- # We set the default RACK_ENV to static unless it was already set to something.
101
- ENV['RACK_ENV'] ||= 'static'
109
+ def call
110
+ Variant.force!('static')
102
111
 
103
- Async::Reactor.run do
104
- endpoint = Async::IO::Endpoint.tcp("localhost", 0, reuse_port: true)
105
-
106
- # We bind to a socket to generate a temporary port:
107
- endpoint.bind do |socket|
108
- run(socket.local_address, Pathname.new(parent.root))
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
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Rackula
22
- VERSION = "0.5.0"
22
+ VERSION = "1.1.2"
23
23
  end
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: 0.5.0
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: 2018-07-16 00:00:00.000000000 Z
11
+ date: 2021-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: samovar
14
+ name: falcon
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
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: '1.8'
26
+ version: '0.34'
27
27
  - !ruby/object:Gem::Dependency
28
- name: falcon
28
+ name: samovar
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.17.6
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: 0.17.6
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: '1.15'
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: '1.15'
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: rake
84
+ name: covered
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - "~>"
87
+ - - ">="
60
88
  - !ruby/object:Gem::Version
61
- version: '10.0'
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: '10.0'
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
- rubyforge_project:
123
- rubygems_version: 2.7.6
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
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --format documentation
2
- --backtrace
3
- --require spec_helper
4
- --warnings
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- rvm:
5
- - 2.2
6
- - 2.3
7
- - 2.4
8
- - jruby-head
9
- - ruby-head
10
- env: COVERAGE=true
11
- matrix:
12
- allow_failures:
13
- - rvm: ruby-head
14
- - rvm: jruby-head
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in rackula.gemspec
4
- gemspec
5
-
6
- group :test do
7
- gem 'simplecov'
8
- gem 'coveralls', require: false
9
- end
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
- [![Build Status](https://secure.travis-ci.org/socketry/rackula.svg)](http://travis-ci.org/socketry/rackula)
6
- [![Coverage Status](https://coveralls.io/repos/socketry/rackula/badge.svg)](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
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
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