Skip to content

Commit

Permalink
Merge pull request #25 from snowplow/feature/0.2.0
Browse files Browse the repository at this point in the history
Feature/0.2.0
  • Loading branch information
alexanderdean committed Sep 16, 2014
2 parents 64e08fd + fb8f5e1 commit b824b70
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: scala
scala:
- 2.9.3
- 2.10.4
- 2.11.2
jdk:
- oraclejdk7
- openjdk6
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 0.2.0 (2014-09-16)
--------------------------
Added MaxMind timezone lookup (thanks @pooya!) (#24)
Enabled cross-publishing for 2.11 (thanks @csaltos!) (#23)
Updated test suite to work with Scala version 2.11 (#26)

Version 0.1.0 (2014-07-14)
--------------------------
Renamed project to scala-maxmind-iplookups (#18)
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is a Scala wrapper for the MaxMind [Java Geo-IP] [java-lib] library. The ma

## Installation

The latest version of scala-maxmind-iplookups is **0.1.0** and is compatible with Scala version 2.9.x, where x is at least 3, and Scala version 2.10.x.
The latest version of scala-maxmind-iplookups is **0.2.0** and is compatible with all Scala versions from 2.9.3 onwards.

Add this to your SBT config:

Expand All @@ -21,7 +21,7 @@ val snowplowRepo = "SnowPlow Repo" at "http://maven.snplow.com/releases/"
val twitterRepo = "Twitter Maven Repo" at "http://maven.twttr.com/"

// Dependency
val maxmindIpLookups = "com.snowplowanalytics" %% "scala-maxmind-iplookups" % "0.1.0"
val maxmindIpLookups = "com.snowplowanalytics" %% "scala-maxmind-iplookups" % "0.2.0"
```

Note the double percent (`%%`) between the group and artifactId. That'll ensure you get the right package for your Scala version.
Expand All @@ -40,7 +40,7 @@ import com.snowplowanalytics.maxmind.iplookups.IpLookups
val ipLookups = IpLookups(geoFile = Some("/opt/maxmind/GeoLiteCity.dat"), ispFile = None,
orgFile = None, domainFile = None, memCache = false, lruCache = 20000)

for (loc <- IpLookups.performLookups("213.52.50.8")._1) {
for (loc <- ipLookups.performLookups("213.52.50.8")._1) {
println(loc.countryCode) // => "NO"
println(loc.countryName) // => "Norway"
}
Expand Down Expand Up @@ -92,6 +92,7 @@ case class IpLocation(
city: Option[String],
latitude: Float,
longitude: Float,
timezone: Option[String],
postalCode: Option[String],
dmaCode: Option[Int],
areaCode: Option[Int],
Expand Down
4 changes: 2 additions & 2 deletions project/BuildSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ object BuildSettings {
// Basic settings for our app
lazy val basicSettings = Seq[Setting[_]](
organization := "com.snowplowanalytics",
version := "0.1.0",
version := "0.2.0",
description := "Scala wrapper for MaxMind GeoIP library",
scalaVersion := "2.9.3",
crossScalaVersions := Seq("2.9.3", "2.10.4"),
crossScalaVersions := Seq("2.9.3", "2.10.4", "2.11.2"),
scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
resolvers ++= Dependencies.resolutionRepos
)
Expand Down
3 changes: 1 addition & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Dependencies {
object collUtils {
val _29 = "5.3.10"
val _210 = "6.3.4"
val _211 = "6.12.1"
val _211 = "6.20.0"
}
object specs2 {
val _29 = "1.12.4.1"
Expand All @@ -38,7 +38,6 @@ object Dependencies {
object collUtils {
val _29 = "com.twitter" % "util-collection" % V.collUtils._29
val _210 = "com.twitter" %% "util-collection" % V.collUtils._210
// Not yet released
val _211 = "com.twitter" %% "util-collection" % V.collUtils._211
}
object specs2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package com.snowplowanalytics.maxmind.iplookups
import com.maxmind.geoip.{
LookupService,
Location,
timeZone,
regionName
}

Expand All @@ -30,6 +31,7 @@ case class IpLocation(
city: Option[String],
latitude: Float,
longitude: Float,
timezone: Option[String],
postalCode: Option[String],
dmaCode: Option[Int],
areaCode: Option[Int],
Expand Down Expand Up @@ -60,6 +62,7 @@ object IpLocation {
city = Option(loc.city),
latitude = loc.latitude,
longitude = loc.longitude,
timezone = Option(timeZone.timeZoneByCountryAndRegion(loc.countryCode, loc.region)),
postalCode = Option(loc.postalCode),
dmaCode = optionify(loc.dma_code),
areaCode = optionify(loc.area_code),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ object IpLookupsTest {
city = Some("Delray Beach"),
latitude = 26.461502F,
longitude = -80.0728F,
timezone = Some("America/New_York"),
postalCode = None,
dmaCode = Some(548),
areaCode = Some(561),
Expand All @@ -61,6 +62,7 @@ object IpLookupsTest {
city = Some("Lille"),
latitude = 50.632996F,
longitude = 3.0585938F,
timezone = Some("Europe/Paris"),
postalCode = None,
dmaCode = None,
areaCode = None,
Expand All @@ -76,6 +78,7 @@ object IpLookupsTest {
city = None,
latitude = 0.0F,
longitude = 0.0F,
timezone = None,
postalCode = None,
dmaCode = None,
areaCode = None,
Expand All @@ -90,7 +93,7 @@ object IpLookupsTest {

class IpLookupsTest extends Specification {

"Looking up some IP address locations should match their expected locations" >> {
"Looking up some IP address locations should match their expected locations" should {

val mcf: Boolean => String = mc => if (mc) "using" else "without using"
val lcf: Int => String = lc => if (lc > 0) "LRU cache sized %s".format(lc) else "no LRU cache"
Expand Down Expand Up @@ -139,6 +142,9 @@ class IpLookupsTest extends Specification {
"have longitude = %s".format(e.longitude) in {
a.longitude must_== e.longitude
}
"have timezone = %s".format(e.timezone) in {
a.timezone must_== e.timezone
}
"have postalCode = %s".format(e.postalCode) in {
a.postalCode must_== e.postalCode
}
Expand Down

0 comments on commit b824b70

Please sign in to comment.