scissor-echonest 0.1.0 → 0.1.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/Rakefile +2 -2
- data/lib/scissor/echonest.rb +21 -21
- data/lib/scissor/echonest/{chunk_ext.rb → tape_ext.rb} +1 -1
- data/spec/scissor-echonest_spec.rb +6 -6
- metadata +7 -7
    
        data/Rakefile
    CHANGED
    
    | @@ -21,7 +21,7 @@ DESCRIPTION       = "Scissor extension to use Echo Nest Developers API" | |
| 21 21 | 
             
            RUBYFORGE_PROJECT = "scissorechonest"
         | 
| 22 22 | 
             
            HOMEPATH          = "http://github.com/youpy/scissor-echonest"
         | 
| 23 23 | 
             
            BIN_FILES         = %w(  )
         | 
| 24 | 
            -
            VERS              = "0.1. | 
| 24 | 
            +
            VERS              = "0.1.1"
         | 
| 25 25 |  | 
| 26 26 | 
             
            REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
         | 
| 27 27 | 
             
            CLEAN.include ['**/.*.sw?', '*.gem', '.config']
         | 
| @@ -61,7 +61,7 @@ spec = Gem::Specification.new do |s| | |
| 61 61 | 
             
              s.require_path      = "lib"
         | 
| 62 62 | 
             
              s.test_files        = Dir["test/test_*.rb"]
         | 
