Skip to content

Commit 8b6515f

Browse files
authored
Merge branch 'release/0.5.0'
2 parents 797e46b + 8b90988 commit 8b6515f

29 files changed

+222
-243
lines changed

.travis.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
language: scala
22
scala:
3-
- 2.9.3
4-
- 2.10.1
5-
- 2.11.5
3+
- 2.10.6
4+
- 2.11.8
65
jdk:
76
- oraclejdk7
8-
- openjdk6
97
- openjdk7
108
env:
119
global:
12-
- secure: kxIeiY9eiOSNOr9yn76bCHL/3/XnxyYT8MSSKcdmrAVcYxN9zohWo9kAXQNPi9mDeQxoVYaIG2EOd01gddjTa/DdVyeij93XDSS31e+HmtfqfF7rDa/r819MOemYwP0lgn2lOHnf5BNu6MQtRUnwXCUz6lUh/hXIYBD4TBQmVl4=
13-
addons:
14-
# Fix OpenJDK builds
15-
# https://github.com/travis-ci/travis-ci/issues/5227
16-
hostname: short-hostname
10+
- secure: M/f/K1H0pZS5rgeoQXroFJlz5t2l8UcP+Bogo2jn3drvrqdPB22Z0MzkorH9diBrtykGZmc3X0A8Y9SQob7YaJ+lD0XbSuwzM9TgAKHLg8CpJQffFpE0xUHybcrcdTnC19iiTI3vovr2nQzlYn31F0X0RXMSDyW0zOIDX9kDGuk=
11+
- secure: aEgUK6zpFDbDQNXVsJC9Y3CrvUTrbDci7U6mM/vR2/ksVL4dVMBCJAJsdXWwc12wIlYRNDrtuZ62/R+LbS8O1gjIeyU8hKhc81L8pfyJFOm9BztbN+4XqkPsXS7WqgpqI6lr1TABdHaHPwTCh5kFLtqkCD2NXMmi7uhmScJfVc0=
12+
- secure: LPO6f56t82laN2lzNuVuAIQkmkn8wOvmOzeu5ozYn9afJ+GGxjdJJ9TEYOQA5bZFKY/p6o65MemhlidhdMpZu++G1nVVdPoAh+NvEfesQxkQx0lFta6u2l2nKgUnpZL2mW8skM1LGepOyUZFujBAcSH6GHmQN0IP4zGVSrUvMX0=
13+
- secure: hDo2jt06gx02utmCMb548NEeTAtIgTg53SYL+rPydhryCZHzQISPHlHB/SDKATlalYU6nP+1zz9gANA1HVgN83BaAzI82CoBcsBvVSAw+MKYMDbdf3yoEpe0DJyzibscu57nb7rvi+Xswse93mib1wkdy4eOXB1L0YwKW6dlxB0=
14+
- secure: xtx+EvI6UKAndt1/9pay+YA+6QG8TylETGQemDMGENTp2er/u013CPTZRrJu7znRiQdPamI8hPsy1GRGKt7cCoyFIv5MWtMOodNVcxbhDbl7z3j5mcKIp2RJmv1XaL0nJnltnIJj0P0ohA4BVzpi9jthaj+WzI9O6OIKRyuIvdU=
15+
script:
16+
- sbt test
17+
deploy:
18+
skip_cleanup: true
19+
provider: script
20+
script: ./.travis/deploy.sh $TRAVIS_TAG
21+
on:
22+
condition: '"${TRAVIS_SCALA_VERSION}" == "2.11.8" && "${TRAVIS_JDK_VERSION}" == "oraclejdk7"'
23+
tags: true

.travis/deploy.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
tag_version=$1
4+
5+
mkdir ~/.bintray/
6+
FILE=$HOME/.bintray/.credentials
7+
cat <<EOF >$FILE
8+
realm = Bintray API Realm
9+
host = api.bintray.com
10+
user = $BINTRAY_SNOWPLOW_MAVEN_USER
11+
password = $BINTRAY_SNOWPLOW_MAVEN_API_KEY
12+
EOF
13+
14+
cd $TRAVIS_BUILD_DIR
15+
pwd
16+
17+
project_version=$(sbt version -Dsbt.log.noformat=true | perl -ne 'print $1 if /(\d+\.\d+\.\d+[^\r\n]*)/')
18+
if [ "${project_version}" == "${tag_version}" ]; then
19+
sbt +publish
20+
sbt +bintraySyncMavenCentral
21+
else
22+
echo "Tag version '${tag_version}' doesn't match version in scala project ('${project_version}'). Aborting!"
23+
exit 1
24+
fi

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
Version 0.5.0 (2017-01-24)
2+
--------------------------
3+
Bump crossScalaVersions to 2.10.6 and 2.11.8 (#102)
4+
Drop Scala 2.9 support (#105)
5+
Bump to sbt 0.13.13 (#106)
6+
Remove scala-util dependency (#101)
7+
Add CI/CD (#103)
8+
Add Bintray credentials to .travis.yml (#104)
9+
Update Open Exchange Rates credentials in .travis.yml (#109)
10+
Add Sonatype credentials to .travis.yml (#111)
11+
112
Version 0.4.0 (2016-02-16)
213
--------------------------
314
Fixed handling of invalid API key (#96)

README.md

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@ There are three types of accounts supported by OER API, Unlimited, Enterprise an
2020

2121
### 2.2 Installation
2222

23-
The latest version of Scala Forex is 0.4.0, which is cross-built against Scala 2.9.3, 2.10.x and 2.11.x.
23+
The latest version of Scala Forex is 0.5.0, which is cross-built against 2.10.x and 2.11.x.
2424

2525
If you're using SBT, add the following lines to your build file:
2626

2727
```scala
28-
// Resolvers
29-
val snowplowRepo = "SnowPlow Repo" at "http://maven.snplow.com/releases/"
30-
val oldTwitterRepo = "Twitter Maven Repo" at "http://maven.twttr.com/"
31-
val newTwitterRepo = "Sonatype" at "https://oss.sonatype.org/content/repositories/releases"
32-
33-
// Dependency
34-
val scalaForex = "com.snowplowanalytics" %% "scala-forex" % "0.4.0"
28+
libraryDependencies ++= Seq(
29+
"com.snowplowanalytics" %% "scala-forex" % "0.5.0"
30+
)
3531
```
3632

3733
Note the double percent (`%%`) between the group and artifactId. That'll ensure you get the right package for your Scala version.
@@ -58,13 +54,13 @@ Case class with defaults:
5854

5955
```scala
6056
case class ForexConfig(
61-
nowishCacheSize: Int = 13530,
57+
nowishCacheSize: Int = 13530,
6258
nowishSecs: Int = 300,
6359
eodCacheSize: Int = 405900,
6460
getNearestDay: EodRounding = EodRoundDown,
6561
baseCurrency: String = "USD"
66-
)
67-
```
62+
)
63+
```
6864

6965
To go through each in turn:
7066

@@ -76,7 +72,7 @@ To go through each in turn:
7672

7773
4. `getNearestDay` is the rounding configuration for latest eod(at) lookup. The lookup will be performed on the next day if the rounding mode is set to EodRoundUp, and on the previous day if EodRoundDown.
7874

79-
5. `baseCurrency` can be configured to different currencies by the users.
75+
5. `baseCurrency` can be configured to different currencies by the users.
8076

8177
For an explanation for the default values please see section **4.4 Explanation of defaults** below.
8278

@@ -87,9 +83,9 @@ Case class with defaults:
8783
```scala
8884
case class OerClientConfig(
8985
appId: String,
90-
accountLevel: AccountType
86+
accountLevel: AccountType
9187
) extends ForexClientConfig
92-
```
88+
```
9389

9490
To go through each in turn:
9591

@@ -141,22 +137,22 @@ Lookup the latest EOD (end-of-date) rate prior to your event _(cacheing availabl
141137
```scala
142138
import org.joda.time.{DateTime, DateTimeZone}
143139

144-
// USD => JPY at the end of 12/03/2011
140+
// USD => JPY at the end of 12/03/2011
145141
val fx = Forex(ForexConfig(), OerClientConfig(appId, DeveloperAccount)) // round down to previous day by default
146142
val tradeDate = new DateTime(2011, 3, 13, 11, 39, 27, 567, DateTimeZone.forID("America/New_York"))
147143
val usd2yen = fx.rate.to("JPY").at(tradeDate) // => Right(JPY 82)
148144
```
149145

150-
#### 3.2.5 Latest-post EOD rate
146+
#### 3.2.5 Latest-post EOD rate
151147

152148
Lookup the latest EOD (end-of-date) rate post to your event _(cacheing available)_:
153149

154150
```scala
155151
import org.joda.time.{DateTime, DateTimeZone}
156152
import com.snowplowanalytics.forex.EodRoundUp
157153

158-
// USD => JPY at the end of 13/03/2011
159-
val fx = Forex(ForexConfig(getNearestDay = EodRoundUp), OerClientConfig(appId, DeveloperAccount))
154+
// USD => JPY at the end of 13/03/2011
155+
val fx = Forex(ForexConfig(getNearestDay = EodRoundUp), OerClientConfig(appId, DeveloperAccount))
160156
val tradeDate = new DateTime(2011, 3, 13, 11, 39, 27, 567, DateTimeZone.forID("America/New_York"))
161157
val usd2yen = fx.rate.to("JPY").at(tradeDate) // => Right(JPY 82)
162158
```
@@ -176,7 +172,7 @@ val gbp2jpy = fx.rate.to("JPY").eod(eodDate) // => Right(JPY 131)
176172

177173
#### 3.2.7 Specific EOD rate without cache
178174

179-
Lookup the EOD rate for a specific date _(no cacheing)_:
175+
Lookup the EOD rate for a specific date _(no cacheing)_:
180176

181177
```scala
182178
import org.joda.time.DateTime
@@ -198,15 +194,15 @@ Conversion using the live exchange rate _(no cacheing available)_:
198194
```scala
199195
// 9.99 USD => EUR
200196
val fx = Forex(ForexConfig(), OerClientConfig(appId, DeveloperAccount))
201-
val priceInEuros = fx.convert(9.99).to("EUR").now
197+
val priceInEuros = fx.convert(9.99).to("EUR").now
202198
```
203199

204200
#### 3.3.2 Near-live rate
205201

206202
Conversion using a near-live exchange rate with 500 seconds nowishSecs _(cacheing available)_:
207203

208204
```scala
209-
// 9.99 GBP => EUR
205+
// 9.99 GBP => EUR
210206
val fx = Forex(ForexConfig(nowishSecs = 500), OerClientConfig(appId, DeveloperAccount))
211207
val priceInEuros = fx.convert(9.99, "GBP").to("EUR").nowish
212208
```
@@ -215,7 +211,7 @@ val priceInEuros = fx.convert(9.99, "GBP").to("EUR").nowish
215211

216212
Note that this will be a live rate conversion if cache is not available.
217213
Conversion using a live exchange rate with 500 seconds nowishSecs,
218-
this conversion will be done via HTTP request:
214+
this conversion will be done via HTTP request:
219215

220216
```scala
221217

@@ -231,13 +227,13 @@ Conversion using the latest EOD (end-of-date) rate prior to your event _(cachein
231227
```scala
232228
import org.joda.time.{DateTime, DateTimeZone}
233229

234-
// 10000 GBP => JPY at the end of 12/03/2011
230+
// 10000 GBP => JPY at the end of 12/03/2011
235231
val fx = Forex(ForexConfig(), OerClientConfig(appId, DeveloperAccount))
236232
val tradeDate = new DateTime(2011, 3, 13, 11, 39, 27, 567, DateTimeZone.forID("America/New_York"))
237233
val tradeInYen = fx.convert(10000, "GBP").to("JPY").at(tradeDate)
238234
```
239235

240-
#### 3.3.5 Latest-post EOD rate
236+
#### 3.3.5 Latest-post EOD rate
241237

242238
Lookup the latest EOD (end-of-date) rate following your event _(cacheing available)_:
243239

@@ -246,9 +242,9 @@ import org.joda.time.{DateTime, DateTimeZone}
246242
import com.snowplowanalytics.forex.EodRoundUp
247243

248244
// 10000 GBP => JPY at the end of 13/03/2011
249-
val fx = Forex(ForexConfig(getNearestDay = EodRoundUp), OerClientConfig(appId, DeveloperAccount))
245+
val fx = Forex(ForexConfig(getNearestDay = EodRoundUp), OerClientConfig(appId, DeveloperAccount))
250246
val tradeDate = new DateTime(2011, 3, 13, 11, 39, 27, 567, DateTimeZone.forID("America/New_York"))
251-
val usd2yen = fx.convert(10000, "GBP").to("JPY").at(tradeDate)
247+
val usd2yen = fx.convert(10000, "GBP").to("JPY").at(tradeDate)
252248
```
253249

254250
#### 3.3.6 Specific EOD rate
@@ -266,7 +262,7 @@ val tradeInYen = fx.convert(10000).to("JPY").eod(eodDate)
266262

267263
#### 3.3.7 Specific EOD rate without cache
268264

269-
Conversion using the EOD rate for a specific date, _(no cacheing)_:
265+
Conversion using the EOD rate for a specific date, _(no cacheing)_:
270266

271267
```scala
272268
import org.joda.time.DateTime
@@ -351,7 +347,7 @@ Please note that the LRU cache implementation is **not** thread-safe ([see this
351347

352348
### 5.4 Explanation of defaults
353349

354-
#### 5.4.1 `nowishCache` = (165 * 164 / 2) = 13530
350+
#### 5.4.1 `nowishCache` = (165 * 164 / 2) = 13530
355351

356352
There are 165 currencies provided by the OER API, hence 165 * 164 pairs of currency combinations.
357353
The key in nowish cache is a tuple of source currency and target currency, and the nowish cache was implemented in a way such that a lookup from CurrencyA to CurrencyB or from CurrencyB to CurrencyA will use the same exchange rate, so we don't need to store both in the caches. Hence there are (165 * 164 / 2) pairs of currencies for nowish cache.
@@ -405,7 +401,7 @@ limitations under the License.
405401
[travis]: https://travis-ci.org/snowplow/scala-forex
406402
[travis-image]: https://travis-ci.org/snowplow/scala-forex.png?branch=master
407403

408-
[release-image]: http://img.shields.io/badge/release-0.4.0-blue.svg?style=flat
404+
[release-image]: http://img.shields.io/badge/release-0.5.0-blue.svg?style=flat
409405
[releases]: https://github.com/snowplow/scala-forex/releases
410406

411407
[license-image]: http://img.shields.io/badge/license-Apache--2-blue.svg?style=flat

build.sbt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2013-2017 Snowplow Analytics Ltd. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the Apache License Version 2.0 is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the Apache License Version 2.0 for the specific language governing permissions and
13+
* limitations there under.
14+
*/
15+
16+
lazy val root = project.in(file("."))
17+
.settings(
18+
name := "scala-forex",
19+
version := "0.5.0",
20+
description := "High-performance Scala library for performing currency conversions using Open Exchange Rates"
21+
)
22+
.settings(BuildSettings.buildSettings)
23+
.settings(BuildSettings.publishSettings)
24+
.settings(
25+
libraryDependencies ++= Seq(
26+
Dependencies.Libraries.jodaTime,
27+
Dependencies.Libraries.jodaConvert,
28+
Dependencies.Libraries.jodaMoney,
29+
Dependencies.Libraries.jackson,
30+
Dependencies.Libraries.collUtil,
31+
Dependencies.Libraries.mockito,
32+
Dependencies.Libraries.specs2
33+
)
34+
)

project/BuildSettings.scala

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013-2015 Snowplow Analytics Ltd. All rights reserved.
2+
* Copyright (c) 2013-2017 Snowplow Analytics Ltd. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -10,36 +10,60 @@
1010
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1212
*/
13+
14+
// SBT
1315
import sbt._
1416
import Keys._
1517

18+
// Bintray plugin
19+
import bintray.BintrayPlugin._
20+
import bintray.BintrayKeys._
21+
1622
object BuildSettings {
1723

1824
// Basic settings for our app
19-
lazy val basicSettings = Seq[Setting[_]](
20-
organization := "com.snowplowanalytics",
21-
version := "0.4.0",
22-
description := "High-performance Scala library for performing currency conversions using Open Exchange Rates",
23-
scalaVersion := "2.10.1",
24-
crossScalaVersions := Seq("2.9.3", "2.10.1", "2.11.5"),
25-
scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
26-
resolvers ++= Dependencies.resolutionRepos
25+
lazy val buildSettings = Seq[Setting[_]](
26+
organization := "com.snowplowanalytics",
27+
scalaVersion := "2.11.8",
28+
crossScalaVersions := Seq("2.10.6", "2.11.8"),
29+
scalacOptions := compilerOptions
2730
)
2831

32+
lazy val compilerOptions = Seq(
33+
"-deprecation",
34+
"-encoding", "UTF-8",
35+
"-feature",
36+
"-language:existentials",
37+
"-language:higherKinds",
38+
"-language:implicitConversions",
39+
"-unchecked",
40+
"-Yno-adapted-args",
41+
"-Ywarn-dead-code",
42+
"-Ywarn-numeric-widen",
43+
"-Xfuture",
44+
"-Xlint"
45+
)
2946

3047
// Publish settings
31-
// TODO: update with ivy credentials etc when we start using Nexus
32-
lazy val publishSettings = Seq[Setting[_]](
33-
// Enables publishing to maven repo
48+
lazy val publishSettings = bintraySettings ++ Seq(
3449
publishMavenStyle := true,
35-
36-
publishTo <<= version { version =>
37-
val basePath = "target/repo/%s".format {
38-
if (version.trim.endsWith("SNAPSHOT")) "snapshots/" else "releases/"
39-
}
40-
Some(Resolver.file("Local Maven repository", file(basePath)) transactional())
41-
}
50+
publishArtifact := true,
51+
publishArtifact in Test := false,
52+
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")),
53+
bintrayOrganization := Some("snowplow"),
54+
bintrayRepository := "snowplow-maven",
55+
pomIncludeRepository := { _ => false },
56+
homepage := Some(url("http://snowplowanalytics.com")),
57+
scmInfo := Some(ScmInfo(url("https://github.com/snowplow/scala-forex"),
58+
"scm:[email protected]:snowplow/scala-forex.git")),
59+
pomExtra := (
60+
<developers>
61+
<developer>
62+
<name>Snowplow Analytics Ltd</name>
63+
<email>support@snowplowanalytics.com</email>
64+
<organization>Snowplow Analytics Ltd</organization>
65+
<organizationUrl>http://snowplowanalytics.com</organizationUrl>
66+
</developer>
67+
</developers>)
4268
)
43-
44-
lazy val buildSettings = basicSettings ++ publishSettings
4569
}

0 commit comments

Comments
 (0)