live 0.9.0 → 0.11.0

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: ef147b87ee25d023c9d1c704e285b5a16c507e1f7f60e7efe38ffc47ac6a797a
4
- data.tar.gz: f4db343f08db0794fe8820e53ff94b176aa2c580c4782f865d5988d32b85f8ab
3
+ metadata.gz: 41876a4b4870415b70d8e5747dce78f8eeed867b524bad32b9a0146c56296f41
4
+ data.tar.gz: ba656166a150f8d5a2da0ce37bc358159eb082db4b6340ef751cc2ff3b9f00d1
5
5
  SHA512:
6
- metadata.gz: d43f45adc82166da9ae514f327f9769c5db96d0e176488a9fcfc607b95f46b848e7fc376dc5683fe1144ef12739a8056a94c619aec5f04da912e41ad506b9253
7
- data.tar.gz: f8a2a0fdf18969dd3db1041e8d8d474c2f64e773d79a74451e1aaa34639a94b082ec34596142841dfa4bddb19b9d74a23dcab32a40ad7903e02a5c73ab67b260
6
+ metadata.gz: 39d76c89db7212a85596ef74630816a88107fc752ac8e932f76b43d5e2d943bbb4e631f4a78a44b7c9e4c6ef2095defce9c5d8da83f9334f171afe20d9a41ad6
7
+ data.tar.gz: 86484b279c0a6c16f4d46fe2220627ba35a74810413108377bf4f8002c84c95681bea4f1d7c760842b48bdc10e5c5c7cecdc9e3c7723700df3f415e51256d1f4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/live/element.rb CHANGED
@@ -7,6 +7,9 @@ require 'json'
7
7
  require 'securerandom'
8
8
 
9
9
  module Live
10
+ class PageError < RuntimeError
11
+ end
12
+
10
13
  # Represents a single dynamic content area on the page.
11
14
  class Element
12
15
  def self.unique_id
@@ -66,8 +69,13 @@ module Live
66
69
  # @parameter method [Symbol] The name of the remote functio to invoke.
67
70
  # @parameter arguments [Array]
68
71
  def rpc(*arguments)
69
- # This update might not be sent right away. Therefore, mutable arguments may be serialized to JSON at a later time (or never). This could be a race condition:
70
- @page.updates.enqueue(arguments)
72
+ if @page
73
+ # This update might not be sent right away. Therefore, mutable arguments may be serialized to JSON at a later time (or never). This could be a race condition:
74
+ @page.updates.enqueue(arguments)
75
+ else
76
+ # This is a programming error, as it probably means the element is still part of the logic of the server side (e.g. async loop), but it is not bound to a page, so there is nothing to update/access/rpc.
77
+ raise PageError, "Element is not bound to a page, make sure to implement #close!"
78
+ end
71
79
  end
72
80
  end
73
81
  end
data/lib/live/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  module Live
7
- VERSION = "0.9.0"
7
+ VERSION = "0.11.0"
8
8
  end
data/lib/live/view.rb CHANGED
@@ -68,5 +68,11 @@ module Live
68
68
  end
69
69
  end
70
70
  end
71
+
72
+ # Convenience method for rendering the view as a string.
73
+ # @returns [String] The generated HTML.
74
+ def to_s
75
+ to_html.to_s
76
+ end
71
77
  end
72
78
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,7 +38,7 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2024-05-06 00:00:00.000000000 Z
41
+ date: 2024-05-12 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: async-websocket
metadata.gz.sig CHANGED
Binary file