extraction_token_util 0.0.1.pre.alpha.pre.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a8c36c110cc5d6af1a5e890a61c0d6c5d2b3b25d3a961cac7bb346cc51433d71
4
+ data.tar.gz: 3ccc5f483ff4ea5dc5dbd3fefbfab39f23a55f7abdc42cd398b0cb61da8ede77
5
+ SHA512:
6
+ metadata.gz: 80ab69ab510284292ecea5d026427b0941da44a071816058df70562ae752f08b3c0788bb4ea6cdbb0360802ad491c48be2c413585d5c16e2e90d753cbacaeb9d
7
+ data.tar.gz: 83769f3430332acf1fecc524b1f7c66b70805d72a7948835c2143ee6e09ae96aeeb0091760aac425739aa42c1ea9682aa188b15a20ab28154d2cb950e47a7fb1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Eduardo Martín Rojo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # extraction-token-util
2
+ Set of Ruby methods to provide lexical support to common formats in use in Extraction Lims
@@ -0,0 +1,85 @@
1
+ module ExtractionTokenUtil
2
+ def self.UUID_REGEXP
3
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
4
+ end
5
+
6
+ def self.fluidx_barcode_prefix
7
+ 'F'
8
+ end
9
+
10
+ def self.WILDCARD_REGEXP
11
+ /\?\w*/
12
+ end
13
+
14
+ def self.LOCATION_REGEXP
15
+ /^([A-H])(\d{1,2})$/
16
+ end
17
+
18
+ def self.is_uuid?(str)
19
+ str.kind_of?(String) && !str.match(ExtractionTokenUtil.UUID_REGEXP).nil?
20
+ end
21
+
22
+ def self.quote_if_uuid(str)
23
+ return quote(str) if is_uuid?(str)
24
+ return str
25
+ end
26
+
27
+ def self.is_valid_fluidx_barcode?(barcode)
28
+ barcode.to_s.start_with?(fluidx_barcode_prefix)
29
+ end
30
+
31
+ def self.uuid(str)
32
+ str.match(ExtractionTokenUtil.UUID_REGEXP)[0]
33
+ end
34
+
35
+ def self.is_wildcard?(str)
36
+ str.kind_of?(String) && !str.match(ExtractionTokenUtil.WILDCARD_REGEXP).nil?
37
+ end
38
+
39
+ def self.kind_of_asset_id?(str)
40
+ !!(str.kind_of?(String) && (is_wildcard?(str) || is_uuid?(str)))
41
+ end
42
+
43
+ def self.to_asset_group_name(wildcard)
44
+ return wildcard if wildcard.nil?
45
+ wildcard.gsub('?', '')
46
+ end
47
+
48
+ def self.generate_positions(letters, columns)
49
+ size=letters.size * columns.size
50
+ location_for_position = size.times.map do |i|
51
+ "#{letters[(i%letters.length).floor]}#{pad((columns[(i/letters.length).floor]).to_s,'0',2)}"
52
+ end
53
+ end
54
+
55
+ def self.pad(str,chr,size)
56
+ "#{(size-str.size).times.map{chr}.join('')}#{str}"
57
+ end
58
+
59
+ def self.unpad_location(location)
60
+ return location unless location
61
+ loc = location.match(/(\w)(0*)(\d*)/)
62
+ loc[1]+loc[3]
63
+ end
64
+
65
+ def self.pad_location(location)
66
+ return location unless location
67
+ parts = location.match(ExtractionTokenUtil.LOCATION_REGEXP)
68
+ return nil if parts.length == 0
69
+ letter = parts[1]
70
+ number = parts[2]
71
+ number = ExtractionTokenUtil.pad(number,"0",2) unless number.length == 2
72
+ "#{letter}#{number}"
73
+ end
74
+
75
+ def self.quote(str)
76
+ return str unless str
77
+ "\"#{str}\""
78
+ end
79
+
80
+ def self.unquote(str)
81
+ return str unless str
82
+ str.gsub(/\"/,"")
83
+ end
84
+
85
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: extraction_token_util
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.alpha.pre.4
5
+ platform: ruby
6
+ authors:
7
+ - Eduardo Martin Rojo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - README.md
35
+ - lib/extraction_token_util.rb
36
+ homepage:
37
+ licenses: []
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">"
51
+ - !ruby/object:Gem::Version
52
+ version: 1.3.1
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.7.7
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Set of Ruby methods to provide lexical support to common formats in use in
59
+ Extraction Lims
60
+ test_files: []