Skip to content

Instantly share code, notes, and snippets.

@rebelwarrior
Last active November 20, 2017 15:41
Show Gist options
  • Save rebelwarrior/dbe2f757955b801a2cd90e52989cedc6 to your computer and use it in GitHub Desktop.
Save rebelwarrior/dbe2f757955b801a2cd90e52989cedc6 to your computer and use it in GitHub Desktop.

Revisions

  1. rebelwarrior revised this gist Nov 20, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion identify_os.rb
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ def idenfity_os
    end

    def identify_linux_distro
    distro = `python -c "import platform; print platform.dist()"`
    distro = `python -c "import platform; print(platform.dist())"`
    case distro
    when /ubutu/i
    :ubuntu
  2. rebelwarrior revised this gist Nov 14, 2017. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions identify_os.rb
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,14 @@ def idenfity_os
    else
    fail "Couldn't recognize OS"
    end
    end

    def identify_linux_distro
    distro = `python -c "import platform; print platform.dist()"`
    case distro
    when /ubutu/i
    :ubuntu
    else
    :linux
    end
    end
  3. rebelwarrior created this gist Nov 14, 2017.
    16 changes: 16 additions & 0 deletions identify_os.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    def idenfity_os
    require 'rbconfig'
    host_os = RbConfig::CONFIG['host_os']
    case host_os
    when /darwin/, /Mac/
    :mac
    when /linux/
    identify_linux_distro
    when /cygwin|mswin|mingw|bccwin|wince|emx/
    :windows
    when /solaris|bsd/
    :unix
    else
    fail "Couldn't recognize OS"
    end
    end