| 63 63 |  | 
| 64 | 
            -
              s.add_dependency('scissor', '>=0. | 
| 64 | 
            +
              s.add_dependency('scissor', '>=0.2.3')
         | 
| 65 65 | 
             
              s.add_dependency('ruby-echonest', '>=0.1.1')
         | 
| 66 66 | 
             
              #s.required_ruby_version = '>= 1.8.2'
         | 
| 67 67 |  | 
    
        data/lib/scissor/echonest.rb
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            require 'scissor'
         | 
| 2 2 | 
             
            require 'echonest'
         | 
| 3 | 
            -
            require 'scissor/echonest/ | 
| 3 | 
            +
            require 'scissor/echonest/tape_ext.rb'
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Scissor
         | 
| 6 6 | 
             
              def self.echonest_api_key=(echonest_api_key)
         | 
| 7 | 
            -
                Scissor:: | 
| 7 | 
            +
                Scissor::Tape.echonest_api_key = echonest_api_key
         | 
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 | 
            -
              class  | 
| 10 | 
            +
              class Tape
         | 
| 11 11 | 
             
                class << self
         | 
| 12 12 | 
             
                  attr_accessor :echonest_api_key
         | 
| 13 13 |  | 
| @@ -19,46 +19,46 @@ module Scissor | |
| 19 19 | 
             
                def bars
         | 
| 20 20 | 
             
                  analyze do |analysis|
         | 
| 21 21 | 
             
                    bars = analysis.bars
         | 
| 22 | 
            -
                    bars.inject([]) do | | 
| 23 | 
            -
                       | 
| 24 | 
            -
                       | 
| 25 | 
            -
                       | 
| 26 | 
            -
                       | 
| 22 | 
            +
                    bars.inject([]) do |tapes, bar|
         | 
| 23 | 
            +
                      tape = self[bar.start, bar.duration]
         | 
| 24 | 
            +
                      tape.set_delegate(bar)
         | 
| 25 | 
            +
                      tapes << tape
         | 
| 26 | 
            +
                      tapes
         | 
| 27 27 | 
             
                    end
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 31 | 
             
                def beats
         | 
| 32 32 | 
             
                  analyze do |analysis|
         | 
| 33 | 
            -
                     | 
| 33 | 
            +
                    tapes = []
         | 
| 34 34 | 
             
                    beats = analysis.beats
         | 
| 35 35 |  | 
| 36 36 | 
             
                    if beats.size != 0
         | 
| 37 | 
            -
                       | 
| 37 | 
            +
                      tape = self[0, beats.first.start]
         | 
| 38 38 | 
             
                      beat = Beat.new(0.0, beats.first.start, 1.0)
         | 
| 39 | 
            -
                       | 
| 40 | 
            -
                       | 
| 39 | 
            +
                      tape.set_delegate(beat)
         | 
| 40 | 
            +
                      tapes << tape
         | 
| 41 41 | 
             
                    end
         | 
| 42 42 |  | 
| 43 43 | 
             
                    beats.inject do |m, beat|
         | 
| 44 | 
            -
                       | 
| 45 | 
            -
                       | 
| 46 | 
            -
                       | 
| 44 | 
            +
                      tape = self[m.start, beat.start - m.start]
         | 
| 45 | 
            +
                      tape.set_delegate(m)
         | 
| 46 | 
            +
                      tapes << tape
         | 
| 47 47 | 
             
                      beat
         | 
| 48 48 | 
             
                    end
         | 
| 49 49 |  | 
| 50 | 
            -
                     | 
| 50 | 
            +
                    tapes
         | 
| 51 51 | 
             
                  end
         | 
| 52 52 | 
             
                end
         | 
| 53 53 |  | 
| 54 54 | 
             
                def segments
         | 
| 55 55 | 
             
                  analyze do |analysis|
         | 
| 56 56 | 
             
                    segments = analysis.segments
         | 
| 57 | 
            -
                    segments.inject([]) do | | 
| 58 | 
            -
                       | 
| 59 | 
            -
                       | 
| 60 | 
            -
                       | 
| 61 | 
            -
                       | 
| 57 | 
            +
                    segments.inject([]) do |tapes, segment|
         | 
| 58 | 
            +
                      tape = self[segment.start, segment.duration]
         | 
| 59 | 
            +
                      tape.set_delegate(segment)
         | 
| 60 | 
            +
                      tapes << tape
         | 
| 61 | 
            +
                      tapes
         | 
| 62 62 | 
             
                    end
         | 
| 63 63 | 
             
                  end
         | 
| 64 64 | 
             
                end
         | 
| @@ -8,17 +8,17 @@ describe Scissor do | |
| 8 8 | 
             
              it 'should set Echo Nest API key' do
         | 
| 9 9 | 
             
                Scissor.echonest_api_key = 'XXX'
         | 
| 10 10 |  | 
| 11 | 
            -
                Scissor:: | 
| 11 | 
            +
                Scissor::Tape.echonest_api_key.should eql('XXX')
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              it 'should get an instance of EchoNest::Api' do
         | 
| 15 15 | 
             
                Scissor.echonest_api_key = 'XXX'
         | 
| 16 16 |  | 
| 17 | 
            -
                echonest = Scissor:: | 
| 17 | 
            +
                echonest = Scissor::Tape.echonest
         | 
| 18 18 | 
             
                echonest.user_agent.send_timeout = 300
         | 
| 19 19 |  | 
| 20 20 | 
             
                echonest.should be_an_instance_of(Echonest::Api)
         | 
| 21 | 
            -
                Scissor:: | 
| 21 | 
            +
                Scissor::Tape.echonest.user_agent.send_timeout.should eql(300)
         | 
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
| 24 24 | 
             
              describe 'analysis' do |object|
         | 
| @@ -31,7 +31,7 @@ describe Scissor do | |
| 31 31 | 
             
                  track_methods.stub!(:analysis).and_return(Echonest::Analysis.new(open(fixture('analysis.json')).read))
         | 
| 32 32 |  | 
| 33 33 | 
             
                  @scissor = Scissor(fixture('sample.mp3'))
         | 
| 34 | 
            -
                  Scissor:: | 
| 34 | 
            +
                  Scissor::Tape.stub!(:echonest).and_return(api)
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                it 'should get bars' do
         | 
| @@ -48,12 +48,12 @@ describe Scissor do | |
| 48 48 | 
             
                  beats = @scissor.beats
         | 
| 49 49 |  | 
| 50 50 | 
             
                  beats.size.should eql(324)
         | 
| 51 | 
            -
                  beats[0].should be_an_instance_of(Scissor:: | 
| 51 | 
            +
                  beats[0].should be_an_instance_of(Scissor::Tape)
         | 
| 52 52 | 
             
                  beats[0].start.should eql(0.0)
         | 
| 53 53 | 
             
                  beats[0].duration.should eql(0.27661)
         | 
| 54 54 | 
             
                  beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
         | 
| 55 55 | 
             
                  beats[0].confidence.should eql(1.0)
         | 
| 56 | 
            -
                  beats[1].should be_an_instance_of(Scissor:: | 
| 56 | 
            +
                  beats[1].should be_an_instance_of(Scissor::Tape)
         | 
| 57 57 | 
             
                  beats[1].start.should eql(0.27661)
         | 
| 58 58 | 
             
                  beats[1].duration.should eql(0.36476)
         | 
| 59 59 | 
             
                  beats[1].fragments.first.filename.should eql(fixture('sample.mp3'))
         | 
    
        metadata
    CHANGED
    
    | @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version | |
| 5 5 | 
             
              segments: 
         | 
| 6 6 | 
             
              - 0
         | 
| 7 7 | 
             
              - 1
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: 0.1. | 
| 8 | 
            +
              - 1
         | 
| 9 | 
            +
              version: 0.1.1
         | 
| 10 10 | 
             
            platform: ruby
         | 
| 11 11 | 
             
            authors: 
         | 
| 12 12 | 
             
            - youpy
         | 
| @@ -14,7 +14,7 @@ autorequire: | |
| 14 14 | 
             
            bindir: bin
         | 
| 15 15 | 
             
            cert_chain: []
         | 
| 16 16 |  | 
| 17 | 
            -
            date: 2011- | 
| 17 | 
            +
            date: 2011-12-02 00:00:00 +09:00
         | 
| 18 18 | 
             
            default_executable: 
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -26,9 +26,9 @@ dependencies: | |
| 26 26 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 27 27 | 
             
                    segments: 
         | 
| 28 28 | 
             
                    - 0
         | 
| 29 | 
            -
                    -  | 
| 30 | 
            -
                    -  | 
| 31 | 
            -
                    version: 0. | 
| 29 | 
            +
                    - 2
         | 
| 30 | 
            +
                    - 3
         | 
| 31 | 
            +
                    version: 0.2.3
         | 
| 32 32 | 
             
              type: :runtime
         | 
| 33 33 | 
             
              version_requirements: *id001
         | 
| 34 34 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -63,7 +63,7 @@ files: | |
| 63 63 | 
             
            - spec/scissor-echonest_spec.rb
         | 
| 64 64 | 
             
            - spec/spec.opts
         | 
| 65 65 | 
             
            - spec/spec_helper.rb
         | 
| 66 | 
            -
            - lib/scissor/echonest/ | 
| 66 | 
            +
            - lib/scissor/echonest/tape_ext.rb
         | 
| 67 67 | 
             
            - lib/scissor/echonest.rb
         | 
| 68 68 | 
             
            - examples/afromb.rb
         | 
| 69 69 | 
             
            has_rdoc: true
         |