Skip to content

Commit

Permalink
feat(base): create hello world with C++ bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Joseph committed May 11, 2016
1 parent 33a6211 commit 2f4fcf5
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "lob",
"globals": {
"expect": false
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ coverage
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
build

# Dependency directory
node_modules
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: node_js
sudo: false
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages:
- libpoppler-cpp-dev
- libpoppler-dev
- libfontconfig1-dev
- libpng12-dev
- libjpeg-turbo8-dev
- libtiff4-dev
- g++-4.9
env: CXX=g++-4.9
node_js:
- '0.10'
- '0.12'
- '4'
- '5'
- '6'
before_install:
- npm i npm -g
script:
- npm test
- npm run lint
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# pdffonts
Node bindings for Poppler's pdffonts CLI

Node bindings for Poppler's `pdffonts` CLI.

## Dependencies

For this module to install and build correctly, you'll need to make sure that [`poppler`](https://poppler.freedesktop.org/) is installed on your machine.

To install Poppler on Mac OS X using Homebrew:

```
brew install poppler
```

To install Poppler on Ubuntu:

```
apt-get install pkg-config
apt-get install libpoppler-cpp-dev
```

## Testing

```bash
$ npm i
$ npm test
```

## Linting

```bash
$ npm run lint
```
13 changes: 13 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"targets": [
{
"target_name": "pdffonts",
"sources": [
"src/pdffonts.cc"
],
"include_dirs": [
"<!(node -e \"require('nan')\")"
]
}
]
}
3 changes: 3 additions & 0 deletions lib/pdffonts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('bindings')('pdffonts');
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "pdffonts",
"version": "0.0.1",
"description": "Node bindings for Poppler's pdffonts CLI",
"main": "./lib/pdffonts.js",
"scripts": {
"lint": "eslint .",
"release:major": "changelog -M && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version major && git push origin && git push origin --tags",
"release:minor": "changelog -m && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version minor && git push origin && git push origin --tags",
"release:patch": "changelog -p && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version patch && git push origin && git push origin --tags",
"test": "node-gyp rebuild && mocha test --require test/setup.js --recursive --timeout 30000"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lob/pdffonts.git"
},
"keywords": [
"poppler",
"pdffonts",
"pdf",
"fonts"
],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/lob/pdffonts/issues"
},
"homepage": "https://github.com/lob/pdffonts#readme",
"dependencies": {
"bindings": "^1.2.1",
"nan": "^2.3.3"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^1.10.3",
"eslint-config-lob": "^1.0.1",
"generate-changelog": "^1.0.1",
"mocha": "^2.4.5"
}
}
13 changes: 13 additions & 0 deletions src/pdffonts.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <nan.h>

using namespace v8;

NAN_METHOD(Hello) {
info.GetReturnValue().Set(Nan::New("world").ToLocalChecked());
}

NAN_MODULE_INIT(Init) {
Nan::Set(target, Nan::New("hello").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(Hello)).ToLocalChecked());
}

NODE_MODULE(pdffonts, Init)
15 changes: 15 additions & 0 deletions test/pdffonts.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

var Pdffonts = require('../lib/pdffonts');

describe('pdffonts', function () {

describe('hello', function () {

it('returns "world"', function () {
expect(Pdffonts.hello()).to.eql('world');
});

});

});
5 changes: 5 additions & 0 deletions test/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

var Chai = require('chai');

global.expect = Chai.expect;

0 comments on commit 2f4fcf5

Please sign in to comment.