make own dummy, less confusing what is gem/engine and what is app

This commit is contained in:
Torsten 2023-02-08 17:18:57 +02:00
parent ad237c3afb
commit 951ced7734
84 changed files with 255 additions and 90 deletions

10
.gitignore vendored
View File

@ -3,8 +3,8 @@
/log/*.log
/pkg/
/tmp/
/test/dummy/db/*.sqlite3
/test/dummy/db/*.sqlite3-*
/test/dummy/log/*.log
/test/dummy/storage/
/test/dummy/tmp/
/dummy/db/*.sqlite3
/dummy/db/*.sqlite3-*
/dummy/log/*.log
/dummy/storage/
/dummy/tmp/

View File

@ -3,7 +3,8 @@
VueR is a Vue.js inspired reactive frontend framework in ruby. It allows for the same kind of
declaritive change management as vue, albeit in smaller scope. Many vue-like features
work, and work continues, but this will the current scope is personal.
work, and work continues, but the current scope is personal, so it's not meant as
a vue.js replacement.
## Usage

View File

@ -1,14 +0,0 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.
ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path("../lib/vue_r/engine", __dir__)
APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
require "rails/all"
require "rails/engine/commands"

1
dummy/.ruby-version Normal file
View File

@ -0,0 +1 @@
3.0.4

View File

@ -2,15 +2,13 @@ source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Specify your gem's dependencies in vue_r.gemspec.
gemspec
gem "vue_r" , path: "../"
gem "rails"
gem "sprockets-rails"
gem "bootsnap" , "1.15.0"
gem "puma" , "5.6.5"
gem "haml-rails"
gem "sqlite3"
gem "active_hash"
gem "opal-rails"
# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"

View File

@ -1,5 +1,5 @@
PATH
remote: .
remote: ..
specs:
vue_r (0.1.0)
opal-browser (>= 0.3.0)
@ -76,6 +76,8 @@ 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)
@ -106,6 +108,7 @@ 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
@ -193,11 +196,10 @@ PLATFORMS
DEPENDENCIES
active_hash
bootsnap (= 1.15.0)
haml-rails
opal-rails
puma (= 5.6.5)
rails
sprockets-rails
sqlite3
vue_r!

24
dummy/README.md Normal file
View File

@ -0,0 +1,24 @@
# README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...

View File

@ -0,0 +1,3 @@
//= require opal_main
Opal.require('opal_main');

View File

@ -0,0 +1 @@
require "vue_r"

View File

@ -2,11 +2,11 @@
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* compiled file so the styles you add here take precedence over styles defined in any other CSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*

View File

@ -1,3 +1,2 @@
class ApplicationController < ActionController::Base
helper OpalHelper
end

View File

@ -0,0 +1,3 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"

View File

@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
export { application }

View File

@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}

View File

@ -0,0 +1,11 @@
// Import and register all your controllers from the importmap under controllers/*
import { application } from "controllers/application"
// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
// lazyLoadControllersFrom("controllers", application)

View File

@ -6,6 +6,7 @@
%a.underline{ e_click: "bg_change" , r_class: 'back'}
{{ back }}
:opal
puts "here1"
class Clicker < VueR::Application
def bg_change
self.state = !self.state
@ -15,5 +16,8 @@
end
end
kanta = Clicker.new(bg: 'bg-cyan-200' , state: true)
kanta.mount("#app")
puts "here2"
click = Clicker.new(bg: 'bg-cyan-200' , state: true)
click.mount("#app")
puts "here3"

View File

@ -7,7 +7,7 @@
<%= csp_meta_tag %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "dummy" %>
<%= javascript_include_tag "application" %>
</head>
<body>

114
dummy/bin/bundle Executable file
View File

@ -0,0 +1,114 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'bundle' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require "rubygems"
m = Module.new do
module_function
def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
end
def env_var_version
ENV["BUNDLER_VERSION"]
end
def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
update_index = i
end
bundler_version
end
def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?
File.expand_path("../Gemfile", __dir__)
end
def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end
def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end
def bundler_requirement
@bundler_requirement ||=
env_var_version || cli_arg_version ||
bundler_requirement_for(lockfile_version)
end
def bundler_requirement_for(version)
return "#{Gem::Requirement.default}.a" unless version
bundler_gem_version = Gem::Version.new(version)
requirement = bundler_gem_version.approximate_recommendation
return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
requirement += ".a" if bundler_gem_version.prerelease?
requirement
end
def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile
activate_bundler
end
def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end
def activation_error_handling
yield
nil
rescue StandardError, LoadError => e
e
end
end
m.load_bundler!
if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end

4
dummy/bin/importmap Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative "../config/application"
require "importmap/commands"

View File

@ -1,19 +1,15 @@
require_relative "boot"
require "rails/all"
require "vue_r/engine"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "vue_r"
module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
# For compatibility with applications that use this config
config.action_controller.include_all_helpers = false
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#

4
dummy/config/boot.rb Normal file
View File

@ -0,0 +1,4 @@
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.

View File

@ -0,0 +1 @@
xJzmq1Pw1x72vwQAg22RHDysAIra3RSk3F094+9xgpG7ncrRdp4jFujPvmkopWmRRNd9KbGrVvQOKsTDk+oNXFOBvS5HGpS1vPAVZZD7CtHFnK5I7LrzTqp6zKgPUFTuoJ4LNCRhpH25EvTPRYSRuQvnDzd+kB5Qm3OfK3mrrtOkyB/LwIvdy8OSFOWGh02arvz3blGFu7rkJbCxL9agVPTzeB8z08dS3cqURn+XeyBpiwOm+YXsX44jn8vMjlzF0eNwfVcVkcWxODlLfZAa0uqoZblu24dGFSSBwiEMXZPFBxvK0/6uJZgI+WtxMXHdbTeZkKZlONvnpJ78c7oywVrrKGHBaN3lKiwwutLvbYzh4DbTEgQ7mNKPgpvhrkIC4lihDcIv4h7PtgzGYteu2Qt9ay6LzlqG2vmp--u+1vnLC+O6PtJ7gf--lY0+OprIHTdx59wgIuqNfQ==

View File

@ -0,0 +1,7 @@
# Pin npm packages by running ./bin/importmap
pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"

1
dummy/config/master.key Normal file
View File

@ -0,0 +1 @@
1de93911f6ced9a733304cb90579fc18

7
dummy/db/seeds.rb Normal file
View File

@ -0,0 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)

0
dummy/public/favicon.ico Normal file
View File

1
dummy/public/robots.txt Normal file
View File

@ -0,0 +1 @@
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file

View File

@ -0,0 +1,5 @@
require "test_helper"
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
end

View File

@ -0,0 +1,11 @@
require "test_helper"
class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
# test "connects with cookies" do
# cookies.signed[:user_id] = 42
#
# connect
#
# assert_equal connection.user_id, "42"
# end
end

View File

0
dummy/test/fixtures/files/.keep vendored Normal file
View File

0
dummy/test/helpers/.keep Normal file
View File

View File

0
dummy/test/mailers/.keep Normal file
View File

0
dummy/test/models/.keep Normal file
View File

0
dummy/test/system/.keep Normal file
View File

13
dummy/test/test_helper.rb Normal file
View File

@ -0,0 +1,13 @@
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
class ActiveSupport::TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end

View File

@ -1,21 +0,0 @@
require "opal"
require "native"
require 'promise'
require 'opal-parser'
require 'browser/setup/mini'
require "vue_r/application"
require "vue_r/mounter"
puts "hello world!"
# Uncomment the following to print out you're hello-world with Opal:
#
#
# The following will append a hello-world to your <body> element:
#
# require "native"
# $$[:document].addEventListener :DOMContentLoaded do
# $$[:document][:body][:innerHTML] += '<h2>Hello World!</h2>'
# end

View File

@ -1,5 +0,0 @@
# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)

View File

@ -1,22 +0,0 @@
# Check out the full list of the available configuration options at
# https://github.com/opal/opal/blob/master/lib/opal/config.rb
Rails.application.configure do
# We suggest keeping the configuration above as default for all environments,
# disabling some of them might slightly reduce the bundle size or reduce performance
# by degrading some ruby features.
config.opal.method_missing_enabled = true
config.opal.const_missing_enabled = true
config.opal.arity_check_enabled = true
config.opal.freezing_stubs_enabled = true
config.opal.dynamic_require_severity = :ignore
# To enable passing assigns from the controller to the opal template handler
# change the following configuration to one of these values:
#
# - true # both locals and instance variables
# - :locals # only locals
# - :ivars # only instance variables
#
config.opal.assigns_in_templates = false
end