head_music 0.24.2 → 0.24.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 204a1613a88b8c14b7f9441a2a593637dc3a496076abda2621d71f85ffbdf604
4
- data.tar.gz: c9819f9c1983934caad0d58d625fbda15a787148d6e15f7cc92473de8200c2f7
3
+ metadata.gz: 282655f6692a3065a0f4e8faf6b2e6938b53ab36c5d229183cfa4c747906414e
4
+ data.tar.gz: ac59b613c452d5ec06981b19c94da581f9474aeb8923f5040409c8b47668670e
5
5
  SHA512:
6
- metadata.gz: e7e0fa5267eaa482b16abf497fb7122d6f3ade4c55f9a6ac40c43043dbfbe68a03dc9ae3a8c83262ade571965c0bf997121a9a774aee950e5598097a3fba33dd
7
- data.tar.gz: 6617eabf6992c8bf5ab1a7533d605ca2a54f58873c13fa91e79cc65acbfe925906bd727a100d969fd057a560a1bb64d470eaa18f37a751e5b41f584909b3b007
6
+ metadata.gz: 7e4d3d051057115e4b5751eb5113722dd50716daff6b73da4d21ae6a180b9eeb3ff42afe54be3b6a6b73e6c791b57cb58f0748349877966f487026ece28a79a7
7
+ data.tar.gz: a80791c1504b9ab101ef8ffd82efcd80e17686e09a7761c40ade3d310ca0c6b10f3387138e2ce73a83bf9a9b6550d5f10039de31bac389020033e01a62e7f00e
@@ -1,36 +1,83 @@
1
1
  ---
2
- - name_key: alto_flute
3
- - name_key: guitar
2
+ guitar:
4
3
  family: string
5
4
  classifications:
6
- - string
7
- - chordophone
5
+ - string
6
+ - chordophone
8
7
  default_clefs:
9
- - treble_clef
10
- - name_key: piano
8
+ - treble_clef
9
+ voice: tenor
10
+ piano:
11
11
  family: string
12
12
  classifications:
13
- - string
14
- - chordophone
15
- - keyboard
13
+ - string
14
+ - chordophone
15
+ - keyboard
16
16
  default_clefs:
17
- - treble_clef
18
- - bass_clef
19
- - name_key: violin
17
+ - treble_clef
18
+ - bass_clef
19
+ violin:
20
+ family: string
20
21
  alias_name_keys:
21
- - fiddle
22
+ - fiddle
23
+ classifications:
24
+ - string
25
+ - chordophone
26
+ - bowed
27
+ default_clefs:
28
+ - treble_clef
29
+ voice: soprano
30
+ viola:
22
31
  family: string
23
32
  classifications:
24
- - string
25
- - chordophone
26
- - bowed
33
+ - string
34
+ - chordophone
35
+ - bowed
27
36
  default_clefs:
28
- - treble_clef
29
- - name_key: viola
37
+ - alto_clef
38
+ voice: alto
39
+ cello:
30
40
  family: string
31
41
  classifications:
32
- - string
33
- - chordophone
34
- - bowed
42
+ - string
43
+ - chordophone
44
+ - bowed
45
+ default_clefs:
46
+ - bass_clef
47
+ voice: tenor
48
+ double_bass:
49
+ family: string
50
+ classifications:
51
+ - string
52
+ - chordophone
53
+ - bowed
54
+ default_clefs:
55
+ - bass_clef
56
+ voice: bass
57
+ harp:
58
+ family: string
59
+ classifications:
60
+ - string
61
+ - chordophone
62
+ - plucked
63
+ default_clefs:
64
+ - treble_clef
65
+ - bass_clef
66
+ flute:
67
+ family: woodwind
68
+ classifications:
69
+ - woodwind
70
+ - wind
71
+ - aerophone
72
+ - edge-blown aerophone
73
+ default_clefs:
74
+ - treble_clef
75
+ voice: soprano
76
+ organ:
77
+ classifications:
78
+ - aerophone
79
+ - keyboard
35
80
  default_clefs:
36
- - alto_clef
81
+ - treble_clef
82
+ - bass_clef
83
+ - bass_clef
@@ -6,16 +6,16 @@ class HeadMusic::GrandStaff
6
6
  piano: {
7
7
  instrument: :piano,
8
8
  staves: [
9
- { clef: :treble_clef, instrument: :piano },
10
- { clef: :bass_clef, instrument: :piano },
9
+ { clef: :treble_clef, for: :right_hand },
10
+ { clef: :bass_clef, for: :left_hand },
11
11
  ],
12
12
  },
