From a334c33e723d7bae0ea54ea535d8c250da459e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cardoso?= Date: Sun, 3 Sep 2023 01:13:39 +0100 Subject: [PATCH 1/4] Correct path to use when initializing submodule --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b52289..7f2cda6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ git clone --recursive https://github.com/ua-parser/uap-scala.git If uap-scala was checked out and core was not properly initialized, the following can be done ``` -cd core +cd uap-scala git submodule update --init --recursive ``` From 3b96980666f13874b058f436f8799d01fd711e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cardoso?= Date: Sun, 3 Sep 2023 01:27:17 +0100 Subject: [PATCH 2/4] Use publishLocal instead of package --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f2cda6..e333136 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,17 @@ git submodule update --init --recursive ``` ### Build -To build for the default Scala (currently 2.11): + +To build and publish locally for the default Scala (currently 2.13.11): + ```scala -sbt package +sbt publishLocal ``` + To cross-build for different Scala versions: + ```scala -sbt +package +sbt +publishLocal ``` ### Linking From 0fec61388647668365549e8a77b5654fdc81e45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cardoso?= Date: Sun, 3 Sep 2023 01:49:58 +0100 Subject: [PATCH 3/4] Add new section on how to add the dependency --- README.md | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index e333136..9ea0b27 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ uap-scala A Scala user-agent string parser based on [ua-parser/uap-core](https://github.com/ua-parser/uap-core). It extracts browser, OS and device information. ### Checkout + The code for this repository can be checked out normally. It uses a [git submodule](https://git-scm.com/docs/git-submodule) to include the files needed from [uap-core](https://github.com/ua-parser/uap-core) so care must be taken to make sure the `core` directory is properly checked out and initialized. Checking out the repo for the first time @@ -34,47 +35,22 @@ To cross-build for different Scala versions: sbt +publishLocal ``` -### Linking -Linking - -You can link against this library in your program at the following coordinates: - -Scala 2.10 -``` -groupId: org.uaparser -artifactId: uap-scala_2.10 -version: 0.11.0 -``` - -Scala 2.11 -``` -groupId: org.uaparser -artifactId: uap-scala_2.11 -version: 0.11.0 -``` +### Usage -Scala 2.12 -``` -groupId: org.uaparser -artifactId: uap-scala_2.12 -version: 0.11.0 -``` +To use this library in your own project, add the following dependency in `build.sbt`: -Scala 2.13 ``` -groupId: org.uaparser -artifactId: uap-scala_2.13 -version: 0.11.0 +libraryDependencies += "org.uaparser" %% "uap-scala" % "0.16.0" ``` -### Usage - #### Note about these examples + Instantiating Parser.default also instantiates secondary classes and reads in YAML files. This is slow. If performance is critical or you are handling user agents in real time, be sure not to do this on the critical path for processing requests. #### Retrieve data on a user-agent string + ```scala import org.uaparser.scala.Parser @@ -83,8 +59,10 @@ val client = Parser.default.parse(ua) // you can also use CachingParser println(client) // Client(UserAgent(Mobile Safari,Some(5),Some(1),None),OS(iOS,Some(5),Some(1),Some(1),None),Device(iPhone)) ``` #### Extract partial data from user-agent string + The time costs of parsing all the data may be high. To reduce the costs, we can just parse partial data. + ```scala import org.uaparser.scala.Parser @@ -100,6 +78,7 @@ println(userAgent) // UserAgent(Mobile Safari,Some(5),Some(1),None) val device = parser.deviceParser.parse(raw) println(device) // Device(iPhone,Some(Apple),Some(iPhone)) ``` + ### Maintainers * Piotr Adamski ([@mcveat](https://twitter.com/mcveat)) (Author. Based on the java implementation by Steve Jiang [@sjiang](https://twitter.com/sjiang) and using agent data from BrowserScope) From 0a1930db91b4d233fbcadac370290a23febb056f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cardoso?= Date: Sun, 3 Sep 2023 01:52:10 +0100 Subject: [PATCH 4/4] Re organize sections --- README.md | 58 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 9ea0b27..e2dfebf 100644 --- a/README.md +++ b/README.md @@ -6,35 +6,6 @@ uap-scala A Scala user-agent string parser based on [ua-parser/uap-core](https://github.com/ua-parser/uap-core). It extracts browser, OS and device information. -### Checkout - -The code for this repository can be checked out normally. It uses a [git submodule](https://git-scm.com/docs/git-submodule) to include the files needed from [uap-core](https://github.com/ua-parser/uap-core) so care must be taken to make sure the `core` directory is properly checked out and initialized. - -Checking out the repo for the first time -``` -git clone --recursive https://github.com/ua-parser/uap-scala.git -``` -If uap-scala was checked out and core was not properly initialized, the following can be done - -``` -cd uap-scala -git submodule update --init --recursive -``` - -### Build - -To build and publish locally for the default Scala (currently 2.13.11): - -```scala -sbt publishLocal -``` - -To cross-build for different Scala versions: - -```scala -sbt +publishLocal -``` - ### Usage To use this library in your own project, add the following dependency in `build.sbt`: @@ -79,6 +50,35 @@ val device = parser.deviceParser.parse(raw) println(device) // Device(iPhone,Some(Apple),Some(iPhone)) ``` +### Development + +The code for this repository can be checked out normally. It uses a [git submodule](https://git-scm.com/docs/git-submodule) to include the files needed from [uap-core](https://github.com/ua-parser/uap-core) so care must be taken to make sure the `core` directory is properly checked out and initialized. + +Checking out the repo for the first time +``` +git clone --recursive https://github.com/ua-parser/uap-scala.git +``` +If uap-scala was checked out and core was not properly initialized, the following can be done + +``` +cd uap-scala +git submodule update --init --recursive +``` + +#### Build + +To build and publish locally for the default Scala (currently 2.13.11): + +```scala +sbt publishLocal +``` + +To cross-build for different Scala versions: + +```scala +sbt +publishLocal +``` + ### Maintainers * Piotr Adamski ([@mcveat](https://twitter.com/mcveat)) (Author. Based on the java implementation by Steve Jiang [@sjiang](https://twitter.com/sjiang) and using agent data from BrowserScope)