zbar 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
- = zbar
1
+ = zbar {<img src="https://travis-ci.org/willglynn/ruby-zbar.png?branch=travis" alt="Build Status" />}[https://travis-ci.org/willglynn/ruby-zbar]
2
2
  by Will Glynn
3
3
 
4
4
  http://github.com/willglynn/ruby-zbar
5
5
 
6
- == DESCRIPTION:
6
+ == Description:
7
7
 
8
8
  Ruby bindings for ZBar, a barcode recognition library.
9
9
 
10
- == SYNOPSIS:
10
+ == Synopsis:
11
11
 
12
12
  require 'zbar'
13
13
 
@@ -19,40 +19,41 @@ Ruby bindings for ZBar, a barcode recognition library.
19
19
  @quality=15,
20
20
  @symbology="EAN-13">]
21
21
 
22
- == REQUIREMENTS:
22
+ == Download/install:
23
23
 
24
- * FFI
25
- * ZBar, probably 0.10 or more
24
+ Add to your Gemfile:
26
25
 
27
- ZBar can be obtained from http://zbar.sourceforge.net.
26
+ gem "zbar"
28
27
 
29
- == DOWNLOAD/INSTALL:
28
+ Otherwise:
30
29
 
31
- From gemcutter:
30
+ $ [sudo] gem install zbar
32
31
 
33
- [sudo] gem install zbar
34
-
35
- From github:
32
+ You'll also need the +zbar+ C library to make it work. This might be available from your package manager:
33
+
34
+ $ sudo apt-get install libzbar0 # on Debian or Ubuntu
35
+ $ sudo emerge zbar # on Gentoo
36
+ $ brew install zbar # on Mac OS X with Homebrew
36
37
 
37
- git clone git://github.com/delta407/ruby-zbar.git
38
- cd ruby-zbar
39
- rake install
38
+ Alternately, install from source at http://zbar.sf.net/.
40
39
 
41
- == LIMITATIONS:
40
+ == Limitations:
42
41
 
43
42
  Doesn't expose all ZBar functionality, including:
44
43
  * No video functions
45
44
  * No low-level interfaces (scanner, decoder)
46
45
 
