greatseth-mediainfo 0.3 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,13 @@
1
+ v0.5.1 Packaging Fix
2
+ - Gemspec was referencing a missing file
3
+ - Behold: THREE DIGIT VERSION NUMBER. Serious business now!
4
+
5
+ v0.5 Raw, Son
6
+ - You can now initialize an instance from raw CLI output
7
+
8
+ v0.4 Mediainfo Respects Your Existing Customs
9
+ - Define String#shell_escape only if it is not already defined
10
+
1
11
  v0.3 Mediainfo Is High Class
2
12
  - Class instead of instance-level customization of mediainfo binary path.
3
13
  Set Mediainfo.path = /path/to/binary if mediainfo is not in your shell
data/Manifest CHANGED
@@ -1,9 +1,9 @@
1
1
  Changelog
2
- lib/mediainfo/attr_readers.rb
3
- lib/mediainfo/string.rb
4
- lib/mediainfo.rb
5
2
  LICENSE
6
3
  Manifest
7
- mediainfo.gemspec
8
- Rakefile
9
4
  README.markdown
5
+ Rakefile
6
+ lib/mediainfo.rb
7
+ lib/mediainfo/attr_readers.rb
8
+ lib/mediainfo/string.rb
9
+ mediainfo.gemspec
data/README.markdown CHANGED
@@ -25,6 +25,15 @@ the ffmpeg development team, and decided finally that perhaps other
25
25
  tools were better. As such, some of the API for Mediainfo is straight
26
26
  from RVideo::Inspector. Some is not. Just saying.
27
27
 
28
+ ## Requirements
29
+
30
+ This library is compatible with:
31
+
32
+ MediaInfo Command line,
33
+ MediaInfoLib - v0.7.11
34
+
35
+ to the extent that is documented in the tests.
36
+
28
37
  ## Contributors
29
38
 
30
39
  * Seth Thomas Rasmussen - [http://greatseth.com](http://greatseth.com)
data/Rakefile CHANGED
@@ -29,6 +29,7 @@ require "rubygems"
29
29
  require "echoe"
30
30
 
31
31
  Echoe.new "mediainfo" do |p|
32
+ p.description = "Mediainfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)"
32
33
  p.author = "Seth Thomas Rasmussen"
33
34
  p.email = "sethrasmussen@gmail.com"
34
35
  p.url = "http://greatseth.com"
data/lib/mediainfo.rb CHANGED
@@ -14,6 +14,16 @@ require "mediainfo/attr_readers"
14
14
  # about a file. Some attributes may be present for some files where others
15
15
  # are not.
16
16
  #
17
+ # You may also initialize a Mediainfo instance using raw CLI output
18
+ # you have saved for some reason.
19
+ #
20
+ # info = Mediainfo.new
21
+ # info.raw_response = cli_output
22
+ #
23
+ # Setting the raw_response triggers the system call, and from that point on
24
+ # the object should behave the same as if you'd initialized it with the path
25
+ # to a file.
26
+ #
17
27
  # For a list of all possible attributes supported:
18
28
  #
19
29
  # Mediainfo.supported_attributes
@@ -170,17 +180,25 @@ class Mediainfo
170
180
  attr_reader :raw_response, :parsed_response,
171
181
  :full_filename, :filename, :path, :escaped_full_filename
172
182
 
173
- def initialize(full_filename)
174
- @full_filename = File.expand_path full_filename
175
- @path = File.dirname @full_filename
176
- @filename = File.basename @full_filename
177
-
178
- raise ArgumentError, "need a path to a video file, got nil" unless @full_filename
179
- raise ArgumentError, "need a path to a video file, #{@full_filename} does not exist" unless File.exist? @full_filename
180
-
181
- @escaped_full_filename = @full_filename.shell_escape
182
- @raw_response = mediainfo!
183
+ def initialize(full_filename = nil)
184
+ if full_filename
185
+ @full_filename = File.expand_path full_filename
186
+ @path = File.dirname @full_filename
187
+ @filename = File.basename @full_filename
188
+
189
+ raise ArgumentError, "need a path to a video file, got nil" unless @full_filename
190
+ raise ArgumentError, "need a path to a video file, #{@full_filename} does not exist" unless File.exist? @full_filename
191
+
192
+ @escaped_full_filename = @full_filename.shell_escape
193
+
194
+ self.raw_response = mediainfo!
195
+ end
196
+ end
197
+
198
+ def raw_response=(mediainfo_cli_output)
199
+ @raw_response = mediainfo_cli_output
183
200
  parse!
201
+ @raw_response
184
202
  end
185
203
 
186
204
  class << self; attr_accessor :path; end
@@ -198,6 +216,10 @@ class Mediainfo
198
216
  class Error < StandardError; end
199
217
  class ExecutionError < Error; end
200
218
 
219
+ def inspect
220
+ super.sub /@raw_response=".+?", @/, %{@raw_response="...", @}
221
+ end
222
+
201
223
  private
202
224
  def mediainfo!
203
225
  # for bash, see: http://www.faqs.org/docs/bashman/bashref_12.html
@@ -5,5 +5,5 @@ class String
5
5
  # The $'' is for bash, see http://www.faqs.org/docs/bashman/bashref_12.html,
6
6
  # but appears to be working for other shells: sh, zsh, ksh, dash
7
7
  "$'#{gsub(/\\|'/) { |c| "\\#{c}" }}'"
8
- end
8
+ end unless method_defined?(:shell_escape)
9
9
  end
data/mediainfo.gemspec CHANGED
@@ -2,21 +2,21 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mediainfo}
5
- s.version = "0.3"
5
+ s.version = "0.5.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Seth Thomas Rasmussen"]
9
- s.date = %q{2009-07-20}
10
- s.description = %q{}
9
+ s.date = %q{2009-09-16}
10
+ s.description = %q{Mediainfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)}
11
11
  s.email = %q{sethrasmussen@gmail.com}
12
- s.extra_rdoc_files = ["lib/mediainfo/attr_readers.rb", "lib/mediainfo/string.rb", "lib/mediainfo.rb", "LICENSE", "README.markdown"]
13
- s.files = ["Changelog", "lib/mediainfo/attr_readers.rb", "lib/mediainfo/string.rb", "lib/mediainfo.rb", "LICENSE", "Manifest", "mediainfo.gemspec", "Rakefile", "README.markdown", "test/mediainfo_awaywego_encoded_test.rb", "test/mediainfo_awaywego_test.rb", "test/mediainfo_dinner_test.rb", "test/mediainfo_hats_test.rb", "test/mediainfo_string_test.rb", "test/mediainfo_test.rb", "test/mediainfo_vimeo_test.rb", "test/mediainfo_vimeoimage_test.rb", "test/test_helper.rb"]
12
+ s.extra_rdoc_files = ["LICENSE", "README.markdown", "lib/mediainfo.rb", "lib/mediainfo/attr_readers.rb", "lib/mediainfo/string.rb"]
13
+ s.files = ["Changelog", "LICENSE", "Manifest", "README.markdown", "Rakefile", "lib/mediainfo.rb", "lib/mediainfo/attr_readers.rb", "lib/mediainfo/string.rb", "mediainfo.gemspec", "test/mediainfo_awaywego_encoded_test.rb", "test/mediainfo_awaywego_test.rb", "test/mediainfo_dinner_test.rb", "test/mediainfo_hats_test.rb", "test/mediainfo_string_test.rb", "test/mediainfo_test.rb", "test/mediainfo_vimeo_test.rb", "test/mediainfo_vimeoimage_test.rb", "test/test_helper.rb"]
14
14
  s.homepage = %q{http://greatseth.com}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mediainfo", "--main", "README.markdown"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{mediainfo}
18
- s.rubygems_version = %q{1.3.4}
19
- s.summary = %q{}
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{Mediainfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)}
20
20
  s.test_files = ["test/mediainfo_awaywego_encoded_test.rb", "test/mediainfo_awaywego_test.rb", "test/mediainfo_dinner_test.rb", "test/mediainfo_hats_test.rb", "test/mediainfo_string_test.rb", "test/mediainfo_test.rb", "test/mediainfo_vimeo_test.rb", "test/mediainfo_vimeoimage_test.rb", "test/test_helper.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
@@ -102,4 +102,11 @@ class MediainfoTest < ActiveSupport::TestCase
102
102
  m = Mediainfo.new "/dev/null"
103
103
  assert_equal "/opt/local/bin/mediainfo $'/dev/null'", m.last_command
104
104
  end
105
+
106
+ test "can be initialized with a raw response" do
107
+ m = Mediainfo.new
108
+ m.raw_response = mediainfo_fixture("AwayWeGo_24fps.mov")
109
+ assert m.video?
110
+ assert m.audio?
111
+ end
105
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greatseth-mediainfo
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Thomas Rasmussen
@@ -9,32 +9,32 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-20 00:00:00 -07:00
12
+ date: 2009-09-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: ""
16
+ description: Mediainfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)
17
17
  email: sethrasmussen@gmail.com
18
18
  executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - lib/mediainfo/attr_readers.rb
24
- - lib/mediainfo/string.rb
25
- - lib/mediainfo.rb
26
23
  - LICENSE
27
24
  - README.markdown
28
- files:
29
- - Changelog
25
+ - lib/mediainfo.rb
30
26
  - lib/mediainfo/attr_readers.rb
31
27
  - lib/mediainfo/string.rb
32
- - lib/mediainfo.rb
28
+ files:
29
+ - Changelog
33
30
  - LICENSE
34
31
  - Manifest
35
- - mediainfo.gemspec
36
- - Rakefile
37
32
  - README.markdown
33
+ - Rakefile
34
+ - lib/mediainfo.rb
35
+ - lib/mediainfo/attr_readers.rb
36
+ - lib/mediainfo/string.rb
37
+ - mediainfo.gemspec
38
38
  - test/mediainfo_awaywego_encoded_test.rb
39
39
  - test/mediainfo_awaywego_test.rb
40
40
  - test/mediainfo_dinner_test.rb
@@ -46,6 +46,7 @@ files:
46
46
  - test/test_helper.rb
47
47
  has_rdoc: false
48
48
  homepage: http://greatseth.com
49
+ licenses:
49
50
  post_install_message:
50
51
  rdoc_options:
51
52
  - --line-numbers
@@ -71,10 +72,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  requirements: []
72
73
 
73
74
  rubyforge_project: mediainfo
74
- rubygems_version: 1.2.0
75
+ rubygems_version: 1.3.5
75
76
  signing_key:
76
77
  specification_version: 3
77
- summary: ""
78
+ summary: Mediainfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)
78
79
  test_files:
79
80
  - test/mediainfo_awaywego_encoded_test.rb
80
81
  - test/mediainfo_awaywego_test.rb