Skip to content

Commit ea1769b

Browse files
committed
Fix Rubocop Error
1 parent a4bbcac commit ea1769b

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

lib/react_on_rails/helper.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def react_component(component_name, options = {})
9494
end
9595

9696
def load_pack_for_component(component_name)
97-
component_pack_file_path = "#{generated_components_pack(component_name)}.#{PacksGenerator.generated_pack_extension}"
98-
is_component_pack_present = File.exist?(component_pack_file_path)
97+
98+
is_component_pack_present = File.exist?(generated_components_pack_path(component_name))
9999
is_development = ENV["RAILS_ENV"] == "development"
100100

101101
if is_development && !is_component_pack_present
@@ -109,8 +109,10 @@ def load_pack_for_component(component_name)
109109
append_stylesheet_pack_tag "generated/#{component_name}"
110110
end
111111

112-
def generated_components_pack(component_name)
113-
"#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}"
112+
def generated_components_pack_path(component_name)
113+
extension = PacksGenerator.generated_pack_extension
114+
115+
"#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{component_name}.#{extension}"
114116
end
115117

116118
# react_component_hash is used to return multiple HTML strings for server rendering, such as for

lib/react_on_rails/packs_generator.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ class PacksGenerator
99
MINIMUM_SHAKAPACKER_MAJOR_VERSION = 6
1010
MINIMUM_SHAKAPACKER_MINOR_VERSION = 5
1111
MINIMUM_SHAKAPACKER_PATCH_VERSION = 1
12-
GENERATED_PACK_EXTENSION = "js".freeze
12+
self.GENERATED_PACK_EXTENSION = "js"
13+
14+
class << self
15+
attr_accessor :GENERATED_PACK_EXTENSION
16+
end
1317

1418
def self.generate
1519
packs_generator = PacksGenerator.new
@@ -21,10 +25,6 @@ def self.raise_nested_entries_disabled
2125
packs_generator.raise_nested_entries_disabled
2226
end
2327

24-
def self.generated_pack_extension
25-
GENERATED_PACK_EXTENSION
26-
end
27-
2828
def verify_setup_and_generate_packs
2929
return unless components_subdirectory.present?
3030

@@ -157,7 +157,7 @@ def relative_path(from, to)
157157
end
158158

159159
def generated_pack_path(file_path)
160-
"#{generated_packs_directory_path}/#{component_name(file_path)}.#{generated_pack_extension}"
160+
"#{generated_packs_directory_path}/#{component_name(file_path)}.#{GENERATED_PACK_EXTENSION}"
161161
end
162162

163163
def component_name(file_path)

0 commit comments

Comments
 (0)