Skip to content

Commit 3311b9a

Browse files
author
Matthew Saginario
committed
some rubocop cleanup
1 parent fd35d7b commit 3311b9a

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

ruby/rails-hyperstack/lib/generators/hyperstack/install_generator.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def add_hotloader
2525
unless Hyperstack.imported? 'hyperstack/hotloader'
2626
inject_into_initializer(
2727
"Hyperstack.import 'hyperstack/hotloader', "\
28-
"client_only: true if Rails.env.development?"
28+
'client_only: true if Rails.env.development?'
2929
)
3030
end
3131
create_file 'Procfile', <<-TEXT
@@ -80,7 +80,6 @@ def add_webpacker_manifests
8080
config.assets.paths << Rails.root.join('public', 'packs-test', 'js').to_s
8181
RUBY
8282
end
83-
8483
end
8584

8685
def add_webpacks
@@ -98,23 +97,23 @@ def cancel_react_source_import
9897
return if skip_webpack?
9998
inject_into_initializer(
10099
"Hyperstack.cancel_import 'react/react-source-browser' "\
101-
"# bring your own React and ReactRouter via Yarn/Webpacker"
100+
'# bring your own React and ReactRouter via Yarn/Webpacker'
102101
)
103102
end
104103

105104
def install_webpacker
106105
return if skip_webpack?
107106
gem 'webpacker'
108107
Bundler.with_clean_env do
109-
run "bundle install"
108+
run 'bundle install'
110109
end
111110
run 'bundle exec rails webpacker:install'
112111
end
113112

114113
def create_policies_directory
115114
return if skip_hyper_model?
116115
policy_file = File.join('app', 'policies', 'application_policy.rb')
117-
unless File.exists? policy_file
116+
unless File.exist? policy_file
118117
create_file policy_file, <<-RUBY
119118
# #{policy_file}
120119
@@ -141,7 +140,7 @@ def move_and_update_application_record
141140
return if skip_hyper_model?
142141
rails_app_record_file = File.join('app', 'models', 'application_record.rb')
143142
hyper_app_record_file = File.join('app', 'hyperstack', 'models', 'application_record.rb')
144-
unless File.exists? hyper_app_record_file
143+
unless File.exist? hyper_app_record_file
145144
empty_directory File.join('app', 'hyperstack', 'models')
146145
`mv #{rails_app_record_file} #{hyper_app_record_file}`
147146
create_file rails_app_record_file, <<-RUBY
@@ -162,24 +161,24 @@ def add_engine_route
162161
def report
163162
say "\n\n"
164163
unless skip_adding_component?
165-
say "🎢 Top Level App Component successfully installed at app/hyperstack/components/app.rb 🎢", :green
164+
say '🎢 Top Level App Component successfully installed at app/hyperstack/components/app.rb 🎢', :green
166165
end
167166
if !new_rails_app?
168-
say "🎢 Top Level App Component skipped, you can manually generate it later 🎢", :green
167+
say '🎢 Top Level App Component skipped, you can manually generate it later 🎢', :green
169168
end
170169
unless skip_webpack?
171-
say "📦 Webpack integrated with Hyperstack. "\
172-
"Add javascript assets to app/javascript/packs/client_only.js and /client_and_server.js 📦", :green
170+
say '📦 Webpack integrated with Hyperstack. '\
171+
'Add javascript assets to app/javascript/packs/client_only.js and /client_and_server.js 📦', :green
173172
end
174173
unless skip_hyper_model?
175-
say "👩‍✈️ Basic development policy defined. See app/policies/application_policy.rb 👨🏽‍✈️", :green
176-
say "💽 HyperModel installed. Move any Active Record models to the app/hyperstack/models to access them from the client 📀", :green
174+
say '👩‍✈️ Basic development policy defined. See app/policies/application_policy.rb 👨🏽‍✈️', :green
175+
say '💽 HyperModel installed. Move any Active Record models to the app/hyperstack/models to access them from the client 📀', :green
177176
end
178-
if File.exists?(init = File.join('config', 'initializers', 'hyperstack.rb'))
177+
if File.exist?(init = File.join('config', 'initializers', 'hyperstack.rb'))
179178
say "☑️ Check #{init} for other configuration options. ☑️", :green
180179
end
181180
unless skip_hotloader?
182-
say "🚒 Hyperstack Hotloader installed - use bundle exec foreman start and visit localhost:5000 🚒", :green
181+
say '🚒 Hyperstack Hotloader installed - use bundle exec foreman start and visit localhost:5000 🚒', :green
183182
end
184183

185184
say "\n\n"
@@ -220,7 +219,7 @@ def new_rails_app?
220219

221220
def inject_into_initializer(s)
222221
file_name = File.join('config', 'initializers', 'hyperstack.rb')
223-
if File.exists?(file_name)
222+
if File.exist?(file_name)
224223
prepend_to_file(file_name) { "#{s}\n" }
225224
else
226225
create_file file_name, <<-RUBY

ruby/rails-hyperstack/lib/generators/hyperstack/install_generator_base.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def create_component_file(template)
2626

2727

2828
def clear_cache
29-
run 'rm -rf tmp/cache' unless Dir.exists?(File.join('app', 'hyperstack'))
29+
run 'rm -rf tmp/cache' unless Dir.exist?(File.join('app', 'hyperstack'))
3030
end
3131

3232
def insure_hyperstack_loader_installed
@@ -54,17 +54,16 @@ def insure_hyperstack_loader_installed
5454
end
5555
end
5656

57-
5857
def insure_base_component_class_exists
5958
@component_base_class = options['base-class'] || Hyperstack.component_base_class
6059
file_name = File.join(
6160
'app', 'hyperstack', 'components', "#{@component_base_class.underscore}.rb"
6261
)
63-
template 'hyper_component_template.rb', file_name unless File.exists? file_name
62+
template 'hyper_component_template.rb', file_name unless File.exist? file_name
6463
end
6564

6665
def add_to_manifest(manifest, &block)
67-
if File.exists? "app/javascript/packs/#{manifest}"
66+
if File.exist? "app/javascript/packs/#{manifest}"
6867
append_file "app/javascript/packs/#{manifest}", &block
6968
else
7069
create_file "app/javascript/packs/#{manifest}", &block

0 commit comments

Comments
 (0)