Skip to content

Commit

Permalink
Merge pull request #14 from JuliaWeb/rz/v1_updates
Browse files Browse the repository at this point in the history
Cleanup for julia 1.0
  • Loading branch information
randyzwitch authored Dec 19, 2018
2 parents 13073b8 + 4fd02ab commit 7fb06eb
Show file tree
Hide file tree
Showing 13 changed files with 88,824 additions and 3,353 deletions.
43 changes: 27 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
## Documentation: http://docs.travis-ci.com/user/languages/julia/
sudo: required
language: julia

julia:
- 0.6
- nightly

os:
- linux
- osx
julia:
- 1.0
- nightly
notifications:
email: false
git:
depth: 99999999

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia: nightly

notifications:
email: false

before_script:
- export PATH=$HOME/.local/bin:$PATH

script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("UAParser"); Pkg.test("UAParser"; coverage=true)'
## uncomment and modify the following lines to manually install system packages
#addons:
# apt: # apt-get for linux
# packages:
# - gfortran
#before_script: # homebrew for mac
# - if [ $TRAVIS_OS_NAME = osx ]; then brew install gcc; fi

## uncomment the following lines to override the default test script
#script:
# - julia -e 'Pkg.clone(pwd()); Pkg.build("UAParser"); Pkg.test("UAParser"; coverage=true)'
after_success:
- julia -e 'cd(Pkg.dir("UAParser")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Coveralls
#- julia -e 'using Pkg; cd(Pkg.dir("UAParser")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'using Pkg; cd(Pkg.dir("UAParser")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
#- julia -e 'using Pkg; Pkg.add("Documenter")'
#- julia -e 'using Pkg; cd(Pkg.dir("UAParser")); include(joinpath("docs", "make.jl"))'
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# UAParser

[![Build Status](https://travis-ci.org/JuliaWeb/UAParser.jl.svg?branch=master)](https://travis-ci.org/JuliaWeb/UAParser.jl)
[![Build Status](https://travis-ci.org/JuliaWeb/UAParser.jl.svg?branch=master)](https://travis-ci.org/JuliaWeb/UAParser.jl) </br>
[![Coverage Status](https://coveralls.io/repos/JuliaWeb/UAParser.jl/badge.svg)](https://coveralls.io/r/JuliaWeb/UAParser.jl)

[![UAParser](http://pkg.julialang.org/badges/UAParser_0.3.svg)](http://pkg.julialang.org/?pkg=UAParser&ver=0.3)
[![UAParser](http://pkg.julialang.org/badges/UAParser_0.4.svg)](http://pkg.julialang.org/?pkg=UAParser&ver=0.4)

UAParser is a Julia port of [ua-parser](https://github.com/tobie/ua-parser), which itself is a multi-language port of [BrowserScope's](http://www.browserscope.org) [user agent string parser](http://code.google.com/p/ua-parser/). Per the [README file](https://github.com/tobie/ua-parser/blob/master/README.markdown) from that project:
UAParser is a Julia port of [ua-parser](https://github.com/ua-parser/uap-python), which itself is a multi-language port of [BrowserScope's](http://www.browserscope.org) [user agent string parser](http://code.google.com/p/ua-parser/). Per the [README file](https://github.com/ua-parser/uap-core/blob/master/README.md) of the main project:

> "The crux of the original parser--the data collected by [Steve Souders](http://stevesouders.com/) over the years--has been extracted into a separate [YAML file](https://github.com/tobie/ua-parser/blob/master/regexes.yaml) so as to be reusable _as is_ by implementations in other programming languages."
UAParser is a limited Julia implementation heavily influenced by the [Python code](https://github.com/tobie/ua-parser/tree/master/py) from the ua-parser
library.
UAParser is a limited Julia implementation heavily influenced by the [Python code](https://github.com/ua-parser/uap-python) from the ua-parser library.

New regexes have were retrieved from [here](https://github.com/ua-parser/uap-core/blob/master/regexes.yaml). This was the most up-to-date source that could be
found as of 2017-10-18.
New regexes have were retrieved from [here](https://github.com/ua-parser/uap-core/blob/master/regexes.yaml) on 2018-12-19.

## UAParser API

Expand All @@ -40,10 +36,10 @@ The API for UAParser revolves around three functions: `parsedevice`, `parseos` a
parsedevice(user_agent_string) #> DeviceResult("iPhone", "Apple", "iPhone")

#Get browser information from user-agent string
parseuseragent(user_agent_string) #> UAResult("Mobile Safari","5","1",nothing)
parseuseragent(user_agent_string) #> UAResult("Mobile Safari","5","1",missing)

#Get os information
parseos(user_agent_string) #> OSResult("iOS","5","1",nothing,nothing)
parseos(user_agent_string) #> OSResult("iOS","5","1",missing,missing)

```

Expand All @@ -59,7 +55,19 @@ You can index into the results of these functions like any other Julia composite
x2.family #> "iOS"
```

Each function is vectorized using `Base.@vectorize_1arg`, so passing an array of user-agent strings will return an array. Finally, DataFrame methods have been defined for arrays of each UAParser type, so calling `DataFrame(DeviceResult)` will transform the array to a DataFrame.
## A Note On Parser Accuracy

When this library was created, it became very obvious that it would be hard to replicate the Python parser code with 100% accuracy. The authors decided that a _reasonably accurate_ implementation was more useful than spending the time to achieve 100% accuracy.

The tests in this library test against the accuracy of the parser. As of v0.6 of this package, here are the accuracy statistics against the files provided by the main ua-core project:

```
parse_device: 15144/16017 (94.6%)
parse_os: 1517/1528 (99.3%)
parse_ua: 204/205 (99.5%)
```

Of course, if someone would like to achieve 100% accuracy, PRs will absolutely be reviewed.

## Licensing

Expand Down
7 changes: 3 additions & 4 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
julia 0.6
YAML
DataFrames 0.11
Missings
julia 1.0
YAML 0.3.2
DataFrames 0.15.2
49 changes: 23 additions & 26 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 1
- julia_version: nightly

platform:
# - x86 # 32-bit
- x64 # 64-bit

# # Uncomment the following lines to allow failures on nightly julia
# # (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia_version: latest

branches:
only:
- master
- /release-.*/

matrix:
allow_failures:
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"UAParser\"); Pkg.build(\"UAParser\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"UAParser\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
Loading

0 comments on commit 7fb06eb

Please sign in to comment.