ffprober 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -5,3 +5,4 @@ rvm:
5
5
  - 1.9.3
6
6
  - jruby-19mode # JRuby in 1.9 mode
7
7
  - rbx-19mode
8
+ - ruby-head
data/README.md CHANGED
@@ -27,13 +27,13 @@ Or install it yourself as:
27
27
 
28
28
  ## FFMPEG version
29
29
 
30
- tested with ffprobe version 0.10.2 and 0.11.1
30
+ tested with ffprobe version 0.9, 0.10, 0.11 and 1.0
31
31
 
32
- according to [ffmpeg changelog](http://git.videolan.org/?p=ffmpeg.git;a=blob_plain;f=Changelog) json out was added in version 0.9
32
+ according to [ffmpeg changelog](http://git.videolan.org/?p=ffmpeg.git;a=blob_plain;f=Changelog) json output was added in version 0.9
33
33
 
34
34
  ## Supported Rubies
35
35
 
36
- OmniAuth Vimeo is tested under 1.9.2, 1.9.3, JRuby (1.9mode) and Rubinius (1.9mode).
36
+ Ffprober is tested under 1.9.2, 1.9.3, 2.0, JRuby (1.9mode) and Rubinius (1.9mode).
37
37
 
38
38
  [![Build Status](https://secure.travis-ci.org/beanieboi/ffprober.png?branch=master)](http://travis-ci.org/beanieboi/ffprober)
39
39
 
@@ -1,18 +1,57 @@
1
1
  module Ffprober
2
2
  class Parser
3
3
  @@options = '-v quiet -print_format json -show_format -show_streams'
4
+ @@version_regex = /^ffprobe version (?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/
4
5
 
5
- def self.from_file(file_to_parse)
6
- raise ArgumentError.new("no or unsupported ffprobe version found. (version: #{ffprobe_version})") unless ffprobe_version_valid?
6
+ class << self
7
+ def from_file(file_to_parse)
8
+ unless ffprobe_version_valid?
9
+ raise ArgumentError.new("no or unsupported ffprobe version found.\
10
+ (version: #{ffprobe_version})")
11
+ end
7
12
 
8
- json_output = `#{ffprobe_path} #{@@options} #{file_to_parse}`
9
- from_json(json_output)
10
- end
13
+ json_output = `#{ffprobe_path} #{@@options} #{file_to_parse}`
14
+ from_json(json_output)
15
+ end
16
+
17
+ def from_json(json_to_parse)
18
+ parser = self.new
19
+ parser.parse(json_to_parse)
20
+ parser
21
+ end
22
+
23
+ def ffprobe_version_valid?
24
+ valid_versions.include?(ffprobe_version)
25
+ end
26
+
27
+ def ffprobe_version
28
+ version = `#{ffprobe_path} -version`.match(@@version_regex)
29
+ raise Errno::ENOENT if version.nil?
30
+ major, minor, patch = version[1].to_i, version[2].to_i, version[3].to_i
31
+ {major: major, minor: minor, patch: patch}
32
+ rescue Errno::ENOENT => e
33
+ {major: 0, minor: 0, patch: 0}
34
+ end
35
+
36
+ def valid_versions
37
+ [{major: 0, minor: 9, patch: 0},
38
+ {major: 0, minor: 10, patch: 0},
39
+ {major: 0, minor: 11, patch: 0},
40
+ {major: 1, minor: 0, patch: 0}]
41
+ end
11
42
 
12
- def self.from_json(json_to_parse)
13
- parser = self.new
14
- parser.parse(json_to_parse)
15
- parser
43
+ def ffprobe_path
44
+ name = 'ffprobe'
45
+
46
+ if File.executable? name
47
+ cmd
48
+ else
49
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |path|
50
+ File.executable? File.join(path, name)
51
+ }
52
+ path && File.expand_path(name, path)
53
+ end
54
+ end
16
55
  end
17
56
 
18
57
  def parse(json_to_parse)
@@ -36,30 +75,5 @@ module Ffprober
36
75
  end
37
76
  end
38
77
 
39
- def self.ffprobe_version_valid?
40
- ffprobe_version[:minor] > 9
41
- end
42
-
43
- def self.ffprobe_version
44
- version = `#{ffprobe_path} -version`.match(/^ffprobe version (?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/)
45
- raise Errno::ENOENT if version.nil?
46
- major, minor, patch = version[1].to_i, version[2].to_i, version[3].to_i
47
- {major: major, minor: minor, patch: patch}
48
- rescue Errno::ENOENT => e
49
- {major: 0, minor: 0, patch: 0}
50
- end
51
-
52
- def self.ffprobe_path
53
- name = 'ffprobe'
54
-
55
- if File.executable? name
56
- cmd
57
- else
58
- path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |path|
59
- File.executable? File.join(path, name)
60
- }
61
- path && File.expand_path(name, path)
62
- end
63
- end
64
78
  end
65
79
  end
@@ -1,3 +1,3 @@
1
1
  module Ffprober
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Ffprober::Parser do
5
+ let(:before_one_zero) { {major: 0, minor: 9, patch: 0} }
6
+ let(:one_zero) { {major: 1, minor: 0, patch: 0} }
7
+ let(:after_one_zero) { {major: 1, minor: 9, patch: 0} }
8
+
9
+ context 'validates the ffprobe version' do
10
+ it 'detects versions < 0.9' do
11
+ Ffprober::Parser.stub(:ffprobe_version) { before_one_zero }
12
+ Ffprober::Parser.ffprobe_version_valid?.should be_true
13
+ end
14
+
15
+ it 'detects versions 1.0' do
16
+ Ffprober::Parser.stub(:ffprobe_version) { one_zero }
17
+ Ffprober::Parser.ffprobe_version_valid?.should be_true
18
+ end
19
+
20
+ it 'detects versions 1.9' do
21
+ Ffprober::Parser.stub(:ffprobe_version) { after_one_zero }
22
+ Ffprober::Parser.ffprobe_version_valid?.should be_false
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffprober
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,56 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-23 00:00:00.000000000 Z
12
+ date: 2012-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '2.9'
20
- none: false
21
- prerelease: false
22
22
  type: :development
23
- name: rspec
24
- requirement: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
28
29
  version: '2.9'
29
- none: false
30
30
  - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
32
34
  requirements:
33
35
  - - ~>
34
36
  - !ruby/object:Gem::Version
35
37
  version: '0.9'
36
- none: false
37
- prerelease: false
38
38
  type: :development
39
- name: rake
40
- requirement: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
41
42
  requirements:
42
43
  - - ~>
43
44
  - !ruby/object:Gem::Version
44
45
  version: '0.9'
45
- none: false
46
46
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
47
+ name: multi_json
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
48
50
  requirements:
49
51
  - - ~>
50
52
  - !ruby/object:Gem::Version
51
53
  version: '1.3'
52
- none: false
53
- prerelease: false
54
54
  type: :runtime
55
- name: multi_json
56
- requirement: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
57
58
  requirements:
58
59
  - - ~>
59
60
  - !ruby/object:Gem::Version
60
61
  version: '1.3'
61
- none: false
62
62
  description: a Ruby wrapper for ffprobe
63
63
  email:
64
64
  - beanie@benle.de
@@ -83,6 +83,7 @@ files:
83
83
  - lib/ffprober/video_stream.rb
84
84
  - spec/assets/301-extracting_a_ruby_gem.json
85
85
  - spec/assets/301-extracting_a_ruby_gem.m4v
86
+ - spec/ffprober/parser_spec.rb
86
87
  - spec/ffprober_spec.rb
87
88
  - spec/spec_helper.rb
88
89
  homepage: https://github.com/beanieboi/ffprober
@@ -92,25 +93,26 @@ rdoc_options: []
92
93
  require_paths:
93
94
  - lib
94
95
  required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
95
97
  requirements:
96
98
  - - ! '>='
97
99
  - !ruby/object:Gem::Version
98
100
  version: 1.9.2
99
- none: false
100
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
101
103
  requirements:
102
104
  - - ! '>='
103
105
  - !ruby/object:Gem::Version
104
106
  version: '0'
105
- none: false
106
107
  requirements: []
107
108
  rubyforge_project: ffprober
108
- rubygems_version: 1.8.24
109
+ rubygems_version: 1.8.23
109
110
  signing_key:
110
111
  specification_version: 3
111
112
  summary: a Ruby wrapper for ffprobe (part of ffmpeg)
112
113
  test_files:
113
114
  - spec/assets/301-extracting_a_ruby_gem.json
114
115
  - spec/assets/301-extracting_a_ruby_gem.m4v
116
+ - spec/ffprober/parser_spec.rb
115
117
  - spec/ffprober_spec.rb
116
118
  - spec/spec_helper.rb