rackula 1.0.0 → 1.1.3

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: b249cc4bf0e7bb535b6ece14d8dce90b558a98c5f7921e735cb851341a36551f
4
- data.tar.gz: 2ff7b7e2ea8e11abc58a6f73aab66548e82cbcb993fcd79c3ef4218024343cfa
3
+ metadata.gz: '0281af1617fada7ee4c90875d489a0f681c45164fb4941718ddff54754e67a30'
4
+ data.tar.gz: 727840b9497c08f9a31b13ffda2fa584c642bc00697c29370b30a04a360d4f52
5
5
  SHA512:
6
- metadata.gz: dfab9891149e0474e8b0649282a9931a96bdf3bfaa9bc72948e2e82f5b4889ede982944ae39384637b3c1da12d347ba9b772c86f01b431ef34c32642dd6b4276
7
- data.tar.gz: 38ee786386165c2e06ced60ab591b5aa1141530f6603adc14e5db7a9f2a20ef0b797ebc1a9ab157543660176cde326e9b0382f55b315cbd95a394d9b4b3fb75e
6
+ metadata.gz: 8b9f2d4ce3a41e1aaae806ea69d59f2673617105d874bdd42414eb2e60d8f05afcd4a2d22fd06fd560b9faee7b0ffebb685ae119ab3bf6cce8b093112172a4ab
7
+ data.tar.gz: 2a2309ce12cc4679863fe97bc0d7f209ed9f20c9b968b28b86bacf099b086ce38a7738f074d3a29afd51c89cec77b27514741b2f950c8abb6664d571536d00ce
@@ -21,6 +21,7 @@
21
21
  require 'samovar'
22
22
 
23
23
  require 'pathname'
24
+ require 'fileutils'
24
25
  require 'rack'
25
26
 
26
27
  require 'falcon/server'
@@ -29,6 +30,8 @@ require 'async/io'
29
30
  require 'async/container'
30
31
  require 'async/http'
31
32
 
33
+ require 'variant'
34
+
32
35
  module Rackula
33
36
  module Command
34
37
  # Server setup commands.
@@ -41,8 +44,6 @@ module Rackula
41
44
  option '-o/--output-path <path>', "The output path to save static site.", default: 'static'
42
45
 
43
46
  option '-f/--force', "If the output path exists, delete it.", default: false
44
-
45
- option '--count', "The number of server instances to spawn.", default: 4
46
47
  end
47
48
 
48
49
  def copy_and_fetch(port, root)
@@ -57,7 +58,7 @@ module Rackula
57
58
  raise Samovar::Failure.new("Output path already exists!")
58
59
  end
59
60
  end
60
-
61
+
61
62
  # Create output directory
62
63
  Dir.mkdir(output_path)
63
64
 
@@ -72,23 +73,31 @@ module Rackula
72
73
  end
73
74
 
74
75
  def serve(endpoint, root)
75
- container = Async::Container::Threaded.new
76
+ container = Async::Container.new
76
77
 
77
78
  config_path = root + @options[:config]
78
- rack_app, options = Rack::Builder.parse_file(config_path.to_s)
79
-
80
- app = ::Falcon::Server.middleware(rack_app, verbose: @options[:verbose])
81
- server = ::Falcon::Server.new(app, endpoint)
82
79
 
83
- container.run(count: @options[:count]) do
84
- 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
85
90
  end
91
+
92
+ container.wait_until_ready
93
+
94
+ return container
86
95
  end
87
96
 
88
97
  def run(address, root)
89
- endpoint = Async::HTTP::URLEndpoint.parse("http://localhost", port: address.ip_port, reuse_port: true)
98
+ endpoint = Async::HTTP::Endpoint.parse("http://localhost", port: address.ip_port, reuse_port: true)
90
99
 
91
- puts "Setting up container to serve site on port #{address.ip_port}..."
100
+ Console.logger.info(self) {"Setting up container to serve site on port #{address.ip_port}..."}
92
101
  container = serve(endpoint, root)
93
102
 
94
103
  # puts "Copy and fetch site to static..."
@@ -98,17 +107,14 @@ module Rackula
98
107
  end
99
108
 
100
109
  def call
101
- # We set the default RACK_ENV to static unless it was already set to something.
102
- ENV['RACK_ENV'] ||= 'static'
110
+ Variant.force!('static')
103
111
 
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
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))
112
118
  end
113
119
  end
114
120
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Rackula
22
- VERSION = "1.0.0"
22
+ VERSION = "1.1.3"
23
23
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackula
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.3
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: 2019-03-26 00:00:00.000000000 Z
11
+ date: 2021-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: falcon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.34'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.34'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: samovar
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,21 +39,21 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '2.1'
27
41
  - !ruby/object:Gem::Dependency
28
- name: falcon
42
+ name: variant
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '0.27'
47
+ version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '0.27'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: covered
56
+ name: bake-bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -67,19 +81,19 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: covered
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '10.0'
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '10.0'
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,32 +108,23 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '3.0'
97
- description:
111
+ description:
98
112
  email:
99
- - samuel.williams@oriontransfer.co.nz
100
113
  executables:
101
114
  - rackula
102
115
  extensions: []
103
116
  extra_rdoc_files: []
104
117
  files:
105
- - ".editorconfig"
106
- - ".gitignore"
107
- - ".rspec"
108
- - ".travis.yml"
109
- - Gemfile
110
- - README.md
111
- - Rakefile
112
118
  - bin/rackula
113
119
  - lib/rackula.rb
114
120
  - lib/rackula/command.rb
115
121
  - lib/rackula/command/generate.rb
116
122
  - lib/rackula/version.rb
117
- - rackula.gemspec
118
123
  homepage: https://github.com/socketry/rackula
119
124
  licenses:
120
125
  - MIT
121
126
  metadata: {}
122
- post_install_message:
127
+ post_install_message:
123
128
  rdoc_options: []
124
129
  require_paths:
125
130
  - lib
@@ -134,8 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
139
  - !ruby/object:Gem::Version
135
140
  version: '0'
136
141
  requirements: []
137
- rubygems_version: 3.0.3
138
- signing_key:
142
+ rubygems_version: 3.2.22
143
+ signing_key:
139
144
  specification_version: 4
140
145
  summary: Generate a static site from any rackup compatible application.
141
146
  test_files: []
data/.editorconfig DELETED
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
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,17 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- matrix:
5
- include:
6
- - rvm: 2.3
7
- - rvm: 2.4
8
- - rvm: 2.5
9
- - rvm: 2.6
10
- env: COVERAGE=BriefSummary,Coveralls
11
- - rvm: ruby-head
12
- - rvm: jruby-head
13
- - rvm: truffleruby
14
- allow_failures:
15
- - rvm: ruby-head
16
- - rvm: jruby-head
17
- - rvm: truffleruby
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,28 +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", "~> 2.1"
22
- spec.add_dependency "falcon", "~> 0.27"
23
-
24
- spec.add_development_dependency "covered"
25
- spec.add_development_dependency "bundler"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
28
- end