handbrake.rb icon indicating copy to clipboard operation
handbrake.rb copied to clipboard

Allow #output method to accept a block which is passed each line from the CLI output.

Open veloper opened this issue 12 years ago • 8 comments

  • I apologize that there are no tests associated with this change.
  • This new feature allows for better control over the output. (see example below)
bar = ProgressBar.new("Handbrake", 100)
handbrake.input(tmp_mkv_file.to_s).preset('High Profile').output(tmp_m4v_file.to_s) do |line|
  match = line.match(/Encoding:.*\s([0-9\.]+)\s%/)
  bar.set( percentage = match[1].to_f ) if match
end
bar.finish

Thanks for making this great wrapper gem!

veloper avatar Sep 09 '13 00:09 veloper

Thanks for the contribution. Could you take a look at the failing tests in travis and see if you can fix/explain them?

rsutphin avatar Sep 12 '13 15:09 rsutphin

I'll take a look at the failing tests tonight.

veloper avatar Sep 12 '13 15:09 veloper

I'll also revert the style changes as they serve only to add a liability in this case -- good point!

veloper avatar Sep 12 '13 15:09 veloper

Closing and reopening in hopes that Travis will pick up on it.

veloper avatar Sep 13 '13 02:09 veloper

Ok, the original failing tests that (_I think_) this pull request introduced have been resolved.

However, looking at the Latest Travis Build for this pull request it seems like the errors occurring are not a result of the changes I've made.

Checking the 1.9.3 environment test output reveals some issue with the Travis test environment -- some errors are popping up:

Using worker: worker-linux-6-2.bb.travis-ci.org:travis-linux-9
git.1
$ git clone --depth=50 git://github.com/rsutphin/handbrake.rb.git rsutphin/handbrake.rb
Cloning into 'rsutphin/handbrake.rb'...
remote: Counting objects: 362, done.
remote: Compressing objects: 100% (190/190), done.
remote: Total 362 (delta 168), reused 355 (delta 164)
Receiving objects: 100% (362/362), 68.94 KiB | 0 bytes/s, done.
Resolving deltas: 100% (168/168), done.
$ cd rsutphin/handbrake.rb
git.2
$ git fetch origin +refs/pull/7/merge: 
remote: Counting objects: 22, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 17 (delta 7), reused 13 (delta 4)
Unpacking objects: 100% (17/17), done.
From git://github.com/rsutphin/handbrake.rb
 * branch            refs/pull/7/merge -> FETCH_HEAD
git.3
$ git checkout -qf FETCH_HEAD
$ rvm use 1.9.2 --install --binary --fuzzy
Using /home/travis/.rvm/gems/ruby-1.9.2-p320
$ export BUNDLE_GEMFILE=$PWD/Gemfile
$ gem query --local | grep bundler >/dev/null || gem install bundler
$ ruby --version
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux]
$ rvm --version
rvm 1.21.3 (latest-minor) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
$ gem --version
2.0.3
$ bundle install
The source :rubygems is deprecated because HTTP requests are insecure.
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Installing rake (0.9.6) 
Installing diff-lcs (1.2.4) 
Installing json (1.8.0) 
Installing structured_warnings (0.1.4) 
Installing rubytree (0.8.3) 
Using handbrake (0.4.1.pre) from source at /home/travis/build/rsutphin/handbrake.rb 
Installing rdiscount (2.1.6) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
    /home/travis/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb 
checking for random()... yes
checking for srandom()... yes
checking for rand()... yes
checking for srand()... yes
checking size of unsigned long... long
checking size of unsigned int... int
no int with size 4
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/travis/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
    --with-rdiscount-dir
    --without-rdiscount-dir
    --with-rdiscount-include
    --without-rdiscount-include=${rdiscount-dir}/include
    --with-rdiscount-lib
    --without-rdiscount-lib=${rdiscount-dir}/lib
Gem files will remain installed in /home/travis/.rvm/gems/ruby-1.9.2-p320/gems/rdiscount-2.1.6 for inspection.
Results logged to /home/travis/.rvm/gems/ruby-1.9.2-p320/gems/rdiscount-2.1.6/ext/gem_make.out
An error occurred while installing rdiscount (2.1.6), and Bundler cannot
continue.
Make sure that `gem install rdiscount -v '2.1.6'` succeeds before bundling.
The command "bundle install" failed. Retrying, 2 of 3.
The source :rubygems is deprecated because HTTP requests are insecure.
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Using rake (0.9.6) 
Using diff-lcs (1.2.4) 
Using json (1.8.0) 
Using structured_warnings (0.1.4) 
Using rubytree (0.8.3) 
Using handbrake (0.4.1.pre) from source at /home/travis/build/rsutphin/handbrake.rb 
Installing rdiscount (2.1.6) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
    /home/travis/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb 
checking for random()... yes
checking for srandom()... yes
checking for rand()... yes
checking for srand()... yes
checking size of unsigned long... long
checking size of unsigned int... int
no int with size 4
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/travis/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
    --with-rdiscount-dir
    --without-rdiscount-dir
    --with-rdiscount-include
    --without-rdiscount-include=${rdiscount-dir}/include
    --with-rdiscount-lib
    --without-rdiscount-lib=${rdiscount-dir}/lib
Gem files will remain installed in /home/travis/.rvm/gems/ruby-1.9.2-p320/gems/rdiscount-2.1.6 for inspection.
Results logged to /home/travis/.rvm/gems/ruby-1.9.2-p320/gems/rdiscount-2.1.6/ext/gem_make.out
An error occurred while installing rdiscount (2.1.6), and Bundler cannot
continue.
Make sure that `gem install rdiscount -v '2.1.6'` succeeds before bundling.
The command "bundle install" failed. Retrying, 3 of 3.
The source :rubygems is deprecated because HTTP requests are insecure.
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Using rake (0.9.6) 
Using diff-lcs (1.2.4) 
Using json (1.8.0) 
Using structured_warnings (0.1.4) 
Using rubytree (0.8.3) 
Using handbrake (0.4.1.pre) from source at /home/travis/build/rsutphin/handbrake.rb 
Installing rdiscount (2.1.6) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
    /home/travis/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb 
checking for random()... yes
checking for srandom()... yes
checking for rand()... yes
checking for srand()... yes
checking size of unsigned long... long
checking size of unsigned int... int
no int with size 4
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/travis/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
    --with-rdiscount-dir
    --without-rdiscount-dir
    --with-rdiscount-include
    --without-rdiscount-include=${rdiscount-dir}/include
    --with-rdiscount-lib
    --without-rdiscount-lib=${rdiscount-dir}/lib
Gem files will remain installed in /home/travis/.rvm/gems/ruby-1.9.2-p320/gems/rdiscount-2.1.6 for inspection.
Results logged to /home/travis/.rvm/gems/ruby-1.9.2-p320/gems/rdiscount-2.1.6/ext/gem_make.out
An error occurred while installing rdiscount (2.1.6), and Bundler cannot
continue.
Make sure that `gem install rdiscount -v '2.1.6'` succeeds before bundling.
The command "bundle install" failed and exited with 5 during install.
Your build has been stopped.

veloper avatar Sep 13 '13 13:09 veloper

Is there anything else you would like me to do regarding the prep of this pull request?

veloper avatar Sep 16 '13 19:09 veloper

I don't need any more from you at this point. I'll review and address when I get a chance — sometime in the next couple of weeks. Thanks again for the contribution.

rsutphin avatar Sep 16 '13 19:09 rsutphin

@rsutphin - Sounds good. Thanks again for this gem!

veloper avatar Sep 16 '13 19:09 veloper