s3_website_monadic 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 486eca634309564e0eee312970f5b65e0886f848
4
- data.tar.gz: 828bc8f2c6a316b7ec10b5987e5dd0138ecdd00b
3
+ metadata.gz: f86d4b06157085efd1c389f9a8ec15bdd019aa66
4
+ data.tar.gz: b4b461eb8fd319a95b87231430831ca5fc56e288
5
5
  SHA512:
6
- metadata.gz: 824b5b8cf528ee55fe3e525c185344691918314766d25f6f6534dd27be57a00fd59d0ccf417b4c02a3d961f7c6764e71ada6150e3bf38dbe3c2c75562b6c1c7f
7
- data.tar.gz: 603f6e64ed8d5a8764e137df3d66154e0f9445eafc7cf3709babab4477579ac0afebf29fc35bdc3a47c412256adcad6018ac489dc6d600552e144eb5ab3f1568
6
+ metadata.gz: 65805273617dcf99e2dedd7e32a7640fdc85fd40c055ecbe282be74bb050ab70d101cdbf5bb9c20cc703f6a1425f996c5d1a7ce972be8d203454c22682de9daf
7
+ data.tar.gz: 3f369bb8674f34540bdf5d39cff572542f93e9dced36a1aeab402213ebe1860e77f38ff058ad562a64f50fa1864718a2f90c19dd9a20a91fdf7d8108c0796ed3
data/s3_website.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "s3_website_monadic"
6
- s.version = "0.0.12"
6
+ s.version = "0.0.13"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Lauri Lehmijoki"]
9
9
  s.email = ["lauri.lehmijoki@iki.fi"]
@@ -104,7 +104,7 @@ object CloudFront {
104
104
 
105
105
 
106
106
  def needsInvalidation: PartialFunction[PushSuccessReport, Boolean] = {
107
- case SuccessfulUpload(upload) => upload.uploadType match {
107
+ case SuccessfulUpload(upload, _) => upload.uploadType match {
108
108
  case Update => true
109
109
  case _ => false
110
110
  }
@@ -138,7 +138,7 @@ object Push {
138
138
  failureOrSuccess => failureOrSuccess.fold(
139
139
  (failureReport: PushFailureReport) => counts.copy(failures = counts.failures + 1),
140
140
  (successReport: PushSuccessReport) => successReport match {
141
- case SuccessfulUpload(upload) => upload.uploadType match {
141
+ case SuccessfulUpload(upload, _) => upload.uploadType match {
142
142
  case NewFile => counts.copy(newFiles = counts.newFiles + 1)
143
143
  case Update => counts.copy(updates = counts.updates + 1)
144
144
  case Redirect => counts.copy(redirects = counts.redirects + 1)
@@ -21,8 +21,9 @@ class S3(implicit s3Settings: S3Settings, executor: ExecutionContextExecutor) {
21
21
 
22
22
  def upload(upload: Upload with UploadTypeResolved, a: Attempt = 1)(implicit config: Config): Future[Either[FailedUpload, SuccessfulUpload]] =
23
23
  Future {
24
- s3Settings.s3Client(config) putObject toPutObjectRequest(upload)
25
- val report = SuccessfulUpload(upload)
24
+ val putObjectRequest = toPutObjectRequest(upload)
25
+ s3Settings.s3Client(config) putObject putObjectRequest
26
+ val report = SuccessfulUpload(upload, putObjectRequest.getMetadata)
26
27
  info(report)
27
28
  Right(report)
28
29
  } recoverWith retry(a)(
@@ -136,11 +137,19 @@ object S3 {
136
137
  def s3Key: String
137
138
  }
138
139
 
139
- case class SuccessfulUpload(upload: Upload with UploadTypeResolved) extends PushSuccessReport {
140
+ case class SuccessfulUpload(upload: Upload with UploadTypeResolved, metadata: ObjectMetadata) extends PushSuccessReport {
141
+ def metadataReport =
142
+ (metadata.getCacheControl :: metadata.getContentType :: metadata.getContentEncoding :: Nil)
143
+ .map(Option(_))
144
+ .collect {
145
+ case Some(metadatum) => metadatum
146
+ }
147
+ .mkString(" | ")
148
+
140
149
  def reportMessage =
141
150
  upload.uploadType match {
142
- case NewFile => s"Created ${upload.s3Key}"
143
- case Update => s"Updated ${upload.s3Key}"
151
+ case NewFile => s"Created ${upload.s3Key} ($metadataReport)"
152
+ case Update => s"Updated ${upload.s3Key} ($metadataReport)"
144
153
  case Redirect => s"Redirecting ${upload.essence.left.get.key} to ${upload.essence.left.get.redirectTarget}"
145
154
  }
146
155
 
@@ -85,7 +85,7 @@ class S3WebsiteSpec extends Specification {
85
85
  }
86
86
 
87
87
  "create a file if does not exist on S3" in new SiteDirectory with MockAWS {
88
- implicit val site = siteWithFilesAndContent(localFilesWithContent = ("index.html", "<h1>hello</h1>") :: Nil)
88
+ implicit val site = siteWithFiles(localFiles = "index.html" :: Nil)
89
89
  Push.pushSite
90
90
  sentPutObjectRequest.getKey must equalTo("index.html")
91
91
  }
@@ -98,14 +98,14 @@ class S3WebsiteSpec extends Specification {
98
98
  }
99
99
 
100
100
  "try again if the upload fails" in new SiteDirectory with MockAWS {
101
- implicit val site = siteWithFilesAndContent(localFilesWithContent = ("index.html", "<h1>hello</h1>") :: Nil)
101
+ implicit val site = siteWithFiles(localFiles = "index.html" :: Nil)
102
102
  uploadFailsAndThenSucceeds(howManyFailures = 5)
103
103
  Push.pushSite
104
104
  verify(amazonS3Client, times(6)).putObject(Matchers.any(classOf[PutObjectRequest]))
105
105
  }
106
106
 
107
107
  "not try again if the upload fails on because of invalid credentials" in new SiteDirectory with MockAWS {
108
- implicit val site = siteWithFilesAndContent(localFilesWithContent = ("index.html", "<h1>hello</h1>") :: Nil)
108
+ implicit val site = siteWithFiles(localFiles = "index.html" :: Nil)
109
109
  when(amazonS3Client.putObject(Matchers.any(classOf[PutObjectRequest]))).thenThrow {
110
110
  val e = new AmazonServiceException("your credentials are incorrect")
111
111
  e.setStatusCode(403)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website_monadic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki