diff --git a/rails/app/models/batch.rb b/rails/app/models/batch.rb index b746ddf..152c248 100644 --- a/rails/app/models/batch.rb +++ b/rails/app/models/batch.rb @@ -3,8 +3,4 @@ class Batch < ApplicationRecord has_many :menu_options has_many :wheel_options has_many :key_binds - - def render - actions.collect(&:render).join("; ") - end end diff --git a/rails/app/models/execution.rb b/rails/app/models/execution.rb index 3d0fd35..9ac6e09 100644 --- a/rails/app/models/execution.rb +++ b/rails/app/models/execution.rb @@ -1,7 +1,6 @@ class Execution < ApplicationRecord belongs_to :command has_many :actions - has_one :execution, ->(o){Execution.find(o.value)} def execution Execution.find(value) diff --git a/rails/app/models/setup.rb b/rails/app/models/setup.rb index 917d57e..495f767 100644 --- a/rails/app/models/setup.rb +++ b/rails/app/models/setup.rb @@ -3,10 +3,4 @@ class Setup < ApplicationRecord has_many :wheels has_many :menus has_many :input_devices - - def render - key_binds.collect { |key_bind| - %(alias batch#{id} \"#{key_bind.batch.render}\"\nbind #{key_bind.key.ingame} batch#{id}) - }.join("\n") - end end diff --git a/rails/db/migrate/20221127130223_create_keys.rb b/rails/db/migrate/20221127130223_create_keys.rb index 9fe2458..5cb0c3f 100644 --- a/rails/db/migrate/20221127130223_create_keys.rb +++ b/rails/db/migrate/20221127130223_create_keys.rb @@ -52,6 +52,7 @@ class CreateKeys < ActiveRecord::Migration[7.0] t.string :name t.string :regex t.integer :specifity + t.boolean :is_nestable, null: false t.timestamps end diff --git a/rails/db/schema.rb b/rails/db/schema.rb index eec76c3..73097dd 100644 --- a/rails/db/schema.rb +++ b/rails/db/schema.rb @@ -43,6 +43,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_27_130223) do t.string "name" t.string "regex" t.integer "specifity" + t.boolean "is_nestable", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end diff --git a/rails/db/seeds.rb b/rails/db/seeds.rb index a484b20..0837470 100644 --- a/rails/db/seeds.rb +++ b/rails/db/seeds.rb @@ -317,16 +317,32 @@ keys.each do |key| end { - 'none' => /^$/, - 'command' => /^.*$/, - 'string' => /^.*$/, - 'integer' => /^\d+$/, - 'float' => /^\d+(?:\.\d+)|\.\d+$/, -}.each_with_index do |(name, regex), i| + 'none' => { + regex: /^$/, + is_nestable: true, + }, + 'command' => { + regex: /^.*$/, + is_nestable: false, + }, + 'string' => { + regex: /^.*$/, + is_nestable: false, + }, + 'integer' => { + regex: /^\d+$/, + is_nestable: true, + }, + 'float' => { + regex: /^\d+(?:\.\d+)|\.\d+$/, + is_nestable: true, + }, +}.each_with_index do |(name, conf), i| Datatype .find_or_initialize_by(name: name) .update!({ - regex: regex.to_s, + regex: conf[:regex].to_s, + is_nestable: conf[:is_nestable], specifity: i, }) end @@ -379,6 +395,7 @@ Setup command: Command.find_by!( datatype: Datatype.find_by!(name: 'float'), ), + value: 2.0, ), ) )