extraction_token_util 0.0.2 → 0.0.3a11
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 +4 -4
- data/lib/extraction_token_util.rb +52 -31
- metadata +33 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 807964dad3726d71b70ad733c4d1d2362ad0d7ece464e277d5c86868d616db12
         | 
| 4 | 
            +
              data.tar.gz: 947c1a665fdf8e23bf01789b17ce487aa8e62d8f6bbbc3214e7728c4531e06a4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: aa5a205ebdf99bd9b2b314fe02a9e58f8303955a075b1a79ca105c3cb678cc90af08eb1eeeea938938fc8af4b14a97e9176dc268a68ced77cec5eb3eb8205422
         | 
| 7 | 
            +
              data.tar.gz: 77973aab9f3e5bc6256a5d2f746df0889dfda93ff162aa2ddc24034d9869634ac3dcb1e2798612a6fedaf9fc6bbf0520d75599a31645b8da03b7838c780195c9
         | 
| @@ -1,85 +1,106 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # This Gem provides support for common string operations with tokens in
         | 
| 5 | 
            +
            # Extraction lims like:
         | 
| 6 | 
            +
            # - quoting / unquoting strings
         | 
| 7 | 
            +
            # - padding / unpadding a string of digits until reaching a fixed size by
         | 
| 8 | 
            +
            # using zeroes support to perform recognizion of the following tokens:
         | 
| 9 | 
            +
            # - generate the address positions of the wells of a rack (A01, B01... F12)
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # Also provides pattern recognision for UUID, Wildcard variables (Eg: ?a,
         | 
| 12 | 
            +
            # ?rack, etc.), Fluidx barcodes: (Eg: FR1234678), Well Location: (Eg: A02, F11)
         | 
| 13 | 
            +
            #
         | 
| 1 14 | 
             
            module ExtractionTokenUtil
         | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 15 | 
            +
              UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.freeze
         | 
| 16 | 
            +
              WILDCARD = /\?\w*/.freeze
         | 
| 17 | 
            +
              LOCATION = /^([A-H])(\d{1,2})$/.freeze
         | 
| 5 18 |  | 
| 6 19 | 
             
              def self.fluidx_barcode_prefix
         | 
| 7 20 | 
             
                'F'
         | 
| 8 21 | 
             
              end
         | 
| 9 22 |  | 
| 10 | 
            -
              def self. | 
| 11 | 
            -
                 | 
| 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?
         | 
| 23 | 
            +
              def self.uuid?(str)
         | 
| 24 | 
            +
                str.is_a?(String) && !str.match(ExtractionTokenUtil::UUID).nil?
         | 
| 20 25 | 
             
              end
         | 
| 21 26 |  | 
| 22 27 | 
             
              def self.quote_if_uuid(str)
         | 
| 23 | 
            -
                return quote(str) if  | 
| 24 | 
            -
             | 
| 28 | 
            +
                return quote(str) if uuid?(str)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                str
         | 
| 25 31 | 
             
              end
         | 
| 26 32 |  | 
| 27 | 
            -
              def self. | 
| 33 | 
            +
              def self.valid_fluidx_barcode?(barcode)
         | 
| 28 34 | 
             
                barcode.to_s.start_with?(fluidx_barcode_prefix)
         | 
| 29 35 | 
             
              end
         | 
| 30 36 |  | 
| 31 37 | 
             
              def self.uuid(str)
         | 
| 32 | 
            -
                str.match(ExtractionTokenUtil | 
| 38 | 
            +
                str.match(ExtractionTokenUtil::UUID)[0]
         | 
| 33 39 | 
             
              end
         | 
| 34 40 |  | 
| 35 | 
            -
              def self. | 
| 36 | 
            -
                str. | 
| 41 | 
            +
              def self.wildcard?(str)
         | 
| 42 | 
            +
                str.is_a?(String) && !str.match(ExtractionTokenUtil::WILDCARD).nil?
         | 
| 37 43 | 
             
              end
         | 
| 38 44 |  | 
| 39 45 | 
             
              def self.kind_of_asset_id?(str)
         | 
| 40 | 
            -
                 | 
| 46 | 
            +
                (str.is_a?(String) && (wildcard?(str) || uuid?(str)))
         | 
| 41 47 | 
             
              end
         | 
| 42 48 |  | 
| 43 49 | 
             
              def self.to_asset_group_name(wildcard)
         | 
| 44 50 | 
             
                return wildcard if wildcard.nil?
         | 
| 51 | 
            +
             | 
| 45 52 | 
             
                wildcard.gsub('?', '')
         | 
| 46 53 | 
             
              end
         | 
| 47 54 |  | 
| 48 55 | 
             
              def self.generate_positions(letters, columns)
         | 
| 49 | 
            -
                size=letters.size * columns.size
         | 
| 50 | 
            -
                 | 
| 51 | 
            -
                   | 
| 56 | 
            +
                size = letters.size * columns.size
         | 
| 57 | 
            +
                size.times.map do |idx|
         | 
| 58 | 
            +
                  letter = position_letter_for_index(idx, letters)
         | 
| 59 | 
            +
                  number = position_number_for_index(idx, letters, columns)
         | 
| 60 | 
            +
                  "#{letter}#{number}"
         | 
| 52 61 | 
             
                end
         | 
| 53 62 | 
             
              end
         | 
| 54 63 |  | 
| 55 | 
            -
              def self. | 
| 56 | 
            -
                 | 
| 64 | 
            +
              def self.position_letter_for_index(idx, letters)
         | 
| 65 | 
            +
                letters[(idx % letters.length).floor]
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              def self.position_number_for_index(idx, letters, columns)
         | 
| 69 | 
            +
                pad((columns[(idx / letters.length).floor]).to_s, '0', 2)
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              def self.pad(str, chr, size)
         | 
| 73 | 
            +
                "#{(size - str.size).times.map { chr }.join('')}#{str}"
         | 
| 57 74 | 
             
              end
         | 
| 58 75 |  | 
| 59 76 | 
             
              def self.unpad_location(location)
         | 
| 60 77 | 
             
                return location unless location
         | 
| 78 | 
            +
             | 
| 61 79 | 
             
                loc = location.match(/(\w)(0*)(\d*)/)
         | 
| 62 | 
            -
                loc[1]+loc[3]
         | 
| 80 | 
            +
                loc[1] + loc[3]
         | 
| 63 81 | 
             
              end
         | 
| 64 82 |  | 
| 65 83 | 
             
              def self.pad_location(location)
         | 
| 66 84 | 
             
                return location unless location
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                 | 
| 85 | 
            +
             | 
| 86 | 
            +
                parts = location.match(ExtractionTokenUtil::LOCATION)
         | 
| 87 | 
            +
                return nil if parts.to_a.empty?
         | 
| 88 | 
            +
             | 
| 69 89 | 
             
                letter = parts[1]
         | 
| 70 90 | 
             
                number = parts[2]
         | 
| 71 | 
            -
                number = ExtractionTokenUtil.pad(number, | 
| 91 | 
            +
                number = ExtractionTokenUtil.pad(number, '0', 2) unless number.length == 2
         | 
| 72 92 | 
             
                "#{letter}#{number}"
         | 
| 73 93 | 
             
              end
         | 
| 74 94 |  | 
| 75 95 | 
             
              def self.quote(str)
         | 
| 76 96 | 
             
                return str unless str
         | 
| 97 | 
            +
             | 
| 77 98 | 
             
                "\"#{str}\""
         | 
| 78 99 | 
             
              end
         | 
| 79 100 |  | 
| 80 101 | 
             
              def self.unquote(str)
         | 
| 81 102 | 
             
                return str unless str
         | 
| 82 | 
            -
                str.gsub(/\"/,"")
         | 
| 83 | 
            -
              end
         | 
| 84 103 |  | 
| 104 | 
            +
                str.gsub(/\"/, '')
         | 
| 105 | 
            +
              end
         | 
| 85 106 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: extraction_token_util
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.3a11
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Eduardo Martin Rojo
         | 
| @@ -24,6 +24,34 @@ dependencies: | |
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '3'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rubocop
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0.80'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0.80'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rubocop-rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 27 55 | 
             
            description: 
         | 
| 28 56 | 
             
            email: 
         | 
| 29 57 | 
             
            executables: []
         | 
| @@ -48,11 +76,12 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 48 76 | 
             
                  version: '0'
         | 
| 49 77 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 50 78 | 
             
              requirements:
         | 
| 51 | 
            -
              - - " | 
| 79 | 
            +
              - - ">"
         | 
| 52 80 | 
             
                - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                  version:  | 
| 81 | 
            +
                  version: 1.3.1
         | 
| 54 82 | 
             
            requirements: []
         | 
| 55 | 
            -
             | 
| 83 | 
            +
            rubyforge_project: 
         | 
| 84 | 
            +
            rubygems_version: 2.7.7
         | 
| 56 85 | 
             
            signing_key: 
         | 
| 57 86 | 
             
            specification_version: 4
         | 
| 58 87 | 
             
            summary: Set of Ruby methods to provide lexical support to common formats in use in
         |