Sha256: 67fa16421cf3436d6a1d8ad58d9d233d3c2f8413a714527393a192e9656d6b7b

Contents?: true

Size: 989 Bytes

Versions: 18

Compression:

Stored size: 989 Bytes

Contents

module Tlapse
  module Doctor
    CHECKS = %i(gphoto2 camera)

    def doctor
      CHECKS.each do |check|
        print "Checking #{check}..."
        send "check_#{check}!"
        puts "ok!"
      end

      puts "Looks good!"
    end

    def status
      CHECKS.each { |check| send "check_#{check}!" }
      "OK"
    rescue StandardError => e
      e.message
    end

    def okay?
      status == "OK"
    end

    private ###################################################################

    def check_gphoto2!
      raise "Could not find gphoto2 :(" if `which gphoto2`.empty?
    end

    def check_camera!
      cameras = `gphoto2 --auto-detect`

      # Output looks like this:
      #
      #   Model       Port
      #   --------------------
      #   Camera      :usb
      #
      # If there is a third line, a camera was detected

      unless cameras.split("\n").length > 2
        raise "gphoto2 couldn't find a camera :("
      end
    end
  end # Doctor
end # Tlapse

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
tlapse-0.9.0 lib/tlapse/doctor.rb
tlapse-0.8.0 lib/tlapse/doctor.rb
tlapse-0.7.0 lib/tlapse/doctor.rb
tlapse-0.6.3 lib/tlapse/doctor.rb
tlapse-0.6.2 lib/tlapse/doctor.rb
tlapse-0.6.1 lib/tlapse/doctor.rb
tlapse-0.6.0 lib/tlapse/doctor.rb
tlapse-0.5.1 lib/tlapse/doctor.rb
tlapse-0.5.0 lib/tlapse/doctor.rb
tlapse-0.4.1 lib/tlapse/doctor.rb
tlapse-0.4.0 lib/tlapse/doctor.rb
tlapse-0.3.3 lib/tlapse/doctor.rb
tlapse-0.3.2 lib/tlapse/doctor.rb
tlapse-0.3.1 lib/tlapse/doctor.rb
tlapse-0.3.0 lib/tlapse/doctor.rb
tlapse-0.2.1 lib/tlapse/doctor.rb
tlapse-0.2.0 lib/tlapse/doctor.rb
tlapse-0.1.2 lib/tlapse/doctor.rb