pedalboard 0.0.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 +7 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +65 -0
- data/README.md +25 -0
- data/bin/pedalboard +6 -0
- data/du/Dino.cpp +257 -0
- data/du/Dino.h +85 -0
- data/du/du.ino +19 -0
- data/examples/main_stage.rb +57 -0
- data/lib/pedalboard.rb +22 -0
- data/lib/pedalboard/cli.rb +21 -0
- data/lib/pedalboard/commands.rb +44 -0
- data/lib/pedalboard/components/base_component.rb +20 -0
- data/lib/pedalboard/components/led.rb +28 -0
- data/lib/pedalboard/components/pedal.rb +52 -0
- data/lib/pedalboard/components/pot.rb +78 -0
- data/lib/pedalboard/device.rb +32 -0
- data/lib/pedalboard/dsl_parser.rb +25 -0
- data/lib/pedalboard/version.rb +11 -0
- data/pedalboard.gemspec +27 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/unit/pedalboard/cli_spec.rb +40 -0
- data/spec/unit/pedalboard/components/led_spec.rb +43 -0
- data/spec/unit/pedalboard/components/pedal_spec.rb +34 -0
- data/spec/unit/pedalboard/components/pot_spec.rb +54 -0
- data/spec/unit/pedalboard/device_spec.rb +47 -0
- data/spec/unit/pedalboard/dsl_parser_spec.rb +64 -0
- data/spec/unit/pedalboard_spec.rb +79 -0
- metadata +165 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pedalboard/cli'
|
4
|
+
|
5
|
+
module Pedalboard
|
6
|
+
describe CLI do
|
7
|
+
subject { CLI.new }
|
8
|
+
|
9
|
+
describe '#create_device' do
|
10
|
+
it 'should load the contents of the file and use them to create the device' do
|
11
|
+
filename = double
|
12
|
+
file = double
|
13
|
+
config = 'some_method'
|
14
|
+
config_proc = double
|
15
|
+
|
16
|
+
expect(File).to receive(:open)
|
17
|
+
.with(filename)
|
18
|
+
.and_return(file)
|
19
|
+
|
20
|
+
expect(file).to receive(:read)
|
21
|
+
.and_return(config)
|
22
|
+
|
23
|
+
expect(Pedalboard).to receive(:create)
|
24
|
+
|
25
|
+
subject.create_device(filename)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#run' do
|
30
|
+
context 'when passed a single file' do
|
31
|
+
let(:args) { ['a-file'] }
|
32
|
+
|
33
|
+
it 'should create a device from the file' do
|
34
|
+
expect(subject).to receive(:create_device).with('a-file')
|
35
|
+
subject.run(args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pedalboard/components/led'
|
4
|
+
|
5
|
+
module Pedalboard; module Components
|
6
|
+
describe Led do
|
7
|
+
let(:dino_component) { double }
|
8
|
+
|
9
|
+
subject { Led.new(
|
10
|
+
dino_component: dino_component
|
11
|
+
) }
|
12
|
+
|
13
|
+
describe '#light_if' do
|
14
|
+
context 'when passed true' do
|
15
|
+
it 'should turn the led on' do
|
16
|
+
expect(subject).to receive(:on)
|
17
|
+
subject.light_if true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when passed false' do
|
22
|
+
it 'should turn the led off' do
|
23
|
+
expect(subject).to receive(:off)
|
24
|
+
subject.light_if false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#off' do
|
30
|
+
it 'should turn the led off' do
|
31
|
+
expect(dino_component).to receive(:send).with(:off)
|
32
|
+
subject.off
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#on' do
|
37
|
+
it 'should turn the led on' do
|
38
|
+
expect(dino_component).to receive(:send).with(:on)
|
39
|
+
subject.on
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end; end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'dino/board'
|
4
|
+
require 'pedalboard/components/pedal'
|
5
|
+
|
6
|
+
module Pedalboard; module Components
|
7
|
+
describe Pedal do
|
8
|
+
describe '#initialize' do
|
9
|
+
let(:board) { double('Dino::Board') }
|
10
|
+
let(:pedalboard) { double(board: board) }
|
11
|
+
let(:pin) { double }
|
12
|
+
let(:press) { double }
|
13
|
+
let(:long_press) { double }
|
14
|
+
|
15
|
+
subject { Pedal.new(
|
16
|
+
pedalboard: pedalboard,
|
17
|
+
pin: pin,
|
18
|
+
press: press,
|
19
|
+
long_press: long_press
|
20
|
+
) }
|
21
|
+
|
22
|
+
before :each do
|
23
|
+
Pedal
|
24
|
+
.any_instance
|
25
|
+
.stub(:configure_dino_component)
|
26
|
+
end
|
27
|
+
|
28
|
+
its(:pedalboard) { should equal pedalboard }
|
29
|
+
its(:pin) { should equal pin }
|
30
|
+
its(:press) { should equal press }
|
31
|
+
its(:long_press) { should equal long_press }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end; end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pedalboard/components/pot'
|
4
|
+
|
5
|
+
module Pedalboard; module Components
|
6
|
+
describe Pot do
|
7
|
+
let(:tolerance) { 10 }
|
8
|
+
let(:upper_limit) { 110 }
|
9
|
+
let(:lower_limit) { 10 }
|
10
|
+
let(:inverted) { false }
|
11
|
+
let(:change) { ->(value) { puts 'poop'; change_value = value } }
|
12
|
+
let(:dino_component) { Dino::Components::Sensor.new(board: board, pin: 1) }
|
13
|
+
let(:board) { double(add_analog_hardware: nil, start_read: nil) }
|
14
|
+
let(:pedalboard) { double(board: board) }
|
15
|
+
|
16
|
+
subject { Pot.new(
|
17
|
+
tolerance: tolerance,
|
18
|
+
upper_limit: upper_limit,
|
19
|
+
lower_limit: lower_limit,
|
20
|
+
inverted: inverted,
|
21
|
+
change: change,
|
22
|
+
pedalboard: pedalboard,
|
23
|
+
dino_component: dino_component
|
24
|
+
) }
|
25
|
+
|
26
|
+
context 'when the dino component recieves data' do
|
27
|
+
it 'should call the change proc with the normalised value' do
|
28
|
+
expect(subject.value).to equal(10)
|
29
|
+
expect(subject).to receive(:run_command).with(change, 35)
|
30
|
+
dino_component.update 256
|
31
|
+
expect(subject.value).to equal(35)
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the change is within the tolerance' do
|
35
|
+
it 'should not change the value' do
|
36
|
+
subject.value = 34
|
37
|
+
expect(subject).to_not receive(:run_command).with(change, 35)
|
38
|
+
dino_component.update 256
|
39
|
+
expect(subject.value).to equal(34)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when inverted' do
|
44
|
+
let(:inverted) { true }
|
45
|
+
|
46
|
+
it 'should call the change proc with the inverted value' do
|
47
|
+
expect(subject).to receive(:run_command).with(change, 75)
|
48
|
+
dino_component.update 256
|
49
|
+
expect(subject.value).to equal(75)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end; end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pedalboard/device'
|
4
|
+
require 'pedalboard/components/pedal'
|
5
|
+
|
6
|
+
module Pedalboard
|
7
|
+
describe Device do
|
8
|
+
describe '#add_component' do
|
9
|
+
let(:connection) { double }
|
10
|
+
let(:board) { double }
|
11
|
+
let(:midi_input) { double }
|
12
|
+
let(:midi_output) { double }
|
13
|
+
|
14
|
+
subject { Device.new(
|
15
|
+
connection: connection,
|
16
|
+
board: board,
|
17
|
+
midi_output: midi_output,
|
18
|
+
midi_input: midi_input
|
19
|
+
) }
|
20
|
+
|
21
|
+
before :each do
|
22
|
+
allow(subject)
|
23
|
+
.to receive(:initialize_board)
|
24
|
+
.and_return(board)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should add a component to the board' do
|
28
|
+
args = {option1: 'someopt'}
|
29
|
+
pedal = double
|
30
|
+
|
31
|
+
expect(Components::Pedal)
|
32
|
+
.to receive(:new)
|
33
|
+
.with({
|
34
|
+
option1: 'someopt',
|
35
|
+
pedalboard: subject
|
36
|
+
})
|
37
|
+
.and_return(pedal)
|
38
|
+
|
39
|
+
expect(subject.add_component :pedal, args)
|
40
|
+
.to be(pedal)
|
41
|
+
|
42
|
+
expect(subject.components.include?(pedal))
|
43
|
+
.to be_true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pedalboard/dsl_parser'
|
4
|
+
|
5
|
+
module Pedalboard
|
6
|
+
describe DSLParser do
|
7
|
+
def pedalboard
|
8
|
+
@pedalboard ||= double
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
subject { DSLParser }
|
13
|
+
|
14
|
+
it 'should accept a board' do
|
15
|
+
expect(subject.new(pedalboard).pedalboard)
|
16
|
+
.to equal(pedalboard)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#board' do
|
21
|
+
let (:board) { double }
|
22
|
+
let (:pedalboard) { double(board: board) }
|
23
|
+
|
24
|
+
subject { DSLParser.new(pedalboard).board }
|
25
|
+
|
26
|
+
it { should == board }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'components' do
|
30
|
+
let(:args) { double }
|
31
|
+
subject { DSLParser.new(pedalboard) }
|
32
|
+
|
33
|
+
describe '#led' do
|
34
|
+
it 'should create a led component' do
|
35
|
+
expect(pedalboard)
|
36
|
+
.to receive(:add_component)
|
37
|
+
.with(:led, args)
|
38
|
+
|
39
|
+
subject.led args
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#pedal' do
|
44
|
+
it 'should create a pedal component' do
|
45
|
+
expect(pedalboard)
|
46
|
+
.to receive(:add_component)
|
47
|
+
.with(:pedal, args)
|
48
|
+
|
49
|
+
subject.pedal args
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#pot' do
|
54
|
+
it 'should create a pot component' do
|
55
|
+
expect(pedalboard)
|
56
|
+
.to receive(:add_component)
|
57
|
+
.with(:pot, args)
|
58
|
+
|
59
|
+
subject.pot args
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pedalboard'
|
4
|
+
|
5
|
+
describe Pedalboard do
|
6
|
+
describe '.create' do
|
7
|
+
let(:connection) { double }
|
8
|
+
let(:board) { double }
|
9
|
+
let(:midi_input) { double }
|
10
|
+
let(:midi_output) { double }
|
11
|
+
let(:device_class) { double }
|
12
|
+
let(:dsl_parser) { double }
|
13
|
+
|
14
|
+
let(:device_options) {
|
15
|
+
{
|
16
|
+
connection: connection,
|
17
|
+
board: board,
|
18
|
+
midi_output: midi_output,
|
19
|
+
midi_input: midi_input
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
subject { Pedalboard }
|
24
|
+
|
25
|
+
it 'should return a new device instance' do
|
26
|
+
device = double
|
27
|
+
parser = double
|
28
|
+
|
29
|
+
expect(device_class).to receive(:new)
|
30
|
+
.with(device_options)
|
31
|
+
.and_return(device)
|
32
|
+
|
33
|
+
expect(dsl_parser).to receive(:new)
|
34
|
+
.with(device)
|
35
|
+
.and_return(parser)
|
36
|
+
|
37
|
+
expect(parser).to receive(:pedalboard)
|
38
|
+
.and_return(device)
|
39
|
+
|
40
|
+
expect(subject.create(
|
41
|
+
device_options.merge(
|
42
|
+
device_class: device_class,
|
43
|
+
dsl_parser: dsl_parser
|
44
|
+
)
|
45
|
+
)
|
46
|
+
).to equal(device)
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when passed a block' do
|
50
|
+
it 'should execute the block in the context of the dsl parser' do
|
51
|
+
device = double
|
52
|
+
parser = double
|
53
|
+
|
54
|
+
expect(device_class).to receive(:new)
|
55
|
+
.with(device_options)
|
56
|
+
.and_return(device)
|
57
|
+
|
58
|
+
expect(dsl_parser).to receive(:new)
|
59
|
+
.with(device)
|
60
|
+
.and_return(parser)
|
61
|
+
|
62
|
+
expect(parser).to receive(:some_method)
|
63
|
+
|
64
|
+
expect(parser).to receive(:pedalboard)
|
65
|
+
.and_return(device)
|
66
|
+
|
67
|
+
expect(subject.create(
|
68
|
+
device_options.merge(
|
69
|
+
device_class: device_class,
|
70
|
+
dsl_parser: dsl_parser
|
71
|
+
)
|
72
|
+
) do
|
73
|
+
some_method
|
74
|
+
end
|
75
|
+
).to equal(device)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pedalboard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Phillips
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dino
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: micromidi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mixlib-cli
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Quick and easy prototyping for Arduino-based MIDI pedalboards
|
98
|
+
email: adam@29ways.co.uk
|
99
|
+
executables:
|
100
|
+
- pedalboard
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .rspec
|
105
|
+
- .rvmrc
|
106
|
+
- .travis.yml
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- README.md
|
110
|
+
- bin/pedalboard
|
111
|
+
- du/Dino.cpp
|
112
|
+
- du/Dino.h
|
113
|
+
- du/du.ino
|
114
|
+
- examples/main_stage.rb
|
115
|
+
- lib/pedalboard.rb
|
116
|
+
- lib/pedalboard/cli.rb
|
117
|
+
- lib/pedalboard/commands.rb
|
118
|
+
- lib/pedalboard/components/base_component.rb
|
119
|
+
- lib/pedalboard/components/led.rb
|
120
|
+
- lib/pedalboard/components/pedal.rb
|
121
|
+
- lib/pedalboard/components/pot.rb
|
122
|
+
- lib/pedalboard/device.rb
|
123
|
+
- lib/pedalboard/dsl_parser.rb
|
124
|
+
- lib/pedalboard/version.rb
|
125
|
+
- pedalboard.gemspec
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
- spec/unit/pedalboard/cli_spec.rb
|
128
|
+
- spec/unit/pedalboard/components/led_spec.rb
|
129
|
+
- spec/unit/pedalboard/components/pedal_spec.rb
|
130
|
+
- spec/unit/pedalboard/components/pot_spec.rb
|
131
|
+
- spec/unit/pedalboard/device_spec.rb
|
132
|
+
- spec/unit/pedalboard/dsl_parser_spec.rb
|
133
|
+
- spec/unit/pedalboard_spec.rb
|
134
|
+
homepage: https://github.com/adamphillips/pedalboard
|
135
|
+
licenses: []
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.1.11
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Easy Arduino MIDI pedalboard
|
157
|
+
test_files:
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/unit/pedalboard/cli_spec.rb
|
160
|
+
- spec/unit/pedalboard/components/led_spec.rb
|
161
|
+
- spec/unit/pedalboard/components/pedal_spec.rb
|
162
|
+
- spec/unit/pedalboard/components/pot_spec.rb
|
163
|
+
- spec/unit/pedalboard/device_spec.rb
|
164
|
+
- spec/unit/pedalboard/dsl_parser_spec.rb
|
165
|
+
- spec/unit/pedalboard_spec.rb
|