cuesnap 1.1.0 → 1.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/README.md CHANGED
@@ -11,6 +11,7 @@ _Tested on Mac OS X 10.7 (Lion)._
11
11
  **Prerequisites**
12
12
 
13
13
  1. [Mac OS X](http://store.apple.com)
14
+ 1. [Homebrew](http://mxcl.github.com/homebrew/)
14
15
  1. [Ruby 1.8.7 or Greater](http://ruby-lang.org/) _Comes pre-installed in OS X_
15
16
 
16
17
  **Okay, let's go**
@@ -56,16 +57,22 @@ _Tested on Mac OS X 10.7 (Lion)._
56
57
 
57
58
  That's it, now code something awesome and tell me about it.
58
59
 
60
+ ## Changelog
61
+
62
+ ### 1.1.1
63
+
64
+ * Now properly escaping shell characters found in file names
65
+
59
66
  ## Todo
60
67
 
61
68
  1. Unicode Support _Fail test is already in_.
62
- 2. Error Message when mp3splt is missing.
69
+ 1. Error Message when mp3splt is missing.
63
70
 
64
71
  ## Contributing
65
72
 
66
73
  1. [Fork it](https://github.com/mutewinter/cuesnap/fork_select).
67
- 2. Create your feature branch (`git checkout -b my_sweet_feature`).
68
- 3. Write some kickass code.
69
- 3. Commit your changes (`git commit -am 'Added a sweet feature'`).
70
- 4. Push to the branch (`git push origin my_sweet_feature`).
71
- 5. Create new [Pull Request](https://github.com/mutewinter/cuesnap/pulls).
74
+ 1. Create your feature branch (`git checkout -b my_sweet_feature`).
75
+ 1. Write some kickass code.
76
+ 1. Commit your changes (`git commit -am 'Added a sweet feature'`).
77
+ 1. Push to the branch (`git push origin my_sweet_feature`).
78
+ 1. Create new [Pull Request](https://github.com/mutewinter/cuesnap/pulls).
data/bin/cuesnap CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'bundler/setup'
5
5
 
6
6
  begin
7
- require 'cuesnap/cli'
7
+ require 'cuesnap'
8
8
  CueSnap::CLI.go!
9
9
  rescue Interrupt => e
10
10
  puts "\nQuitting..."
data/lib/cuesnap/cli.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'methadone'
2
2
  require 'pathname'
3
3
 
4
- require 'cuesnap/splitter'
5
-
6
4
  module CueSnap
7
5
  class CLI
8
6
  include Methadone::Main
@@ -12,12 +10,18 @@ module CueSnap
12
10
  # no-numbers comes in false when it's set, I know, crazy.
13
11
  options[:no_numbers] = !options[:'no-numbers'] if options.has_key?(:'no-numbers')
14
12
 
15
- file_not_found mp3_file unless File.exists? mp3_file
16
-
17
- splitter = CueSnap::Splitter.new(mp3_file, cue_file, options)
13
+ begin
14
+ splitter = CueSnap::Splitter.new(mp3_file, cue_file, options)
15
+ rescue FileNotFound => e
16
+ file_not_found e.message
17
+ end
18
18
 
19
19
  if File.exists? splitter.cue_file
20
- splitter.split!
20
+ begin
21
+ splitter.split!
22
+ rescue Iconv::IllegalSequence => e
23
+ exit_now! "Unicode isn't quite working yet, sorry. Strip it out of your .cue file for a temporary fix."
24
+ end
21
25
  else
22
26
  file_not_found splitter.cue_file
23
27
  end
@@ -1,8 +1,15 @@
1
1
  require 'hashie'
2
2
  require 'rubycue'
3
+ require 'shellwords'
3
4
 
4
5
  module CueSnap
6
+ class FileNotFound < StandardError; end
7
+ class MP3FileNotFound < FileNotFound; end
8
+ class CueFileNotFound < FileNotFound; end
9
+
5
10
  class Splitter
11
+ attr_reader :mp3_file, :cue_file, :output_folder, :options
12
+
6
13
  # Public: Loads an mp3 and a RubyCue cuesheet.
7
14
  #
8
15
  # mp3_file - String file path to an mp3 file.
@@ -15,6 +22,8 @@ module CueSnap
15
22
  #
16
23
  # Returns the initalized object.
17
24
  def initialize(mp3_file, cue_file = nil, options = {})
25
+ raise CueSnap::MP3FileNotFound, mp3_file unless File.exists? mp3_file
26
+
18
27
  @mp3_file = mp3_file
19
28
  if cue_file and cue_file.strip != ''
20
29
  @cue_file = cue_file
@@ -22,6 +31,8 @@ module CueSnap
22
31
  @cue_file = File.expand_path("#{mp3_filename}.cue", File.dirname(@mp3_file))
23
32
  end
24
33
 
34
+ raise CueSnap::CueFileNotFound, @cue_file unless File.exists? @cue_file
35
+
25
36
  @options = Hashie::Mash.new options
26
37
  @output_folder = @options.output_folder
27
38
  @output_folder ||= mp3_filename
@@ -66,14 +77,14 @@ module CueSnap
66
77
  format = "#{number_format} #{format}" unless @options.no_numbers
67
78
 
68
79
  # Got to esape the spaces for the shell
69
- format.gsub!(/\s/, '\\ ')
80
+ format = Shellwords.escape format
70
81
 
71
82
  command = ['mp3splt',
72
- "-d #{output_folder}",
83
+ "-d #{escaped_output_folder}",
73
84
  "-o #{format}",
74
- "-c #@cue_file"]
85
+ "-c #{escaped_cue_file}"]
75
86
  command.push '-Q' if @options.quiet
76
- command.push @mp3_file
87
+ command.push escaped_mp3_file
77
88
 
78
89
  system command.join(' ')
79
90
  end
@@ -83,7 +94,27 @@ module CueSnap
83
94
  File.basename(@mp3_file, '.mp3')
84
95
  end
85
96
 
86
- attr_reader :mp3_file, :cue_file, :output_folder, :options
97
+ # Public: The space-escaped mp3 file path.
98
+ def escaped_mp3_file
99
+ escape_path @mp3_file
100
+ end
101
+
102
+ # Public: The space-escaped output folder path.
103
+ def escaped_output_folder
104
+ escape_path @output_folder
105
+ end
106
+
107
+ # Public: The space-escaped cue file path.
108
+ def escaped_cue_file
109
+ escape_path @cue_file
110
+ end
111
+
112
+ private
113
+
114
+ # Internal: Escape a path for the shell.
115
+ def escape_path(file)
116
+ Shellwords.escape file
117
+ end
87
118
 
88
119
  end
89
120
  end
@@ -1,3 +1,3 @@
1
1
  module CueSnap
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuesnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.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: 2012-08-17 00:00:00.000000000 Z
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubycue