Permalink
Browse files

use bundler + rspec2 + jeweler

  • Loading branch information...
1 parent c57d740 commit a163ce137c492a769cfdbd0cf6d6c3f102995e2e @youpy committed Jan 19, 2012
Showing with 125 additions and 126 deletions.
  1. +2 −0 .gitignore
  2. +0 −1 spec/spec.opts → .rspec
  3. +16 −0 Gemfile
  4. +44 −0 Gemfile.lock
  5. +35 −97 Rakefile
  6. +27 −27 spec/scissor_spec.rb
  7. +1 −1 spec/sound_file_spec.rb
View
@@ -1,3 +1,5 @@
pkg
coverage
*.gem
+vendor/bundle
+.bundle
@@ -1,3 +1,2 @@
-c
-fs
-
View
@@ -0,0 +1,16 @@
+source 'http://rubygems.org'
+
+gem 'open4', '>= 1.3.0'
+gem 'ruby-mp3info'
+gem 'riff', '<= 0.3.0'
+gem 'tempdir'
+gem 'streamio-ffmpeg'
+
+group :development do
+ gem 'rspec', '~> 2.3.0'
+ gem 'bundler', '~> 1.0.0'
+ gem 'jeweler', '~> 1.6.4'
+ gem 'rcov', '>= 0'
+ gem 'rdoc'
+ gem 'fakeweb'
+end
View
@@ -0,0 +1,44 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.3)
+ fakeweb (1.3.0)
+ git (1.2.5)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ json (1.6.5)
+ open4 (1.3.0)
+ rake (0.9.2.2)
+ rcov (0.9.11)
+ rdoc (3.12)
+ json (~> 1.4)
+ riff (0.3)
+ rspec (2.3.0)
+ rspec-core (~> 2.3.0)
+ rspec-expectations (~> 2.3.0)
+ rspec-mocks (~> 2.3.0)
+ rspec-core (2.3.1)
+ rspec-expectations (2.3.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.3.0)
+ ruby-mp3info (0.6.16)
+ streamio-ffmpeg (0.8.4)
+ tempdir (0.0.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bundler (~> 1.0.0)
+ fakeweb
+ jeweler (~> 1.6.4)
+ open4 (>= 1.3.0)
+ rcov
+ rdoc
+ riff (<= 0.3.0)
+ rspec (~> 2.3.0)
+ ruby-mp3info
+ streamio-ffmpeg
+ tempdir
View
@@ -1,110 +1,48 @@
-require 'rubygems'
-gem 'rspec', '< 2'
-require 'rake'
-require 'rake/clean'
-require 'spec/rake/spectask'
-require 'rake/packagetask'
-require 'rake/gempackagetask'
-require 'rake/rdoctask'
-require 'rake/contrib/rubyforgepublisher'
-require 'rake/contrib/sshpublisher'
-require 'fileutils'
-include FileUtils
-
-NAME = "scissor"
-AUTHOR = "youpy"
-EMAIL = "youpy@buycheapviagraonlinenow.com"
-DESCRIPTION = "utility to chop sound files"
-RUBYFORGE_PROJECT = "scissor"
-HOMEPATH = "http://github.com/youpy/scissor"
-BIN_FILES = %w( )
-VERS = "0.2.8"
+# encoding: utf-8
-REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
-CLEAN.include ['**/.*.sw?', '*.gem', '.config']
-RDOC_OPTS = [
- '--title', "#{NAME} documentation",
- "--charset", "utf-8",
- "--opname", "index.html",
- "--line-numbers",
- "--main", "README.rdoc",
- "--inline-source",
-]
-
-task :default => [:spec]
-task :package => [:clean]
-
-Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--options', "spec/spec.opts"]
- t.spec_files = FileList['spec/*_spec.rb']
- t.rcov = true
+require 'rubygems'
+require 'bundler'
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
end
+require 'rake'
-spec = Gem::Specification.new do |s|
- s.name = NAME
- s.version = VERS
- s.platform = Gem::Platform::RUBY
- s.has_rdoc = true
- s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
- s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
- s.summary = DESCRIPTION
- s.description = DESCRIPTION
- s.author = AUTHOR
- s.email = EMAIL
- s.executables = BIN_FILES
- s.rubyforge_project = RUBYFORGE_PROJECT
- s.bindir = "bin"
- s.require_path = "lib"
- s.homepage = HOMEPATH
- s.test_files = Dir["test/test_*.rb"]
-
- s.add_dependency('open4', '>= 1.3.0')
- s.add_dependency('ruby-mp3info')
- s.add_dependency('riff', '<= 0.3.0')
- s.add_dependency('tempdir')
- s.add_dependency('streamio-ffmpeg')
- s.add_development_dependency('fakeweb')
- #s.required_ruby_version = '>= 1.8.2'
-
- s.files = %w(README.rdoc ChangeLog Rakefile) +
- Dir.glob("{bin,doc,test,lib,data,templates,generator,extras,website,script}/**/*") +
- Dir.glob("ext/**/*.{h,c,rb}") +
- Dir.glob("examples/**/*.rb") +
- Dir.glob("tools/*.rb")
-
- s.extensions = FileList["ext/**/extconf.rb"].to_a
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
+ gem.name = "scissor"
+ gem.summary = %Q{utility to chop sound files}
+ gem.description = %Q{utility to chop sound files}
+ gem.email = "youpy@buycheapviagraonlinenow.com"
+ gem.authors = ["youpy"]
+ gem.homepage = "http://github.com/youpy/scissor"
+ # dependencies defined in Gemfile
end
+Jeweler::RubygemsDotOrgTasks.new
-Rake::GemPackageTask.new(spec) do |p|
- p.need_tar = true
- p.gem_spec = spec
+require 'rspec/core'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
end
-task :install do
- name = "#{NAME}-#{VERS}.gem"
- sh %{rake package}
- sh %{sudo gem install pkg/#{name}}
+RSpec::Core::RakeTask.new(:rcov) do |spec|
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
end
-task :uninstall => [:clean] do
- sh %{sudo gem uninstall #{NAME}}
-end
+task :default => :spec
+require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
- rdoc.rdoc_dir = 'html'
- rdoc.options += RDOC_OPTS
- rdoc.template = "resh"
- #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
- if ENV['DOC_FILES']
- rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
- else
- rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
- rdoc.rdoc_files.include('lib/**/*.rb')
- rdoc.rdoc_files.include('ext/**/*.c')
- end
-end
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
-desc 'Show information about the gem.'
-task :debug_gem do
- puts spec.to_ruby
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "scissor #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
end
View
@@ -27,20 +27,20 @@
mp3 = Scissor(url)
mp3.should be_an_instance_of(Scissor::Tape)
- mp3.duration.should be_close(178.1, 0.1)
+ mp3.duration.should be_within(0.1).of(178.1)
end
it "should expand given path" do
cp fixture('sample.mp3'), '/tmp/scissor-test'
mp3 = Scissor('~/../../../../../../../../../../tmp/scissor-test/sample.mp3')
mp3.should be_an_instance_of(Scissor::Tape)
- mp3.duration.should be_close(178.1, 0.1)
+ mp3.duration.should be_within(0.1).of(178.1)
end
it "should get duration" do
@mp3.should respond_to(:duration)
- @mp3.duration.should be_close(178.1, 0.1)
+ @mp3.duration.should be_within(0.1).of(178.1)
end
it "should slice" do
@@ -55,7 +55,7 @@
end
it "should cut down if sliced range is out of duration" do
- @mp3.slice(0, 179).duration.should be_close(178.1, 0.1)
+ @mp3.slice(0, 179).duration.should be_within(0.1).of(178.1)
end
it "should concatenate" do
@@ -74,7 +74,7 @@
it "should concat silence" do
scissor = @mp3.slice(0, 12).concat(Scissor.silence(0.32009))
- scissor.duration.should be_close(12.32, 0.01)
+ scissor.duration.should be_within(0.01).of(12.32)
end
it "should concatenate and create new instance" do
@@ -87,12 +87,12 @@
it "should slice concatenated one" do
scissor = @mp3.slice(0.33, 1).concat(@mp3.slice(0.2, 0.1)).slice(0.9, 0.2)
- scissor.duration.should be_close(0.2, 0.001)
+ scissor.duration.should be_within(0.001).of(0.2)
scissor.fragments.size.should eql(2)
- scissor.fragments[0].start.should be_close(1.23, 0.001)
- scissor.fragments[0].duration.should be_close(0.1, 0.001)
- scissor.fragments[1].start.should be_close(0.2, 0.001)
- scissor.fragments[1].duration.should be_close(0.1, 0.001)
+ scissor.fragments[0].start.should be_within(0.001).of(1.23)
+ scissor.fragments[0].duration.should be_within(0.001).of(0.1)
+ scissor.fragments[1].start.should be_within(0.001).of(0.2)
+ scissor.fragments[1].duration.should be_within(0.001).of(0.1)
end
it "should loop" do
@@ -110,7 +110,7 @@
splits = (@mp3.slice(0.33, 1) + @mp3.slice(0.2, 0.1)).split(5)
splits.length.should eql(5)
splits.each do |split|
- split.duration.should be_close(0.22, 0.001)
+ split.duration.should be_within(0.001).of(0.22)
end
splits[0].fragments.size.should eql(1)
@@ -124,7 +124,7 @@
splits = (@mp3.slice(0.33, 1) + @mp3.slice(0.2, 0.1)) / 5
splits.length.should eql(5)
splits.each do |split|
- split.duration.should be_close(0.22, 0.001)
+ split.duration.should be_within(0.001).of(0.22)
end
splits[0].fragments.size.should eql(1)
@@ -193,8 +193,8 @@
scissor = @mp3.slice(0, 0.1)
scissor.duration.should eql(0.1)
- scissor.pitch((0.1 / 120) * 100, true).duration.should be_close(120.0, 0.1)
- scissor.stretch((120 / 0.1) * 100).duration.should be_close(120.0, 0.1)
+ scissor.pitch((0.1 / 120) * 100, true).duration.should be_within(0.01).of(120.0)
+ scissor.stretch((120 / 0.1) * 100).duration.should be_within(0.1).of(120.0)
stretched = scissor.stretch((120 / 0.1) * 100).slice(0, 10)
stretched.fragments.first.should be_stretched
@@ -223,7 +223,7 @@
scissor = Scissor.mix([a, b], '/tmp/scissor-test/out.mp3')
scissor.should be_an_instance_of(Scissor::Tape)
- scissor.duration.should be_close(120, 0.1)
+ scissor.duration.should be_within(0.1).of(120)
scissor.fragments.size.should eql(1)
end
@@ -237,13 +237,13 @@
scissor = @mp3.slice(0, 120) + @mp3.slice(150, 20)
result = scissor.to_file('/tmp/scissor-test/out.mp3')
result.should be_an_instance_of(Scissor::Tape)
- result.duration.should be_close(140, 0.1)
+ result.duration.should be_within(0.1).of(140)
end
it "should write to mp3 file" do
scissor = @mp3.slice(0, 120) + @mp3.slice(150, 20)
result = scissor.to_file('/tmp/scissor-test/out.mp3')
- result.duration.should be_close(140, 0.1)
+ result.duration.should be_within(0.1).of(140)
end
it "should write to expanded path" do
@@ -256,51 +256,51 @@
it "should write to wav file" do
scissor = @mp3.slice(0, 120) + @mp3.slice(150, 20)
result = scissor.to_file('/tmp/scissor-test/out.wav')
- result.duration.should be_close(140, 0.1)
+ result.duration.should be_within(0.1).of(140)
end
it "should write to file using 'greater than' operator" do
result = @mp3.slice(0, 120) + @mp3.slice(150, 20) > '/tmp/scissor-test/out.wav'
- result.duration.should be_close(140, 0.1)
+ result.duration.should be_within(0.1).of(140)
end
it "should write to file with many fragments" do
scissor = (@mp3.slice(0, 120) / 100).inject(Scissor()){|m, s| m + s } + @mp3.slice(10, 20)
result = scissor.to_file('/tmp/scissor-test/out.mp3')
result.should be_an_instance_of(Scissor::Tape)
- result.duration.should be_close(140, 0.1)
+ result.duration.should be_within(0.1).of(140)
end
it "should overwrite existing file" do
result = @mp3.slice(0, 10).to_file('/tmp/scissor-test/out.mp3')
- result.duration.should be_close(10, 0.1)
+ result.duration.should be_within(0.1).of(10)
result = @mp3.slice(0, 12).to_file('/tmp/scissor-test/out.mp3',
:overwrite => true)
- result.duration.should be_close(12, 0.1)
+ result.duration.should be_within(0.1).of(12)
end
it "should overwrite existing file using double 'greater than' oprator" do
result = @mp3.slice(0, 10).to_file('/tmp/scissor-test/out.mp3')
- result.duration.should be_close(10, 0.1)
+ result.duration.should be_within(0.1).of(10)
result = @mp3.slice(0, 12) >> '/tmp/scissor-test/out.mp3'
- result.duration.should be_close(12, 0.1)
+ result.duration.should be_within(0.1).of(12)
end
it "should write to file in the variable pitch" do
scissor = @mp3.slice(0, 120) + @mp3.slice(150, 20)
result = scissor.pitch(50).to_file('/tmp/scissor-test/out.mp3')
- result.duration.should be_close(280, 0.1)
+ result.duration.should be_within(0.1).of(280)
result = scissor.pitch(200).to_file('/tmp/scissor-test/out.mp3', :overwrite => true)
- result.duration.should be_close(70, 0.1)
+ result.duration.should be_within(0.1).of(70)
end
it "should raise error if overwrite option is false" do
result = @mp3.slice(0, 10).to_file('/tmp/scissor-test/out.mp3')
- result.duration.should be_close(10, 0.1)
+ result.duration.should be_within(0.1).of(10)
lambda {
@mp3.slice(0, 10).to_file('/tmp/scissor-test/out.mp3',
Oops, something went wrong.

0 comments on commit a163ce1

Please sign in to comment.