maxy-gen 0.3.2 → 0.3.3
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 +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +8 -1
- data/lib/maxy/gen/cli.rb +1 -1
- data/lib/maxy/gen/generator.rb +5 -1
- data/lib/maxy/gen/parser.rb +14 -6
- data/lib/maxy/gen/tokenizer.rb +11 -10
- data/lib/maxy/gen/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4e86040c41c2e7c72dad39a7aa9cb2f5747c4ee675c8ff95f44d96f556c24a0
|
4
|
+
data.tar.gz: 53d688a7848ce51d8c198c938189114578e536aefb92640a31eb702d7e117227
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc189243c8caea6c73b8b2b4740591c974d47ab33c6f26c9eeb492ffd09123af01476e895e16accd0795573751937526f873cc4af1bae633562cc70dc0c36e6
|
7
|
+
data.tar.gz: db4d6a15270c862b2719e2f845893610bf7e82ae9b108077c2be4c2ea93d135b698db636a1a5392535dc1c69dc940bf1c505d911e9680607738ef8ec8591d0e9
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
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
|
-

|
6
6
|
|
7
7
|
## Installation and Upgrading
|
8
8
|
|
@@ -39,6 +39,8 @@ Use an [emmet](https://emmet.io/)-like pattern to generate a max patch, e.g.
|
|
39
39
|
As of now you can use
|
40
40
|
|
41
41
|
- `-` dashes to indicate patch chords
|
42
|
+
- `=` equal signs to connect a row (as in `t b b`) to multiple objects at once
|
43
|
+
- `<` less than signs to connect a single outlet to an object with many inputs (as in `pack 1 2 3`)
|
42
44
|
- `{}` curly braces to denote arguments passed to objects
|
43
45
|
- `+` to denote sibling objects
|
44
46
|
- `(...)` to group objects together (see demo above)
|
@@ -46,10 +48,15 @@ As of now you can use
|
|
46
48
|
A couple of objects need escaping (with `\`), because some characters are taken, obviously. These are:
|
47
49
|
|
48
50
|
- `\==`
|
51
|
+
- `\<`
|
52
|
+
- `\<=`
|
49
53
|
- `\-`
|
50
54
|
- `\+`
|
55
|
+
- `\<<`
|
51
56
|
- `\*`
|
52
57
|
- `\==~`
|
58
|
+
- `\<=~`
|
59
|
+
- `\<~`
|
53
60
|
- `\-~`
|
54
61
|
- `\+=~`
|
55
62
|
- `\+~`
|
data/lib/maxy/gen/cli.rb
CHANGED
@@ -55,7 +55,7 @@ module Maxy
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
library[:objects].select { |k, _v| k.match?(/\A^[-+*={}()].*/) }.each do |k, _v|
|
58
|
+
library[:objects].select { |k, _v| k.match?(/\A^[-+*={}()<].*/) }.each do |k, _v|
|
59
59
|
key = "\\#{k}"
|
60
60
|
library[:objects][key] = library[:objects].delete k
|
61
61
|
end
|
data/lib/maxy/gen/generator.rb
CHANGED
@@ -14,7 +14,7 @@ module Maxy
|
|
14
14
|
attr_accessor :library
|
15
15
|
|
16
16
|
def initialize
|
17
|
-
raise
|
17
|
+
raise 'No object definitions were found. please run `maxy-gen install` first' unless File.exist?("#{ENV['HOME']}/.maxy-gen/library.yml")
|
18
18
|
|
19
19
|
@object_count = 1
|
20
20
|
@patch = Psych.load_file(File.join(__dir__, '../../../assets/blank.yml')).dup
|
@@ -40,6 +40,10 @@ module Maxy
|
|
40
40
|
generate_node(child_node, child_id)
|
41
41
|
if node.flags.include? :connect_children_individually
|
42
42
|
@patch['patcher']['lines'] << make_line(id, child_id, index, 0)
|
43
|
+
elsif node.flags.include? :connect_all_child_inlets
|
44
|
+
0.upto(child_node.args.split.count - 1) do |i|
|
45
|
+
@patch['patcher']['lines'] << make_line(id, child_id, 0, i)
|
46
|
+
end
|
43
47
|
else
|
44
48
|
@patch['patcher']['lines'] << make_line(id, child_id)
|
45
49
|
end
|
data/lib/maxy/gen/parser.rb
CHANGED
@@ -2,7 +2,7 @@ module Maxy
|
|
2
2
|
module Gen
|
3
3
|
class Parser
|
4
4
|
def initialize(tokens)
|
5
|
-
raise
|
5
|
+
raise 'No object definitions were found. please run `maxy-gen install` first' unless File.exist?("#{ENV['HOME']}/.maxy-gen/library.yml")
|
6
6
|
|
7
7
|
@library = Psych.load_file("#{ENV['HOME']}/.maxy-gen/library.yml").freeze
|
8
8
|
@tokens = tokens
|
@@ -13,11 +13,12 @@ module Maxy
|
|
13
13
|
def parse(parent_node=@tree, closing_group=false)
|
14
14
|
if closing_group
|
15
15
|
if peek(:dash) || peek(:identifier) || peek(:escaped_identifier)
|
16
|
-
raise
|
16
|
+
raise 'Parsing Error: only + is allowed after a ) closing a group.'
|
17
17
|
end
|
18
18
|
else
|
19
19
|
parse_begin_group parent_node
|
20
20
|
child_node = parse_identifier parent_node
|
21
|
+
parse_less_than child_node
|
21
22
|
parse_equals child_node
|
22
23
|
parse_dash child_node
|
23
24
|
end
|
@@ -51,7 +52,7 @@ module Maxy
|
|
51
52
|
|
52
53
|
arguments = parse_arguments || ''
|
53
54
|
|
54
|
-
raise
|
55
|
+
raise "Could not find #{obj_name} in object definitions." if @library[:objects][obj_name].nil?
|
55
56
|
|
56
57
|
new_obj_node = ObjectNode.new(obj_name, arguments, [])
|
57
58
|
parent.child_nodes << new_obj_node
|
@@ -72,12 +73,12 @@ module Maxy
|
|
72
73
|
if token.type == expected_type
|
73
74
|
token
|
74
75
|
else
|
75
|
-
raise
|
76
|
+
raise "Expected token type #{expected_type.inspect}, but got #{token.type.inspect}"
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
80
|
def peek(expected_type)
|
80
|
-
@tokens.length
|
81
|
+
@tokens.length.positive? && @tokens.fetch(0).type == expected_type
|
81
82
|
end
|
82
83
|
|
83
84
|
def parse_plus(obj_node)
|
@@ -101,6 +102,14 @@ module Maxy
|
|
101
102
|
parse(obj_node)
|
102
103
|
end
|
103
104
|
end
|
105
|
+
|
106
|
+
def parse_less_than(obj_node)
|
107
|
+
if peek(:less_than)
|
108
|
+
consume(:less_than)
|
109
|
+
obj_node.flags << :connect_all_child_inlets
|
110
|
+
parse(obj_node)
|
111
|
+
end
|
112
|
+
end
|
104
113
|
end
|
105
114
|
|
106
115
|
ObjectNode = Struct.new(:name, :args, :child_nodes, :x_rank, :y_rank, :flags) do
|
@@ -109,6 +118,5 @@ module Maxy
|
|
109
118
|
end
|
110
119
|
end
|
111
120
|
RootNode = Struct.new(:child_nodes)
|
112
|
-
|
113
121
|
end
|
114
122
|
end
|
data/lib/maxy/gen/tokenizer.rb
CHANGED
@@ -2,14 +2,15 @@ module Maxy
|
|
2
2
|
module Gen
|
3
3
|
class Tokenizer
|
4
4
|
TOKEN_TYPES = [
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
[:arguments, /({[^{}]*})/],
|
6
|
+
[:escaped_identifier, /(\\[\S][^-+={}<()\\]*)(?=[-+=*<{}])?/],
|
7
|
+
[:identifier, /([^-+={}<()\\]+)(?=[-+=*<{}])?/],
|
8
|
+
[:oparen, /(\()/],
|
9
|
+
[:cparen, /(\))/],
|
10
|
+
[:plus, /(\+)/],
|
11
|
+
[:less_than, /(<)/],
|
12
|
+
[:equals, /(=)/],
|
13
|
+
[:dash, /(-)/]
|
13
14
|
]
|
14
15
|
|
15
16
|
def initialize(pattern)
|
@@ -34,10 +35,10 @@ module Maxy
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
raise
|
38
|
+
raise "Couldn't match token on #{@pattern.inspect}"
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
42
|
Token = Struct.new(:type, :value)
|
42
43
|
end
|
43
|
-
end
|
44
|
+
end
|
data/lib/maxy/gen/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.3
|
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-
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,7 @@ extra_rdoc_files: []
|
|
118
118
|
files:
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
121
122
|
- ".ruby-version"
|
122
123
|
- ".travis.yml"
|
123
124
|
- Gemfile
|