Skip to content

Commit ce4e768

Browse files
Gareth AdamsGareth Adams
authored andcommitted
Initial implementation
0 parents  commit ce4e768

19 files changed

Lines changed: 422 additions & 0 deletions

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.bundle/
2+
/.yardoc
3+
/Gemfile.lock
4+
/_yardoc/
5+
/coverage/
6+
/doc/
7+
/pkg/
8+
/spec/reports/
9+
/tmp/

.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--format documentation
2+
--color

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: ruby
2+
rvm:
3+
- 2.1.5

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in hid_api.gemspec
4+
gemspec

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Gareth Adams
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# HidApi
2+
3+
HidApi is an FFI wrapper around the C library '[hidapi][1]' provided by Signal11.
4+
5+
[1]: http://www.signal11.us/oss/hidapi/
6+
7+
This gem is my first attempt at writing any FFI code, and my first attempt to use USB. It's very possible that conventions will be broken, edge cases missed and that nothing will work if you're not using it exactly how I am. But let me know (open a Github issue, or even better see the Contributing section below) and I might be able to do something about it.
8+
9+
## Dependencies
10+
11+
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:
12+
13+
$ brew install hidapi
14+
15+
## Installation
16+
17+
Add this line to your application's Gemfile:
18+
19+
```ruby
20+
gem 'hid_api'
21+
```
22+
23+
And then execute:
24+
25+
$ bundle
26+
27+
Or install it yourself as:
28+
29+
$ gem install hid_api
30+
31+
## Usage
32+
33+
TODO: Write usage instructions here
34+
35+
## Development
36+
37+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
38+
39+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40+
41+
## Contributing
42+
43+
1. Fork it ( https://github.com/gareth/ruby_hid_api/fork )
44+
2. Create your feature branch (`git checkout -b my-new-feature`)
45+
3. Commit your changes (`git commit -am 'Add some feature'`)
46+
4. Push to the branch (`git push origin my-new-feature`)
47+
5. Create a new Pull Request

Rakefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "bundler/gem_tasks"
2+
3+
begin
4+
require 'rspec/core/rake_task'
5+
RSpec::Core::RakeTask.new(:spec)
6+
rescue LoadError
7+
end
8+
9+
task :default => :spec

bin/console

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
3+
require "bundler/setup"
4+
require "hid_api"
5+
6+
# You can add fixtures and/or initialization code here to make experimenting
7+
# with your gem easier. You can also use a different console, if you like.
8+
9+
# (If you use this, don't forget to add pry to your Gemfile!)
10+
require "pry"
11+
Pry.start
12+
13+
# require "irb"
14+
# IRB.start

bin/setup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
bundle install
6+
7+
# Do any other automated setup that you need to do here

hid_api.gemspec

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding: utf-8
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require 'hid_api/version'
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = "hid_api"
8+
spec.version = HidApi::VERSION
9+
spec.licenses = ["MIT"]
10+
spec.authors = ["Gareth Adams"]
11+
spec.email = ["g@rethada.ms"]
12+
13+
spec.summary = %q{A Ruby FFI wrapper around the System11 hidapi C library}
14+
spec.description = %q{}
15+
spec.homepage = "https://github.com/gareth/ruby_hid_api"
16+
17+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18+
spec.bindir = "exe"
19+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20+
spec.require_paths = ["lib"]
21+
22+
spec.add_dependency "ffi", "~> 1.9"
23+
24+
spec.add_development_dependency "bundler", "~> 1.8"
25+
spec.add_development_dependency "rake", "~> 10.0"
26+
27+
spec.add_development_dependency "rspec", "> 0"
28+
29+
spec.add_development_dependency "pry", "> 0"
30+
spec.add_development_dependency "awesome_print", "> 0"
31+
end

0 commit comments

Comments
 (0)