webern 0.3.0 → 0.4.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.
- data/.gitignore +0 -3
- data/LICENSE.txt +22 -0
- data/README.md +32 -12
- data/lib/webern/formatters.rb +12 -0
- data/lib/webern/formatters/base_formatter.rb +20 -0
- data/lib/webern/formatters/{lilypond.rb → lilypond_formatter.rb} +3 -3
- data/lib/webern/formatters/{pdf.rb → pdf_formatter.rb} +3 -3
- data/lib/webern/formatters/{text.rb → text_formatter.rb} +3 -3
- data/lib/webern/row.rb +8 -0
- data/lib/webern/version.rb +1 -1
- data/spec/fixtures/files/row.ly +66 -0
- data/spec/fixtures/files/row.pdf +4384 -0
- data/spec/fixtures/files/row.txt +49 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/matchers/be_generated_correctly.rb +15 -0
- data/spec/webern/formatters/lilypond_formatter_spec.rb +9 -0
- data/spec/webern/formatters/pdf_formatter_spec.rb +9 -0
- data/spec/webern/formatters/text_formatter_spec.rb +28 -0
- metadata +21 -8
- data/lib/webern/formatters/base.rb +0 -15
- data/spec/webern_spec.rb +0 -10
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 2 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 3 | 
            +
            |    0    |   11    |    3    |    4    |    8    |    7    |    9    |    5    |    6    |    1    |    2    |   10    |
         | 
| 4 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 5 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 6 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 7 | 
            +
            |    1    |    0    |    4    |    5    |    9    |    8    |   10    |    6    |    7    |    2    |    3    |   11    |
         | 
| 8 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 9 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 10 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 11 | 
            +
            |    9    |    8    |    0    |    1    |    5    |    4    |    6    |    2    |    3    |   10    |   11    |    7    |
         | 
| 12 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 13 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 14 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 15 | 
            +
            |    8    |    7    |   11    |    0    |    4    |    3    |    5    |    1    |    2    |    9    |   10    |    6    |
         | 
| 16 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 17 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 18 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 19 | 
            +
            |    4    |    3    |    7    |    8    |    0    |   11    |    1    |    9    |   10    |    5    |    6    |    2    |
         | 
| 20 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 21 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 22 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 23 | 
            +
            |    5    |    4    |    8    |    9    |    1    |    0    |    2    |   10    |   11    |    6    |    7    |    3    |
         | 
| 24 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 25 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 26 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 27 | 
            +
            |    3    |    2    |    6    |    7    |   11    |   10    |    0    |    8    |    9    |    4    |    5    |    1    |
         | 
| 28 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 29 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 30 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 31 | 
            +
            |    7    |    6    |   10    |   11    |    3    |    2    |    4    |    0    |    1    |    8    |    9    |    5    |
         | 
| 32 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 33 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 34 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 35 | 
            +
            |    6    |    5    |    9    |   10    |    2    |    1    |    3    |   11    |    0    |    7    |    8    |    4    |
         | 
| 36 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 37 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 38 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 39 | 
            +
            |   11    |   10    |    2    |    3    |    7    |    6    |    8    |    4    |    5    |    0    |    1    |    9    |
         | 
| 40 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 41 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 42 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 43 | 
            +
            |   10    |    9    |    1    |    2    |    6    |    5    |    7    |    3    |    4    |   11    |    0    |    8    |
         | 
| 44 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 45 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
| 46 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 47 | 
            +
            |    2    |    1    |    5    |    6    |   10    |    9    |   11    |    7    |    8    |    3    |    4    |    0    |
         | 
| 48 | 
            +
            |         |         |         |         |         |         |         |         |         |         |         |         |
         | 
| 49 | 
            +
            |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,3 +1,12 @@ | |
| 1 1 | 
             
            require 'rubygems'
         | 
| 2 2 | 
             
            require 'bundler/setup'
         | 
| 3 3 | 
             
            require 'webern'
         | 
| 4 | 
            +
            require 'fileutils'
         | 
| 5 | 
            +
            include FileUtils
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RSpec.configure do |config|
         | 
| 10 | 
            +
              config.before(:all) { mkdir 'spec/test_files' }
         | 
| 11 | 
            +
              config.after(:all) { rm_r 'spec/test_files' }
         | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            RSpec::Matchers.define :be_generated_correctly do
         | 
| 2 | 
            +
              match do |filename|
         | 
| 3 | 
            +
                @fixture_filename = "spec/fixtures/files/#{filename}"
         | 
| 4 | 
            +
                @generated_filename = "spec/test_files/#{filename}"
         | 
| 5 | 
            +
                compare_file(@generated_filename, @fixture_filename)
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              failure_message_for_should do
         | 
| 9 | 
            +
                "#{system("diff #{@fixture_filename} #{@generated_filename}")}"
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              failure_message_for_should_not do
         | 
| 13 | 
            +
                "#{@generated_filename} should not have matched #{@fixture_filename}"
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Webern::Formatters::LilypondFormatter do
         | 
| 4 | 
            +
              it 'should write to file correctly' do
         | 
| 5 | 
            +
                row = Webern::Row.new(11, 10, 2, 3, 7, 6, 8, 4, 5, 0, 1, 9)
         | 
| 6 | 
            +
                row.write(:lilypond, path: 'spec/test_files')
         | 
| 7 | 
            +
                expect('row.ly').to be_generated_correctly
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Webern::Formatters::PdfFormatter do
         | 
| 4 | 
            +
              it 'should write to file correctly' do
         | 
| 5 | 
            +
                row = Webern::Row.new(11, 10, 2, 3, 7, 6, 8, 4, 5, 0, 1, 9)
         | 
| 6 | 
            +
                row.write(:pdf, path: 'spec/test_files')
         | 
| 7 | 
            +
                expect('row.pdf').to be_generated_correctly
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Webern::Formatters::TextFormatter do
         | 
| 4 | 
            +
              before do
         | 
| 5 | 
            +
                @row = Webern::Row.new(11, 10, 2, 3, 7, 6, 8, 4, 5, 0, 1, 9)
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              it 'should write to file correctly' do
         | 
| 9 | 
            +
                @row.write(:text, show_pitches: false, path: 'spec/test_files')
         | 
| 10 | 
            +
                expect('row.txt').to be_generated_correctly
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it 'should print to the console correctly' do
         | 
| 14 | 
            +
                output = capture_stdout { @row.draw(show_pitches: false) }
         | 
| 15 | 
            +
                expect(output).to eq File.read('spec/fixtures/files/row.txt')
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            def capture_stdout(&block)
         | 
| 20 | 
            +
              original_stdout = $stdout
         | 
| 21 | 
            +
              $stdout = fake = StringIO.new
         | 
| 22 | 
            +
              begin
         | 
| 23 | 
            +
                yield
         | 
| 24 | 
            +
              ensure
         | 
| 25 | 
            +
                $stdout = original_stdout
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
              fake.string
         | 
| 28 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: webern
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013- | 
| 12 | 
            +
            date: 2013-06-26 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: prawn
         | 
| @@ -154,15 +154,22 @@ files: | |
| 154 154 | 
             
            - README.md
         | 
| 155 155 | 
             
            - Rakefile
         | 
| 156 156 | 
             
            - lib/webern.rb
         | 
| 157 | 
            -
            - lib/webern/formatters | 
| 158 | 
            -
            - lib/webern/formatters/ | 
| 159 | 
            -
            - lib/webern/formatters/ | 
| 160 | 
            -
            - lib/webern/formatters/ | 
| 157 | 
            +
            - lib/webern/formatters.rb
         | 
| 158 | 
            +
            - lib/webern/formatters/base_formatter.rb
         | 
| 159 | 
            +
            - lib/webern/formatters/lilypond_formatter.rb
         | 
| 160 | 
            +
            - lib/webern/formatters/pdf_formatter.rb
         | 
| 161 | 
            +
            - lib/webern/formatters/text_formatter.rb
         | 
| 161 162 | 
             
            - lib/webern/row.rb
         | 
| 162 163 | 
             
            - lib/webern/version.rb
         | 
| 164 | 
            +
            - spec/fixtures/files/row.ly
         | 
| 165 | 
            +
            - spec/fixtures/files/row.pdf
         | 
| 166 | 
            +
            - spec/fixtures/files/row.txt
         | 
| 163 167 | 
             
            - spec/spec_helper.rb
         | 
| 168 | 
            +
            - spec/support/matchers/be_generated_correctly.rb
         | 
| 169 | 
            +
            - spec/webern/formatters/lilypond_formatter_spec.rb
         | 
| 170 | 
            +
            - spec/webern/formatters/pdf_formatter_spec.rb
         | 
| 171 | 
            +
            - spec/webern/formatters/text_formatter_spec.rb
         | 
| 164 172 | 
             
            - spec/webern/row_spec.rb
         | 
| 165 | 
            -
            - spec/webern_spec.rb
         | 
| 166 173 | 
             
            - webern.gemspec
         | 
| 167 174 | 
             
            homepage: ''
         | 
| 168 175 | 
             
            licenses:
         | 
| @@ -190,6 +197,12 @@ signing_key: | |
| 190 197 | 
             
            specification_version: 3
         | 
| 191 198 | 
             
            summary: Calculates all 48 possible 12-tone rows from the given input
         | 
| 192 199 | 
             
            test_files:
         | 
| 200 | 
            +
            - spec/fixtures/files/row.ly
         | 
| 201 | 
            +
            - spec/fixtures/files/row.pdf
         | 
| 202 | 
            +
            - spec/fixtures/files/row.txt
         | 
| 193 203 | 
             
            - spec/spec_helper.rb
         | 
| 204 | 
            +
            - spec/support/matchers/be_generated_correctly.rb
         | 
| 205 | 
            +
            - spec/webern/formatters/lilypond_formatter_spec.rb
         | 
| 206 | 
            +
            - spec/webern/formatters/pdf_formatter_spec.rb
         | 
| 207 | 
            +
            - spec/webern/formatters/text_formatter_spec.rb
         | 
| 194 208 | 
             
            - spec/webern/row_spec.rb
         | 
| 195 | 
            -
            - spec/webern_spec.rb
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module Webern
         | 
| 2 | 
            -
              module Formatters
         | 
| 3 | 
            -
                class Base
         | 
| 4 | 
            -
                  PITCH_CLASSES = %w{ C C# D Eb E F F# G Ab A Bb B }
         | 
| 5 | 
            -
                  def initialize(prime_row, show_pitch_classes=true)
         | 
| 6 | 
            -
                    @prime_row = prime_row
         | 
| 7 | 
            -
                    @show_pitch_classes = show_pitch_classes
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  def pitch_value(n)
         | 
| 11 | 
            -
                    @show_pitch_classes ? PITCH_CLASSES[n] : n.to_s
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
    
        data/spec/webern_spec.rb
    DELETED
    
    | @@ -1,10 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Webern do
         | 
| 4 | 
            -
              it 'should output correctly' do
         | 
| 5 | 
            -
                row = Webern::Row.new(11, 10, 2, 3, 7, 6, 8, 4, 5, 0, 1, 9)
         | 
| 6 | 
            -
                Webern::Formatters::Text.new(row, false).write_to_file('row.txt')
         | 
| 7 | 
            -
                Webern::Formatters::Pdf.new(row).write_to_file('row.pdf')
         | 
| 8 | 
            -
                Webern::Formatters::Lilypond.new(row).write_to_file('lilypond-row.ly')
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
            end
         |