Skip to content

Commit

Permalink
Merge pull request #12 from jshor/show-hrt
Browse files Browse the repository at this point in the history
adds option to show/hide human readable text
  • Loading branch information
jshor authored Oct 30, 2018
2 parents 3855b2d + be4ed71 commit a1a862f
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install:
# ensure source install works
- npm install --build-from-source --clang=1
# test our module
- npm run test-travis
- npm run test

before_script:
# if publishing, do it
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v1.2.2

- adds option to show/hide human-readable text
- adds targeted build names back to CI

v1.2.1

- fixes travis config
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Symbology.js - v1.2.1.
Symbology.js
Copyright (c) 2018 Josh Shor.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,25 @@ Result: {

## 4. Available options (struct)

A Symbol is a regular JavaScript object with the following available properties:

| Enumerated type | Type | Meaning | Required? | Default value |
|-----------------|--------------------|-----------------------------------------------------------------------------------------------------------------|-----------|---------------|
| symbology | Symbology enum | The enumerated type of the symbology (see [Enumerated Barcode Types](#enumerated-barcode-types) for more info). | **Yes** | |
| height | Number | The height of the image. If specified, this will maintain the aspect ratio. | No | 50 |
| whitespaceWidth | Number | Width of whitespace, for barcodes which have this option. | No | 0 |
| borderWidth | Number | Width of border. | No | 0 |
| outputOptions | Number | Symbology-specific output option. | No | `NULL` |
| foregroundColor | Hexadecimal number | Barcode foreground color. | No | FFFFFF |
| backgroundColor | Hexadecimal number | Barcode background color. | No | 000000 |
| fileName | String | Full path to the file to render. | **Yes*** | |
| scale | Number | Scale of the barcode image. Applies only to PNG. | No | 1.0 |
| option1 | Number | Symbology-type-specific option value. | No | `NULL` |
| option2 | Number | Symbology-type-specific option value. | No | `NULL` |
| option3 | Number | Symbology-type-specific option value. | No | `NULL` |

\* required only if using `createFile`.
A `Symbol` is a regular JavaScript object with the following available properties:

| Enumerated type | Type | Meaning | Required? | Default value |
|-----------------------|--------------------|-----------------------------------------------------------------------------------------------------------------|-----------|---------------|
| symbology | Symbology enum | The enumerated type of the symbology (see [Enumerated Barcode Types](#enumerated-barcode-types) for more info). | **Yes** | |
| height | Number | The height of the image. If specified, this will maintain the aspect ratio. | No | 50 |
| whitespaceWidth | Number | Width of whitespace, for barcodes which have this option. | No | 0 |
| borderWidth | Number | Width of border. | No | 0 |
| outputOptions | Number | Symbology-specific output option. | No | `NULL` |
| foregroundColor | Hexadecimal number | Barcode foreground color. | No | FFFFFF |
| backgroundColor | Hexadecimal number | Barcode background color. | No | 000000 |
| fileName | String | Full path to the file to render. | **Yes** | |
| scale | Number | Scale of the barcode image. Applies only to PNG. | No | 1.0 |
| option1 | Number | Symbology-type-specific option value. | No | `NULL` |
| option2 | Number | Symbology-type-specific option value. | No | `NULL` |
| option3 | Number | Symbology-type-specific option value. | No | `NULL` |
| showHumanReadableText | Boolean | Show or hide the symbology data as human-readable text (if applicable). | No | `true` |

\* required only if using `createFile()`.

## 5. Error handling

Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "symbology",
"version": "1.2.1",
"version": "1.2.2",
"description": "Generate 50+ different 1D or 2D barcodes in png, eps, or svg format.",
"keywords": [
"barcode",
Expand All @@ -20,9 +20,9 @@
},
"binary": {
"module_name": "symbology",
"module_path": "./lib/binding/{configuration}/",
"module_path": "./lib/binding/{configuration}/{node_abi}-{platform}-{arch}/",
"remote_path": "./{module_name}/v{version}/{configuration}/",
"package_name": "{module_name}-v{version}.tar.gz",
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz",
"host": "https://symbologyjs.s3-us-west-2.amazonaws.com"
},
"dependencies": {
Expand All @@ -48,8 +48,7 @@
"scripts": {
"start": "node ./foo.js",
"install": "node-pre-gyp install --fallback-to-build",
"test-travis": "./node_modules/istanbul/lib/cli.js cover _mocha -- -R spec ./src/**/*.test.js",
"test": "mocha ./test/*",
"test": "./node_modules/istanbul/lib/cli.js cover _mocha -- -R spec ./src/**/*.test.js",
"prepublish": "npm ls",
"build": "node-pre-gyp build",
"package-binary": "node-pre-gyp build package",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getSymbol(obj) {
option1: obj.option1 || -1,
option2: obj.option2 || -1,
option3: obj.option3 || -1,
show_hrt: obj.show_hrt || 1
showHumanReadableText: obj.showHumanReadableText || 0
// input_mode: BINARY_MODE,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var defaultSymbol = {
option1: -1,
option2: -1,
option3: -1,
show_hrt: 1 // show human-readable text
showHumanReadableText: 1 // show human-readable text
// input_mode: BINARY_MODE,
};

Expand Down Expand Up @@ -77,7 +77,7 @@ function createSymbology(symbologyStruct, barcodeData, fnName) {
symbologyStruct.option1,
symbologyStruct.option2,
symbologyStruct.option3,
// symbologyStruct.showHrt,
symbologyStruct.showHumanReadableText ? 1 : 0,
// symbologyStruct.input_mode,
(symbologyStruct.text || barcodeData)
);
Expand Down
5 changes: 4 additions & 1 deletion src/lib/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ namespace symbology {
// file name to render
copyArgStr(*args[8], (char*)&symbol->outfile[0], sizeof(symbol->outfile));

// show/hide human-readable text
symbol->show_hrt = argToInt(*args[13]);

// text to display
copyArgStr(*args[13], (char*)&symbol->text[0], sizeof(symbol->text));
copyArgStr(*args[14], (char*)&symbol->text[0], sizeof(symbol->text));

return symbol;
}
Expand Down

0 comments on commit a1a862f

Please sign in to comment.