patch 0.4.14 → 0.4.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40b17b9d6b5e727dc820833191e39eed4436b6eb
4
- data.tar.gz: 6d51227ecb4d486b7899673db3a4d88630a6ff3a
3
+ metadata.gz: 89ece74ab2dba3ae14594532a505c35eab007f30
4
+ data.tar.gz: 218c8db751291d328f42156c6ad672902f84fb0c
5
5
  SHA512:
6
- metadata.gz: 525242393d6c58f27a9bd70561b753475c51e168e11ab43f6a54ed4eec807d28674b29457fecf2397158749e1c8b5ea20cd829b767e872eb2bab17ca47416737
7
- data.tar.gz: b281f5d838d52dad011e1a2773b637113b17622c37fcd8a3b61b246fd05a1c66a4719b8dea07f04a91a177254bdc0be541b42c83a5c9dd12c26beab0ea1ab2ff
6
+ metadata.gz: 3b62a32cf912eae5e4eb1938eb2c8048fa73f0e7efe93312fdac660343d6085746398023a3214641080d3011efef099c2ae2027af13954492ddba2120fbd0225
7
+ data.tar.gz: af71587809704451cc2f6c89163007ed4234ae7742174f787c6cb324b4ebd4f60a56e68d3dd342e01240001892d185e3d173b1364aad670b3b2dad34de14064f
data/README.md CHANGED
@@ -14,7 +14,7 @@ Other possibilities:
14
14
  * HTTP
15
15
  * [JSON RPC 2.0](http://en.wikipedia.org/wiki/JSON-RPC)
16
16
 
17
- Patch can receive messages in these formats and instantly translate and send them to another format.
17
+ Patch receives messages in these formats and instantly translates and sends them to others
18
18
 
19
19
  For example:
20
20
 
@@ -46,7 +46,7 @@ require "patch"
46
46
  A *node* is a single source and/or destination of control messages. Here, we define three nodes:
47
47
 
48
48
  ```ruby
49
- websocket = Patch::IO::Websocket.new(1, "localhost", 9006)
49
+ websocket = Patch::IO::Websocket::Node.new(1, "localhost", 9006)
50
50
 
51
51
  midi = Patch::IO::MIDI::Input.new(2, "Apple Inc. IAC Driver")
52
52
 
@@ -168,5 +168,6 @@ You can run Patch at the command line by executing `patchrb nodes.yml patches.ym
168
168
 
169
169
  ## License
170
170
 
171
- This version under Apache 2.0, See the file LICENSE
171
+ Apache 2.0, See the file LICENSE
172
+
172
173
  Copyright (c) 2014-2015 [Ari Russo](http://arirusso.com)
@@ -32,6 +32,7 @@ module Patch
32
32
  # @return [Boolean] Whether nodes were enabled
33
33
  def enable(patch)
34
34
  result = @to.map do |to_node|
35
+ to_node.puts(patch, patch.default_messages)
35
36
  enabled = @from.map do |from_node|
36
37
  from_node.listen(patch) do |messages|
37
38
  to_node.puts(patch, messages)
data/lib/patch/patch.rb CHANGED
@@ -13,6 +13,19 @@ module Patch
13
13
  populate(maps, actions)
14
14
  end
15
15
 
16
+ # Patch messages for the default values in the patch
17
+ # @return [Array<Patch::Message>]
18
+ def default_messages
19
+ actions_with_default = @actions.select do |action|
20
+ !action[:default][:value].nil?
21
+ end
22
+ actions_with_default.map do |action|
23
+ value = action[:default][:value]
24
+ index = @actions.index(action)
25
+ Message.new(:index => index, :patch_name => @name, :value => value)
26
+ end
27
+ end
28
+
16
29
  # Enable the given nodes to implement this patch
17
30
  # @param [Node::Container] nodes
18
31
  # @return [Boolean]
data/lib/patch.rb CHANGED
@@ -37,6 +37,6 @@ require "patch/em_patch"
37
37
 
38
38
  module Patch
39
39
 
40
- VERSION = "0.4.14"
40
+ VERSION = "0.4.15"
41
41
 
42
42
  end
@@ -7,6 +7,7 @@
7
7
  :key: zoom
8
8
  :default:
9
9
  :scale: !ruby/range 0.1..5.0
10
+ :value: 1
10
11
  :midi:
11
12
  :channel: 0
12
13
  :index: 0
@@ -18,6 +19,7 @@
18
19
  :key: contrast
19
20
  :default:
20
21
  :scale: !ruby/range 0..5.0
22
+ :value: 0.5
21
23
  :osc:
22
24
  :address: /1/rotaryD
23
25
  :scale: !ruby/range 0..1.0
@@ -26,16 +28,18 @@
26
28
  :key: saturation
27
29
  :default:
28
30
  :scale: !ruby/range 0..2.0
31
+ :value: 1
29
32
  :osc:
30
33
  :address: /faderM
31
- :scale:
34
+ :scale:
32
35
  :osc: !ruby/range 0..1.0
33
36
 
34
37
  - :name: Z Depth
35
38
  :key: zDepth
36
39
  :default:
37
40
  :scale: !ruby/range 0..1000
41
+ :value: 200
38
42
  :osc:
39
43
  :address: /1/faderA
40
- :scale:
44
+ :scale:
41
45
  :osc: !ruby/range 0..1.0
@@ -29,18 +29,23 @@ class Patch::Node::MapTest < Minitest::Test
29
29
  context "#enable" do
30
30
 
31
31
  setup do
32
- @maps = @patches.first.maps
32
+ @patch = @patches.first
33
+ @maps = @patch.maps
33
34
  refute_empty @nodes
34
35
  assert [Patch::IO::MIDI::Input, Patch::IO::OSC::Server, Patch::IO::Websocket::Node].all? { |klass| @nodes.map(&:class).include?(klass) }
35
36
  ::Patch::Thread.expects(:new).times(@nodes.count)
37
+ @maps.each do |map|
38
+ map.to.expects(:puts).at_least_once.with(@patch, @patch.default_messages)
39
+ end
36
40
  end
37
41
 
38
42
  teardown do
39
43
  ::Patch::Thread.unstub(:new)
44
+ @maps.each { |map| map.to.unstub(:puts) }
40
45
  end
41
46
 
42
47
  should "create node start threads" do
43
- assert @maps.first.enable(@patches.first)
48
+ assert @maps.first.enable(@patch)
44
49
  end
45
50
 
46
51
  end
data/test/patch_test.rb CHANGED
@@ -32,6 +32,25 @@ class Patch::PatchTest < Minitest::Test
32
32
 
33
33
  end
34
34
 
35
+ context "#default_messages" do
36
+
37
+ setup do
38
+ @patch = @patches.first
39
+ @messages = @patch.default_messages
40
+ @actions_with_default = @patch.actions.select { |action| !action[:default].nil? }
41
+ end
42
+
43
+ should "populate messages from defaults" do
44
+ refute_nil @messages
45
+ refute_empty @messages
46
+ assert_equal @actions_with_default.count, @messages.count
47
+ @actions_with_default.each_with_index do |action, i|
48
+ refute_nil @messages.find { |message| message.index == i }
49
+ end
50
+ end
51
+
52
+ end
53
+
35
54
  context "#enable" do
36
55
 
37
56
  setup do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Russo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest