youpy-scissor 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -38,7 +38,7 @@ supported file format:
38
38
  foo + bar > 'foobar.mp3'
39
39
 
40
40
  # slice + concat
41
- foo[10, 1] + bar.slice[2, 3] > 'slicefoobar.mp3'
41
+ foo[10, 1] + bar[2, 3] > 'slicefoobar.mp3'
42
42
 
43
43
  # slice + concat + loop
44
44
  (foo[10, 1] + bar[2, 3]) * 4 > 'slicefoobarloop.mp3'
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ DESCRIPTION = "utility to chop sound files"
17
17
  RUBYFORGE_PROJECT = "scissor"
18
18
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
19
19
  BIN_FILES = %w( )
20
- VERS = "0.0.17"
20
+ VERS = "0.0.18"
21
21
 
22
22
  REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
23
23
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
data/lib/scissor.rb CHANGED
@@ -17,4 +17,10 @@ module Scissor
17
17
  def self.sequence(*args)
18
18
  Scissor::Sequence.new(*args)
19
19
  end
20
+
21
+ def self.join(scissor_array)
22
+ scissor_array.inject(Scissor()) do |m, scissor|
23
+ m + scissor
24
+ end
25
+ end
20
26
  end
data/lib/scissor/chunk.rb CHANGED
@@ -2,7 +2,6 @@ require 'digest/md5'
2
2
  require 'pathname'
3
3
  require 'open4'
4
4
  require 'logger'
5
- require 'bigdecimal'
6
5
 
7
6
  module Scissor
8
7
  class Chunk
@@ -43,15 +42,14 @@ module Scissor
43
42
  end
44
43
 
45
44
  def duration
46
- BigDecimal(
47
- @fragments.inject(0) do |memo, fragment|
48
- memo += fragment.duration
49
- end.to_s).round(3).to_f
45
+ @fragments.inject(0) do |memo, fragment|
46
+ memo += fragment.duration
47
+ end
50
48
  end
51
49
 
52
50
  def slice(start, length)
53
51
  if start + length > duration
54
- raise OutOfDuration
52
+ length = duration - start
55
53
  end
56
54
 
57
55
  new_instance = self.class.new
@@ -123,7 +121,7 @@ module Scissor
123
121
  remain = filled_duration
124
122
  new_instance = self.class.new
125
123
 
126
- while filled_duration > new_instance.duration
124
+ while !remain.zero? && filled_duration > new_instance.duration
127
125
  if remain < duration
128
126
  added = slice(0, remain)
129
127
  else
@@ -134,6 +132,7 @@ module Scissor
134
132
  remain -= added.duration
135
133
  end
136
134
 
135
+
137
136
  new_instance
138
137
  end
139
138
 
@@ -4,7 +4,7 @@ require 'riff/reader'
4
4
 
5
5
  module Scissor
6
6
  class SoundFile
7
- SUPPORTED_FORMAT = %w/mp3 wav/
7
+ SUPPORTED_FORMATS = %w/mp3 wav/
8
8
 
9
9
  class Error < StandardError; end
10
10
  class UnknownFormat < Error; end
@@ -13,7 +13,7 @@ module Scissor
13
13
  @filename = Pathname.new(filename)
14
14
  @ext = @filename.extname.sub(/^\./, '').downcase
15
15
 
16
- unless SUPPORTED_FORMAT.include?(@ext)
16
+ unless SUPPORTED_FORMATS.include?(@ext)
17
17
  raise UnknownFormat
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youpy-scissor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - youpy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-15 00:00:00 -07:00
12
+ date: 2009-07-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency