From 9080e458c4367f672b2d0f7a08c2899d405e293d Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 8 Feb 2023 20:37:47 +0200 Subject: [PATCH] debugging eval, weird pipeline cache problems --- dummy/Gemfile | 3 ++- dummy/Gemfile.lock | 5 +--- dummy/app/assets/javascript/opal_main.js.rb | 7 +++++- dummy/app/views/images/show.html.haml | 8 ++++--- dummy/config/application.rb | 1 + dummy/config/boot.rb | 1 - dummy/config/environments/development.rb | 4 ++-- opal/vue_r.rb | 2 +- opal/vue_r/application.rb | 26 +++++++++++++-------- 9 files changed, 34 insertions(+), 23 deletions(-) diff --git a/dummy/Gemfile b/dummy/Gemfile index 6f99b80..7f716c7 100644 --- a/dummy/Gemfile +++ b/dummy/Gemfile @@ -6,9 +6,10 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "vue_r" , path: "../" gem "rails" -gem "bootsnap" , "1.15.0" gem "puma" , "5.6.5" gem "haml-rails" gem "sqlite3" gem "active_hash" + +gem "opal-rails" diff --git a/dummy/Gemfile.lock b/dummy/Gemfile.lock index 3e98957..6333b73 100644 --- a/dummy/Gemfile.lock +++ b/dummy/Gemfile.lock @@ -76,8 +76,6 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) ast (2.4.2) - bootsnap (1.15.0) - msgpack (~> 1.2) builder (3.2.4) concurrent-ruby (1.2.0) crass (1.0.6) @@ -108,7 +106,6 @@ GEM method_source (1.0.0) mini_mime (1.1.2) minitest (5.17.0) - msgpack (1.6.0) net-imap (0.3.4) date net-protocol @@ -196,8 +193,8 @@ PLATFORMS DEPENDENCIES active_hash - bootsnap (= 1.15.0) haml-rails + opal-rails puma (= 5.6.5) rails sqlite3 diff --git a/dummy/app/assets/javascript/opal_main.js.rb b/dummy/app/assets/javascript/opal_main.js.rb index 35fd141..776367e 100644 --- a/dummy/app/assets/javascript/opal_main.js.rb +++ b/dummy/app/assets/javascript/opal_main.js.rb @@ -1 +1,6 @@ -require "vue_r" +require 'opal' +require 'promise' +require 'native' +require 'browser/setup/mini' +require "vue_r/application" +require "vue_r/mounter" diff --git a/dummy/app/views/images/show.html.haml b/dummy/app/views/images/show.html.haml index 9928a52..be3c93d 100644 --- a/dummy/app/views/images/show.html.haml +++ b/dummy/app/views/images/show.html.haml @@ -3,15 +3,17 @@ = #@image.attributes .flex.justify-center - %a.underline{ e_click: "bg_change" , r_class: 'back'} + %a.underline{ e_click: "bg_change" , r_class: 'back(50)'} {{ back }} :opal class Clicker < VueR::Application def bg_change self.state = !self.state end - def back - self.state ? "bg-cyan-50" : "bg-cyan-200" + def back(arg) + puts "Arg:#{arg}:#{arg.class}" + str = self.state ? "bg-cyan-50" : "bg-cyan-200" + str + " " + arg.to_s end end diff --git a/dummy/config/application.rb b/dummy/config/application.rb index 9b9479e..82cac35 100644 --- a/dummy/config/application.rb +++ b/dummy/config/application.rb @@ -1,6 +1,7 @@ require_relative "boot" require "rails/all" +require 'sprockets/railtie' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/dummy/config/boot.rb b/dummy/config/boot.rb index 988a5dd..2820116 100644 --- a/dummy/config/boot.rb +++ b/dummy/config/boot.rb @@ -1,4 +1,3 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/dummy/config/environments/development.rb b/dummy/config/environments/development.rb index 8500f45..1b75218 100644 --- a/dummy/config/environments/development.rb +++ b/dummy/config/environments/development.rb @@ -57,8 +57,8 @@ Rails.application.configure do config.active_record.verbose_query_logs = true # Suppress logger output for asset requests. - config.assets.quiet = true - + config.assets.quiet = false + config.assets.debug = true # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true diff --git a/opal/vue_r.rb b/opal/vue_r.rb index 77eedd7..776367e 100644 --- a/opal/vue_r.rb +++ b/opal/vue_r.rb @@ -1,6 +1,6 @@ require 'opal' -require 'native' require 'promise' +require 'native' require 'browser/setup/mini' require "vue_r/application" require "vue_r/mounter" diff --git a/opal/vue_r/application.rb b/opal/vue_r/application.rb index 974d53d..e657184 100644 --- a/opal/vue_r/application.rb +++ b/opal/vue_r/application.rb @@ -65,27 +65,33 @@ module VueR def send_self(expression) method , args = decompose(expression) - puts "Sending #{method}(#{args.join(',')})" - self.send method , *args + method = method.strip + puts "Sending #{method}(#{args&.join(',')})" + if(args == nil or args.empty?) + self.send( method ) + else + self.send( method , *args ) + end end def decompose(expression) matches = expression.match(/\b[^()]+\((.*)\)$/) - return expression if matches.blank? + return expression if matches.nil? method = expression.split("(").first - return [method , [] ] if m[1].empty? - args = m[1].split(",").collect{| arg | transform_arg(arg) } + puts "METHOD:#{method}" + return [method , [] ] if matches[1].empty? + args = matches[1].split(",").collect{| arg | transform_arg(arg) } return [method , args] end - def transform_arg(arg) - arg = arg.strip - puts "Arg:#{arg}:" + def transform_arg(argument) + arg = argument.strip + #puts "Arg:#{arg}:" return true if arg == "true" return false if arg == "false" return nil if arg == "nil" - return arg.to_i if arg == arg.to_to_s - arg + return arg.to_i if arg == arg.to_i.to_s + return arg end end end