Improve OS detection
This commit is contained in:
parent
bb63579379
commit
635a607afa
@ -77,10 +77,12 @@ class AsciicastDecorator < ApplicationDecorator
|
|||||||
private
|
private
|
||||||
|
|
||||||
def os_from_user_agent
|
def os_from_user_agent
|
||||||
os_part = user_agent.split(' ')[2]
|
if user_agent =~ %r{^asciinema/\d(\.\d+)+ [^/\s]+/[^/\s]+ (.+)$}
|
||||||
os = os_part.split('/').first
|
os = $2.sub('-', '/').split('/').first.sub(/[dD]arwin/, 'OS X')
|
||||||
|
os[0].upcase + os[1..-1]
|
||||||
guess_os(os)
|
else
|
||||||
|
'unknown'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def os_from_uname
|
def os_from_uname
|
||||||
|
@ -22,6 +22,16 @@ describe AsciicastDecorator do
|
|||||||
it { should == 'Linux' }
|
it { should == 'Linux' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'and the OS is *BSD (pre-0.9.9 client)' do
|
||||||
|
before do
|
||||||
|
asciicast.user_agent =
|
||||||
|
"asciinema/0.9.8 CPython/2.7.5 " \
|
||||||
|
"FreeBSD/10.0-RELEASE-p7-amd64-64bit-ELF"
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should == 'FreeBSD' }
|
||||||
|
end
|
||||||
|
|
||||||
context 'and the OS is Linux (0.9.9+ client)' do
|
context 'and the OS is Linux (0.9.9+ client)' do
|
||||||
before do
|
before do
|
||||||
asciicast.user_agent =
|
asciicast.user_agent =
|
||||||
|
Loading…
Reference in New Issue
Block a user