diff --git a/.travis.yml b/.travis.yml index 884ef18..e8380e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ language: ruby rvm: - 2.1.5 +before_install: + - sudo apt-get -y install libhidapi-dev libhidapi-hidraw0 libhidapi-libusb0 diff --git a/README.md b/README.md index 986a097..e820d44 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,14 @@ This gem is my first attempt at writing any FFI code, and my first attempt to us The gem requires the hidapi library to be installed and available to Ruby. On Mac with homebrew installed, this can be done with the command: +### For macOS + $ brew install hidapi +### For Debian + + $ sudo apt install libhidapi-dev libhidapi-hidraw0 libhidapi-libusb0 + ## Installation Add this line to your application's Gemfile: diff --git a/lib/hid_api.rb b/lib/hid_api.rb index 5196746..c5f2ca8 100644 --- a/lib/hid_api.rb +++ b/lib/hid_api.rb @@ -4,8 +4,10 @@ module HidApi class HidError < StandardError; end + HIDAPI_LIBS = %w(hidapi hidapi-libusb hidapi-hidraw).freeze + extend FFI::Library - ffi_lib "hidapi" + ffi_lib HIDAPI_LIBS autoload :Deprecated, "hid_api/deprecated" autoload :Device, "hid_api/device" diff --git a/spec/hid_api_spec.rb b/spec/hid_api_spec.rb index 580fdbf..dbe359d 100644 --- a/spec/hid_api_spec.rb +++ b/spec/hid_api_spec.rb @@ -4,8 +4,4 @@ it "has a version number" do expect(HidApi::VERSION).not_to be nil end - - it "does something useful" do - expect(false).to eq(true) - end end