diff --git a/.gitignore b/.gitignore index 5879813..e5bbac5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ .*.swp *.tmproj -ext/qrdecode/*.o -ext/qrdecode/*.dll -ext/qrdecode/Makefile -ext/qrdecode/*.log -ext/qrdecode/*.bundle -ext/qrdecode/*.a -ext/qrdecode/*.so -ext/qrdecode/conftest.dSYM +ext/qrtools/*.o +ext/qrtools/*.dll +ext/qrtools/Makefile +ext/qrtools/*.log +ext/qrtools/*.bundle +ext/qrtools/*.a +ext/qrtools/*.so +ext/qrtools/conftest.dSYM tags .rake_tasks diff --git a/Rakefile b/Rakefile index 2e1ebe9..255bb24 100644 --- a/Rakefile +++ b/Rakefile @@ -6,26 +6,26 @@ require 'hoe' kind = Config::CONFIG['DLEXT'] windows = RUBY_PLATFORM =~ /mswin/i ? true : false -EXT = "ext/qrdecode/qrdecode.#{kind}" +EXT = "ext/qrtools/qrtools.#{kind}" -Hoe.new('qrdecode', '1.0.0') do |p| +Hoe.new('qrtools', '1.0.0') do |p| p.developer('Aaron Patterson', 'aaronp@rubyforge.org') p.clean_globs = [ - 'ext/qrdecode/Makefile', - 'ext/qrdecode/*.{o,so,bundle,a,log,dll}', - 'ext/qrdecode/conftest.dSYM', + 'ext/qrtools/Makefile', + 'ext/qrtools/*.{o,so,bundle,a,log,dll}', + 'ext/qrtools/conftest.dSYM', ] - p.spec_extras = { :extensions => ["ext/qrdecode/extconf.rb"] } + p.spec_extras = { :extensions => ["ext/qrtools/extconf.rb"] } end -task 'ext/qrdecode/Makefile' do - Dir.chdir('ext/qrdecode') do +task 'ext/qrtools/Makefile' do + Dir.chdir('ext/qrtools') do ruby "extconf.rb #{ENV['EXTOPTS']}" end end -task EXT => 'ext/qrdecode/Makefile' do - Dir.chdir('ext/qrdecode') do +task EXT => 'ext/qrtools/Makefile' do + Dir.chdir('ext/qrtools') do sh 'make' end end diff --git a/ext/qrdecode/qrdecode.c b/ext/qrdecode/qrdecode.c deleted file mode 100644 index 2802cda..0000000 --- a/ext/qrdecode/qrdecode.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -VALUE mQRDecode; - -void Init_qrdecode() -{ - VALUE qrdecode = rb_define_module("QRDecode"); - mQRDecode = qrdecode; - - init_qrdecode_image(); -} diff --git a/ext/qrdecode/qrdecode.h b/ext/qrdecode/qrdecode.h deleted file mode 100644 index 3b0ce53..0000000 --- a/ext/qrdecode/qrdecode.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef QRDECODE_QRDECODE -#define QRDECODE_QRDECODE - -#include -#include -#include -#include - -#include - -extern VALUE mQRDecode; - -#endif diff --git a/ext/qrdecode/qrdecode_image.c b/ext/qrdecode/qrdecode_image.c deleted file mode 100644 index d1e53f3..0000000 --- a/ext/qrdecode/qrdecode_image.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -static void dealloc(IplImage * img) -{ - cvReleaseImage(&img); -} - -static VALUE load(VALUE klass, VALUE path) -{ - IplImage *src = cvLoadImage(StringValuePtr(path), 1); - return Data_Wrap_Struct(klass, NULL, dealloc, src); -} - -void init_qrdecode_image() -{ - VALUE qrdecode = rb_define_module("QRDecode"); - VALUE image = rb_define_class_under(qrdecode, "Image", rb_cObject); - - rb_define_singleton_method(image, "load", load, 1); -} diff --git a/ext/qrdecode/qrdecode_image.h b/ext/qrdecode/qrdecode_image.h deleted file mode 100644 index ca978de..0000000 --- a/ext/qrdecode/qrdecode_image.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef QRDECODE_IMAGE -#define QRDECODE_IMAGE - -#include - -extern VALUE mQRDecodeImage; - -void init_qrdecode_image(); - -#endif - diff --git a/ext/qrdecode/Makefile.in b/ext/qrtools/Makefile.in similarity index 100% rename from ext/qrdecode/Makefile.in rename to ext/qrtools/Makefile.in diff --git a/ext/qrdecode/bitstream.cpp b/ext/qrtools/bitstream.cpp similarity index 100% rename from ext/qrdecode/bitstream.cpp rename to ext/qrtools/bitstream.cpp diff --git a/ext/qrdecode/bitstream.h b/ext/qrtools/bitstream.h similarity index 100% rename from ext/qrdecode/bitstream.h rename to ext/qrtools/bitstream.h diff --git a/ext/qrdecode/codedata.cpp b/ext/qrtools/codedata.cpp similarity index 100% rename from ext/qrdecode/codedata.cpp rename to ext/qrtools/codedata.cpp diff --git a/ext/qrdecode/codedata.h b/ext/qrtools/codedata.h similarity index 100% rename from ext/qrdecode/codedata.h rename to ext/qrtools/codedata.h diff --git a/ext/qrdecode/container.cpp b/ext/qrtools/container.cpp similarity index 100% rename from ext/qrdecode/container.cpp rename to ext/qrtools/container.cpp diff --git a/ext/qrdecode/container.h b/ext/qrtools/container.h similarity index 100% rename from ext/qrdecode/container.h rename to ext/qrtools/container.h diff --git a/ext/qrdecode/decodeqr.h b/ext/qrtools/decodeqr.h similarity index 100% rename from ext/qrdecode/decodeqr.h rename to ext/qrtools/decodeqr.h diff --git a/ext/qrdecode/ecidecoder.cpp b/ext/qrtools/ecidecoder.cpp similarity index 100% rename from ext/qrdecode/ecidecoder.cpp rename to ext/qrtools/ecidecoder.cpp diff --git a/ext/qrdecode/ecidecoder.h b/ext/qrtools/ecidecoder.h similarity index 100% rename from ext/qrdecode/ecidecoder.h rename to ext/qrtools/ecidecoder.h diff --git a/ext/qrdecode/extconf.rb b/ext/qrtools/extconf.rb similarity index 95% rename from ext/qrdecode/extconf.rb rename to ext/qrtools/extconf.rb index 20ad2ef..555408d 100644 --- a/ext/qrdecode/extconf.rb +++ b/ext/qrtools/extconf.rb @@ -22,4 +22,4 @@ abort "need #{lib}" unless have_library(lib) end have_library('stdc++') -create_makefile('qrdecode') +create_makefile('qrtools') diff --git a/ext/qrdecode/formatinfo.cpp b/ext/qrtools/formatinfo.cpp similarity index 100% rename from ext/qrdecode/formatinfo.cpp rename to ext/qrtools/formatinfo.cpp diff --git a/ext/qrdecode/formatinfo.h b/ext/qrtools/formatinfo.h similarity index 100% rename from ext/qrdecode/formatinfo.h rename to ext/qrtools/formatinfo.h diff --git a/ext/qrdecode/galois.cpp b/ext/qrtools/galois.cpp similarity index 100% rename from ext/qrdecode/galois.cpp rename to ext/qrtools/galois.cpp diff --git a/ext/qrdecode/galois.h b/ext/qrtools/galois.h similarity index 100% rename from ext/qrdecode/galois.h rename to ext/qrtools/galois.h diff --git a/ext/qrdecode/imagereader.cpp b/ext/qrtools/imagereader.cpp similarity index 100% rename from ext/qrdecode/imagereader.cpp rename to ext/qrtools/imagereader.cpp diff --git a/ext/qrdecode/imagereader.h b/ext/qrtools/imagereader.h similarity index 100% rename from ext/qrdecode/imagereader.h rename to ext/qrtools/imagereader.h diff --git a/ext/qrdecode/libdecodeqr.cpp b/ext/qrtools/libdecodeqr.cpp similarity index 100% rename from ext/qrdecode/libdecodeqr.cpp rename to ext/qrtools/libdecodeqr.cpp diff --git a/ext/qrdecode/libdecodeqr.dep b/ext/qrtools/libdecodeqr.dep similarity index 100% rename from ext/qrdecode/libdecodeqr.dep rename to ext/qrtools/libdecodeqr.dep diff --git a/ext/qrdecode/libdecodeqr.dsp b/ext/qrtools/libdecodeqr.dsp similarity index 100% rename from ext/qrdecode/libdecodeqr.dsp rename to ext/qrtools/libdecodeqr.dsp diff --git a/ext/qrdecode/libdecodeqr.dsw b/ext/qrtools/libdecodeqr.dsw similarity index 100% rename from ext/qrdecode/libdecodeqr.dsw rename to ext/qrtools/libdecodeqr.dsw diff --git a/ext/qrdecode/libdecodeqr.mak b/ext/qrtools/libdecodeqr.mak similarity index 100% rename from ext/qrdecode/libdecodeqr.mak rename to ext/qrtools/libdecodeqr.mak diff --git a/ext/qrdecode/qrerror.h b/ext/qrtools/qrerror.h similarity index 100% rename from ext/qrdecode/qrerror.h rename to ext/qrtools/qrerror.h diff --git a/ext/qrtools/qrtools.c b/ext/qrtools/qrtools.c new file mode 100644 index 0000000..37aebca --- /dev/null +++ b/ext/qrtools/qrtools.c @@ -0,0 +1,12 @@ +#include + +VALUE mQRTools; + +void Init_qrtools() +{ + VALUE qrtools = rb_define_module("QRTools"); + mQRTools = qrtools; + + init_qrtools_image(); + init_qrtools_decoder(); +} diff --git a/ext/qrtools/qrtools.h b/ext/qrtools/qrtools.h new file mode 100644 index 0000000..87b3570 --- /dev/null +++ b/ext/qrtools/qrtools.h @@ -0,0 +1,14 @@ +#ifndef QRTOOLS_QRTOOLS +#define QRTOOLS_QRTOOLS + +#include +#include +#include +#include + +#include +#include + +extern VALUE mQRTools; + +#endif diff --git a/ext/qrtools/qrtools_decoder.c b/ext/qrtools/qrtools_decoder.c new file mode 100644 index 0000000..8eba1ff --- /dev/null +++ b/ext/qrtools/qrtools_decoder.c @@ -0,0 +1,19 @@ +#include + +static VALUE allocate(VALUE klass) +{ + QrDecoderHandle decoder = qr_decoder_open(); + + return Data_Wrap_Struct(klass, NULL, qr_decoder_close, decoder); +} + +VALUE cQRToolsDecoder; +void init_qrtools_decoder() +{ + VALUE qrtools = rb_define_module("QRTools"); + VALUE klass = rb_define_class_under(qrtools, "Decoder", rb_cObject); + + cQRToolsDecoder = klass; + + rb_define_alloc_func(klass, allocate); +} diff --git a/ext/qrtools/qrtools_decoder.h b/ext/qrtools/qrtools_decoder.h new file mode 100644 index 0000000..c27c68e --- /dev/null +++ b/ext/qrtools/qrtools_decoder.h @@ -0,0 +1,10 @@ +#ifndef QRTOOLS_DECODER +#define QRTOOLS_DECODER + +#include + +extern VALUE cQRToolsDecoder; + +void init_qrtools_decoder(); + +#endif diff --git a/ext/qrtools/qrtools_image.c b/ext/qrtools/qrtools_image.c new file mode 100644 index 0000000..7fbd77e --- /dev/null +++ b/ext/qrtools/qrtools_image.c @@ -0,0 +1,24 @@ +#include + +static void dealloc(IplImage * img) +{ + cvReleaseImage(&img); +} + +static VALUE load(VALUE klass, VALUE path) +{ + IplImage *src = cvLoadImage(StringValuePtr(path), 1); + return Data_Wrap_Struct(klass, NULL, dealloc, src); +} + +VALUE cQRToolsImage; + +void init_qrtools_image() +{ + VALUE qrtools = rb_define_module("QRTools"); + VALUE klass = rb_define_class_under(qrtools, "Image", rb_cObject); + + cQRToolsImage = klass; + + rb_define_singleton_method(klass, "load", load, 1); +} diff --git a/ext/qrtools/qrtools_image.h b/ext/qrtools/qrtools_image.h new file mode 100644 index 0000000..c9e5e4e --- /dev/null +++ b/ext/qrtools/qrtools_image.h @@ -0,0 +1,10 @@ +#ifndef QRTOOLS_IMAGE +#define QRTOOLS_IMAGE + +#include + +extern VALUE cQRToolsImage; + +void init_qrtools_image(); + +#endif diff --git a/ext/qrdecode/qrtypes.h b/ext/qrtools/qrtypes.h similarity index 100% rename from ext/qrdecode/qrtypes.h rename to ext/qrtools/qrtypes.h diff --git a/ext/qrdecode/version.h b/ext/qrtools/version.h similarity index 100% rename from ext/qrdecode/version.h rename to ext/qrtools/version.h diff --git a/lib/qrdecode.rb b/lib/qrdecode.rb deleted file mode 100644 index e5fd7f1..0000000 --- a/lib/qrdecode.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'qrdecode/qrdecode' # native - -module QRDecode - VERSION = '1.0.0' -end diff --git a/lib/qrtools.rb b/lib/qrtools.rb new file mode 100644 index 0000000..4594494 --- /dev/null +++ b/lib/qrtools.rb @@ -0,0 +1,5 @@ +require 'qrtools/qrtools' # native + +module QRTools + VERSION = '1.0.0' +end diff --git a/test/helper.rb b/test/helper.rb index 50879c3..f52f73e 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -4,9 +4,9 @@ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path))) end -require 'qrdecode' +require 'qrtools' -class QRDecodeTestCase < Test::Unit::TestCase +class QRToolsTestCase < Test::Unit::TestCase ASSETS = File.expand_path(File.join(File.dirname(__FILE__), 'assets')) unless RUBY_VERSION >= '1.9' diff --git a/test/test_decoder.rb b/test/test_decoder.rb new file mode 100644 index 0000000..cec9ce4 --- /dev/null +++ b/test/test_decoder.rb @@ -0,0 +1,8 @@ +require File.expand_path(File.join(File.dirname(__FILE__), "helper")) + +class DecoderTestCase < QRToolsTestCase + def test_new + assert decoder = QRTools::Decoder.new + end +end + diff --git a/test/test_image.rb b/test/test_image.rb index 02a78a8..472c237 100644 --- a/test/test_image.rb +++ b/test/test_image.rb @@ -1,7 +1,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) -class ImageTestCase < QRDecodeTestCase +class ImageTestCase < QRToolsTestCase def test_load - assert img = QRDecode::Image.load(File.join(ASSETS, '01-1.jpg')) + assert img = QRTools::Image.load(File.join(ASSETS, '01-1.jpg')) end end