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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cbefab8ff3594384572c6ee138527d03b2cea4904cc052d4a3450a7d3d2abfd
4
- data.tar.gz: afcbbd8734e1f5e144964a73ced12244576b63aacfbd3e91ea401febe2e89fda
3
+ metadata.gz: 5039707ba9bb39bbbfddfc7fc89340e4ac80035adbe7b1fd6384e31192c58fde
4
+ data.tar.gz: eb3c3ea58a63accd923ff265ceee6c92bd3cb075e853aa635378ba359e199181
5
5
  SHA512:
6
- metadata.gz: 825a72fb2f86258c1f45fc2decfef3ff7265fca9758cd9c25f180ada833e6191a87f2e1e2aaa978d3ec78e2dbc5391ccbbae8ed7965f1106ac2d4117301dd522
7
- data.tar.gz: be3e211bb625e32a57cf5e7a60f45082eb4f5711f9ad8ff4aeff59a5ad8ed1c06d4d964059d8d25917e2807542a5da8fc19963a301f832dad45fde1b6df445a8
6
+ metadata.gz: ec376d563599f830413d6f4a63c662cc3727651b42239d7d27ee3f999f72fe8774e23c7f972bd1f05bee9fa48e78c01f713598a3da9b613c1cab39bf57456121
7
+ data.tar.gz: b59920cbe6cc4d5260ce4c64a08e5c4e1b09d897aff4247d83d9ef8ccad4ceb8eb42ffed404c269e8bea8c01d48103fc69e3865ced9f6c911bf2807f8ab58179
@@ -0,0 +1,6 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = tab
5
+ indent_size = 2
6
+
@@ -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
@@ -10,3 +10,4 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ /spec/static
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://secure.travis-ci.org/socketry/rackula.svg)](http://travis-ci.org/socketry/rackula)
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
@@ -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,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 'falcon'
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!("wget", "--mirror", "--recursive", "--continue", "--convert-links", "--adjust-extension", "--no-host-directories", "--directory-prefix", output_path.to_s, "http://localhost:#{port}")
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
- container_class = Async::Container::Threaded
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 = container_class.new(concurrency: @options[:concurrency]) do
80
- server = Falcon::Server.new(app, [
81
- endpoint
82
- ])
83
-
84
- server.run
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::IO::Endpoint.tcp("localhost", address.ip_port, reuse_port: true)
97
+ endpoint = Async::HTTP::Endpoint.parse("http://localhost", port: address.ip_port, reuse_port: true)
90
98
 
91
- puts "Setting up container to serve site on port #{address.ip_port}..."
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.stop if container
105
+ container&.stop
98
106
  end
99
107
 
100
- def invoke(parent)
101
- # We set the default RACK_ENV to static unless it was already set to something.
102
- ENV['RACK_ENV'] ||= 'static'
108
+ def call
109
+ Variant.force!('static')
103
110
 
104
- Async::Reactor.run do
105
- endpoint = Async::IO::Endpoint.tcp("localhost", 0, reuse_port: true)
106
-
107
- # We bind to a socket to generate a temporary port:
108
- endpoint.bind do |socket|
109
- run(socket.local_address, Pathname.new(parent.root))
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
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Rackula
22
- VERSION = "0.4.0"
22
+ VERSION = "1.1.1"
23
23
  end
@@ -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.8"
22
- spec.add_dependency "falcon"
23
-
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 10.0"
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: 0.4.0
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: 2018-03-24 00:00:00.000000000 Z
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.8'
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.8'
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: '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: bake-bundler
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,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
- rubyforge_project:
123
- rubygems_version: 2.7.6
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: []
@@ -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/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