musa-dsl 0.23.14 → 0.23.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dab879e30a1ece7bc5a71a32398213d0592b4a95bb6a852346ec472314bcee7
|
4
|
+
data.tar.gz: c10467430f594206804aee8521c51b514af79c29bca67b70782e0c7820294eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 892c2017cc142814b475872a1bd9a4471686667b8237c5130ea3e7589fd50a0a0eb6d163ef40bd46b4924385fff4dc0ff9abfb18186349053fb362fe65becb17
|
7
|
+
data.tar.gz: 9f287f7302a6d3547e5b85190c5cbda040e4a2e0f0c4dc89b4bb0dea3823772fcaae32c137aec1733b1e658fefe06963ef3cb4bbcc468244a77ef623f0cd7c17
|
@@ -33,7 +33,7 @@ module Musa
|
|
33
33
|
_call value_parameters, key_parameters
|
34
34
|
end
|
35
35
|
|
36
|
-
def _call(value_parameters, key_parameters)
|
36
|
+
def _call(value_parameters, key_parameters = {})
|
37
37
|
if @on_rescue
|
38
38
|
begin
|
39
39
|
__call value_parameters, key_parameters
|
@@ -45,7 +45,7 @@ module Musa
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
private def __call(value_parameters, key_parameters)
|
48
|
+
private def __call(value_parameters, key_parameters = {})
|
49
49
|
effective_value_parameters, effective_key_parameters = apply(*value_parameters, **key_parameters)
|
50
50
|
|
51
51
|
if effective_key_parameters.empty?
|
@@ -19,12 +19,10 @@ module Musa
|
|
19
19
|
else
|
20
20
|
binder.call(*effective_value_parameters, **effective_key_parameters)
|
21
21
|
end
|
22
|
+
elsif effective_value_parameters.empty? && effective_key_parameters.empty?
|
23
|
+
instance_eval &block
|
22
24
|
else
|
23
|
-
|
24
|
-
instance_eval &block
|
25
|
-
else
|
26
|
-
instance_exec *effective_value_parameters, **effective_key_parameters, &block
|
27
|
-
end
|
25
|
+
instance_exec *effective_value_parameters, **effective_key_parameters, &block
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -20,7 +20,7 @@ module Musa
|
|
20
20
|
def value
|
21
21
|
{ kind: :parallel,
|
22
22
|
parallel: [{ kind: :serie,
|
23
|
-
serie: S(*capture(:aa).value) }] +
|
23
|
+
serie: Musa::Series::Constructors.S(*capture(:aa).value) }] +
|
24
24
|
captures(:bb).collect { |c| { kind: :serie, serie: Musa::Series::Constructors.S(*c.value) } }
|
25
25
|
}.extend(Musa::Neumas::Neuma::Parallel)
|
26
26
|
end
|
@@ -101,15 +101,28 @@ module Musa
|
|
101
101
|
|
102
102
|
# TODO on with and map methods implement parameter passing with cloning on restart as on E()
|
103
103
|
#
|
104
|
-
def with(
|
105
|
-
|
106
|
-
|
104
|
+
def with(*with_series, on_restart: nil, isolate_values: nil, **with_key_series, &block)
|
105
|
+
if with_series.any? && with_key_series.any?
|
106
|
+
raise ArgumentError, 'Can\'t use extra parameters series and key named parameters series'
|
107
|
+
end
|
108
|
+
|
109
|
+
extra_series = if with_series.any?
|
110
|
+
with_series
|
111
|
+
elsif with_key_series.any?
|
112
|
+
with_key_series
|
113
|
+
end
|
114
|
+
|
115
|
+
isolate_values ||= isolate_values.nil? ? true : isolate_values
|
116
|
+
|
117
|
+
ProcessWith.new self, extra_series, on_restart, isolate_values: isolate_values, &block
|
107
118
|
end
|
108
119
|
|
109
120
|
alias_method :eval, :with
|
110
121
|
|
111
|
-
def map(&block)
|
112
|
-
|
122
|
+
def map(isolate_values: nil, &block)
|
123
|
+
isolate_values ||= isolate_values.nil? ? false : isolate_values
|
124
|
+
|
125
|
+
ProcessWith.new self, isolate_values: isolate_values, &block
|
113
126
|
end
|
114
127
|
|
115
128
|
def anticipate(&block)
|
@@ -129,12 +142,16 @@ module Musa
|
|
129
142
|
sources: true, sources_as: :with_sources, mandatory_sources: false,
|
130
143
|
smart_block: true)
|
131
144
|
|
132
|
-
|
145
|
+
using Musa::Extension::Arrayfy
|
146
|
+
|
147
|
+
def initialize(serie, with_series = nil, on_restart = nil, isolate_values: nil, &block)
|
133
148
|
self.source = serie
|
134
|
-
self.with_sources = with_series ||
|
149
|
+
self.with_sources = with_series || []
|
135
150
|
self.on_restart = on_restart
|
136
151
|
self.proc = block if block
|
137
152
|
|
153
|
+
@isolate_values = isolate_values
|
154
|
+
|
138
155
|
init
|
139
156
|
end
|
140
157
|
|
@@ -152,21 +169,59 @@ module Musa
|
|
152
169
|
|
153
170
|
private def _restart
|
154
171
|
@source.restart
|
155
|
-
|
172
|
+
|
173
|
+
case @sources
|
174
|
+
when Array
|
175
|
+
@sources.each(&:restart)
|
176
|
+
when Hash
|
177
|
+
@sources.each_value(&:restart)
|
178
|
+
end
|
179
|
+
|
156
180
|
@on_restart.call if @on_restart
|
157
181
|
end
|
158
182
|
|
159
183
|
private def _next_value
|
160
184
|
main = @source.next_value
|
161
|
-
|
185
|
+
|
186
|
+
others = case @sources
|
187
|
+
when Array
|
188
|
+
@sources.map(&:next_value)
|
189
|
+
when Hash
|
190
|
+
@sources.transform_values(&:next_value)
|
191
|
+
end
|
162
192
|
|
163
193
|
value = nil
|
164
194
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
195
|
+
|
196
|
+
if main
|
197
|
+
case others
|
198
|
+
when Array
|
199
|
+
unless others.include?(nil)
|
200
|
+
value = if @block
|
201
|
+
if @isolate_values
|
202
|
+
raise ArgumentError, "Received 'with_sources' as an Array and asked to 'isolate_values'. This can't be done. Please, set 'isolate_values' to false or make with_sources to be a Hash." if others.any?
|
203
|
+
|
204
|
+
@block._call([main])
|
205
|
+
else
|
206
|
+
@block._call(main.arrayfy + others)
|
207
|
+
end
|
208
|
+
else
|
209
|
+
if @isolate_values
|
210
|
+
[main, others]
|
211
|
+
else
|
212
|
+
main.arrayfy + others
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
when Hash
|
218
|
+
unless others.values.include?(nil)
|
219
|
+
value = if @block
|
220
|
+
@block._call(main, others)
|
221
|
+
else
|
222
|
+
[main, others]
|
223
|
+
end
|
224
|
+
end
|
170
225
|
end
|
171
226
|
end
|
172
227
|
|
@@ -243,7 +298,7 @@ module Musa
|
|
243
298
|
end
|
244
299
|
|
245
300
|
def infinite?
|
246
|
-
@source.infinite? && @sources.any?
|
301
|
+
@source.infinite? && @sources.any?(&:infinite?)
|
247
302
|
end
|
248
303
|
end
|
249
304
|
|
@@ -287,7 +342,7 @@ module Musa
|
|
287
342
|
end
|
288
343
|
|
289
344
|
def infinite?
|
290
|
-
@source.infinite? && @sources.any?
|
345
|
+
@source.infinite? && @sources.any?(&:infinite?)
|
291
346
|
end
|
292
347
|
end
|
293
348
|
|
@@ -641,9 +696,7 @@ module Musa
|
|
641
696
|
else
|
642
697
|
value = @pending_values.shift
|
643
698
|
|
644
|
-
if value.nil?
|
645
|
-
value = _next_value
|
646
|
-
end
|
699
|
+
value = _next_value if value.nil?
|
647
700
|
|
648
701
|
value
|
649
702
|
end
|
data/lib/musa-dsl.rb
CHANGED
data/musa-dsl.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'musa-dsl'
|
3
|
-
s.version = '0.23.
|
4
|
-
s.date = '2021-09-
|
3
|
+
s.version = '0.23.15'
|
4
|
+
s.date = '2021-09-07'
|
5
5
|
s.summary = 'A simple Ruby DSL for making complex music'
|
6
6
|
s.description = 'Musa-DSL: A Ruby framework and DSL for algorithmic sound and musical thinking and composition'
|
7
7
|
s.authors = ['Javier Sánchez Yeste']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musa-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Sánchez Yeste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citrus
|