music-arrangement 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.rdoc
3
+ LICENSE.txt
@@ -0,0 +1,7 @@
1
+ Gemfile.lock
2
+ doc/
3
+ pkg/
4
+ vendor/cache/*.gem
5
+ .yardoc
6
+ *~
7
+ .project
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1 @@
1
+ --markup rdoc --title "music-arrangement Documentation" --protected
@@ -0,0 +1,10 @@
1
+ === 0.3.0 / 2013-08-12
2
+
3
+ * Initial release
4
+
5
+ * Started with musicality-0.2.1 gem, removing uneeded files.
6
+
7
+ * Instrument assignments are based on:
8
+
9
+ 1. ClassSpecifier, that details any file/gem requirements, and the fully qualified class name.
10
+ 2. Instrument settings, where a String indicates an instrument preset name, and a Hash indicates values mapped to instrument setting name/key.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 James Tunnell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ = music-arrangement
2
+
3
+ * {Homepage}[https://github.com/jamestunnell/music-arrangement]
4
+ * {Issues}[https://github.com/jamestunnell/music-arrangement/issues]
5
+ * {Documentation}[http://rubydoc.info/gems/music-arrangement/frames]
6
+ * {Email}[mailto:jamestunnell@lavabit.com]
7
+
8
+ == Description
9
+
10
+ Prepare a musical arrangement from a score by assigning instruments to parts.
11
+
12
+ == Features
13
+
14
+ == Examples
15
+
16
+ require 'music-arrangement'
17
+
18
+ == Requirements
19
+
20
+ == Install
21
+
22
+ $ gem install music-arrangement
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2012 James Tunnell
27
+
28
+ See LICENSE.txt for details.
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler'
7
+ rescue LoadError => e
8
+ warn e.message
9
+ warn "Run `gem install bundler` to install Bundler."
10
+ exit -1
11
+ end
12
+
13
+ begin
14
+ Bundler.setup(:development)
15
+ rescue Bundler::BundlerError => e
16
+ warn e.message
17
+ warn "Run `bundle install` to install missing gems."
18
+ exit e.status_code
19
+ end
20
+
21
+ require 'rake'
22
+
23
+ require 'rspec/core/rake_task'
24
+ RSpec::Core::RakeTask.new
25
+
26
+ task :test => :spec
27
+ task :default => :spec
28
+
29
+ require "bundler/gem_tasks"
30
+
31
+ require 'yard'
32
+ YARD::Rake::YardocTask.new
33
+ task :doc => :yard
34
+
35
+ task :make_samples do
36
+ current_dir = Dir.getwd
37
+ samples_dir = File.join(File.dirname(__FILE__), 'samples')
38
+ Dir.chdir samples_dir
39
+
40
+ samples = []
41
+ Dir.glob('**/make*.rb') do |file|
42
+ samples.push File.expand_path(file)
43
+ end
44
+
45
+ samples.each do |sample|
46
+ dirname = File.dirname(sample)
47
+ filename = File.basename(sample)
48
+
49
+ Dir.chdir dirname
50
+ ruby filename
51
+ end
52
+
53
+ Dir.chdir current_dir
54
+ end
@@ -0,0 +1,7 @@
1
+ require 'hashmake'
2
+
3
+ require 'music-arrangement/version'
4
+ require 'music-arrangement/gem_requirement'
5
+ require 'music-arrangement/file_requirement'
6
+ require 'music-arrangement/class_specifier'
7
+ require 'music-arrangement/instrument_assignment'
@@ -0,0 +1,40 @@
1
+ module Music
2
+ module Arrangement
3
+
4
+ class ClassSpecifier
5
+ include Hashmake::HashMakeable
6
+
7
+ # hashed-arg specs (for hash-makeable idiom)
8
+ ARG_SPECS = {
9
+ :requirements => arg_spec_array(:reqd => false, :type => [GemRequirement, FileRequirement]),
10
+ :qualified_name => arg_spec(:reqd => true, :type => String),
11
+ }
12
+
13
+ def initialize args={}
14
+ hash_make args, ClassSpecifier::ARG_SPECS
15
+ end
16
+
17
+ def load_requirements
18
+ @requirements.each do |req|
19
+ req.load
20
+ end
21
+ end
22
+
23
+ def to_class
24
+ load_requirements
25
+ tokens = @qualified_name.split(/::/)
26
+
27
+ module_names = tokens[0...-1]
28
+ class_name = tokens.last
29
+
30
+ cur_module = Kernel
31
+ module_names.each do |module_name|
32
+ cur_module = cur_module.const_get(module_name)
33
+ end
34
+
35
+ return cur_module.const_get(class_name)
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ module Music
2
+ module Arrangement
3
+
4
+ class FileRequirement
5
+ def initialize file_path, relative = false
6
+ @file_path = file_path
7
+ @relative = relative
8
+ end
9
+
10
+ def load
11
+ if @relative
12
+ require_relative @file_path
13
+ else
14
+ require @file_path
15
+ end
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Music
2
+ module Arrangement
3
+
4
+ class GemRequirement
5
+ def initialize gem_name, gem_version = ""
6
+ @gem_name = gem_name
7
+ @gem_version = gem_version
8
+ end
9
+
10
+ def load
11
+ if @gem_version.empty?
12
+ gem @gem_name
13
+ else
14
+ gem @gem_name, @gem_version
15
+ end
16
+ require @gem_name
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module Music
2
+ module Arrangement
3
+
4
+ # Contains all the information needed to create the instrument plugin, configure
5
+ # initial settings, and any settings changes.
6
+ #
7
+ # @author James Tunnell
8
+ class InstrumentAssignment
9
+ include Hashmake::HashMakeable
10
+
11
+ # hashed-arg specs (for hash-makeable idiom)
12
+ ARG_SPECS = {
13
+ :class_specifier => arg_spec(:reqd => true, :type => ClassSpecifier),
14
+ :initial_settings => arg_spec_array(:reqd => false, :type => [String, Hash])
15
+ }
16
+
17
+ # A new instance of InstrumentConfig.
18
+ def initialize args={}
19
+ hash_make args, InstrumentAssignment::ARG_SPECS
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ module Music
2
+ # Arrange music scores by assigning instruments to parts and such
3
+ module Arrangement
4
+ VERSION = "0.3.0"
5
+ end
6
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/music-arrangement/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "music-arrangement"
7
+ gem.version = Music::Arrangement::VERSION
8
+ gem.summary = %q{Arrange music scores by assigning instruments to parts and such}
9
+ gem.description = <<DESCRIPTION
10
+ Prepare a musical arrangement from a score by assigning instruments to parts.
11
+ DESCRIPTION
12
+ gem.license = "MIT"
13
+ gem.authors = ["James Tunnell"]
14
+ gem.email = "jamestunnell@lavabit.com"
15
+ gem.homepage = "https://github.com/jamestunnell/music-arrangement"
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ['lib']
21
+
22
+ gem.add_dependency 'hashmake', '>= 0.2.1'
23
+
24
+ gem.add_development_dependency 'bundler', '~> 1.0'
25
+ gem.add_development_dependency 'rake', '~> 0.8'
26
+ gem.add_development_dependency 'rspec', '~> 2.4'
27
+ gem.add_development_dependency 'yard', '~> 0.8'
28
+ gem.add_development_dependency 'pry'
29
+ gem.add_development_dependency 'pry-nav'
30
+ gem.add_development_dependency 'ore'
31
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ClassSpecifier do
4
+ describe '#load_requirements' do
5
+ it 'should load any FileRequirement given in requirements' do
6
+ expect { Testing::Testing::Dummy2 }.to raise_error
7
+ ClassSpecifier.new(
8
+ :requirements => [FileRequirement.new('dummy2')],
9
+ :qualified_name => "Testing::Testing::Dummy2"
10
+ ).load_requirements
11
+ expect { Testing::Testing::Dummy2 }.not_to raise_error
12
+ end
13
+
14
+ it 'should load any GemRequirement given in requirements' do
15
+ expect { YARD::Logger }.to raise_error
16
+ ClassSpecifier.new(
17
+ :requirements => [GemRequirement.new('yard')],
18
+ :qualified_name => "YARD::Logger"
19
+ ).load_requirements
20
+ expect { YARD::Logger }.not_to raise_error
21
+ end
22
+ end
23
+
24
+ describe '#to_class' do
25
+ context 'file requirement given' do
26
+ it 'should search through module namespaces to find class' do
27
+ expect { Testing::Testing::Dummy3 }.to raise_error
28
+ ClassSpecifier.new(
29
+ :requirements => [FileRequirement.new('dummy3')],
30
+ :qualified_name => "Testing::Testing::Dummy3"
31
+ ).to_class.should eq(Testing::Testing::Dummy3)
32
+ end
33
+ end
34
+
35
+ context 'gem requirement given' do
36
+ it 'should search through module namespaces to find class' do
37
+ expect { Ore::Template::Directory }.to raise_error
38
+ ClassSpecifier.new(
39
+ :requirements => [FileRequirement.new('ore')],
40
+ :qualified_name => "Ore::Template::Directory"
41
+ ).to_class.should eq(Ore::Template::Directory)
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,6 @@
1
+ module Testing
2
+ module Testing
3
+ class Dummy
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Testing
2
+ module Testing
3
+ class Dummy2
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Testing
2
+ module Testing
3
+ class Dummy3
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe FileRequirement do
4
+ describe '#load' do
5
+ it 'should load the file given during initialization' do
6
+ req = FileRequirement.new('dummy')
7
+ expect { Testing::Testing::Dummy }.to raise_error
8
+ req.load
9
+ expect { Testing::Testing::Dummy }.not_to raise_error
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe GemRequirement do
4
+ describe '#load' do
5
+ it 'should load the file given during initialization' do
6
+ req = GemRequirement.new('rake')
7
+ expect { Rake::FileTask }.to raise_error
8
+ req.load
9
+ expect { Rake::FileTask }.not_to raise_error
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe InstrumentAssignment do
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Music::Arrangement do
4
+ it "should have a VERSION constant" do
5
+ subject.const_get('VERSION').should_not be_empty
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Music::Arrangement do
4
+ it "should have a VERSION constant" do
5
+ subject.const_get('VERSION').should_not be_empty
6
+ end
7
+ end
@@ -0,0 +1,40 @@
1
+ require 'rspec'
2
+ require 'music-arrangement'
3
+
4
+ include Music::Arrangement
5
+
6
+ UPPERCASE_LETTERS = [
7
+ "A", "B", "C", "D", "E", "F", "G", "H", "I",
8
+ "J", "K", "L", "M", "N", "O", "P", "Q", "R",
9
+ "S", "T", "U", "V", "W", "X", "Y", "Z"
10
+ ]
11
+
12
+ LOWERCASE_LETTERS = [
13
+ "a", "b", "c", "d", "e", "f", "g", "h", "i",
14
+ "j", "k", "l", "m", "n", "o", "p", "q", "r",
15
+ "s", "t", "u", "v", "w", "x", "y", "z"
16
+ ]
17
+
18
+ def rand_identifier len
19
+ id = UPPERCASE_LETTERS[rand(UPPERCASE_LETTERS.count)]
20
+ (len-1).times do
21
+ id.concat LOWERCASE_LETTERS[rand(LOWERCASE_LETTERS.count)]
22
+ end
23
+ return id
24
+ end
25
+
26
+ def make_empty_class_file dir_name, class_name, *module_names
27
+ file_name = "#{class_name.downcase}.rb"
28
+ File.open("#{dir_name}/#{file_name}", "w") do |file|
29
+ module_names.each do |module_name|
30
+ file.write("module #{module_name}\n")
31
+ end
32
+
33
+ file.write("class #{class_name}\nend\n")
34
+
35
+ module_names.each do |module_name|
36
+ file.write("end\n")
37
+ end
38
+ end
39
+ return file_name
40
+ end
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: music-arrangement
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James Tunnell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashmake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.8'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.4'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.4'
78
+ - !ruby/object:Gem::Dependency
79
+ name: yard
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '0.8'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.8'
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: pry-nav
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: ore
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: ! 'Prepare a musical arrangement from a score by assigning instruments
143
+ to parts.
144
+
145
+ '
146
+ email: jamestunnell@lavabit.com
147
+ executables: []
148
+ extensions: []
149
+ extra_rdoc_files: []
150
+ files:
151
+ - .document
152
+ - .gitignore
153
+ - .rspec
154
+ - .yardopts
155
+ - ChangeLog.rdoc
156
+ - Gemfile
157
+ - LICENSE.txt
158
+ - README.rdoc
159
+ - Rakefile
160
+ - lib/music-arrangement.rb
161
+ - lib/music-arrangement/class_specifier.rb
162
+ - lib/music-arrangement/file_requirement.rb
163
+ - lib/music-arrangement/gem_requirement.rb
164
+ - lib/music-arrangement/instrument_assignment.rb
165
+ - lib/music-arrangement/version.rb
166
+ - music-arrangement.gemspec
167
+ - spec/class_specifier_spec.rb
168
+ - spec/dummy.rb
169
+ - spec/dummy2.rb
170
+ - spec/dummy3.rb
171
+ - spec/file_requirement_spec.rb
172
+ - spec/gem_requirement_spec.rb
173
+ - spec/instrument_assignment_spec.rb
174
+ - spec/music_arrangement_spec.rb
175
+ - spec/musicality_spec.rb
176
+ - spec/spec_helper.rb
177
+ homepage: https://github.com/jamestunnell/music-arrangement
178
+ licenses:
179
+ - MIT
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ segments:
191
+ - 0
192
+ hash: 2719038841856936110
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ segments:
200
+ - 0
201
+ hash: 2719038841856936110
202
+ requirements: []
203
+ rubyforge_project:
204
+ rubygems_version: 1.8.23
205
+ signing_key:
206
+ specification_version: 3
207
+ summary: Arrange music scores by assigning instruments to parts and such
208
+ test_files:
209
+ - spec/class_specifier_spec.rb
210
+ - spec/dummy.rb
211
+ - spec/dummy2.rb
212
+ - spec/dummy3.rb
213
+ - spec/file_requirement_spec.rb
214
+ - spec/gem_requirement_spec.rb
215
+ - spec/instrument_assignment_spec.rb
216
+ - spec/music_arrangement_spec.rb
217
+ - spec/musicality_spec.rb
218
+ - spec/spec_helper.rb
219
+ has_rdoc: