maxy-gen 0.3.0 → 0.3.1

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: 5207d413af11f892c06645d4a52eb920dc9fdb131bea13311d13285754609b33
4
- data.tar.gz: 2fb7405ad16c771c903a0eb6af81947bb577aa528ccf70d62c24a98c6e7a29a1
3
+ metadata.gz: 2df80188bc19f248b46a0ad7662c2420c71947d3bf33c145a799b175ecbf4da1
4
+ data.tar.gz: 6dbc80719b431ba5e282328d4c51a6c2e97e53ff9d094ae67286d2c3dd08ebed
5
5
  SHA512:
6
- metadata.gz: 4ccd516764930052b407fcf3c2bc4cea320292e9f980eda73cc9e7cf5a1d43ba72a682826e8600a7dad82cef54c7d603127ced8e27b4ae5739cd7f35ad3f6787
7
- data.tar.gz: 3fa95ba2e3289e5ef500d3d86c4b030e241886880124053822b08f1a43dacf9e166bf655609b01598dbb2c7c1a78d1917b31c87cf4a47aa2c187433dd472eedf
6
+ metadata.gz: f145c3e6f1bb9f842cbb325a992aea9d0fde4bbf4eba243e6fadb004b6e5d83f10b60fadc7f2843cb0226e57fded36fdadeb29de1085d92b856df6fdf8ca6f0b
7
+ data.tar.gz: 20be68f4c03f1f008f03f41da605a56d4ed2385403f9c295355948976d33f78d7d5e6dc5f0eac384563ad17d1149a1177ce482aa679650418d7cf0a9093898f9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maxy-gen (0.2.2)
4
+ maxy-gen (0.3.0)
5
5
  nokogiri
6
6
  thor
7
7
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A commandline tool to generate max patches in an emmet-like fashion
4
4
 
5
- ![](https://s3.eu-central-1.amazonaws.com/maxy-gen/maxygen-demo.gif)
5
+ ![](https://s3.eu-central-1.amazonaws.com/maxy-gen/maxygen-demo-v0.3.0.gif)
6
6
 
7
7
  ## Installation
8
8
 
@@ -28,7 +28,7 @@ Note: This is totally untested on Windows!
28
28
 
29
29
  Use an [emmet](https://emmet.io/)-like pattern to generate a max patch, e.g.
30
30
 
31
- $ maxy-gen generate 'cycle~{440.}-*~{0.2}-ezdac~' > test.maxpat
31
+ $ maxy-gen generate 'inlet-(\-{3.14}-print)+(trigger{b}-(outlet+print))' > complex_grouping.maxpat
32
32
 
33
33
  (or shorter, `maxy-gen g ...`)
34
34
 
@@ -38,6 +38,8 @@ As of now you can use
38
38
 
39
39
  - `-` dashes to indicate patch chords
40
40
  - `{}` curly braces to denote arguments passed to objects
41
+ - `+` to denote sibling objects
42
+ - `(...)` to group objects together (see demo above)
41
43
 
42
44
  A couple of objects need escaping (with `\`), because some characters are taken, obviously. These are:
43
45
 
@@ -67,4 +69,4 @@ Please include:
67
69
  ## Support
68
70
  This is a pure side project and depends on your support!
69
71
 
70
- If you'd like to support the development of `maxy-gen` and my other projects, take a look at [https://www.patreon.com/znibbles](https://www.patreon.com/znibbles)
72
+ If you'd like to support the development of `maxy-gen` and my other projects, take a look at [https://www.patreon.com/znibbles](https://www.patreon.com/znibbles)
@@ -35,10 +35,14 @@ module Maxy
35
35
  @patch['patcher']['boxes'] << make_box(node, id)
36
36
  @object_count += 1
37
37
 
38
- node.child_nodes.each do |child_node|
38
+ node.child_nodes.each_with_index do |child_node, index|
39
39
  child_id = "obj_#{@object_count}"
40
40
  generate_node(child_node, child_id)
41
- @patch['patcher']['lines'] << make_line(id, child_id)
41
+ if node.flags.include? :connect_children_individually
42
+ @patch['patcher']['lines'] << make_line(id, child_id, index, 0)
43
+ else
44
+ @patch['patcher']['lines'] << make_line(id, child_id)
45
+ end
42
46
  end
43
47
  end
44
48
 
@@ -46,15 +50,19 @@ module Maxy
46
50
  box = @library[:objects][node.name].dup
47
51
  box['id'] = id
48
52
  box['patching_rect'] = [OFFSET_X + (node.x_rank - 1) * STEP_X, OFFSET_Y + (node.y_rank - 1) * STEP_Y, box['width'] || WIDTH, box['height'] || HEIGHT]
49
- unless box['text'].nil?
50
- box['text'] += " #{node.args}"
51
- end
53
+ box['text'] += " #{node.args}" unless box['text'].nil?
52
54
 
53
55
  box
54
56
  end
55
57
 
56
- def make_line(parent_id, child_id)
57
- { patchline: { destination: [child_id, 0], source: [parent_id, 0]} }
58
+ def make_line(parent_id, child_id, parent_outlet = 0, child_inlet = 0)
59
+ {
60
+ patchline:
61
+ {
62
+ destination: [child_id, child_inlet],
63
+ source: [parent_id, parent_outlet]
64
+ }
65
+ }
58
66
  end
59
67
 
60
68
  def align_tree(node, x_rank = 1, y_rank = 1)
@@ -71,6 +79,5 @@ module Maxy
71
79
  node
72
80
  end
73
81
  end
74
-
75
82
  end
76
- end
83
+ end
@@ -18,6 +18,7 @@ module Maxy
18
18
  else
19
19
  parse_begin_group parent_node
20
20
  child_node = parse_identifier parent_node
21
+ parse_equals child_node
21
22
  parse_dash child_node
22
23
  end
23
24
 
@@ -92,9 +93,21 @@ module Maxy
92
93
  parse(obj_node)
93
94
  end
94
95
  end
96
+
97
+ def parse_equals(obj_node)
98
+ if peek(:equals)
99
+ consume(:equals)
100
+ obj_node.flags << :connect_children_individually
101
+ parse(obj_node)
102
+ end
103
+ end
95
104
  end
96
105
 
97
- ObjectNode = Struct.new(:name, :args, :child_nodes, :x_rank, :y_rank)
106
+ ObjectNode = Struct.new(:name, :args, :child_nodes, :x_rank, :y_rank, :flags) do
107
+ def initialize(name, args, child_nodes, x_rank=0, y_rank=0, flags=[])
108
+ super
109
+ end
110
+ end
98
111
  RootNode = Struct.new(:child_nodes)
99
112
 
100
113
  end
@@ -3,11 +3,12 @@ module Maxy
3
3
  class Tokenizer
4
4
  TOKEN_TYPES = [
5
5
  [:arguments, /({[^{}]*})/],
6
- [:escaped_identifier, /(\\[\S][^-+{}()\\]*)(?=[-+*{}])?/],
7
- [:identifier, /([^-+{}()\\]+)(?=[-+*{}])?/],
6
+ [:escaped_identifier, /(\\[\S][^-+={}()\\]*)(?=[-+=*{}])?/],
7
+ [:identifier, /([^-+={}()\\]+)(?=[-+=*{}])?/],
8
8
  [:oparen, /(\()/],
9
9
  [:cparen, /(\))/],
10
10
  [:plus, /(\+)/],
11
+ [:equals, /(=)/],
11
12
  [:dash, /(-)/]
12
13
  ]
13
14
 
@@ -1,5 +1,5 @@
1
1
  module Maxy
2
2
  module Gen
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxy-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler