From 390c1e8326acd6d643fb1221a57e18e662fd6efd Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Thu, 6 Apr 2017 13:34:55 -0500 Subject: [PATCH] Possible fix for `settings saved` bug --- app/models/celery_script_settings_bag.rb | 9 ++++++++- latest_corpus.rb | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/celery_script_settings_bag.rb b/app/models/celery_script_settings_bag.rb index 7580489b9..5a53128e3 100644 --- a/app/models/celery_script_settings_bag.rb +++ b/app/models/celery_script_settings_bag.rb @@ -7,6 +7,7 @@ module CeleryScriptSettingsBag DIGITAL, ANALOG = 0, 1 ALLOWED_PIN_MODES = [DIGITAL, ANALOG] + ALLOWED_VAR_TYPES = %w(location) ALLOWED_RPC_NODES = %w(home emergency_lock emergency_unlock read_status sync check_updates power_off reboot toggle_pin config_update calibrate execute move_absolute @@ -41,9 +42,14 @@ module CeleryScriptSettingsBag BAD_TOOL_ID = 'Tool #%s does not exist.' BAD_PACKAGE = '"%s" is not a valid package. Allowed values: %s' BAD_AXIS = '"%s" is not a valid axis. Allowed values: %s' - + BAD_VAR_TYPE = '"%s" is not a valid type. Allowed values: %s' Corpus = CeleryScript::Corpus .new + .defineArg(:var_type, [String]) do |node| + within(ALLOWED_VAR_TYPES, node) do |val| + BAD_VAR_TYPE % [val.to_s, ALLOWED_VAR_TYPES.inspect] + end + end .defineArg(:pin_mode, [Fixnum]) do |node| within(ALLOWED_PIN_MODES, node) do |val| BAD_ALLOWED_PIN_MODES % [val.to_s, ALLOWED_PIN_MODES.inspect] @@ -147,6 +153,7 @@ module CeleryScriptSettingsBag .defineNode(:add_point, [:location], [:pair]) .defineNode(:take_photo, [], []) .defineNode(:data_update, [:value], [:pair]) + .defineNode(:variable, [:var_type, :label], []) # Given an array of allowed values and a CeleryScript AST node, will DETERMINE # if the node contains a legal value. Throws exception and invalidates if not. diff --git a/latest_corpus.rb b/latest_corpus.rb index ecfbe6b93..128111d72 100755 --- a/latest_corpus.rb +++ b/latest_corpus.rb @@ -139,5 +139,6 @@ result.push(enum_type :LegalKindString, HASH[:nodes].map{ |x| x[:name] }.sort.un result.push(enum_type :LegalSequenceKind, CeleryScriptSettingsBag::STEPS.sort) result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES) result.push(enum_type :ResourceName, CeleryScriptSettingsBag::RESOURCE_NAME) +result.push(enum_type :BindingType, CeleryScriptSettingsBag::ALLOWED_VAR_TYPES) puts result.join.gsub("\n\n\n", "\n")