vision_mate 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 608977bf7d441a9d8204ddbf4c4703eeb282192f
4
+ data.tar.gz: 57fb18ba7ba7b085387cf651a995c59f870541c4
5
+ SHA512:
6
+ metadata.gz: ab720466261ea0aa58cec7cc0deff1b170628990305ba72c7cbfca01dab325a09452be8dcc67526709bfb917a056e364c98f46745cefb761a6a98fc27721381d
7
+ data.tar.gz: 12e8f2f44bba08caec4f8a7883b1d215dc78c04a7336dfc3d6f92f67484d2b031356de36848b8678c4e8196006b0ec392de7b2c44dddf947b4bd77a25a3555b1
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ StringLiterals:
4
+ Enabled: false
5
+
6
+ Documentation:
7
+ Enabled: false
8
+
9
+ SignalException:
10
+ EnforcedStyle: only_raise
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ - "2.1.0"
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vision_mate.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 SciMed Solutions
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ [![Build Status](https://travis-ci.org/SciMed/vision_mate.png?branch=master)](https://travis-ci.org/SciMed/vision_mate)
2
+ [![Code Climate](https://codeclimate.com/github/SciMed/vision_mate.png)](https://codeclimate.com/github/SciMed/vision_mate)
3
+
4
+ # VisionMate
5
+
6
+ VisionMate provides a Ruby interface to the Thermo Scientific VisionMate 2D
7
+ barcode scanner used to bulk scan multiple test tubes set in a rack. The library
8
+ provides a wrapper around the Telnet interface used by the VisionMate scanner.
9
+
10
+ ![Workflow Example](assets/images/vision_mate_workflow.png)
11
+
12
+ ## Installation
13
+
14
+ Add it to the project's Gemfile with:
15
+
16
+ ```Ruby
17
+ gem 'vision_mate'
18
+ ```
19
+
20
+ Run the `bundle` command to install it.
21
+
22
+ ## Usage
23
+
24
+ Configure the connection in an initializer file. e.g.
25
+ `config/initializers/vision_mate.rb`
26
+
27
+ ```Ruby
28
+ VisionMate.configure do |config|
29
+ config.host = '192.168.1.1'
30
+ config.port = '8000'
31
+ end
32
+ ```
33
+
34
+ Initialize a connection and perform a scan.
35
+
36
+ ```Ruby
37
+ scanner = VisionMate.connect
38
+ scanner.scan # => (results)
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork this repository ( http://github.com/SciMed/vision_mate/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
48
+
49
+ ## Copyright
50
+
51
+ Copyright (c) 2014 SciMed Solutions Inc. Licensed under the MIT license. See
52
+ [LICENSE](LICENSE.txt) for details.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ task default: :spec
@@ -0,0 +1,10 @@
1
+ module VisionMate
2
+ # The Configuration provides access to long lived information needed
3
+ # throughout the scanning process.
4
+ #
5
+ module Configuration
6
+ class << self
7
+ attr_accessor :host, :port
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module VisionMate
2
+ # Connection is an abstract interface used to wrap the Telnet connection to
3
+ # the scanner. It provides a high level API for the scanner and standardizes
4
+ # the output returned.
5
+ #
6
+ class Connection
7
+ attr_accessor :telnet_connection
8
+
9
+ def initialize(host, port, telnet_class = Telnet)
10
+ self.telnet_connection = Telnet.connect(host, port)
11
+ end
12
+
13
+ def scan
14
+ VisionMate::Rack.new(telnet_connection.scan)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module VisionMate
2
+ class NoTube
3
+ attr_accessor :barcode, :position
4
+
5
+ def initialize(_, position)
6
+ self.position = position
7
+ end
8
+
9
+ def empty?
10
+ true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,44 @@
1
+ module VisionMate
2
+ class Rack
3
+ include Enumerable
4
+ attr_accessor :tubes, :number_of_rows, :number_of_columns
5
+
6
+ class PositionOutOfRange < StandardError; end
7
+
8
+ def initialize(tube_string)
9
+ self.number_of_rows = 8
10
+ self.number_of_columns = 12
11
+ self.tubes = new_rack(tube_string)
12
+ end
13
+
14
+ def each(&block)
15
+ tubes.each(&block)
16
+ end
17
+
18
+ def at_position(position)
19
+ tubes.find { |tube| tube.position == position } ||
20
+ raise(PositionOutOfRange)
21
+ end
22
+
23
+ def empty?
24
+ tubes.all?(&:empty?)
25
+ end
26
+
27
+ private
28
+
29
+ def new_rack(tube_string)
30
+ tube_strings = tube_string.split(",").compact
31
+ tube_strings.each_with_index.map do |barcode, position|
32
+ Tube.create barcode, converted_position(position)
33
+ end
34
+ end
35
+
36
+ def converted_position(position)
37
+ row_letters = ("A".."Z").take(number_of_rows)
38
+ row_letter = row_letters[position % number_of_columns]
39
+ row_number = (position / number_of_columns) + 1
40
+
41
+ "#{row_letter}#{row_number}"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,77 @@
1
+ require "net/telnet"
2
+
3
+ module VisionMate
4
+ class Telnet
5
+ attr_accessor :telnet_connection
6
+ class CouldNotConnect < StandardError; end
7
+ class BadHostNameOrPort < StandardError; end
8
+ class TubeReadError < StandardError; end
9
+
10
+ # For ruby 1.9 compatibility
11
+ class Net::OpenTimeout; end
12
+
13
+ def self.connect(host, port, telnet_class = Net::Telnet)
14
+ new(telnet_class.new("Host" => host, "Port" => port))
15
+ rescue Net::OpenTimeout, Timeout::Error
16
+ raise CouldNotConnect, "Failed to connect to #{host}:#{port}"
17
+ rescue SocketError
18
+ raise BadHostNameOrPort, "Malformed host name or port"
19
+ end
20
+
21
+ def initialize(telnet_connection)
22
+ self.telnet_connection = telnet_connection
23
+ set_scanner_to_manual
24
+ end
25
+
26
+ def scan
27
+ initiate_scan
28
+ result = retrieve_data
29
+ raise TubeReadError, "One or more tubes not read" if result[/No Read/]
30
+ strip_prefix(result)
31
+ end
32
+
33
+ def initiate_scan
34
+ telnet_connection.cmd("String" => "S", "Match" => /OK/)
35
+ wait_for_data
36
+ end
37
+
38
+ private
39
+
40
+ def wait_for_data
41
+ sleep 0.1 while scanner_status["finished_scan"]
42
+ sleep 0.1 until scanner_status["data_ready"]
43
+ end
44
+
45
+ def scanner_status
46
+ result = telnet_connection.cmd("String" => "L", "Match" => /OK/)
47
+ status = strip_prefix(result)
48
+ status_names = %w{initializing scanning finished_scan data_ready
49
+ data_sent rack96 empty error}
50
+ status_values = extract_statuses(status)
51
+
52
+ Hash[status_names.zip(status_values)]
53
+ end
54
+
55
+ def extract_statuses(status_string)
56
+ statuses = to_binary_string(status_string.to_i).split('')
57
+
58
+ statuses.map { |status| status == "1" }
59
+ end
60
+
61
+ def to_binary_string(int)
62
+ int.to_s(2)
63
+ end
64
+
65
+ def retrieve_data
66
+ telnet_connection.cmd("String" => "D", "Match" => /OK/)
67
+ end
68
+
69
+ def set_scanner_to_manual
70
+ telnet_connection.cmd("String" => "M0", "Match" => /OK/)
71
+ end
72
+
73
+ def strip_prefix(string)
74
+ string[/^OK(.*)/, 1]
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,24 @@
1
+ module VisionMate
2
+ # Tube provides barcode and other meta information for each individual test
3
+ # tube inside the rack. Tube's are usually returned as a collection within
4
+ # a `Rack` object once a scan is performed.
5
+ #
6
+ class Tube
7
+ attr_accessor :barcode, :position
8
+
9
+ def self.create(barcode, position)
10
+ return NoTube.new(barcode, position) if barcode == "No Tube"
11
+
12
+ Tube.new(barcode, position)
13
+ end
14
+
15
+ def initialize(barcode, position)
16
+ self.barcode = barcode
17
+ self.position = position
18
+ end
19
+
20
+ def empty?
21
+ false
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module VisionMate
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ require "vision_mate/configuration"
2
+ require "vision_mate/connection"
3
+ require "vision_mate/no_tube"
4
+ require "vision_mate/rack"
5
+ require "vision_mate/telnet"
6
+ require "vision_mate/tube"
7
+ require "vision_mate/version"
8
+ require "uri"
9
+
10
+ module VisionMate
11
+ # Used to configure long lived information needed throughout the scanning
12
+ # process. Provides access to `host` and `port` along with other information
13
+ # used to configure the orientation and dimensions of scanned racks.
14
+ #
15
+ # Example:
16
+ # VisionMate.configure do |config|
17
+ # config.host = "192.168.1.1"
18
+ # config.port = "8080"
19
+ # end
20
+ #
21
+ # VisionMate::Configuration.host # => "192.168.1.1"
22
+ # VisionMate::Configuration.port # => "8080"
23
+ #
24
+ def self.configure(&block)
25
+ block.call(VisionMate::Configuration)
26
+ end
27
+
28
+ def self.connect
29
+ host = Configuration.host
30
+ port = Configuration.port
31
+ Connection.new(host, port)
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ OKNo Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,
@@ -0,0 +1 @@
1
+ OKNo Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,0093404544,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,No Tube,
@@ -0,0 +1,61 @@
1
+ require_relative "../lib/vision_mate"
2
+ require "net/telnet"
3
+
4
+ class MockTelnet
5
+ def initialize(*); end
6
+ end
7
+
8
+ describe "Integrating With a Scanner" do
9
+ let(:telnet) { double("telnet") }
10
+ before(:each) do
11
+ telnet.stub(:cmd).with(hash_including("String" => "M0"))
12
+ telnet.stub(:cmd).with(hash_including("String" => "S"))
13
+ telnet.stub(:cmd).with(hash_including("String" => "D"))
14
+ .and_return one_tube_string
15
+ telnet.stub(:cmd).with(hash_including("String" => "L")).and_return("OK37")
16
+ Net::Telnet.stub new: telnet
17
+ end
18
+
19
+ it "scans a rack of tubes" do
20
+ VisionMate.configure do |config|
21
+ config.host = "http://192.168.3.132"
22
+ config.port = "8000"
23
+ end
24
+ vm_client = VisionMate.connect
25
+ result = vm_client.scan.reject(&:empty?)
26
+ expect(result.first.barcode).to eq first_tube_barcode
27
+ expect(result.first.position).to eq first_tube_position
28
+ end
29
+
30
+ it "throws an error for no read" do
31
+ telnet.stub(:cmd).with(hash_including("String" => "D"))
32
+ .and_return bad_read_string
33
+ VisionMate.configure do |config|
34
+ config.host = "http://192.168.3.132"
35
+ config.port = "8000"
36
+ end
37
+
38
+ vm_client = VisionMate.connect
39
+ expect { vm_client.scan }.to raise_error(
40
+ VisionMate::Telnet::TubeReadError
41
+ )
42
+ end
43
+
44
+ def first_tube_position
45
+ "H1"
46
+ end
47
+
48
+ def first_tube_barcode
49
+ "0093404544"
50
+ end
51
+
52
+ def bad_read_string
53
+ one_tube_string.sub(/No Tube/, "No Read")
54
+ end
55
+
56
+ def one_tube_string
57
+ gem_path = File.expand_path('../..', __FILE__)
58
+ asset_path = gem_path + "/spec/assets/one_tube_results.txt"
59
+ File.read(asset_path)
60
+ end
61
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "../../lib/vision_mate/connection"
2
+
3
+ class VisionMate::Telnet; end
4
+
5
+ class VisionMate::Rack; end
6
+
7
+ describe VisionMate::Connection do
8
+ let(:uri) { double("uri", host: "192.168.3.132", port: "8000") }
9
+
10
+ describe "#scan" do
11
+ subject { VisionMate::Connection.new uri.host, uri.port }
12
+ let(:rack_size) { 96 }
13
+
14
+ it "returns an rack" do
15
+ VisionMate::Telnet.stub connect: double("telnet", scan: "NOOP")
16
+ # .with("String" => "D", "Match" => /OK/)
17
+ # .and_return(one_tube_string)
18
+ VisionMate::Rack.stub new: double("rack", empty?: false)
19
+ rack = subject.scan
20
+ expect(rack).not_to be_empty
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,63 @@
1
+ require_relative "../../lib/vision_mate/rack"
2
+ require_relative "../../lib/vision_mate/tube"
3
+ require_relative "../../lib/vision_mate/no_tube"
4
+
5
+ describe VisionMate::Rack do
6
+ subject { VisionMate::Rack.new(one_tube_string) }
7
+ let(:position_with_tube) { "H1" }
8
+ let(:position_without_tube) { "A1" }
9
+ let(:out_of_range_position) { "Z100" }
10
+
11
+ it "behaves like an array of tubes" do
12
+ expect(subject.to_a.count).to eq 96
13
+ end
14
+
15
+ it "assigns the correct positions to tubes" do
16
+ VisionMate::Tube.should_receive(:new).with(/\d+/, "H1")
17
+ VisionMate::Rack.new(one_tube_string)
18
+ end
19
+
20
+ describe "#at_position" do
21
+ it "can find a tube at a position" do
22
+ tube = subject.at_position position_with_tube
23
+ expect(tube).not_to be_empty
24
+ end
25
+
26
+ it "returns a NoTube object at a posistion with no tube" do
27
+ tube = subject.at_position position_without_tube
28
+ expect(tube).to be_empty
29
+ end
30
+
31
+ it "raises an error when a tube is not found at position" do
32
+ expect do
33
+ subject.at_position out_of_range_position
34
+ end.to raise_error(VisionMate::Rack::PositionOutOfRange)
35
+ end
36
+ end
37
+
38
+ describe "#empty?" do
39
+ it "is empty if there are no tubes in it" do
40
+ rack = VisionMate::Rack.new(no_tube_string)
41
+ expect(rack).to be_empty
42
+ end
43
+
44
+ it "is not empty if there are any tubes" do
45
+ rack = VisionMate::Rack.new(one_tube_string)
46
+ expect(rack).not_to be_empty
47
+ end
48
+ end
49
+
50
+ def no_tube_string
51
+ read_tube_file "/assets/empty_tube_results.txt"
52
+ end
53
+
54
+ def one_tube_string
55
+ read_tube_file "/assets/one_tube_results.txt"
56
+ end
57
+
58
+ def read_tube_file(path)
59
+ gem_path = File.expand_path('../..', __FILE__)
60
+ asset_path = gem_path + path
61
+ File.read(asset_path)[/OK(.*)/, 1]
62
+ end
63
+ end
@@ -0,0 +1,102 @@
1
+ require_relative "../../lib/vision_mate/telnet"
2
+
3
+ class MockTelnet; end
4
+
5
+ describe VisionMate::Telnet do
6
+ subject { VisionMate::Telnet.new(telnet_connection) }
7
+ let(:uri) { double("uri", host: "192.168.3.132", port: "8000") }
8
+ let(:telnet_connection) { double "telnet_connection" }
9
+
10
+ describe ".connect" do
11
+ it "connects to telnet using a host and port" do
12
+ MockTelnet.should_receive(:new)
13
+ .with(hash_including("Host" => uri.host, "Port" => uri.port))
14
+ .and_return double("telnet_connection").as_null_object
15
+
16
+ VisionMate::Telnet.connect(uri.host, uri.port, MockTelnet)
17
+ end
18
+
19
+ it "thows an exception if it cannot connect" do
20
+ MockTelnet.stub(:new).and_raise(Timeout::Error)
21
+ expect do
22
+ VisionMate::Telnet.connect("bad_host.com", "88", MockTelnet)
23
+ end.to raise_error(VisionMate::Telnet::CouldNotConnect)
24
+ end
25
+
26
+ it "throws an exception if the port or host is invalid" do
27
+ MockTelnet.stub(:new).and_raise(SocketError)
28
+ expect do
29
+ VisionMate::Telnet.connect("bad_host", "899999", MockTelnet)
30
+ end.to raise_error(VisionMate::Telnet::BadHostNameOrPort)
31
+ end
32
+
33
+ it "sets the scanner to manual" do
34
+ MockTelnet.stub(new: telnet_connection)
35
+ telnet_connection.should_receive(:cmd).with(
36
+ "String" => "M0", "Match" => /OK/
37
+ )
38
+ VisionMate::Telnet.connect("foo.com", "80", MockTelnet)
39
+ end
40
+ end
41
+
42
+ describe "#scan" do
43
+ before do
44
+ telnet_connection.stub(:cmd).with("String" => "L", "Match" => /OK/)
45
+ .and_return("OK37")
46
+ end
47
+
48
+ it "scans and returns a string of barcodes and no bacodes" do
49
+ telnet_connection.should_receive(:cmd).with(
50
+ "String" => "M0", "Match" => /OK/
51
+ )
52
+ telnet_connection.should_receive(:cmd).with(
53
+ "String" => "S", "Match" => /OK/
54
+ )
55
+ telnet_connection.should_receive(:cmd).with(
56
+ "String" => "L", "Match" => /OK/
57
+ )
58
+ telnet_connection.should_receive(:cmd).with(
59
+ "String" => "D", "Match" => /OK/
60
+ ).and_return one_tube_results
61
+ return_value = subject.scan
62
+ expect(return_value).to match(/0093404544/)
63
+ expect(return_value).to match(/No Tube/)
64
+ end
65
+
66
+ it "raises an error if there are no reads" do
67
+ telnet_connection.stub cmd: "OK37"
68
+ subject.stub(:retrieve_data).and_return(no_read_results)
69
+ expect { subject.scan }.to raise_error(VisionMate::Telnet::TubeReadError)
70
+ end
71
+ end
72
+
73
+ describe "#initate_scan" do
74
+ it "waits for the data to be ready to retrieve it" do
75
+ start_time = Time.now
76
+ telnet_connection.stub(:cmd) do |command|
77
+ if command["String"] == "L" && (Time.now - start_time) <= 0.1
78
+ "OK35"
79
+ else
80
+ "OK45"
81
+ end
82
+ end
83
+
84
+ subject.should_receive(:retrieve_data).and_return "OKSome Data"
85
+ subject.scan
86
+ end
87
+ end
88
+
89
+ def no_read_results
90
+ one_tube_results.sub(/No Tube/, "No Read")
91
+ end
92
+
93
+ def one_tube_results
94
+ read_tube_file "/assets/one_tube_results.txt"
95
+ end
96
+
97
+ def read_tube_file(path)
98
+ gem_path = File.expand_path('../..', __FILE__)
99
+ asset_path = gem_path + path
100
+ File.read(asset_path)
101
+ end
102
+ end
@@ -0,0 +1,28 @@
1
+ require_relative "../../lib/vision_mate/tube"
2
+ require_relative "../../lib/vision_mate/no_tube"
3
+
4
+ describe VisionMate::Tube do
5
+ describe ".create" do
6
+ it "returns a tube object if there is a barcode" do
7
+ expect(VisionMate::Tube.create("NOOP", "A2")).not_to be_empty
8
+ end
9
+
10
+ it "returns a tube object if the barcode is No Tube" do
11
+ expect(VisionMate::Tube.create("No Tube", "A2")).to be_empty
12
+ end
13
+ end
14
+
15
+ describe "#barcode" do
16
+ it "returns a barcode" do
17
+ tube = VisionMate::Tube.new "foo-barcode", "A1"
18
+ expect(tube.barcode).to eq "foo-barcode"
19
+ end
20
+ end
21
+
22
+ describe "#position" do
23
+ it "returns it's own position" do
24
+ tube = VisionMate::Tube.new "foo-barcode", "A1"
25
+ expect(tube.position).to eq "A1"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ require_relative "../lib/vision_mate"
2
+
3
+ describe VisionMate do
4
+ describe ".configure" do
5
+ it "can set the connection host" do
6
+ VisionMate.configure do |config|
7
+ config.host = "http://192.168.3.132"
8
+ end
9
+ VisionMate::Configuration.host.should == "http://192.168.3.132"
10
+ end
11
+
12
+ it "can set the connection port" do
13
+ VisionMate.configure do |config|
14
+ config.port = "8000"
15
+ end
16
+ VisionMate::Configuration.port.should == "8000"
17
+ end
18
+ end
19
+
20
+ describe ".connect" do
21
+ it "returns a connection object with the host" do
22
+ VisionMate::Configuration.stub host: "host"
23
+ VisionMate::Connection.stub new: double("connection", host: "host")
24
+ connection = subject.connect
25
+ expect(connection.host).to eq "host"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vision_mate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vision_mate"
8
+ spec.version = VisionMate::VERSION
9
+ spec.authors = ["Joe Jackson", "Joseph Jaber"]
10
+ spec.email = ["joe.jackson@scimedsolutions.com", "mail@josephjaber.com"]
11
+ spec.summary = %q{ Ruby client for the Thermo Scientific VisionMate 2D Scanner. }
12
+ spec.description = %q{ Ruby client for the Thermo Scientific VisionMate 2D Scanner. }
13
+ spec.homepage = "http://github.com/SciMed/vision_mate"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.13"
24
+ spec.add_development_dependency "yard"
25
+ spec.add_development_dependency "rubocop"
26
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vision_mate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Joe Jackson
8
+ - Joseph Jaber
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.5'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.13'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.13'
56
+ - !ruby/object:Gem::Dependency
57
+ name: yard
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: " Ruby client for the Thermo Scientific VisionMate 2D Scanner. "
85
+ email:
86
+ - joe.jackson@scimedsolutions.com
87
+ - mail@josephjaber.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".rubocop.yml"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - assets/images/vision_mate_workflow.png
101
+ - lib/vision_mate.rb
102
+ - lib/vision_mate/configuration.rb
103
+ - lib/vision_mate/connection.rb
104
+ - lib/vision_mate/no_tube.rb
105
+ - lib/vision_mate/rack.rb
106
+ - lib/vision_mate/telnet.rb
107
+ - lib/vision_mate/tube.rb
108
+ - lib/vision_mate/version.rb
109
+ - spec/assets/empty_tube_results.txt
110
+ - spec/assets/one_tube_results.txt
111
+ - spec/scanner_integeration_spec.rb
112
+ - spec/vision_mate/connection_spec.rb
113
+ - spec/vision_mate/rack_spec.rb
114
+ - spec/vision_mate/telnet_spec.rb
115
+ - spec/vision_mate/tube_spec.rb
116
+ - spec/vision_mate_spec.rb
117
+ - vision_mate.gemspec
118
+ homepage: http://github.com/SciMed/vision_mate
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.2.0
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Ruby client for the Thermo Scientific VisionMate 2D Scanner.
142
+ test_files:
143
+ - spec/assets/empty_tube_results.txt
144
+ - spec/assets/one_tube_results.txt
145
+ - spec/scanner_integeration_spec.rb
146
+ - spec/vision_mate/connection_spec.rb
147
+ - spec/vision_mate/rack_spec.rb
148
+ - spec/vision_mate/telnet_spec.rb
149
+ - spec/vision_mate/tube_spec.rb
150
+ - spec/vision_mate_spec.rb
151
+ has_rdoc: