Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jun 2, 2009
0 parents commit 5bbde11
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .autotest
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- ruby -*-

require 'autotest/restart'

# Autotest.add_hook :initialize do |at|
# at.extra_files << "../some/external/dependency.rb"
#
# at.libs << ":../some/external"
#
# at.add_exception 'vendor'
#
# at.add_mapping(/dependency.rb/) do |f, _|
# at.files_matching(/test_.*rb$/)
# end
#
# %w(TestA TestB).each do |klass|
# at.extra_class_map[klass] = "test/test_misc.rb"
# end
# end

# Autotest.add_hook :run_command do |at|
# system "rake build"
# end
6 changes: 6 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=== 1.0.0 / 2009-06-01

* 1 major enhancement

* Birthday!

7 changes: 7 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
History.txt
Manifest.txt
README.txt
Rakefile
bin/nfc
lib/nfc.rb
test/test_nfc.rb
48 changes: 48 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
= nfc

* FIX (url)

== DESCRIPTION:

FIX (describe your package)

== FEATURES/PROBLEMS:

* FIX (list of features or problems)

== SYNOPSIS:

FIX (code sample of usage)

== REQUIREMENTS:

* FIX (list of requirements)

== INSTALL:

* FIX (sudo gem install, anything else)

== LICENSE:

(The MIT License)

Copyright (c) 2009 FIX

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 12 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- ruby -*-

require 'rubygems'
require 'hoe'
$: << "lib"
require 'nfc'

Hoe.new('nfc', NFC::VERSION) do |p|
p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
end

# vim: syntax=Ruby
3 changes: 3 additions & 0 deletions bin/nfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby

abort "you need to write me"
15 changes: 15 additions & 0 deletions lib/nfc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'nfc/lib_nfc'

class NFC
VERSION = '1.0.0'

attr_reader :device

def initialize
@device = nil
end

def connect
@device = NFC::LibNFC::Device.new(NFC::LibNFC.nfc_connect)
end
end
23 changes: 23 additions & 0 deletions lib/nfc/lib_nfc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'ffi'

class NFC
class LibNFC # :nodoc
extend FFI::Library
ffi_lib 'nfc'

attach_function :nfc_connect, [], :pointer
attach_function :nfc_disconnect, [:pointer], :void

class Device < FFI::Struct
layout(:name, [:char, 256])

def name
pointer.read_string
end

def self.release ptr
LibNFC.nfc_disconnect ptr
end
end
end
end
11 changes: 11 additions & 0 deletions test/test_nfc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "test/unit"
require "nfc"

class TestNFC < Test::Unit::TestCase
def test_connect
nfc = NFC.new
assert_nil nfc.device
nfc.connect
assert_not_nil nfc.device
end
end

0 comments on commit 5bbde11

Please sign in to comment.