Permalink
Browse files

* add Scissor#/

 * version 0.0.2
  • Loading branch information...
1 parent 8189e2c commit 880468a6cdc535c41691860d532ef5fb4829cb93 @youpy committed Mar 29, 2009
Showing with 29 additions and 7 deletions.
  1. +4 −1 README.rdoc
  2. +1 −1 Rakefile
  3. +11 −0 lib/scissor.rb
  4. +5 −5 scissor.gemspec
  5. +8 −0 spec/scissor_spec.rb
View
@@ -27,7 +27,10 @@ utility to chop mp3 files
(foo.slice(10, 1) + bar.slice(2, 3)).to_file('slicefoobar.mp3')
# slice + concat + loop
- ((foo.slice(10, 1) + bar.slice(2, 3)) * 3).to_file('slicefoobarloop.mp3')
+ ((foo.slice(10, 1) + bar.slice(2, 3)) * 4).to_file('slicefoobarloop.mp3')
+
+ # split
+ (Scissor.new('sequence.mp3') / 16).to_file('split.mp3')
== Copyright
View
@@ -17,7 +17,7 @@ DESCRIPTION = "utility to chop mp3 files"
RUBYFORGE_PROJECT = "scissor"
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
BIN_FILES = %w( )
-VERS = "0.0.1"
+VERS = "0.0.2"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
View
@@ -91,6 +91,17 @@ def *(count)
self
end
+ def /(count)
+ splitted_duration = duration / count.to_f
+ results = []
+
+ count.times do |i|
+ results << slice(i, splitted_duration)
+ end
+
+ results
+ end
+
def to_file(filename)
outfiles = []
tmpdir = '/tmp/scissor-' + $$.to_s
View
@@ -1,17 +1,17 @@
Gem::Specification.new do |s|
s.name = %q{scissor}
- s.version = "0.0.1"
+ s.version = "0.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["youpy"]
- s.date = %q{2009-03-29}
+ s.date = %q{2009-03-30}
s.description = %q{utility to chop mp3 files}
s.email = %q{youpy@buycheapviagraonlinenow.com}
- s.extra_rdoc_files = ["README", "ChangeLog"]
- s.files = ["README", "ChangeLog", "Rakefile", "lib/scissor.rb"]
+ s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
+ s.files = ["README.rdoc", "ChangeLog", "Rakefile", "lib/scissor.rb"]
s.has_rdoc = true
s.homepage = %q{http://scissor.rubyforge.org}
- s.rdoc_options = ["--title", "scissor documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README", "--inline-source", "--exclude", "^(examples|extras)/"]
+ s.rdoc_options = ["--title", "scissor documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{scissor}
s.rubygems_version = %q{1.2.0}
@@ -36,6 +36,14 @@
new_mp3.duration.should eql(30)
end
+ it "should split" do
+ splits = @mp3.slice(0, 10) / 10
+ splits.length.should eql(10)
+ splits.each do |split|
+ split.duration.to_i.should eql(1)
+ end
+ end
+
it "should write to file" do
new_mp3 = @mp3.slice(0, 120) + @mp3.slice(150, 20)
file = new_mp3.to_file('/tmp/scissor-test/out.mp3')

0 comments on commit 880468a

Please sign in to comment.