From 8d6e78c53f9c6b6c5f15144c93d054eab77d951e Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 16 Apr 2018 20:36:16 +0300 Subject: [PATCH] adding debugger and opal rails --- Gemfile | 9 +++- Gemfile.lock | 61 ++++++++++++++++++++++++-- app/assets/javascripts/debug.js.rb | 3 ++ app/assets/stylesheets/debug.css | 4 ++ app/controllers/debugger_controller.rb | 6 +++ app/views/debugger/index.html.haml | 7 +++ config/application.rb | 6 +++ config/initializers/assets.rb | 14 +++--- config/initializers/debugger.rb | 2 + config/routes.rb | 2 + 10 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/debug.js.rb create mode 100644 app/assets/stylesheets/debug.css create mode 100644 app/controllers/debugger_controller.rb create mode 100644 app/views/debugger/index.html.haml create mode 100644 config/initializers/debugger.rb diff --git a/Gemfile b/Gemfile index de56e3e..fff3d32 100644 --- a/Gemfile +++ b/Gemfile @@ -11,8 +11,13 @@ gem "haml-rails" gem "susy" , "2.2.12" gem 'high_voltage' -gem "kramdown" -gem "maruku" + +gem 'opal-rails' +gem 'opal-browser' +gem "rubyx-debugger" , "0.3" , path: "../rubyx-debugger" , require: false +gem "rubyx" , "0.6" , :path => "../rubyx" , require: false +gem "rx-file" , :git => "https://github.com/ruby-x/rx-file" + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] diff --git a/Gemfile.lock b/Gemfile.lock index 917b8f2..c603fb1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,21 @@ +GIT + remote: https://github.com/ruby-x/rx-file + revision: c1de10352d8af105fe532008ceafcdd30b5fbdab + specs: + rx-file (0.3.0) + +PATH + remote: ../rubyx-debugger + specs: + rubyx-debugger (0.3) + +PATH + remote: ../rubyx + specs: + rubyx (0.6.0) + parser (~> 2.3.0) + rx-file (~> 0.3) + GEM remote: https://rubygems.org/ specs: @@ -45,6 +63,7 @@ GEM addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) arel (9.0.0) + ast (2.4.0) bindex (0.5.0) builder (3.2.3) byebug (10.0.2) @@ -77,6 +96,7 @@ GEM html2haml (>= 1.0.1) railties (>= 4.0.1) high_voltage (3.0.0) + hike (1.2.3) html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) @@ -84,7 +104,10 @@ GEM ruby_parser (~> 3.5) i18n (1.0.0) concurrent-ruby (~> 1.0) - kramdown (1.16.2) + jquery-rails (4.3.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) launchy (2.4.3) addressable (~> 2.3) listen (3.1.5) @@ -98,7 +121,6 @@ GEM mini_mime (>= 0.1.1) marcel (0.3.2) mimemagic (~> 0.3.2) - maruku (0.7.3) method_source (0.9.0) mimemagic (0.3.2) mini_mime (1.0.0) @@ -107,6 +129,33 @@ GEM nio4r (2.3.0) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) + opal (0.10.5) + hike (~> 1.2) + sourcemap (~> 0.1.0) + sprockets (~> 3.1) + tilt (>= 1.4) + opal-activesupport (0.3.1) + opal (>= 0.5.0, < 1.0.0) + opal-browser (0.2.0) + opal + paggio + opal-jquery (0.4.2) + opal (>= 0.7.0, < 0.11.0) + opal-rails (0.9.4) + jquery-rails + opal (>= 0.10.0, < 0.12) + opal-activesupport (>= 0.0.5) + opal-jquery (~> 0.4.0) + opal-sprockets (~> 0.4.1) + rails (>= 4.1, < 6.0) + sprockets-rails (>= 2.3.3, < 4.0) + opal-sprockets (0.4.1.0.10.4.3.1.0) + opal (~> 0.10.4) + sprockets (~> 3.1) + tilt (>= 1.4) + paggio (0.2.6) + parser (2.3.3.1) + ast (~> 2.2) public_suffix (3.0.2) puma (3.11.3) rack (2.0.4) @@ -168,6 +217,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) sexp_processor (4.11.0) + sourcemap (0.1.1) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -211,12 +261,15 @@ DEPENDENCIES capybara-screenshot haml-rails high_voltage - kramdown listen (>= 3.0.5, < 3.2) - maruku + opal-browser + opal-rails puma (~> 3.11) rails rspec-rails + rubyx (= 0.6)! + rubyx-debugger (= 0.3)! + rx-file! sass-rails spring spring-watcher-listen (~> 2.0.0) diff --git a/app/assets/javascripts/debug.js.rb b/app/assets/javascripts/debug.js.rb new file mode 100644 index 0000000..8e5bd70 --- /dev/null +++ b/app/assets/javascripts/debug.js.rb @@ -0,0 +1,3 @@ +require "opal" + +require "debugger" diff --git a/app/assets/stylesheets/debug.css b/app/assets/stylesheets/debug.css new file mode 100644 index 0000000..2b0d526 --- /dev/null +++ b/app/assets/stylesheets/debug.css @@ -0,0 +1,4 @@ +/* +*= require css/menu +*= require css/app +*/ diff --git a/app/controllers/debugger_controller.rb b/app/controllers/debugger_controller.rb new file mode 100644 index 0000000..433cdf9 --- /dev/null +++ b/app/controllers/debugger_controller.rb @@ -0,0 +1,6 @@ +class DebuggerController < ApplicationController + + def index + render layout: false + end +end diff --git a/app/views/debugger/index.html.haml b/app/views/debugger/index.html.haml new file mode 100644 index 0000000..b5e0b05 --- /dev/null +++ b/app/views/debugger/index.html.haml @@ -0,0 +1,7 @@ +!!! +%html + %head + %title Debugger + = stylesheet_link_tag 'debug', media: 'all' + %body + = javascript_include_tag "debug" diff --git a/config/application.rb b/config/application.rb index f662d6b..e02acd9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,5 +18,11 @@ module RubyxWebpage config.assets.paths << Gem.loaded_specs['susy'].full_gem_path+'/sass' config.blog_path = Rails.root.to_s + "/app/views/posts" + + config.assets.configure do |env| + env.cache = ActiveSupport::Cache.lookup_store(:memory_store, + { size: 64.megabytes }) + end + end end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 4b828e8..2e0b872 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,12 +3,16 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') +Rails.application.config.opal.method_missing = true +Rails.application.config.opal.optimized_operators = true +Rails.application.config.opal.arity_check = !Rails.env.production? +Rails.application.config.opal.const_missing = true +Rails.application.config.opal.dynamic_require_severity = :ignore # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. -# Rails.application.config.assets.precompile += %w( admin.js admin.css ) +Rails.application.config.assets.precompile += %w( debug.js debug.css) + +Rails.application.config.assets.paths << "#{Gem.loaded_specs["rubyx-debugger"].gem_dir}/assets/" +Rails.application.config.assets.paths << "#{Gem.loaded_specs["rubyx-debugger"].gem_dir}/lib/" diff --git a/config/initializers/debugger.rb b/config/initializers/debugger.rb new file mode 100644 index 0000000..93ff9bb --- /dev/null +++ b/config/initializers/debugger.rb @@ -0,0 +1,2 @@ +Opal.use_gem("rubyx") +Opal.use_gem("ast") diff --git a/config/routes.rb b/config/routes.rb index 5dfccda..92eeb7f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,8 @@ Rails.application.routes.draw do root to: 'high_voltage/pages#show' , id: 'index' + get "/debugger" , to: "debugger#index" , as: :debugger_index + get "/blog" , to: "blog#index" , as: :blog_index get "/blog/*title" , to: "blog#post" , as: :blog_post