lively 0.17.1 → 0.18.0
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
- checksums.yaml.gz.sig +0 -0
- data/bin/lively +3 -2
- data/lib/lively/assets.rb +1 -0
- data/lib/lively/environment/application.rb +48 -36
- data/lib/lively/environment/http.rb +34 -0
- data/lib/lively/environment/htty.rb +22 -0
- data/lib/lively/environment/middleware.rb +48 -0
- data/lib/lively/resolver.rb +1 -1
- data/lib/lively/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +32 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a673a59bd33ad2da10a565846eb708b9dc2390745e22a468763758ce8f6d3296
|
|
4
|
+
data.tar.gz: 4366967a33057ad99f803015799f63574f1fd2fc393053cd37f30dacd5881232
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5bc31ac8e9c2dd9f7f3f400080de7d12b625a9795eea0601b03c2c5f5fde79a3d8bd1f185684655c2ada88ffe7f1113c9ec11c67a13969031bdaa14734644e3
|
|
7
|
+
data.tar.gz: b90a6057a65af77b8fb5221e6760893e78e7d39cc7e986180d0ea97ded8510130a7d372572bec213d74e1538f55fe43b61295ffad66464db949b980b04ee1b9d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/bin/lively
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "async/service"
|
|
5
|
+
require "async/container/threaded"
|
|
5
6
|
require_relative "../lib/lively/environment/application"
|
|
6
7
|
|
|
7
8
|
ARGV.each do |path|
|
|
@@ -11,7 +12,7 @@ end
|
|
|
11
12
|
configuration = Async::Service::Configuration.build do
|
|
12
13
|
service "lively" do
|
|
13
14
|
include Lively::Environment::Application
|
|
14
|
-
end
|
|
15
|
+
end
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
Async::Service::Controller.run(configuration)
|
|
18
|
+
Async::Service::Controller.run(configuration, container_class: Async::Container::Threaded)
|
data/lib/lively/assets.rb
CHANGED
|
@@ -1,56 +1,68 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2021-
|
|
4
|
+
# Copyright, 2021-2026, by Samuel Williams.
|
|
5
5
|
|
|
6
|
-
require_relative "
|
|
7
|
-
require_relative "
|
|
8
|
-
|
|
9
|
-
require "falcon/environment/server"
|
|
6
|
+
require_relative "middleware"
|
|
7
|
+
require_relative "http"
|
|
8
|
+
require_relative "htty"
|
|
10
9
|
|
|
11
10
|
# @namespace
|
|
12
11
|
module Lively
|
|
13
12
|
# @namespace
|
|
14
13
|
module Environment
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
# This
|
|
18
|
-
#
|
|
19
|
-
#
|
|
14
|
+
# Multiplexing environment for Lively applications.
|
|
15
|
+
#
|
|
16
|
+
# Declares the transport selection as explicit, overridable evaluator keys and uses `make_service` to compose the appropriate child environment at service startup time. This keeps transport selection in the service layer rather than in module inclusion hooks.
|
|
17
|
+
#
|
|
18
|
+
# The `htty` key controls which transport is used. Override it in a service block to force a specific transport regardless of the environment variable:
|
|
19
|
+
#
|
|
20
|
+
# ~~~ ruby
|
|
21
|
+
# service "myapp" do
|
|
22
|
+
# include Lively::Environment::Application
|
|
23
|
+
# def htty = false # always use HTTP
|
|
24
|
+
# end
|
|
25
|
+
# ~~~
|
|
20
26
|
module Application
|
|
21
|
-
include
|
|
27
|
+
include Lively::Environment::Middleware
|
|
28
|
+
# Note: does not include Falcon::Environment::Server directly. Falcon is
|
|
29
|
+
# brought in exclusively via http_environment so that the combined
|
|
30
|
+
# evaluator's service_class resolves correctly without shadowing.
|
|
31
|
+
|
|
32
|
+
# Whether to use HTTY transport. Reads ENV["HTTY"] by default.
|
|
33
|
+
# @returns [Boolean]
|
|
34
|
+
def htty
|
|
35
|
+
ENV["HTTY"] == "1"
|
|
36
|
+
end
|
|
22
37
|
|
|
23
|
-
#
|
|
24
|
-
# @returns [
|
|
25
|
-
def
|
|
26
|
-
|
|
38
|
+
# The environment module to use for HTTY transport.
|
|
39
|
+
# @returns [Module]
|
|
40
|
+
def htty_environment
|
|
41
|
+
Lively::Environment::HTTY
|
|
27
42
|
end
|
|
28
43
|
|
|
29
|
-
#
|
|
30
|
-
# @returns [
|
|
31
|
-
def
|
|
32
|
-
|
|
44
|
+
# The environment module to use for HTTP transport.
|
|
45
|
+
# @returns [Module]
|
|
46
|
+
def http_environment
|
|
47
|
+
Lively::Environment::HTTP
|
|
33
48
|
end
|
|
34
49
|
|
|
35
|
-
#
|
|
36
|
-
# @returns [
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
Object.const_get(:Application)
|
|
40
|
-
else
|
|
41
|
-
Console.warn(self, "No Application class defined, using default.")
|
|
42
|
-
::Lively::Application
|
|
43
|
-
end
|
|
50
|
+
# The environment module for the selected transport.
|
|
51
|
+
# @returns [Module]
|
|
52
|
+
def transport_environment
|
|
53
|
+
htty ? htty_environment : http_environment
|
|
44
54
|
end
|
|
45
55
|
|
|
46
|
-
# Build the
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
# Build the service by composing the transport environment on top of this one.
|
|
57
|
+
# Called by Async::Service::Generic.wrap — self is the evaluator at call time.
|
|
58
|
+
# @parameter environment [Async::Service::Environment]
|
|
59
|
+
# @returns [Async::Service::Generic]
|
|
60
|
+
def make_service(environment)
|
|
61
|
+
combined = environment.with(transport_environment)
|
|
62
|
+
combined_evaluator = combined.evaluator
|
|
63
|
+
|
|
64
|
+
# Call `service_class.new` directly rather than `Async::Service::Generic.wrap` — the combined evaluator still has `Application` (and therefore `make_service`) in its ancestor chain, so `wrap` would recurse back into this method.
|
|
65
|
+
return combined_evaluator.service_class.new(combined, combined_evaluator)
|
|
54
66
|
end
|
|
55
67
|
end
|
|
56
68
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2021-2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require_relative "middleware"
|
|
7
|
+
require "falcon/environment/server"
|
|
8
|
+
|
|
9
|
+
# @namespace
|
|
10
|
+
module Lively
|
|
11
|
+
# @namespace
|
|
12
|
+
module Environment
|
|
13
|
+
# Falcon (TCP/HTTP) environment for Lively applications.
|
|
14
|
+
#
|
|
15
|
+
# Combines {Falcon::Environment::Server} for HTTP transport with
|
|
16
|
+
# {Lively::Environment::Middleware} for application and asset serving.
|
|
17
|
+
module HTTP
|
|
18
|
+
include Falcon::Environment::Server
|
|
19
|
+
include Lively::Environment::Middleware
|
|
20
|
+
|
|
21
|
+
# The URL this server binds to.
|
|
22
|
+
# @returns [String]
|
|
23
|
+
def url
|
|
24
|
+
ENV.fetch("LIVELY_URL", "http://localhost:9292")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The number of worker processes/threads to run.
|
|
28
|
+
# @returns [Integer]
|
|
29
|
+
def count
|
|
30
|
+
1
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require_relative "middleware"
|
|
7
|
+
require "async/htty/environment/server"
|
|
8
|
+
|
|
9
|
+
# @namespace
|
|
10
|
+
module Lively
|
|
11
|
+
# @namespace
|
|
12
|
+
module Environment
|
|
13
|
+
# HTTY (terminal side-channel) environment for Lively applications.
|
|
14
|
+
#
|
|
15
|
+
# Combines {Async::HTTY::Environment} for HTTY transport with
|
|
16
|
+
# {Lively::Environment::Middleware} for application and asset serving.
|
|
17
|
+
module HTTY
|
|
18
|
+
include Async::HTTY::Environment::Server
|
|
19
|
+
include Lively::Environment::Middleware
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2021-2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require_relative "../application"
|
|
7
|
+
require_relative "../assets"
|
|
8
|
+
|
|
9
|
+
require "protocol/http/middleware/builder"
|
|
10
|
+
|
|
11
|
+
# @namespace
|
|
12
|
+
module Lively
|
|
13
|
+
# @namespace
|
|
14
|
+
module Environment
|
|
15
|
+
# Shared middleware configuration for Lively application environments.
|
|
16
|
+
#
|
|
17
|
+
# Provides the application class resolver, asset middleware, and the
|
|
18
|
+
# Lively middleware stack. Included by both {HTTP} and {HTTY} environments.
|
|
19
|
+
module Middleware
|
|
20
|
+
# Get the root directory for this application.
|
|
21
|
+
# @returns [String] The current working directory.
|
|
22
|
+
def root
|
|
23
|
+
Dir.pwd
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Resolve the application class to use.
|
|
27
|
+
# @returns [Class] The application class, either user-defined or default.
|
|
28
|
+
def application
|
|
29
|
+
if Object.const_defined?(:Application)
|
|
30
|
+
Object.const_get(:Application)
|
|
31
|
+
else
|
|
32
|
+
Console.warn(self, "No Application class defined, using default.")
|
|
33
|
+
::Lively::Application
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Build the middleware stack for this application.
|
|
38
|
+
# @returns [Protocol::HTTP::Middleware] The complete middleware stack.
|
|
39
|
+
def middleware
|
|
40
|
+
::Protocol::HTTP::Middleware.build do |builder|
|
|
41
|
+
builder.use Lively::Assets, root: File.expand_path("public", self.root)
|
|
42
|
+
builder.use Lively::Assets, root: File.expand_path("../../../public", __dir__)
|
|
43
|
+
builder.use self.application
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/lively/resolver.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Lively
|
|
|
13
13
|
class Resolver < Live::Resolver
|
|
14
14
|
# Initialize a new resolver with shared state.
|
|
15
15
|
# @parameter state [Hash] Key-value pairs to pass to view constructors as keyword arguments.
|
|
16
|
-
def initialize(state =
|
|
16
|
+
def initialize(state = {})
|
|
17
17
|
super()
|
|
18
18
|
@state = state
|
|
19
19
|
end
|
data/lib/lively/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lively
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -52,6 +52,34 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: async-htty
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: async-service
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0.23'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0.23'
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
84
|
name: falcon
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -123,6 +151,9 @@ files:
|
|
|
123
151
|
- lib/lively/application.rb
|
|
124
152
|
- lib/lively/assets.rb
|
|
125
153
|
- lib/lively/environment/application.rb
|
|
154
|
+
- lib/lively/environment/http.rb
|
|
155
|
+
- lib/lively/environment/htty.rb
|
|
156
|
+
- lib/lively/environment/middleware.rb
|
|
126
157
|
- lib/lively/hello_world.rb
|
|
127
158
|
- lib/lively/pages/index.rb
|
|
128
159
|
- lib/lively/pages/index.xrb
|
metadata.gz.sig
CHANGED
|
Binary file
|