Skip to content

Commit

Permalink
change naming of keys for default settings in label_templates.yml
Browse files Browse the repository at this point in the history
- the word 'default' is in the parent key now, so no need to prefix each setting with it too
- change code references to them
- add 'default_' prefix back in when generating Settings file, because they're not grouped under a parent section there, and it will keep it consistent with how it was before, avoiding the need for further code changes
  • Loading branch information
KatyTaylor committed Feb 12, 2024
1 parent da7b7f9 commit 1598b6a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions config/label_templates.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
defaults_by_printer_type:
default_pmb_templates:
pmb_templates:
:plate_double: plate_6mm_double_code39
:plate_a: sqsc_96plate_label_template_code39
:tube_rack: sqsc_96plate_label_template_code39
:tube: tube_label_template_1d

default_sprint_templates:
sprint_templates:
:plate_double: plate_384.yml.erb
:plate_a: plate_96.yml.erb
:tube_rack: plate_96.yml.erb
:tube: tube_label_template_1d.yml.erb

default_printer_type_names:
printer_type_names:
:plate_double: 384 Well Plate Double
:plate_a: 96 Well Plate
:tube_rack: 96 Well Plate
Expand Down
6 changes: 3 additions & 3 deletions lib/purpose_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ def default_label_template
printer_type_key = default_options[:default_printer_type]
{
label_class: default_options[:label_class],
printer_type: @label_template_defaults.fetch('default_printer_type_names').fetch(printer_type_key),
pmb_template: @label_template_defaults.fetch('default_pmb_templates').fetch(printer_type_key),
sprint_template: @label_template_defaults.fetch('default_sprint_templates').fetch(printer_type_key)
printer_type: @label_template_defaults.fetch('printer_type_names').fetch(printer_type_key),
pmb_template: @label_template_defaults.fetch('pmb_templates').fetch(printer_type_key),
sprint_template: @label_template_defaults.fetch('sprint_templates').fetch(printer_type_key)
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/config.rake
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ namespace :config do

label_template_defaults = label_template_config['defaults_by_printer_type']
label_template_defaults.each_key do |key|
# converting the key to a symbol to keep it consistent with how it was before
configuration[key.to_sym] = label_template_defaults[key.to_s]
# adding 'default_' prefix and converting the key to a symbol, to keep it consistent with how it was before
configuration[('default_' + key).to_sym] = label_template_defaults[key.to_s]
end

configuration[:submission_templates] = submission_templates
Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@
.parse_file(Rails.root.join('config/label_templates.yml'))
.to_ruby
.tap do |label_templates|
Settings.default_pmb_templates = label_templates['defaults_by_printer_type']['default_pmb_templates']
Settings.default_sprint_templates = label_templates['defaults_by_printer_type']['default_sprint_templates']
Settings.default_printer_type_names = label_templates['defaults_by_printer_type']['default_printer_type_names']
Settings.default_pmb_templates = label_templates['defaults_by_printer_type']['pmb_templates']
Settings.default_sprint_templates = label_templates['defaults_by_printer_type']['sprint_templates']
Settings.default_printer_type_names = label_templates['defaults_by_printer_type']['printer_type_names']
end
end

Expand Down

0 comments on commit 1598b6a

Please sign in to comment.