Module: MbraveTagsCreator::StaticMethods
- Included in:
- MbraveTagsCreator
- Defined in:
- lib/mbrave_tags_creator.rb
Instance Method Summary collapse
-
#create_tag_plates(tag_layout_templates, user) ⇒ Object
rubocop:disable Metrics/AbcSize.
- #process_create_tag_groups(forward_filename, reverse_filename, version) ⇒ Object
-
#process_create_tag_plates(login, version) ⇒ Object
rubocop:enable Metrics/AbcSize.
- #text_code_for_tag_layout(tag_layout_template) ⇒ Object
Instance Method Details
#create_tag_plates(tag_layout_templates, user) ⇒ Object
rubocop:disable Metrics/AbcSize
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/mbrave_tags_creator.rb', line 152 def create_tag_plates(tag_layout_templates, user) # rubocop:todo Metrics/MethodLength ActiveRecord::Base.transaction do lot_type = LotType.find_by!(name: 'Pre Stamped Tags - 384') tag_layout_templates.each_with_index do |tag_layout_template, _index| lot = lot_type.lots.create!( lot_number: "PSD_#{Time.current.to_f}", template: tag_layout_template, user: user, received_at: Time.current ) text_code = text_code_for_tag_layout(tag_layout_template) = PlateBarcode.(text_code) # barcode object qcc = QcableCreator.create!(lot: lot, user: user, supplied_barcode: ) qcc.qcables.each_with_index do |qcable, _index| qcable.update!(state: 'available') log_line { "#{tag_layout_template.name}:" } log_line { " - #{.}" } # barcode string end end end end |
#process_create_tag_groups(forward_filename, reverse_filename, version) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/mbrave_tags_creator.rb', line 189 def process_create_tag_groups(forward_filename, reverse_filename, version) ActiveRecord::Base.transaction do = MbraveTagsCreator.new( forward_filename: forward_filename, reverse_filename: reverse_filename, tag_identifier: MbraveTagsCreator::TAG_IDENTIFIER, version: version, yaml_filename: MbraveTagsCreator::YAML_FILENAME ) .create_1_tag_group_forward .create_24_tag_groups_reverse .create_tag_layout_templates .write_yaml(MbraveTagsCreator::YAML_FILENAME) end end |
#process_create_tag_plates(login, version) ⇒ Object
rubocop:enable Metrics/AbcSize
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/mbrave_tags_creator.rb', line 178 def process_create_tag_plates(login, version) user = User.find_by!(login:) tag_layout_templates = TagLayoutTemplate.select do |template| template.name.match(Regexp.new("^Bioscan_384_template_(\\d+)_#{version}$")) end create_tag_plates(tag_layout_templates, user) end |
#text_code_for_tag_layout(tag_layout_template) ⇒ Object
146 147 148 149 |
# File 'lib/mbrave_tags_creator.rb', line 146 def text_code_for_tag_layout(tag_layout_template) mreg = tag_layout_template.name.match(Regexp.new('^Bioscan_384_template_(\\d+)_')) "T#{mreg[1]}" end |