Skip to content

Commit

Permalink
Support non-US-ASCII files when using ignore_on_server
Browse files Browse the repository at this point in the history
  • Loading branch information
laurilehmijoki committed Jul 6, 2014
1 parent deda470 commit 208497b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This project uses [Semantic Versioning](http://semver.org).

## 2.1.16

* Support non-US-ASCII files when using `ignore_on_server`

Fixes https://github.com/laurilehmijoki/s3_website/issues/102

## 2.1.15

* Support non-US-ASCII files when using `max_age`
Expand Down
2 changes: 1 addition & 1 deletion lib/s3_website/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module S3Website
VERSION = '2.1.15'
VERSION = '2.1.16'
end
14 changes: 8 additions & 6 deletions src/main/scala/s3/website/Ruby.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package s3.website
object Ruby {
lazy val rubyRuntime = org.jruby.Ruby.newInstance() // Instantiate heavy object

def rubyRegexMatches(text: String, regex: String) =
rubyRuntime.evalScriptlet(
s"""
!!Regexp.new('$regex').match('$text') # Use !! to force a boolean conversion
"""
).toJava(classOf[Boolean]).asInstanceOf[Boolean]
def rubyRegexMatches(text: String, regex: String) = {
val z = rubyRuntime.evalScriptlet(
s"""# encoding: utf-8
!!Regexp.new('$regex').match('$text')"""
)
z.toJava(classOf[Boolean]).asInstanceOf[Boolean]
}

}
2 changes: 1 addition & 1 deletion src/main/scala/s3/website/model/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ object Config {
def erbEval(erbString: String, yamlConfigPath: String): Try[String] = Try {
val erbStringWithoutComments = erbString.replaceAll("^\\s*#.*", "")
rubyRuntime.evalScriptlet(
s"""
s"""|# encoding: utf-8
|require 'erb'
|
|str = <<-ERBSTR
Expand Down
17 changes: 17 additions & 0 deletions src/test/scala/s3/website/S3WebsiteSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ class S3WebsiteSpec extends Specification {
push
noDeletesOccurred must beTrue
}

"support non-US-ASCII files" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
setS3Files(S3File("tags/笔记/test.html", ""))
config = "ignore_on_server: tags/笔记/test.html"
push
noDeletesOccurred must beTrue
}
}

"""
Expand All @@ -354,6 +361,16 @@ class S3WebsiteSpec extends Specification {
push
noDeletesOccurred must beTrue
}

"support non-US-ASCII files" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
setS3Files(S3File("tags/笔记/test.html", ""))
config = """
|ignore_on_server:
| - tags/笔记/test.html
""".stripMargin
push
noDeletesOccurred must beTrue
}
}

"max-age in config" can {
Expand Down

0 comments on commit 208497b

Please sign in to comment.