From 75607a67b4f5e3fb5acf9c49353f102a4ecd9319 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 30 Nov 2016 20:57:50 +0900 Subject: use `Gem.win_platform?` to check windows Ruby platforms `Gem.win_platform?` check if it is Windows more accurately. Ref: https://github.com/ruby/ruby/blob/ruby_2_2/lib/rubygems.rb#L945..L952 --- railties/lib/rails/commands/runner/USAGE | 2 +- railties/lib/rails/generators/actions.rb | 4 ++-- railties/lib/rails/generators/app_base.rb | 2 +- railties/lib/rails/generators/rails/app/app_generator.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/commands/runner/USAGE b/railties/lib/rails/commands/runner/USAGE index dc47a35ff3..b2a6e8493d 100644 --- a/railties/lib/rails/commands/runner/USAGE +++ b/railties/lib/rails/commands/runner/USAGE @@ -8,7 +8,7 @@ Run the Ruby file located at `path/to/filename.rb` after loading the app: <%= executable %> path/to/filename.rb -<% if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ %> +<% unless Gem.win_platform? %> You can also use the runner command as a shebang line for your executables: #!/usr/bin/env <%= File.expand_path(executable) %> diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 5075eb1328..8a60560f86 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -279,13 +279,13 @@ module Rails def execute_command(executor, command, options = {}) log executor, command env = options[:env] || ENV["RAILS_ENV"] || "development" - sudo = options[:sudo] && RbConfig::CONFIG["host_os"] !~ /mswin|mingw/ ? "sudo " : "" + sudo = options[:sudo] && !Gem.win_platform? ? "sudo " : "" in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", verbose: false) } end # Add an extension to the given name based on the platform. def extify(name) - if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ + if Gem.win_platform? "#{name}.bat" else name diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 99fc5d9525..6feb8431a7 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -433,7 +433,7 @@ module Rails def yarn_path commands = ["yarn"] - if RbConfig::CONFIG["host_os"] =~ /mswin|cygwin/ + if Gem.win_platform? ENV["PATHEXT"].split(File::PATH_SEPARATOR).each do |ext| commands << commands[0] + ext end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 03fd298fbc..5f14f989d7 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -428,7 +428,7 @@ module Rails "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4 "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5 "/opt/lampp/var/mysql/mysql.sock" # xampp for linux - ].find { |f| File.exist?(f) } unless RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ + ].find { |f| File.exist?(f) } unless Gem.win_platform? end def get_builder_class -- cgit v1.2.3