signalize 1.0.1 → 1.1.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: 4e4f4fc25e9d3e2f4e343a22ecd6bf37daa4628da775f9c5d7709177881c927e
4
- data.tar.gz: e91df598b0d5c11a6f4a803481e3fabb8476e59ac873c6fa8d0e2f57d3851cae
3
+ metadata.gz: 023d2e474c347003b12bef1210945016175838261a5761dae81cb90d749fe51b
4
+ data.tar.gz: 04adf75c67d46adf30fabfdf996eea3ef1555678f96189444d32355571c5d12d
5
5
  SHA512:
6
- metadata.gz: d9bb28f9f5e35093aaf5567df71a9f8c05edd1467c5788f6afd7a4678790a9bd6a8f08c2296641a9bc7bed8c303da594b17ee308f7b57dcb6754d1bc6a9a7451
7
- data.tar.gz: a85f5867add9ecce1cad3bb7bcc9cd975c69097436ec8d9bfccdc260245aa1c5c93f1031b4aa0337cc144ad5453bc4a67ec71611b8dad850e17481d614b5b5c6
6
+ metadata.gz: 1c6cc8aad7188bde45f3c5e535d8a7c9ceb17e0598f35ebe45791cf194b8489e799fb32680c130f4bd3f0c06e399ae900bfa8dd103fd7431fe779856fb1685cc
7
+ data.tar.gz: e3eacdfae3cecd69c3b17158e4ae5610119d83e778e369479c487a1ac42e88dcb554cb9c3389cf4d1e1689a337f1bab2f0e02230d6a22b59df3b4bb2993069c3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
+ # Changelog
2
+
1
3
  ## [Unreleased]
2
4
 
5
+ ## [1.1.0] - 2023-03-25
6
+
7
+ - Provide better signal/computed inspect strings (fixes #1)
8
+ - Use Concurrent::Map for thread-safe globals (fixes #3)
9
+
10
+ ## [1.0.1] - 2023-03-08
11
+
12
+ - Prevent early returns in effect blocks
13
+ - Use gem's error class (fixes #2)
14
+
3
15
  ## [1.0.0] - 2023-03-07
4
16
 
5
17
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- signalize (1.0.1)
4
+ signalize (1.1.0)
5
+ concurrent-ruby (~> 1.2)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  coderay (1.1.3)
11
+ concurrent-ruby (1.2.2)
10
12
  ffi (1.15.5)
11
13
  formatador (1.1.0)
12
14
  guard (2.18.0)
data/README.md CHANGED
@@ -248,7 +248,3 @@ This project is intended to be a safe, welcoming space for collaboration, and co
248
248
  ## License
249
249
 
250
250
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
251
-
252
- ## Code of Conduct
253
-
254
- Everyone interacting in the Signalize project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/whitefusionhq/signalize/blob/main/CODE_OF_CONDUCT.md).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Signalize
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/signalize.rb CHANGED
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "concurrent"
3
4
  require_relative "signalize/version"
4
5
 
5
6
  module Signalize
6
7
  class Error < StandardError; end
7
8
 
8
9
  class << self
9
- def class_variablize(name)
10
+ def global_map_accessor(name)
10
11
  define_singleton_method "#{name}" do
11
- class_variable_get("@@#{name}")
12
+ GLOBAL_MAP[name]
12
13
  end
13
14
  define_singleton_method "#{name}=" do |value|
14
- class_variable_set("@@#{name}", value)
15
+ GLOBAL_MAP[name] = value
15
16
  end
16
17
  end
17
18
  end
@@ -27,24 +28,26 @@ module Signalize
27
28
  HAS_ERROR = 1 << 4
28
29
  TRACKING = 1 << 5
29
30
 
31
+ GLOBAL_MAP = Concurrent::Map.new
32
+
30
33
  # Computed | Effect | nil
31
- @@eval_context = nil
32
- class_variablize :eval_context
34
+ global_map_accessor :eval_context
35
+ self.eval_context = nil
33
36
 
34
37
  # Effects collected into a batch.
35
- @@batched_effect = nil
36
- class_variablize :batched_effect
37
- @@batch_depth = 0
38
- class_variablize :batch_depth
39
- @@batch_iteration = 0
40
- class_variablize :batch_iteration
38
+ global_map_accessor :batched_effect
39
+ self.batched_effect = nil
40
+ global_map_accessor :batch_depth
41
+ self.batch_depth = 0
42
+ global_map_accessor :batch_iteration
43
+ self.batch_iteration = 0
41
44
 
42
45
  # NOTE: we have removed the global version optimization for Ruby, due to
43
46
  # the possibility of long-running server processes and the number reaching
44
47
  # a dangerously high integer value.
45
48
  #
46
- # @@global_version = 0
47
- # class_variablize :global_version
49
+ # global_map_accessor :global_version
50
+ # self.global_version = 0
48
51
 
49
52
  Node = Struct.new(
50
53
  :_version,
@@ -436,6 +439,10 @@ module Signalize
436
439
  end
437
440
 
438
441
  def peek = @value
442
+
443
+ def inspect
444
+ "#<#{self.class} value: #{peek.inspect}>"
445
+ end
439
446
  end
440
447
 
441
448
  class Computed < Signal
data/signalize.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  # Uncomment to register a new dependency of your gem
30
- # spec.add_dependency "example-gem", "~> 1.0"
30
+ spec.add_dependency "concurrent-ruby", "~> 1.2"
31
31
 
32
32
  # For more information and examples about making a new gem, check out our
33
33
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared White
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-09 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2023-03-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: concurrent-ruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.2'
14
28
  description: A Ruby port of Signals, providing reactive variables, derived computed
15
29
  state, side effect callbacks, and batched updates.
16
30
  email: