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