standard-procedure-signal 0.2.1 → 0.3.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: 8e2b62bb8e8557f431279fe19f3b4534f89125e5bcef004491c7265b7252b93d
4
- data.tar.gz: 32f1b4faef1393beb8d4fa9a519420bc7f8fa75f4d148ad7c1fb5950a7b97c1b
3
+ metadata.gz: e34f420902fc79c8fd58505f632c9fa5b73dc5df2c277a4687d81371f319c43c
4
+ data.tar.gz: 98c9ef6fa142338bd44f18ba952b087d762bb7f8b16c0c3437e9b428642c285d
5
5
  SHA512:
6
- metadata.gz: 32b85c15212935273bbe77459458241b457986f9312abb0ad97be97745796d941d13b60c992d09b9ff041aec96c7bedabf27c56074bd811725b608d0884a42b6
7
- data.tar.gz: c8bd12a00b2e7526fb269e0304f427a26ea223135c26c3f136631006d6451936efccfacbcbd92577eae83a862764227b6a35cc4a839c28ca1e14035d70233859
6
+ metadata.gz: bb75c8d3a57bcd55b624ef4d4b9d9c85bf016d404c49544c969f3eb197d601f2f8cdef8ed5746ee872ac49b54b84c7f5dc4f85f59454e1996abe2b4ababff352
7
+ data.tar.gz: e3b79cbd6df6ab5ccbb0c89bea4c4218b00b8d70adb58a05ee8a3ec0c62f6b8a2175a065ed83afc671fafbc6309ae503aaab327c1d13ee93488179ebc78287c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.3.1] - 2023-09-16
2
+
3
+ - Array and Hash no longer wrap their contents in attributes.
4
+
5
+ ## [0.3.0] - 2023-09-14
6
+
7
+ - Added opal-rspec to ensure that everything works OK when running in a browser context
8
+
1
9
  ## [0.2.0] - 2023-09-14
2
10
 
3
11
  - Improved the API by extending the ruby Signal module
data/README.md CHANGED
@@ -191,6 +191,15 @@ Then
191
191
 
192
192
  require "standard_procedure/signal"
193
193
 
194
+ ## Tests
195
+
196
+ The gem uses rspec for testing.
197
+
198
+ `bundle exec rake spec` will run the specs in the traditional ruby environment.
199
+
200
+ `bundle exec rake opal_spec` will run the specs in Opal.
201
+ This starts a web-server, listening on port 3000. To view the test results, navigate to http://localhost:3000/
202
+
194
203
  ## Contributing
195
204
 
196
205
  Bug reports and pull requests are welcome on GitHub at https://github.com/standard-procedure/standard-procedure-signal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/standard-procedure/standard-procedure-signal/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -8,3 +8,17 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  require "standard/rake"
9
9
 
10
10
  task default: %i[spec standard]
11
+
12
+ require "opal"
13
+ Opal.append_path "lib"
14
+ require "opal/rspec/rake_task"
15
+ Opal::Config.source_map_enabled = true
16
+ Opal::Config.esm = false
17
+
18
+ Opal::RSpec::RakeTask.new(:opal_spec) do |server, task|
19
+ server.append_path "lib"
20
+ task.default_path = "spec"
21
+ task.requires = ["spec_helper"]
22
+ task.files = FileList["spec/**/*_spec.rb"]
23
+ task.runner = :server
24
+ end
@@ -0,0 +1 @@
1
+ 4b52ba8db1ffe69a01d4ea9abcdb1dfe63f37b18a4cad89c347b0919b90c32038bd170266be1a5440f993a73d09109216354d97bff3e21f05b42019f8f9da441
@@ -0,0 +1 @@
1
+ 153c47025ab6b8b78f755c53a3ccca764a71139dce98aa8b6ff34ee36fddc5c1609c085f7507015ee7dd6964c2235e58161bd76978356f0da27126472744ebbf
@@ -7,10 +7,10 @@ module StandardProcedure
7
7
  def set(new_value)
8
8
  new_value = if new_value.nil?
9
9
  nil
10
- elsif new_value.respond_to? :map
11
- new_value.map { |i| Attribute.for i }
10
+ elsif new_value.is_a? Enumerable
11
+ new_value.dup
12
12
  else
13
- [Attribute.new(new_value)]
13
+ [new_value]
14
14
  end
15
15
  super new_value
16
16
  end
@@ -35,7 +35,7 @@ module StandardProcedure
35
35
  end
36
36
 
37
37
  def unshift item
38
- @value.unshift Attribute.for(item)
38
+ @value.unshift item
39
39
  update_observers
40
40
  self
41
41
  end
@@ -4,11 +4,11 @@ module StandardProcedure
4
4
  class Hash < Attribute
5
5
  include Enumerable
6
6
 
7
- def set(new_value)
7
+ def set new_value
8
8
  new_value = if new_value.nil?
9
9
  nil
10
- elsif new_value.respond_to? :transform_values
11
- new_value.transform_values { |value| Attribute.for value }
10
+ elsif new_value.respond_to? :to_hash
11
+ new_value.to_hash.dup
12
12
  else
13
13
  raise ArgumentError.new "#{new_value.inspect} is not recognised as a Hash"
14
14
  end
@@ -31,12 +31,8 @@ module StandardProcedure
31
31
  @value.has_key? key
32
32
  end
33
33
 
34
- def has_value? value, attribute: false
35
- if attribute
36
- @value.has_value? value
37
- else
38
- @value.values.map(&:get).include? value
39
- end
34
+ def has_value? value
35
+ @value.has_value? value
40
36
  end
41
37
 
42
38
  def values
@@ -83,6 +79,10 @@ module StandardProcedure
83
79
  @value.clear
84
80
  update_observers
85
81
  end
82
+
83
+ def to_hash
84
+ @value
85
+ end
86
86
  end
87
87
  end
88
88
  end
@@ -9,8 +9,7 @@ module StandardProcedure
9
9
  when nil then nil
10
10
  when ::Time then new_value
11
11
  when ::Date then new_value.to_time
12
- when String then ::Time.new(new_value)
13
- else raise "#{new_value} not recognised"
12
+ else ::Time.new(new_value)
14
13
  end
15
14
  super new_value
16
15
  rescue => e
@@ -1,4 +1,4 @@
1
- if defined?(Signal) && Signal.is_a?(Class)
1
+ if RUBY_ENGINE == "opal"
2
2
  class Signal
3
3
  extend StandardProcedure::Signal
4
4
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StandardProcedure
4
4
  module Signal
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-procedure-signal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-14 00:00:00.000000000 Z
11
+ date: 2023-09-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Observable attributes which adapt based upon their dependencies so we
14
14
  avoid unecessary updates
@@ -34,6 +34,8 @@ files:
34
34
  - checksums/standard-procedure-signal-0.1.2.gem.sha512
35
35
  - checksums/standard-procedure-signal-0.2.0.gem.sha512
36
36
  - checksums/standard-procedure-signal-0.2.1.gem.sha512
37
+ - checksums/standard-procedure-signal-0.3.0.gem.sha512
38
+ - checksums/standard-procedure-signal-0.3.1.gem.sha512
37
39
  - lib/standard_procedure/signal.rb
38
40
  - lib/standard_procedure/signal/attribute.rb
39
41
  - lib/standard_procedure/signal/attribute/array.rb