Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 5bbde11c16822f942b80fe24519a5540cc10e76e 0 parents
@tenderlove authored
23 .autotest
@@ -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 History.txt
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2009-06-01
+
+* 1 major enhancement
+
+ * Birthday!
+
7 Manifest.txt
@@ -0,0 +1,7 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/nfc
+lib/nfc.rb
+test/test_nfc.rb
48 README.txt
@@ -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 Rakefile
@@ -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  bin/nfc
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+abort "you need to write me"
15 lib/nfc.rb
@@ -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 lib/nfc/lib_nfc.rb
@@ -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 test/test_nfc.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.