13
13
  organ: {
14
14
  instrument: :organ,
15
15
  staves: [
16
- { clef: :treble_clef, instrument: :organ },
17
- { clef: :bass_clef, instrument: :organ },
18
- { clef: :bass_clef, instrument: :pedals },
16
+ { clef: :treble_clef, for: :right_hand },
17
+ { clef: :bass_clef, for: :left_hand },
18
+ { clef: :bass_clef, for: :pedals },
19
19
  ],
20
20
  },
21
21
  }.freeze
@@ -42,10 +42,7 @@ class HeadMusic::GrandStaff
42
42
  def staves
43
43
  @staves ||=
44
44
  data[:staves].map do |staff|
45
- HeadMusic::Staff.new(
46
- staff[:clef],
47
- instrument: staff[:instrument] || instrument
48
- )
45
+ HeadMusic::Staff.new(staff[:clef], instrument: instrument)
49
46
  end
50
47
  end
51
48
 
@@ -13,7 +13,11 @@ class HeadMusic::Instrument
13
13
  new(name)
14
14
  end
15
15
 
16
- attr_reader :name_key, :family, :default_clefs
16
+ def self.all
17
+ INSTRUMENTS.map { |key, _data| get(key) }.sort_by(&:name)
18
+ end
19
+
20
+ attr_reader :name_key, :family, :default_clefs, :classifications, :voice
17
21
 
18
22
  def ==(other)
19
23
  to_s == other.to_s
@@ -28,33 +32,41 @@ class HeadMusic::Instrument
28
32
  if record
29
33
  initialize_data_from_record(record)
30
34
  else
31
- self.name = name
35
+ self.name = name.to_s
32
36
  end
33
37
  end
34
38
 
35
39
  def record_for_name(name)
36
- key = HeadMusic::Utilities::HashKey.for(name)
37
- record_for_key(key) || record_for_key(key_for_name(name))
40
+ record_for_key(HeadMusic::Utilities::HashKey.for(name)) ||
41
+ record_for_key(key_for_name(name))
38
42
  end
39
43
 
40
44
  def key_for_name(name)
41
- INSTRUMENTS.each do |instrument|
45
+ INSTRUMENTS.each do |key, _data|
42
46
  I18n.config.available_locales.each do |locale|
43
- translation = I18n.t("instruments.#{instrument['name_key']}", locale: locale)
44
- return instrument['name_key'] if translation.downcase == name.downcase
47
+ translation = I18n.t("instruments.#{key}", locale: locale)
48
+ return key if translation.downcase == name.downcase
45
49
  end
46
50
  end
47
51
  nil
48
52
  end
49
53
 
50
54
  def record_for_key(key)
51
- INSTRUMENTS.detect { |instrument| instrument['name_key'] == key }
55
+ INSTRUMENTS.each do |name_key, data|
56
+ return data.merge!('name_key' => name_key) if name_key.to_s == key.to_s
57
+ end
52
58
  end
53
59
 
54
60
  def initialize_data_from_record(record)
55
- @family = record['family']
56
- @default_clefs = record['default_clefs']
57
61
  @name_key = record['name_key'].to_sym
58
- self.name = I18n.translate(name_key, scope: 'instruments', locale: 'en')
62
+ @family = record['family']
63
+ @default_clefs = record['default_clefs'] || []
64
+ @classifications = record['classifications'] || []
65
+ @voice = record['voice'].to_s
66
+ self.name = I18n.translate(name_key, scope: 'instruments', locale: 'en', default: inferred_name)
67
+ end
68
+
69
+ def inferred_name
70
+ name_key.to_s.gsub(/_/, ' ')
59
71
  end
60
72
  end
@@ -114,6 +114,7 @@ en:
114
114
  bass_voice: bass
115
115
  bassoon: bassoon
116
116
  castanets: castanets
117
+ cello: cello
117
118
  chimes: chimes
118
119
  clarinet: clarinet
119
120
  clash_cymbals: clash cymbals
@@ -158,7 +159,6 @@ en:
158
159
  vibraphone: vibraphone
159
160
  viola: viola
160
161
  violin: violin
161
- violincello: cello
162
162
  woodblock: woodblock
163
163
  xylophone: xylophone
164
164
  instrument_abbreviations:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeadMusic
4
- VERSION = '0.24.2'
4
+ VERSION = '0.24.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: head_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.2
4
+ version: 0.24.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Head