lis 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzMwYzc5MjBhMGU1NjRkMjY3ZjAwNDIxNjYwZTZmMDRlODU0ZTE5Ng==
4
+ YzJkNjFkOTYxYWNlY2RiMzhkOGI5OThiOGMyYmQxZDFhNmFhNTBjZA==
5
5
  data.tar.gz: !binary |-
6
- NTcyYmJjMWU3ZjMwNzk0MTNhNGY3OTFkMWY3NWE2ZmE5NmFiNDIyNw==
6
+ OGQxMjljYWQ1ZmE4MzAzZTIyYjczOWYxNjFjNTVjZGI4ZGZmZWViNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGE4ZmZmMzQ1MGM4NTg3ZTI3MzI4MjVhZjdmODBjODU5Y2Y2NzIxZjI4Mjcz
10
- NDg4OTc1M2Y1Mjk2ZjZhMDgzYzA4YjEyMjNiOTkzNjZkYTBmNmZmYWE3Y2Ey
11
- YzJkYmZkNGNmNjBjYjZlOWMwOTRhMWEwODdhNmVjYmU5ODJhNWE=
9
+ ZTZlM2E4ZTcwMTE4M2EwMTY3ZjZkZDg5OWI4NTQwNDRjNGRiMGZkYTY1YTYz
10
+ MGMyZWU3MzQ3ZDU3MWJlMjkwMWI4M2FmMDY2MDZhYTEzMmYzMDJkZTU3OWIz
11
+ MmYwOGEzMTk1NDFjZTE2OTJkOTI5Y2VjM2Q3MDQxMjA4NDQyMjI=
12
12
  data.tar.gz: !binary |-
13
- NWExYzhmMmY0Y2U4ZjZlYTM2OTY3NmFiYzlhMmJkZmIxODkzNzM4MGY0Mjdm
14
- NTE4NjM4OTllNTUxOWNlNmNjZTg0MzBjMjQxOTYzMTYzNDA3OTM2NzY4NDA4
15
- MzI5ZWU3MGQ5OWMxZjY4Zjc1N2NhM2Y1M2IyMTQxYzliYWRhMDc=
13
+ NTQ5MTQxMjgwN2E2N2M2NjczM2FhMGY0MTljNjA2Mjc3ODViMDFhODAxZWIx
14
+ MmNiYjM1MDA3N2NlOTBkMWU4NTAxOGM5NjUzOTZkM2IyNTY3NjM0Y2QxMTAz
15
+ N2QxYzY0NTNmOGZjNGVjYjg1MTZmNTMwNzFkYjc1NWUxMzZhMTI=
@@ -1,8 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
-
4
-
5
-
6
3
  Given /^LIS Interface listening for messages$/ do
7
4
  @client, @r, @w = PacketIO::Test::MockServer.build
8
5
  @io = PacketIO::IOListener.new(@r, @w)
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
 
3
3
  require 'lis'
4
4
 
5
- require 'mocha'
5
+ require 'mocha/setup'
6
6
  require 'yaml'
7
7
  require 'aruba/cucumber'
8
8
 
data/lib/lis.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'packet_io'
2
2
  require 'yaml'
3
+ require 'json'
4
+ require 'base64'
3
5
 
4
6
  require 'lis/version'
5
7
  require 'lis/messages.rb'
@@ -3,6 +3,13 @@
3
3
  require 'httparty'
4
4
 
5
5
  class LIS::HTTPInterface
6
+ class HTTP
7
+ include HTTParty
8
+ format :json
9
+ headers 'Accept' => 'application/json', 'Content-Type' => 'application/json'
10
+ end
11
+
12
+
6
13
  def initialize(endpoint)
7
14
  @endpoint = endpoint
8
15
  end
@@ -17,7 +24,7 @@ class LIS::HTTPInterface
17
24
  #
18
25
  def load_requests(device_name, barcode)
19
26
  begin
20
- result = HTTParty.get(uri(device_name, barcode))
27
+ result = HTTP.get(uri(device_name, barcode))
21
28
  data = LIS::Data::Request.from_yaml(result.body, barcode)
22
29
  rescue Exception => e
23
30
  puts e
@@ -25,8 +32,6 @@ class LIS::HTTPInterface
25
32
  data = nil
26
33
  end
27
34
 
28
- warn "data: #{data.inspect}" if $VERBOSE
29
-
30
35
  data
31
36
  end
32
37
 
@@ -51,7 +56,7 @@ class LIS::HTTPInterface
51
56
 
52
57
  # FIXME: WTF: should not just catch everything
53
58
  begin
54
- res = HTTParty.post(uri(device_name, barcode, order.universal_test_id), :body => data)
59
+ res = HTTP.post(uri(device_name, barcode, order.universal_test_id), :body => data.to_json)
55
60
  rescue Exception => e
56
61
  puts "EXCEPTION"
57
62
  p e
@@ -65,7 +70,6 @@ class LIS::HTTPInterface
65
70
  id = [device_name, barcode].join("-")
66
71
 
67
72
  s = [@endpoint, id, test_name].compact.join("/")
68
- warn "uri: #{s}" if $VERBOSE
69
73
 
70
74
  s
71
75
  end
@@ -39,7 +39,7 @@ module LIS::Message
39
39
  has_field 13, :test_completed_at, :type => :timestamp
40
40
 
41
41
  def raw_data
42
- to_message
42
+ Base64.encode64(to_message)
43
43
  end
44
44
 
45
45
  def universal_test_id
@@ -16,16 +16,16 @@ module LIS::Transfer
16
16
  # - :idle :: when a transmission is finished (after EOT is received)
17
17
  #
18
18
  class ASTM::E1394 < ::PacketIO::Base
19
+ EOT = "\004"
20
+ ENQ = "\005"
19
21
  ACK = "\006"
20
22
  NAK = "\025"
21
- ENQ = "\005"
22
- EOT = "\004"
23
23
 
24
24
  # format of a message
25
25
  RX = /(?:
26
- \005 | # ENQ - start a transaction
27
26
  \004 | # EOT - ends a transaction
28
- \005 | # ACK
27
+ \005 | # ENQ - start a transaction
28
+ \006 | # ACK
29
29
  \025 | # NAK
30
30
  (?:\002 (.) (.*?) \015 \003 (.+?) \015 \012) # a message with a checksum
31
31
  # | | `-- checksum
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module LIS
4
- VERSION = "0.4.6"
4
+ VERSION = "0.4.7"
5
5
  end
6
6
 
@@ -6,6 +6,8 @@ require 'mocha/setup'
6
6
 
7
7
  require 'lis'
8
8
 
9
+ $VERBOSE = true
10
+
9
11
  WebMock.disable_net_connect!
10
12
 
11
13
  class Test::Unit::TestCase
@@ -23,7 +23,10 @@ class TestHTTPInterface < Test::Unit::TestCase
23
23
  "test_name"=>"TSTID",
24
24
  "unit"=>"mIU/mL",
25
25
  "value"=>"8.2",
26
- "raw"=>@string}).
26
+ "raw" => Base64.encode64(@string)
27
+ },
28
+ :headers => { 'Accept' => 'application/json',
29
+ 'Content-Type' => 'application/json' }).
27
30
  to_return(:status => 200, :body => "", :headers => {})
28
31
 
29
32
  @interface.send_result(@device_name, @order, @result)
@@ -0,0 +1,12 @@
1
+ [Unit]
2
+ Description=LIS
3
+ ConditionPathExists=/dev/ttyUSB0
4
+ After=network.target
5
+
6
+ [Service]
7
+ ExecStart=lis server -v /dev/ttyUSB0 http://lis.example/lis
8
+ Restart=always
9
+ User=user
10
+
11
+ [Install]
12
+ WantedBy=multi-user.target
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levin Alexander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-06 00:00:00.000000000 Z
11
+ date: 2013-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packet_io
@@ -198,6 +198,7 @@ files:
198
198
  - test/test_astm_e1394.rb
199
199
  - test/test_http_interface.rb
200
200
  - test/test_messages.rb
201
+ - vendor/lis.service
201
202
  homepage: http://github.com/levinalex/lis
202
203
  licenses: []
203
204
  metadata: {}