Skip to content

Commit

Permalink
Merge pull request #36 from kirillplatonov/standard-rb
Browse files Browse the repository at this point in the history
Setup Standard RB
  • Loading branch information
kirillplatonov authored Mar 19, 2023
2 parents dc5bb50 + a834e50 commit f38ce76
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 19 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
pull_request:
branches:
- '*'
push:
branches:
- main

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: StandardRb check
run: bundle exec standardrb
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source 'https://rubygems.org'
git_source(:github) { |repo| 'https://github.com/#{repo}.git' }
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec

gem "standard"
34 changes: 34 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
builder (3.2.4)
concurrent-ruby (1.2.2)
crass (1.0.6)
Expand All @@ -83,6 +84,8 @@ GEM
activesupport (>= 5.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -110,6 +113,11 @@ GEM
nio4r (2.5.8)
nokogiri (1.14.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.2-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.2.1.1)
ast (~> 2.4.1)
racc (1.6.2)
rack (2.2.6.4)
rack-test (2.1.0)
Expand Down Expand Up @@ -140,14 +148,38 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.7.0)
rexml (3.2.5)
rubocop (1.48.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.26.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.27.0)
parser (>= 3.2.1.0)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
standard (1.25.1)
language_server-protocol (~> 3.17.0.2)
rubocop (= 1.48.1)
rubocop-performance (= 1.16.0)
thor (1.2.1)
timeout (0.3.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -157,9 +189,11 @@ PLATFORMS
arm64-darwin-20
arm64-darwin-21
arm64-darwin-22
x86_64-linux

DEPENDENCIES
hotwire-livereload!
standard

BUNDLED WITH
2.4.8
4 changes: 2 additions & 2 deletions app/helpers/hotwire/livereload/livereload_tags_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Hotwire::Livereload::LivereloadTagsHelper
def hotwire_livereload_tags
partial = if Hotwire::Livereload::Engine.config.hotwire_livereload.reload_method == :turbo_stream
'hotwire/livereload/head_turbo_stream'
"hotwire/livereload/head_turbo_stream"
else
'hotwire/livereload/head_action_cable'
"hotwire/livereload/head_action_cable"
end

render partial
Expand Down
14 changes: 7 additions & 7 deletions hotwire-livereload.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require_relative "lib/hotwire/livereload/version"

Gem::Specification.new do |spec|
spec.name = "hotwire-livereload"
spec.version = Hotwire::Livereload::VERSION
spec.authors = ["Kirill Platonov"]
spec.email = ["mail@kirillplatonov.com"]
spec.homepage = "https://github.com/kirillplatonov/hotwire-livereload"
spec.summary = "Automatically reload Hotwire Turbo when app files are modified."
spec.license = "MIT"
spec.name = "hotwire-livereload"
spec.version = Hotwire::Livereload::VERSION
spec.authors = ["Kirill Platonov"]
spec.email = ["mail@kirillplatonov.com"]
spec.homepage = "https://github.com/kirillplatonov/hotwire-livereload"
spec.summary = "Automatically reload Hotwire Turbo when app files are modified."
spec.license = "MIT"

spec.files = Dir["{app,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

Expand Down
8 changes: 4 additions & 4 deletions lib/hotwire/livereload/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class Engine < ::Rails::Engine
config.hotwire_livereload.force_reload_paths ||= []
config.hotwire_livereload.reload_method = :action_cable
config.hotwire_livereload.disable_default_listeners = false
config.autoload_once_paths = %W(
config.autoload_once_paths = %W[
#{root}/app/channels
#{root}/app/helpers
)
]

initializer "hotwire_livereload.assets" do
if Rails.application.config.respond_to?(:assets)
Rails.application.config.assets.precompile += %w( hotwire-livereload.js hotwire-livereload-turbo-stream.js)
Rails.application.config.assets.precompile += %w[hotwire-livereload.js hotwire-livereload-turbo-stream.js]
end
end

Expand Down Expand Up @@ -55,7 +55,7 @@ class Engine < ::Rails::Engine
@listener = Listen.to(*listen_paths) do |modified, added, removed|
unless File.exist?(DISABLE_FILE)
changed = [modified, removed, added].flatten.uniq
return unless changed.any?
next unless changed.any?

force_reload = force_reload_paths.present? && changed.any? do |path|
path.match(%r{#{force_reload_paths}})
Expand Down
6 changes: 3 additions & 3 deletions lib/install/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

if APP_LAYOUT_PATH.exist?
say "Add Hotwire Livereload tag in application layout"
content = <<-HTML
\n <%= hotwire_livereload_tags if Rails.env.development? %>
HTML
content = <<~HTML
\n <%= hotwire_livereload_tags if Rails.env.development? %>
HTML
insert_into_file APP_LAYOUT_PATH, content.chop, before: /\s*<\/head>/
else
say "Default application.html.erb is missing!", :red
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/livereload_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace :livereload do
desc "Install Hotwire::Livereload into the app"
task :install do
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
end

desc "Disable Hotwire::Livereload"
Expand Down

0 comments on commit f38ce76

Please sign in to comment.