From ab08fcc7c1b84855981bba1eb1a7a40fb861d825 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 31 Jul 2015 19:31:02 +0300 Subject: [PATCH] cleaning, upgrade last pre --- Gemfile | 4 +- Gemfile.lock | 4 +- app/block_view.rb | 49 ------------------- app/class_view.rb | 16 ------- app/debugger.rb | 37 -------------- app/instruction_view.rb | 28 ----------- app/main/controllers/main_controller.rb | 12 +---- {tasks => app/main/tasks}/parse_task.rb | 0 app/register_view.rb | 64 ------------------------- app/source_view.rb | 38 --------------- app/status_view.rb | 41 ---------------- config/initializers/client/phaser.rb | 0 test/helper.rb | 22 --------- 13 files changed, 6 insertions(+), 309 deletions(-) delete mode 100644 app/block_view.rb delete mode 100644 app/class_view.rb delete mode 100644 app/debugger.rb delete mode 100644 app/instruction_view.rb rename {tasks => app/main/tasks}/parse_task.rb (100%) delete mode 100644 app/register_view.rb delete mode 100644 app/source_view.rb delete mode 100644 app/status_view.rb delete mode 100644 config/initializers/client/phaser.rb delete mode 100644 test/helper.rb diff --git a/Gemfile b/Gemfile index 9da153b..242a50f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'volt', '0.9.5.pre3' +gem 'volt', '0.9.5.pre4' # volt uses mongo as the default data store. gem 'volt-mongo', '~> 0.1.0' @@ -16,6 +16,8 @@ gem "susy" , "2.2.5" gem 'csso-rails', '~> 0.3.4', require: false gem 'uglifier', '>= 2.4.0', require: false +#gem "foundation" , :github => "zurb/foundation" + group :test do # Testing dependencies gem "minitest" diff --git a/Gemfile.lock b/Gemfile.lock index edca9c4..444e29c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,7 +137,7 @@ GEM uglifier (2.7.1) execjs (>= 0.3.0) json (>= 1.8.0) - volt (0.9.5.pre3) + volt (0.9.5.pre4) bcrypt (~> 3.1.9) bundler (>= 1.5) concurrent-ruby (= 0.8.0) @@ -180,7 +180,7 @@ DEPENDENCIES susy (= 2.2.5) thin (~> 1.6.0) uglifier (>= 2.4.0) - volt (= 0.9.5.pre3) + volt (= 0.9.5.pre4) volt-mongo (~> 0.1.0) BUNDLED WITH diff --git a/app/block_view.rb b/app/block_view.rb deleted file mode 100644 index 6480cb1..0000000 --- a/app/block_view.rb +++ /dev/null @@ -1,49 +0,0 @@ - -require "instruction_view" - -class BlockView - - include React::Component - required_param :interpreter - - define_state :block => [] - define_state :block_name => "" - - before_mount do - interpreter.register_event(:instruction_changed, self) - update_block - end - - def update_block - return unless interpreter.instruction - block_name! interpreter.block.name - codes = interpreter.block.codes.dup - slice = codes.index(interpreter.instruction) #- 1 - codes.shift( slice ) if slice >= 0 - codes.pop while(codes.length > 4) - block! codes - end - - def instruction_changed - update_block - end - - def render - return unless block - div.block_view do - div do - h4 { method_name} - h4 {"Block: #{block_name}"} - end - block.each do |code| - InstructionView :interpreter => interpreter , :instruction => code - end - end - end - - def method_name - bl = interpreter.block - return bl.method if bl.method.is_a? String - "#{bl.method.for_class.name}.#{bl.method.name}" - end -end diff --git a/app/class_view.rb b/app/class_view.rb deleted file mode 100644 index dd64bde..0000000 --- a/app/class_view.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ClassView - include React::Component - - required_param :classes, type: {} - - def render - div.classes do - h4 { "Classes" } - classes.each do |name , clas| - div.one_class do - clas.name - end - end - end - end -end diff --git a/app/debugger.rb b/app/debugger.rb deleted file mode 100644 index 7fe5060..0000000 --- a/app/debugger.rb +++ /dev/null @@ -1,37 +0,0 @@ - -require "register_view" -require "class_view" -require "source_view" -require "block_view" -require "status_view" - -class Debugger - - include React::Component - required_param :machine , :type => Virtual::Machine - define_state :interpreter => Interpreter.new - - before_mount do - code = Ast::ExpressionList.new( [Ast::CallSiteExpression.new(:putstring, [] ,Ast::StringExpression.new("Hello again"))]) - Virtual::Compiler.compile( code , machine.space.get_main ) - machine.run_before "Register::CallImplementation" - interpreter.start machine.init - end - def render - div.debugger_view do - ClassView classes: machine.space.classes - div.file_view do - "Future Source code view" - end - SourceView :interpreter => interpreter - BlockView :interpreter => interpreter - StatusView :interpreter => interpreter - div.registers_view do - interpreter.registers.each do |r , oid| - RegisterView interpreter: interpreter , register: r - end - end - end - - end -end diff --git a/app/instruction_view.rb b/app/instruction_view.rb deleted file mode 100644 index 5e056f6..0000000 --- a/app/instruction_view.rb +++ /dev/null @@ -1,28 +0,0 @@ - - -class InstructionView - - include React::Component - required_param :interpreter - required_param :instruction - - define_state :active => "" - - before_mount do - check_active interpreter.instruction - end - - def check_active i - active! instruction == i ? "bright" : "" - - end - def instruction_changed old , ins - check_active ins - end - - def render - div :class => active do - instruction.to_s if instruction - end - end -end diff --git a/app/main/controllers/main_controller.rb b/app/main/controllers/main_controller.rb index 1c17989..8b4d5a6 100644 --- a/app/main/controllers/main_controller.rb +++ b/app/main/controllers/main_controller.rb @@ -15,7 +15,6 @@ module Main def index init_machine init_classes - init_registers init_blocks init_source end @@ -34,16 +33,7 @@ module Main page._interpreter = { } @volt_app.interpreter.start machine.init end - def init_registers - page._registers!.clear - @volt_app.interpreter.registers.each do |reg , val| - model = RegisterModel.new( :name => reg , :value => val) - page._registers << model - @volt_app.interpreter.register_event(:register_changed, model) - @volt_app.interpreter.register_event(:object_changed, model) - model.register_changed( reg , nil , @volt_app.interpreter.registers[reg]) - end - end + def init_classes page._classes!.clear Virtual.machine.space.classes.each do |name , claz| diff --git a/tasks/parse_task.rb b/app/main/tasks/parse_task.rb similarity index 100% rename from tasks/parse_task.rb rename to app/main/tasks/parse_task.rb diff --git a/app/register_view.rb b/app/register_view.rb deleted file mode 100644 index c2b700f..0000000 --- a/app/register_view.rb +++ /dev/null @@ -1,64 +0,0 @@ - -class RegisterView - - include React::Component - required_param :interpreter - required_param :register - - define_state :objects_id - define_state :fields => [] - - before_mount do - interpreter.register_event(:register_changed, self) - interpreter.register_event(:object_changed, self) - register_changed( register , nil , interpreter.registers[register]) - end - - def register_changed reg , old , value - reg = reg.symbol unless reg.is_a? Symbol - return unless reg == register - objects_id! value - calc_fields - end - - def object_changed reg - reg = reg.symbol unless reg.is_a? Symbol - return unless reg == register - #puts "Object changed in #{reg}" - calc_fields - end - - def calc_fields - #puts "My id #{objects_id} , #{objects_id.class}" - object = Virtual.machine.objects[objects_id] - if object and ! object.is_a?(String) - has_fields = [] - clazz = object.class.name.split("::").last - #puts "found #{clazz}" - has_fields << clazz - object.get_instance_variables.each do |variable| - f = object.get_instance_variable(variable) - has_fields << f - end - fields! has_fields - end - end - - def render - div.register_view do - div do - objects_id.to_s - end - fields.each do |attribute| - div.col_md_12 do - "#{marker(attribute)} - #{attribute.object_id}".span - end - end - end - end - - def marker var - return "W" if var.is_a? String - var.class.name.split("::").last[0] - end -end diff --git a/app/source_view.rb b/app/source_view.rb deleted file mode 100644 index 3efbb68..0000000 --- a/app/source_view.rb +++ /dev/null @@ -1,38 +0,0 @@ -class SourceView - - include React::Component - - required_param :interpreter - - define_state :sources => [] - - before_mount do - interpreter.register_event(:instruction_changed, self) - instruction_changed nil , interpreter.instruction - end - - def instruction_changed old , ins - text = ins ? source_text(ins.source) : "exit" - return if sources.last == text - sources << text - sources.shift if sources.length > 5 - sources! sources - end - - def render - div.source_view do - h4 {"Virtual Machine Instruction"} - sources.each do |s| - s.br - end - end - end - - def source_text source - if source.is_a? Virtual::Instruction - return source.class.name - else - return "Method: #{source.name}" - end - end -end diff --git a/app/status_view.rb b/app/status_view.rb deleted file mode 100644 index f9b2453..0000000 --- a/app/status_view.rb +++ /dev/null @@ -1,41 +0,0 @@ - -class StatusView - - include React::Component - required_param :interpreter - - define_state :state => "starting" - define_state :stdout - - before_mount do - interpreter.register_event(:instruction_changed, self) - end - - def update_state - state! interpreter.state - stdout! interpreter.stdout - end - - def instruction_changed old , nex - update_state - end - - def render - div.status_view do - div do - button.bright { "next" }.on(:click) { interpreter.tick } - " ".br - end - div do - h4 {"Status:"} - state.to_s.br - end - div do - h4 {"Stdout:"} - end - div do - interpreter.stdout.br - end - end - end -end diff --git a/config/initializers/client/phaser.rb b/config/initializers/client/phaser.rb deleted file mode 100644 index e69de29..0000000 diff --git a/test/helper.rb b/test/helper.rb deleted file mode 100644 index 4e2cf3f..0000000 --- a/test/helper.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rubygems' -require 'bundler' - -begin - Bundler.setup(:default, :test) -rescue Bundler::BundlerError => e - $stderr.puts e.message - $stderr.puts "Run `bundle install` to install missing gems" - exit e.status_code -end -if ENV['CODECLIMATE_REPO_TOKEN'] - require "codeclimate-test-reporter" - CodeClimate::TestReporter.start -end - -require "minitest/autorun" - -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', "app" , "main",'lib')) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test')) - -require "salama" -require "interpreter"