maxy-gen 0.3.2 → 0.3.3

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: f53f56c6fbf28759545461bf9040d70820ae267d99b7a494804f840381b0570d
4
- data.tar.gz: b3f8057b1a4568f9988e559f46c6c29c9cc291a169406777ea843f67bab9e54c
3
+ metadata.gz: e4e86040c41c2e7c72dad39a7aa9cb2f5747c4ee675c8ff95f44d96f556c24a0
4
+ data.tar.gz: 53d688a7848ce51d8c198c938189114578e536aefb92640a31eb702d7e117227
5
5
  SHA512:
6
- metadata.gz: 165c624d8b47bb14f04c1a9b021d90005f93e625601e8f9a3e2d101639cd8f1eeda71d6b8d7427a7588367f54006fdf452b57cc2ccf57871166594cab0eb1966
7
- data.tar.gz: 4ff924c93ce593d96b1939fbcfb8c19e0a4af620addae168041b85b6fcdaf786bea6ed0fe16182f51de22a2f83a81ceaaca1a038310de8374e789afaec688382
6
+ metadata.gz: 0bc189243c8caea6c73b8b2b4740591c974d47ab33c6f26c9eeb492ffd09123af01476e895e16accd0795573751937526f873cc4af1bae633562cc70dc0c36e6
7
+ data.tar.gz: db4d6a15270c862b2719e2f845893610bf7e82ae9b108077c2be4c2ea93d135b698db636a1a5392535dc1c69dc940bf1c505d911e9680607738ef8ec8591d0e9
@@ -0,0 +1,2 @@
1
+ Metrics/LineLength:
2
+ Max: 110
@@ -3,3 +3,5 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.3
5
5
  before_install: gem install bundler -v 1.14.6
6
+ script:
7
+ - bundle exec rake spec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maxy-gen (0.3.1)
4
+ maxy-gen (0.3.2)
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-v0.3.0.gif)
5
+ ![](https://s3.eu-central-1.amazonaws.com/maxy-gen/maxygen-demo-v0.3.3.gif)
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
  - `\+~`
@@ -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
@@ -14,7 +14,7 @@ module Maxy
14
14
  attr_accessor :library
15
15
 
16
16
  def initialize
17
- raise RuntimeError.new('No object definitions were found. please run `maxy-gen install` first') unless File.exist?("#{ENV['HOME']}/.maxy-gen/library.yml")
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
@@ -2,7 +2,7 @@ module Maxy
2
2
  module Gen
3
3
  class Parser
4
4
  def initialize(tokens)
5
- raise RuntimeError.new('No object definitions were found. please run `maxy-gen install` first') unless File.exist?("#{ENV['HOME']}/.maxy-gen/library.yml")
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 RuntimeError.new("Parsing Error: only + is allowed after a ) closing a group.")
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 RuntimeError.new("Could not find #{obj_name} in object definitions.") if @library[:objects][obj_name].nil?
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 RuntimeError.new("Expected token type #{expected_type.inspect}, but got #{token.type.inspect}")
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 > 0 && @tokens.fetch(0).type == expected_type
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
@@ -2,14 +2,15 @@ module Maxy
2
2
  module Gen
3
3
  class Tokenizer
4
4
  TOKEN_TYPES = [
5
- [:arguments, /({[^{}]*})/],
6
- [:escaped_identifier, /(\\[\S][^-+={}()\\]*)(?=[-+=*{}])?/],
7
- [:identifier, /([^-+={}()\\]+)(?=[-+=*{}])?/],
8
- [:oparen, /(\()/],
9
- [:cparen, /(\))/],
10
- [:plus, /(\+)/],
11
- [:equals, /(=)/],
12
- [:dash, /(-)/]
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 RuntimeError.new "Couldn't match token on #{@pattern.inspect}"
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
@@ -1,5 +1,5 @@
1
1
  module Maxy
2
2
  module Gen
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
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.2
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-15 00:00:00.000000000 Z
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