File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 1212 fail-fast : false
1313 matrix :
1414 os :
15- - " macos-12"
1615 - " macos-13"
1716 - " macos-14" # arm64
1817 - " ubuntu-20.04"
5150 fail-fast : false
5251 matrix :
5352 os :
54- - " macos-12"
5553 - " macos-13"
5654 - " macos-14" # arm64
5755 ruby :
Original file line number Diff line number Diff line change @@ -331,10 +331,37 @@ def idle_notification(idle_time)
331331 end
332332
333333 class Platform
334- def self . set_flag_as_str! ( flag )
335- raise TypeError , "wrong type argument #{ flag . class } (should be a string)" unless flag . is_a? ( String )
336- raise MiniRacer ::PlatformAlreadyInitialized , "The platform is already initialized." if Context . instance_variable_get ( :@context_initialized )
337- Context . instance_variable_set ( :@use_strict , true ) if "--use_strict" == flag
334+ class << self
335+ def set_flags! ( *args , **kwargs )
336+ flags_to_strings ( [ args , kwargs ] ) . each do |flag |
337+ set_flag_as_str! ( flag )
338+ end
339+ end
340+
341+ private
342+
343+ def flags_to_strings ( flags )
344+ flags . flatten . map { |flag | flag_to_string ( flag ) } . flatten
345+ end
346+
347+ # normalize flags to strings, and adds leading dashes if needed
348+ def flag_to_string ( flag )
349+ if flag . is_a? ( Hash )
350+ flag . map do |key , value |
351+ "#{ flag_to_string ( key ) } #{ value } "
352+ end
353+ else
354+ str = flag . to_s
355+ str = "--#{ str } " unless str . start_with? ( '--' )
356+ str
357+ end
358+ end
359+
360+ def set_flag_as_str! ( flag )
361+ raise TypeError , "wrong type argument #{ flag . class } (should be a string)" unless flag . is_a? ( String )
362+ raise MiniRacer ::PlatformAlreadyInitialized , "The platform is already initialized." if Context . instance_variable_get ( :@context_initialized )
363+ Context . instance_variable_set ( :@use_strict , true ) if "--use_strict" == flag
364+ end
338365 end
339366 end
340367
You can’t perform that action at this time.
0 commit comments