Skip to content

Commit

Permalink
Grails 2.4.4 support and upgraded zxing to 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
goeh committed Mar 13, 2015
1 parent 51b0ec5 commit 1a799ac
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion QrcodeGrailsPlugin.groovy
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
class QrcodeGrailsPlugin {
def version = "0.6"
def version = "0.7"
def grailsVersion = "2.0.0 > *"
def dependsOn = [:]
def pluginExcludes = [
Expand Down
2 changes: 1 addition & 1 deletion application.properties
@@ -1,4 +1,4 @@
#Grails Metadata file
#Fri Apr 27 12:59:28 CEST 2012
app.grails.version=2.2.4
app.grails.version=2.4.4
app.name=qrcode
21 changes: 10 additions & 11 deletions grails-app/conf/BuildConfig.groovy
@@ -1,28 +1,27 @@
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target"
grails.project.target.level = 1.6

grails.project.fork = false

grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
inherits("global") { }
log "warn"
inherits("global")

repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}
dependencies {
compile "ar.com.hjg:pngj:2.1.0"
compile "com.google.zxing:core:3.1.0"
compile "com.google.zxing:core:3.2.0"
}

plugins {
build(":tomcat:$grailsVersion",
":release:2.2.1",
":rest-client-builder:1.0.3") {
export = false
}
runtime(":hibernate:$grailsVersion") {
build ':release:3.0.1', {
export = false
}
}
}
}
Expand Up @@ -29,4 +29,5 @@ package org.codehaus.groovy.grails.plugins.qrcode
*/
class QrCodeService extends QRCodeRenderer {
static scope = 'prototype'
static transactional = false
}
Expand Up @@ -96,7 +96,7 @@ class QRCodeRenderer {
md.setText(PngChunkTextVar.KEY_Author, "Shawn Hartsock")
md.setText(PngChunkTextVar.KEY_Software, "Grails QRCode Plugin")
md.setText(PngChunkTextVar.KEY_Source, this.getClass().getCanonicalName())
md.setText(PngChunkTextVar.KEY_Comment, "Uses ZXing (http://code.google.com/p/zxing/) and pngj (http://code.google.com/p/pngj/)")
md.setText(PngChunkTextVar.KEY_Comment, "Uses ZXing (https://github.com/zxing/zxing) and pngj (https://github.com/leonbloy/pngj)")

// loop over byte array to render but project
// down from the image onto the smaller byte
Expand All @@ -111,7 +111,7 @@ class QRCodeRenderer {
for (int jj = 0; jj < size; jj++) {
int x = jj / scale // truncate
double color = 1.0
if (matrix.get(x, y)) {
if (x < cols && y < cols && matrix.get(x, y)) {
color = 0.0
}
ImageLineHelper.setValD(line, jj * channels, color)
Expand Down
Expand Up @@ -6,6 +6,7 @@ import org.apache.commons.io.IOUtils

class QrcodeControllerTests extends ControllerUnitTestCase {
QrCodeService qrCodeService
QrcodeController controller = new QrcodeController()

void testSimpleRender() {
controller.qrCodeService = qrCodeService
Expand All @@ -23,7 +24,7 @@ class QrcodeControllerTests extends ControllerUnitTestCase {
byte[] png = IOUtils.toByteArray(pngIn)

assert png != null

assert Arrays.equals(png,out)
}
}
Expand Up @@ -6,12 +6,12 @@ class QrcodeTagLibTests extends GroovyPagesTestCase {

void testUrl() {
def template = '<qrcode:url height="100" width="100"/>'
assert applyTemplate(template) == '<img src="/qrcode/url?u=http%3A%2F%2Flocalhost%3A80&s=100" class="qrcode" alt="http://localhost:80"/>'
assert applyTemplate(template) == '<img src="/qrcode/url?u=http%3A%2F%2Flocalhost&s=100" class="qrcode" alt="http://localhost"/>'
}

void testUrlAbsolute() {
def template = '<qrcode:url height="100" width="100" absolute="true"/>'
assert applyTemplate(template) == '<img src="http://localhost/qrcode/url?u=http%3A%2F%2Flocalhost%3A80&s=100" class="qrcode" alt="http://localhost:80"/>'
assert applyTemplate(template) == '<img src="http://localhost/qrcode/url?u=http%3A%2F%2Flocalhost&s=100" class="qrcode" alt="http://localhost"/>'
}

void testImage() {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1a799ac

Please sign in to comment.