fretboard 1.2.0 → 1.3.0

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: b7435bd0a766a28745a79a3741e0b08f3793ca8566ed0ab6cca5c864cba776fd
4
- data.tar.gz: 1e6935842f0d1f730c7d9a7fdfd3e5cc18bb525e725b761cd66b3a4b97207dab
3
+ metadata.gz: 8ce78fbd618190dec7aab13a7f9c8a2d58bc074cd90a035eabfc03a9091ca435
4
+ data.tar.gz: bdfff345ca8d38dd4739061595e5f7cbf92ce0cf624237a8580ad2e83c10ce16
5
5
  SHA512:
6
- metadata.gz: e66075625a1147938126d904ad1f37a5f4b7d44fd18608c87e9c3199a055ada3c401f6d305c5d266ac1b18a4dfdc5dbc68b5d11c1d2d94a37f7538b82b422991
7
- data.tar.gz: 8359c7422823e670980a0bde6add31442a7e739f4e725a33053e9db870088feace52360c7fa9f2388db2afcafbb328ff6d623151764885bc5e77f91be406441d
6
+ metadata.gz: a4175ec01b4eac24ae120b1dd6b41ed5f1ceff0fe9fd32edea143cf04c7a59b5dcd6b75f1a6035e88e766ab6ccfa8ac90519c9dd10501bd6ec9971b45d6d991b
7
+ data.tar.gz: f664ab61567eec56eb49dfb9f9a52da3d1e72d5518def62e6716cea380ed136ec2de2cccb0c60d6fa940b87c820f2ca0932cccc0d5246b08cd09029904da0982
data/README.md CHANGED
@@ -53,12 +53,23 @@ fretboard.draw
53
53
  # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54
54
  ```
55
55
 
56
+ ### Using from the console
57
+
58
+ ```
59
+ bundle exec fretboard --draw-tuning standart
60
+ ```
61
+
56
62
  ### Available tunings:
57
63
 
58
64
  - Standart (`standart`)
59
65
  - Drop C (`drop_c`)
60
66
  - Drop D (`drop_d`)
61
67
  - Double Drop D (`double_drop_d`)
68
+ - Open A (`open_a`)
62
69
  - Open C (`open_c`)
63
70
  - Open D (`open_d`)
71
+ - Open D Minor (`open_d_minor`)
64
72
  - Open G (`open_g`)
73
+ - Open G Minor (`open_g_minor`)
74
+ - Modal D (`modal_d`)
75
+ - Modal G (`modal_g`)
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless File.exist?('./Gemfile')
4
+ abort 'Please run fretboard from the root of the project'
5
+ end
6
+
7
+ require 'rubygems'
8
+
9
+ begin
10
+ require 'bundler'
11
+ Bundler.setup
12
+ rescue StandardError
13
+ end
14
+
15
+ $LOAD_PATH << "#{__dir__}/../lib"
16
+
17
+ require 'fretboard/parser'
18
+
19
+ Fretboard::Parser.parse(ARGV)
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z *.md *.gemspec bin lib`.split("\x0")
18
18
  spec.require_paths = ['lib']
19
19
 
20
- # spec.executables = ['fretboard']
20
+ spec.executables = ['fretboard']
21
21
 
22
22
  spec.add_dependency 'colorize', '~> 0.8.1'
23
23
  spec.add_dependency 'terminal-table', '~> 1.8.0'
@@ -1,3 +1,5 @@
1
+ # require 'active_support/core_ext/hash'
2
+
1
3
  require 'fretboard/console'
2
4
 
3
5
  module Fretboard
@@ -7,9 +9,14 @@ module Fretboard
7
9
  # fretboard = Fretboard::Builder.drop_c
8
10
  # fretboard = Fretboard::Builder.drop_d
9
11
  # fretboard = Fretboard::Builder.double_drop_d
12
+ # fretboard = Fretboard::Builder.open_a
10
13
  # fretboard = Fretboard::Builder.open_c
11
14
  # fretboard = Fretboard::Builder.open_d
15
+ # fretboard = Fretboard::Builder.open_d_minor
12
16
  # fretboard = Fretboard::Builder.open_g
17
+ # fretboard = Fretboard::Builder.open_g_minor
18
+ # fretboard = Fretboard::Builder.modal_d
19
+ # fretboard = Fretboard::Builder.modal_g
13
20
 
14
21
  # fretboard.build
15
22
  # fretboard.data
@@ -22,9 +29,14 @@ module Fretboard
22
29
  # drop_c
23
30
  # drop_d
24
31
  # double_drop_d
32
+ # open_a
25
33
  # open_c
26
34
  # open_d
35
+ # open_d_minor
27
36
  # open_g
37
+ # open_g_minor
38
+ # modal_d
39
+ # modal_g
28
40
  # ].freeze
29
41
 
30
42
  attr_reader :data
@@ -51,6 +63,10 @@ module Fretboard
51
63
  new(:double_drop_d, number_of_frets)
52
64
  end
53
65
 
66
+ def self.open_a(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
67
+ new(:open_a, number_of_frets)
68
+ end
69
+
54
70
  def self.open_c(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
55
71
  new(:open_c, number_of_frets)
56
72
  end
@@ -59,10 +75,26 @@ module Fretboard
59
75
  new(:open_d, number_of_frets)
60
76
  end
61
77
 
78
+ def self.open_d_minor(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
79
+ new(:open_d_minor, number_of_frets)
80
+ end
81
+
62
82
  def self.open_g(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
63
83
  new(:open_g, number_of_frets)
64
84
  end
65
85
 
86
+ def self.open_g_minor(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
87
+ new(:open_g_minor, number_of_frets)
88
+ end
89
+
90
+ def self.modal_d(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
91
+ new(:modal_d, number_of_frets)
92
+ end
93
+
94
+ def self.modal_g(number_of_frets = DEFAULT_NUMBER_OF_FRETS)
95
+ new(:modal_g, number_of_frets)
96
+ end
97
+
66
98
  def initialize(tuning, number_of_frets = DEFAULT_NUMBER_OF_FRETS)
67
99
  @tuning = tuning.upcase.to_sym
68
100
  @number_of_frets = number_of_frets
@@ -3,9 +3,9 @@ require 'terminal-table'
3
3
 
4
4
  module Fretboard
5
5
  class Console
6
- # def self.log(text)
7
- # new(text, nil).print
8
- # end
6
+ def self.log(text)
7
+ new(text, nil).print
8
+ end
9
9
 
10
10
  # def self.success(text)
11
11
  # new(text, :green).print
@@ -0,0 +1,51 @@
1
+ require 'active_support/core_ext'
2
+ require 'optparse'
3
+
4
+ require 'fretboard/builder'
5
+ require 'fretboard/console'
6
+ require 'fretboard/note'
7
+ require 'fretboard/tunings'
8
+
9
+ module Fretboard
10
+ class Parser
11
+ attr_reader :args
12
+
13
+ def self.parse(args)
14
+ new(args).parse
15
+ end
16
+
17
+ def initialize(args)
18
+ @args = args
19
+ end
20
+
21
+ def parse
22
+ parser.parse!(args)
23
+ rescue StandardError => e
24
+ Fretboard::Console.danger("Ambiguously completable string is encountered\n#{e}")
25
+ end
26
+
27
+ private
28
+
29
+ def parser
30
+ OptionParser.new do |opts|
31
+ opts.banner = 'Usage: fretboard [options]'
32
+
33
+ opts.on('-v', '--version', 'The current version of the gem') do
34
+ Fretboard::Console.log(Fretboard::VERSION)
35
+ exit
36
+ end
37
+
38
+ opts.on('-h', '--help', 'Prints this help') do
39
+ Fretboard::Console.log(opts.to_s)
40
+ exit
41
+ end
42
+
43
+ opts.on('--draw-tuning CODE', 'Build a guitar tuning') do |code|
44
+ fretboard = Fretboard::Builder.new(code.to_sym)
45
+ fretboard.build
46
+ fretboard.draw
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -3,40 +3,26 @@ module Fretboard
3
3
  # Fretboard::Tunings.get(:standart)
4
4
  # Fretboard::Tunings.exists?(:standart)
5
5
 
6
- # SPN => Scientific pitch notation
7
-
8
6
  TUNINGS = {
9
7
  STANDART: {
10
8
  STRINGS: {
11
9
  1 => {
12
- NOTE: 'E',
13
- # FREQUENCY: '329.63 Hz',
14
- SPN: 'E4'
10
+ NOTE: 'E'
15
11
  },
16
12
  2 => {
17
- NOTE: 'B',
18
- # FREQUENCY: '246.94 Hz',
19
- SPN: 'B3'
13
+ NOTE: 'B'
20
14
  },
21
15
  3 => {
22
- NOTE: 'G',
23
- # FREQUENCY: '196.00 Hz',
24
- SPN: 'G3'
16
+ NOTE: 'G'
25
17
  },
26
18
  4 => {
27
- NOTE: 'D',
28
- # FREQUENCY: '146.83 Hz',
29
- SPN: 'D3'
19
+ NOTE: 'D'
30
20
  },
31
21
  5 => {
32
- NOTE: 'A',
33
- # FREQUENCY: '110.00 Hz',
34
- SPN: 'A2'
22
+ NOTE: 'A'
35
23
  },
36
24
  6 => {
37
- NOTE: 'E',
38
- # FREQUENCY: '82.41 Hz',
39
- SPN: 'E2'
25
+ NOTE: 'E'
40
26
  }
41
27
  }
42
28
  },
@@ -44,28 +30,22 @@ module Fretboard
44
30
  DROP_C: {
45
31
  STRINGS: {
46
32
  1 => {
47
- NOTE: 'D',
48
- SPN: 'D4'
33
+ NOTE: 'D'
49
34
  },
50
35
  2 => {
51
- NOTE: 'A',
52
- SPN: 'A3'
36
+ NOTE: 'A'
53
37
  },
54
38
  3 => {
55
- NOTE: 'F',
56
- SPN: 'F3'
39
+ NOTE: 'F'
57
40
  },
58
41
  4 => {
59
- NOTE: 'C',
60
- SPN: 'C3'
42
+ NOTE: 'C'
61
43
  },
62
44
  5 => {
63
- NOTE: 'G',
64
- SPN: 'G2'
45
+ NOTE: 'G'
65
46
  },
66
47
  6 => {
67
- NOTE: 'C',
68
- SPN: 'C2'
48
+ NOTE: 'C'
69
49
  }
70
50
  }
71
51
  },
@@ -73,28 +53,22 @@ module Fretboard
73
53
  DROP_D: {
74
54
  STRINGS: {
75
55
  1 => {
76
- NOTE: 'E',
77
- SPN: 'E4'
56
+ NOTE: 'E'
78
57
  },
79
58
  2 => {
80
- NOTE: 'B',
81
- SPN: 'B3'
59
+ NOTE: 'B'
82
60
  },
83
61
  3 => {
84
- NOTE: 'G',
85
- SPN: 'G3'
62
+ NOTE: 'G'
86
63
  },
87
64
  4 => {
88
- NOTE: 'D',
89
- SPN: 'D3'
65
+ NOTE: 'D'
90
66
  },
91
67
  5 => {
92
- NOTE: 'A',
93
- SPN: 'A2'
68
+ NOTE: 'A'
94
69
  },
95
70
  6 => {
96
- NOTE: 'D',
97
- SPN: 'D2'
71
+ NOTE: 'D'
98
72
  }
99
73
  }
100
74
  },
@@ -102,28 +76,48 @@ module Fretboard
102
76
  DOUBLE_DROP_D: {
103
77
  STRINGS: {
104
78
  1 => {
105
- NOTE: 'D',
106
- SPN: 'D4'
79
+ NOTE: 'D'
80
+ },
81
+ 2 => {
82
+ NOTE: 'B'
83
+ },
84
+ 3 => {
85
+ NOTE: 'G'
86
+ },
87
+ 4 => {
88
+ NOTE: 'D'
89
+ },
90
+ 5 => {
91
+ NOTE: 'A'
92
+ },
93
+ 6 => {
94
+ NOTE: 'D'
95
+ }
96
+ }
97
+ },
98
+
99
+ OPEN_A: {
100
+ STRINGS: {
101
+ 1 => {
102
+ NOTE: 'E'
107
103
  },
108
104
  2 => {
109
- NOTE: 'B',
110
- SPN: 'B3'
105
+ NOTE: 'A'
111
106
  },
112
107
  3 => {
113
- NOTE: 'G',
114
- SPN: 'G3'
108
+ NOTE: 'E'
115
109
  },
116
110
  4 => {
117
- NOTE: 'D',
118
- SPN: 'D3'
111
+ NOTE: [
112
+ 'C#',
113
+ 'Db'
114
+ ]
119
115
  },
120
116
  5 => {
121
- NOTE: 'A',
122
- SPN: 'A2'
117
+ NOTE: 'A'
123
118
  },
124
119
  6 => {
125
- NOTE: 'D',
126
- SPN: 'D2'
120
+ NOTE: 'E'
127
121
  }
128
122
  }
129
123
  },
@@ -131,28 +125,22 @@ module Fretboard
131
125
  OPEN_C: {
132
126
  STRINGS: {
133
127
  1 => {
134
- NOTE: 'E',
135
- SPN: 'E4'
128
+ NOTE: 'E'
136
129
  },
137
130
  2 => {
138
- NOTE: 'C',
139
- SPN: 'C4'
131
+ NOTE: 'C'
140
132
  },
141
133
  3 => {
142
- NOTE: 'G',
143
- SPN: 'G3'
134
+ NOTE: 'G'
144
135
  },
145
136
  4 => {
146
- NOTE: 'C',
147
- SPN: 'C3'
137
+ NOTE: 'C'
148
138
  },
149
139
  5 => {
150
- NOTE: 'G',
151
- SPN: 'G2'
140
+ NOTE: 'G'
152
141
  },
153
142
  6 => {
154
- NOTE: 'C',
155
- SPN: 'C2'
143
+ NOTE: 'C'
156
144
  }
157
145
  }
158
146
  },
@@ -160,34 +148,48 @@ module Fretboard
160
148
  OPEN_D: {
161
149
  STRINGS: {
162
150
  1 => {
163
- NOTE: 'D',
164
- SPN: 'D4'
151
+ NOTE: 'D'
165
152
  },
166
153
  2 => {
167
- NOTE: 'A',
168
- SPN: 'A3'
154
+ NOTE: 'A'
169
155
  },
170
156
  3 => {
171
157
  NOTE: [
172
158
  'F#',
173
159
  'Gb'
174
- ],
175
- SPN: [
176
- 'F#3',
177
- 'Gb3'
178
160
  ]
179
161
  },
180
162
  4 => {
181
- NOTE: 'D',
182
- SPN: 'D3'
163
+ NOTE: 'D'
183
164
  },
184
165
  5 => {
185
- NOTE: 'A',
186
- SPN: 'A2'
166
+ NOTE: 'A'
187
167
  },
188
168
  6 => {
189
- NOTE: 'D',
190
- SPN: 'D2'
169
+ NOTE: 'D'
170
+ }
171
+ }
172
+ },
173
+
174
+ OPEN_D_MINOR: {
175
+ STRINGS: {
176
+ 1 => {
177
+ NOTE: 'D'
178
+ },
179
+ 2 => {
180
+ NOTE: 'A'
181
+ },
182
+ 3 => {
183
+ NOTE: 'F'
184
+ },
185
+ 4 => {
186
+ NOTE: 'D'
187
+ },
188
+ 5 => {
189
+ NOTE: 'A'
190
+ },
191
+ 6 => {
192
+ NOTE: 'D'
191
193
  }
192
194
  }
193
195
  },
@@ -195,28 +197,94 @@ module Fretboard
195
197
  OPEN_G: {
196
198
  STRINGS: {
197
199
  1 => {
198
- NOTE: 'D',
199
- SPN: 'D4'
200
+ NOTE: 'D'
201
+ },
202
+ 2 => {
203
+ NOTE: 'B'
204
+ },
205
+ 3 => {
206
+ NOTE: 'G'
207
+ },
208
+ 4 => {
209
+ NOTE: 'D'
210
+ },
211
+ 5 => {
212
+ NOTE: 'G'
213
+ },
214
+ 6 => {
215
+ NOTE: 'D'
216
+ }
217
+ }
218
+ },
219
+
220
+ OPEN_G_MINOR: {
221
+ STRINGS: {
222
+ 1 => {
223
+ NOTE: 'D'
224
+ },
225
+ 2 => {
226
+ NOTE: [
227
+ 'A#',
228
+ 'Bb'
229
+ ]
230
+ },
231
+ 3 => {
232
+ NOTE: 'G'
233
+ },
234
+ 4 => {
235
+ NOTE: 'D'
236
+ },
237
+ 5 => {
238
+ NOTE: 'G'
239
+ },
240
+ 6 => {
241
+ NOTE: 'D'
242
+ }
243
+ }
244
+ },
245
+
246
+ MODAL_D: {
247
+ STRINGS: {
248
+ 1 => {
249
+ NOTE: 'D'
250
+ },
251
+ 2 => {
252
+ NOTE: 'A'
253
+ },
254
+ 3 => {
255
+ NOTE: 'G'
256
+ },
257
+ 4 => {
258
+ NOTE: 'D'
259
+ },
260
+ 5 => {
261
+ NOTE: 'A'
262
+ },
263
+ 6 => {
264
+ NOTE: 'D'
265
+ }
266
+ }
267
+ },
268
+
269
+ MODAL_G: {
270
+ STRINGS: {
271
+ 1 => {
272
+ NOTE: 'D'
200
273
  },
201
274
  2 => {
202
- NOTE: 'B',
203
- SPN: 'B3'
275
+ NOTE: 'C'
204
276
  },
205
277
  3 => {
206
- NOTE: 'G',
207
- SPN: 'G3'
278
+ NOTE: 'G'
208
279
  },
209
280
  4 => {
210
- NOTE: 'D',
211
- SPN: 'D3'
281
+ NOTE: 'D'
212
282
  },
213
283
  5 => {
214
- NOTE: 'G',
215
- SPN: 'G2'
284
+ NOTE: 'G'
216
285
  },
217
286
  6 => {
218
- NOTE: 'D',
219
- SPN: 'D2'
287
+ NOTE: 'D'
220
288
  }
221
289
  }
222
290
  }
@@ -1,6 +1,6 @@
1
1
  module Fretboard
2
2
  MAJOR = 1
3
- MINOR = 2
3
+ MINOR = 3
4
4
  PATCH = 0
5
5
 
6
6
  VERSION = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fretboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-26 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -55,12 +55,14 @@ dependencies:
55
55
  description: Tools for working with the guitar fretboard
56
56
  email:
57
57
  - anton@sokolov.digital
58
- executables: []
58
+ executables:
59
+ - fretboard
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
62
63
  - LICENSE.md
63
64
  - README.md
65
+ - bin/fretboard
64
66
  - fretboard.gemspec
65
67
  - lib/fretboard.rb
66
68
  - lib/fretboard/builder.rb
@@ -68,6 +70,7 @@ files:
68
70
  - lib/fretboard/constants.rb
69
71
  - lib/fretboard/note.rb
70
72
  - lib/fretboard/notes.rb
73
+ - lib/fretboard/parser.rb
71
74
  - lib/fretboard/tunings.rb
72
75
  - lib/fretboard/version.rb
73
76
  homepage: https://github.com/afuno/fretboard