From 5bd6b3517d403ad5776d17fbd169f3c22dfde4f8 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 31 Jul 2015 11:42:26 +0300 Subject: [PATCH] made view component out of register view --- app/main/controllers/registers_controller.rb | 26 ++++++++++++++++++++ app/main/views/main/index.html | 19 +------------- app/main/views/registers/index.html | 21 ++++++++++++++++ spec/app/main/integration/registers_spec.rb | 5 ++++ 4 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 app/main/controllers/registers_controller.rb create mode 100644 app/main/views/registers/index.html create mode 100644 spec/app/main/integration/registers_spec.rb diff --git a/app/main/controllers/registers_controller.rb b/app/main/controllers/registers_controller.rb new file mode 100644 index 0000000..d73ff0a --- /dev/null +++ b/app/main/controllers/registers_controller.rb @@ -0,0 +1,26 @@ +module Main + class RegistersController < Volt::ModelController + + def initialize app , context + super(app , context) + self.model = [] + init_registers attrs.interpreter + end + + def init_registers interpreter + interpreter.registers.each do |reg , val| + r = RegisterModel.new( :name => reg , :value => val) + self.model << r + interpreter.register_event(:register_changed, r) + interpreter.register_event(:object_changed, r) + r.register_changed( reg , nil , interpreter.registers[reg]) + end + end + + def marker var + return "W" if var.is_a? String + var.class.name.split("::").last[0] + end + + end +end diff --git a/app/main/views/main/index.html b/app/main/views/main/index.html index a6ea57e..b834c92 100644 --- a/app/main/views/main/index.html +++ b/app/main/views/main/index.html @@ -12,7 +12,6 @@
- Future Source code view
@@ -50,20 +49,4 @@ {{page._interpreter._stdout}}
-
- {{ page._registers.each do |reg| }} -
-
- {{ reg.name }} -
-
- {{ reg.value }} -
- {{ reg.fields.each do |attribute| }} -
- {{marker(attribute)}} {{attribute.object_id}} -
- {{end}} -
- {{end}} -
+ <:registers interpreter="{{ @interpreter }}"/> diff --git a/app/main/views/registers/index.html b/app/main/views/registers/index.html new file mode 100644 index 0000000..94e0570 --- /dev/null +++ b/app/main/views/registers/index.html @@ -0,0 +1,21 @@ +<:Title> + registers index + +<:Body> +
+ {{ model.each do |reg| }} +
+
+ {{ reg.name }} +
+
+ {{ reg.value }} +
+ {{ reg.fields.each do |attribute| }} +
+ {{marker(attribute)}} {{attribute.object_id}} +
+ {{end}} +
+ {{end}} +
diff --git a/spec/app/main/integration/registers_spec.rb b/spec/app/main/integration/registers_spec.rb new file mode 100644 index 0000000..f8c4990 --- /dev/null +++ b/spec/app/main/integration/registers_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe '', type: :feature do + # Specs here +end