47
- == Note on Patches/Pull Requests
46
+ Additionally, there is a zbar <= 0.10 issue with JPEG decoding; see {lib/zbar/jpeg.rb}[https://github.com/willglynn/ruby-zbar/blob/master/lib/zbar/jpeg.rb] for more. You can check your ZBar::JPEG.bugged? status if you're curious. Otherwise, just try using it, and see if you get a warning on stderr.
47
+
48
+ == Contributing
48
49
 
49
50
  * Fork the project.
50
51
  * Make your feature addition or bug fix.
51
52
  * Add tests for it. This is important so I don't break it in a
52
53
  future version unintentionally.
53
- * Commit, do not mess with rakefile, version, or history.
54
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
54
+ * Commit. Don't change +VERSION+, or if you do, do it in a separate commit.
55
55
  * Send me a pull request. Bonus points for topic branches.
56
+ * Watch the Travis-CI build status on your pull request. Fix any problems.
56
57
 
57
58
  == Copyright
58
59
 
data/Rakefile CHANGED
@@ -19,6 +19,7 @@ Jeweler::Tasks.new do |gem|
19
19
  gem.email = "will@willglynn.com"
20
20
  gem.homepage = "http://github.com/delta407/ruby-zbar"
21
21
  gem.authors = ["Will Glynn"]
22
+ gem.post_install_message = "\nzbar: This gem depends on the \"zbar\" C library.\n If it's not installed, `require \"zbar\"` will fail.\n\n"
22
23
  # dependencies defined in Gemfile
23
24
  end
24
25
  Jeweler::RubygemsDotOrgTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -1,6 +1,7 @@
1
1
  require 'ffi'
2
2
 
3
3
  require 'zbar/lib'
4
+ require 'zbar/library_version'
4
5
  require 'zbar/symbol'
5
6
  require 'zbar/processor'
6
7
  require 'zbar/image'
@@ -11,7 +11,7 @@ module ZBar
11
11
  rescue LoadError => le
12
12
  raise LoadError, [
13
13
  "Didn't find libzbar on your system",
14
- "Please install zbar (http://zbar.sourceforge.net/) or ZBAR_LIB if it's in a weird place",
14
+ "Please install zbar (http://zbar.sourceforge.net/) or set ZBAR_LIB if it's in a weird place",
15
15
  "FFI::Library::ffi_lib() failed with error: #{le}"
16
16
  ].join("\n")
17
17
  end
@@ -24,7 +24,7 @@ module ZBar
24
24
  attach_function :zbar_symbol_get_loc_x, [:pointer, :uint], :int
25
25
  attach_function :zbar_symbol_get_loc_y, [:pointer, :uint], :int
26
26
  attach_function :zbar_symbol_next, [:pointer], :pointer
27
-
27
+
28
28
  attach_function :zbar_image_create, [], :pointer
29
29
  attach_function :zbar_image_destroy, [:pointer], :void
30
30
  attach_function :zbar_image_first_symbol, [:pointer], :pointer
@@ -34,16 +34,17 @@ module ZBar
34
34
  attach_function :zbar_image_get_height, [:pointer], :int
35
35
  attach_function :zbar_image_set_size, [:pointer, :uint, :uint], :void
36
36
  attach_function :zbar_image_set_data, [:pointer, :buffer_in, :uint, :pointer], :void
37
-
37
+
38
38
  attach_function :zbar_processor_create, [:int], :pointer
39
39
  attach_function :zbar_processor_destroy, [:pointer], :void
40
40
  attach_function :zbar_processor_init, [:pointer, :string, :int], :int
41
41
  attach_function :zbar_processor_set_config, [:pointer, :int, :int, :int], :int
42
42
 
43
43
  attach_function :zbar_process_image, [:pointer, :pointer], :int
44
-
44
+
45
45
  attach_function :zbar_parse_config, [:string, :pointer, :pointer, :pointer], :int
46
-
46
+
47
+ attach_function :zbar_version, [:pointer, :pointer], :int
47
48
  attach_function :zbar_set_verbosity, [:int], :void
48
49
  attach_function :zbar_get_symbol_name, [:int], :string
49
50
  attach_function :zbar_get_addon_name, [:int], :string
@@ -0,0 +1,41 @@
1
+ module ZBar
2
+ # Returns a ZBar::LibraryVersion representing the currently loaded library.
3
+ def self.library_version
4
+ @library_version ||= begin
5
+ major = FFI::MemoryPointer.new :uint
6
+ minor = FFI::MemoryPointer.new :uint
7
+ rv = zbar_version(major, minor)
8
+ if rv == 0
9
+ LibraryVersion.new(major.read_uint, minor.read_uint)
10
+ else
11
+ raise "zbar_version failed, returning #{rv}"
12
+ end
13
+ end
14
+ end
15
+
16
+ # Represents a version of the ZBar library, e.g. as returned by
17
+ # ZBar.library_version.
18
+ class LibraryVersion
19
+ def initialize(major, minor) #:nodoc:
20
+ @major, @minor = major, minor
21
+ end
22
+
23
+ # Major version number
24
+ attr_reader :major
25
+
26
+ # Minor version number
27
+ attr_reader :minor
28
+
29
+ # Compare this version to another LibraryVersion
30
+ def <=>(other)
31
+ [major, minor] <=> [other.major, other.minor]
32
+ end
33
+
34
+ include Comparable
35
+
36
+ # Format the library version as a string
37
+ def to_s
38
+ "#{major}.#{minor}"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe ZBar::LibraryVersion do
4
+ let(:major) { 10 }
5
+ let(:minor) { 99 }
6
+ let(:library_version) { described_class.new(major, minor) }
7
+ subject { library_version }
8
+
9
+ its(:major) { should be_kind_of Fixnum }
10
+ its(:minor) { should be_kind_of Fixnum }
11
+
12
+ describe "to_s" do
13
+ subject { library_version.to_s }
14
+ it { should be_kind_of String }
15
+ it "is formatted as major.minor" do
16
+ should == "#{major}.#{minor}"
17
+ end
18
+ end
19
+
20
+ describe "comparisons" do
21
+ let(:bigger_major) { described_class.new(major + 1, minor)}
22
+ let(:bigger_minor) { described_class.new(major, minor + 1)}
23
+ let(:equal) { described_class.new(major, minor)}
24
+
25
+ it { should be_kind_of Comparable }
26
+
27
+ it "compares minors" do
28
+ library_version.should < bigger_minor
29
+ bigger_minor.should > library_version
30
+ end
31
+ it "compares majors" do
32
+ library_version.should < bigger_major
33
+ bigger_major.should > library_version
34
+ end
35
+ it "compares equally" do
36
+ library_version.should == equal
37
+ equal.should == library_version
38
+ end
39
+ end
40
+ end
@@ -2,4 +2,15 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe ZBar do
4
4
  it { should be_kind_of Module }
5
+
6
+ describe "library_version" do
7
+ it "calls zbar_version(uint*, uint*)" do
8
+ ZBar.should_receive(:zbar_version).with(anything, anything).and_return(0)
9
+ ZBar.library_version
10
+ end
11
+
12
+ it "returns LibraryVersion" do
13
+ ZBar.library_version.should be_kind_of ZBar::LibraryVersion
14
+ end
15
+ end
5
16
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "zbar"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Will Glynn"]
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/zbar/image.rb",
30
30
  "lib/zbar/jpeg.rb",
31
31
  "lib/zbar/lib.rb",
32
+ "lib/zbar/library_version.rb",
32
33
  "lib/zbar/processor.rb",
33
34
  "lib/zbar/symbol.rb",
34
35
  "spec/spec_helper.rb",
@@ -36,11 +37,13 @@ Gem::Specification.new do |s|
36
37
  "spec/support/test.jpg",
37
38
  "spec/support/test.pgm",
38
39
  "spec/zbar/image_spec.rb",
40
+ "spec/zbar/library_version_spec.rb",
39
41
  "spec/zbar/processor_spec.rb",
40
42
  "spec/zbar_spec.rb",
41
43
  "zbar.gemspec"
42
44
  ]
43
45
  s.homepage = "http://github.com/delta407/ruby-zbar"
46
+ s.post_install_message = "\nzbar: This gem depends on the \"zbar\" C library.\n If it's not installed, `require \"zbar\"` will fail.\n\n"
44
47
  s.require_paths = ["lib"]
45
48
  s.rubygems_version = "1.8.25"
46
49
  s.summary = "Ruby bindings for ZBar, a barcode recognition library"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -128,6 +128,7 @@ files:
128
128
  - lib/zbar/image.rb
129
129
  - lib/zbar/jpeg.rb
130
130
  - lib/zbar/lib.rb
131
+ - lib/zbar/library_version.rb
131
132
  - lib/zbar/processor.rb
132
133
  - lib/zbar/symbol.rb
133
134
  - spec/spec_helper.rb
@@ -135,12 +136,14 @@ files:
135
136
  - spec/support/test.jpg
136
137
  - spec/support/test.pgm
137
138
  - spec/zbar/image_spec.rb
139
+ - spec/zbar/library_version_spec.rb
138
140
  - spec/zbar/processor_spec.rb
139
141
  - spec/zbar_spec.rb
140
142
  - zbar.gemspec
141
143
  homepage: http://github.com/delta407/ruby-zbar
142
144
  licenses: []
143
- post_install_message:
145
+ post_install_message: ! "\nzbar: This gem depends on the \"zbar\" C library.\n If
146
+ it's not installed, `require \"zbar\"` will fail.\n\n"
144
147
  rdoc_options: []
145
148
  require_paths:
146
149
  - lib
@@ -152,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
155
  version: '0'
153
156
  segments:
154
157
  - 0
155
- hash: 4088186622936310540
158
+ hash: 481266142629962502
156
159
  required_rubygems_version: !ruby/object:Gem::Requirement
157
160
  none: false
158
161
  requirements: