Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyar committed Mar 17, 2014
0 parents commit 2786c1b
Show file tree
Hide file tree
Showing 15 changed files with 433 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
npm-debug.log
90 changes: 90 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* Project specific jshint linting options.
*
* Forked from Airbnb JSHint settings.
*
* @version 0.4.0s
* @see http://www.jshint.com/docs/
* @see https://github.com/airbnb/javascript
*/
{
/*
* ENVIRONMENTS
* =================
*/

// Define globals exposed by modern browsers.
"browser": false,

// Define globals exposed by jQuery.
"jquery": false,

// Define globals exposed by Node.js.
"node": true,

/*
* ENFORCING OPTIONS
* =================
*/

// This option requires you to always put curly braces
// around blocks in loops and conditionals.
"curly": true,

// This option prohibits the use of immediate function
// invocations without wrapping them in parentheses.
"immed": true,

// This option prohibits the use of arguments.caller
// and arguments.callee. Both .caller and .callee make
// quite a few optimizations impossible so they were
// deprecated in future versions of JavaScript.
"noarg": true,

// This option suppresses warnings about the use of
// assignments in cases where comparisons are expected
"boss": true,

// Prohibit use of == and != in favor of === and !==.
"eqeqeq": true,

// Suppress warnings about == null comparisons.
"eqnull": true,

// Prohibit use of a variable before it is defined.
"latedef": true,

// Require capitalized names for constructor functions.
"newcap": true,

// Prohibit trailing whitespace.
"trailing": true,

// Prohibit use of explicitly undeclared variables.
"undef": true,

// Warn when variables are defined but never used.
"unused": true,

// suppress object dot notation warnings, we know what we're doing
"sub": true,

/**
* PROJECT GLOBALS
* ================
*
*/
"globals": {
/* MOCHA */
"suite": false,
"describe": false,
"test": false,
"setup": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false,
"teardown": false,
"assert": false
}
}
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- '0.10'
- '0.8'
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## We use GitHub workflow

You can read more about workflow on GitHub [guides](http://guides.github.com/).

### How to contribute

1. [Create an issue](https://github.com/verybigman/generator-bem/issues/new) with description or take from available.
2. Create a feature-branch with an issue number based on a master branch. For example, for an issue #42: `git checkout -b feature/issue@42`.
3. Commit changes and `push` your branch.
4. Create a pull-request from your feature branch.
5. Link your pull-request with an issue number by comment.
6. Wait for your pull-request and the issue to be closed.

_For pretty work with process you can use [git-extras](https://github.com/visionmedia/git-extras) - very useful tool for Git_
16 changes: 16 additions & 0 deletions CONTRIBUTING.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Мы используем рабочий процесс GitHub'а

Подробнее почитать об этом можно на GitHub [guides](http://guides.github.com/),
а также в статье на [хабре](http://habrahabr.ru/post/189046/).

### Как внести изменения

1. [Создайте новое issue](https://github.com/verybigman/generator-bem/issues/new) с описанием или возьмите существующее.
2. Создайте feature-branch с номером issue от master ветки. Например, для issue #42: `git checkout -b feature/issue@42`.
3. Зафиксируйте изменения и сделайте `push` вашей ветки.
4. Создайте pull-request из вашей ветки.
5. Свяжите ваш pull-request с номером issue через коментарий.
6. Ждите пока ваш pull-request примут, а issue закроют.

_Для продуктивной работы с таким процессом вы можете использовать [git-extras](https://github.com/visionmedia/git-extras)
\- очень полезный инструмент для Git_
53 changes: 53 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

module.exports = function (grunt) {
// Show elapsed time at the end
require('time-grunt')(grunt);
// Load all grunt tasks
require('load-grunt-tasks')(grunt);

// Project configuration.
grunt.initConfig({
mochaTest: {
options: {
ui: 'bdd'
},
test: {
src: ['test/**/*.js']
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['lib/**/*.js']
},
test: {
src: ['test/**/*.js']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib: {
files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib', 'mochaTest']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'mochaTest']
}
}
});

grunt.registerTask('default', ['test']);
grunt.registerTask('test', ['jshint', 'mochaTest']);

};
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# xsltproc [![Build Status](https://secure.travis-ci.org/ilyar/xsltproc.png?branch=master)](http://travis-ci.org/ilyar/xsltproc) [![NPM version](https://badge.fury.io/js/xsltproc.png)](http://badge.fury.io/js/xsltproc)

Wrapper for xsltproc.

## Getting Started

First install the xsltproc if not already installed on your system read [installing an XSLT processor](http://www.sagehill.net/docbookxsl/InstallingAProcessor.html).
Install the module with: `npm install xsltproc --save`

```javascript
var xsltproc = require('xsltproc')

var xslt = xsltproc.transform('stylesheet.xsl', 'data.xml');

xslt.stdout.on('data', function (data) {
console.log('xsltproc stdout: ' + data);
});

xslt.stderr.on('data', function (data) {
console.log('xsltproc stderr: ' + data);
});

xslt.on('exit', function (code) {
console.log('xsltproc process exited with code ' + code);
});
```

```javascript
var xsltproc = require('xsltproc')

xsltproc.transform('stylesheet.xsl', 'data.xml', {
"profile": true,
"output": "test.txt"
});
```

## Release History
- **v0.0.1**:
- initial release

## License
Copyright (c) 2014 Ilya Rogov. Licensed under the MIT license.
93 changes: 93 additions & 0 deletions lib/xsltproc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* xsltproc
* https://github.com/ilyar/xsltproc
*
* Copyright (c) 2014 Ilya Rogov
* Licensed under the MIT license.
*/

'use strict';

var spawn = require('child_process').spawn,
fs = require('fs'),
which = require('which').sync;

/**
* xslt processor
* @param stylesheet
* @param file
* @param options
* @returns EventEmitter
*/
exports.transform = function(stylesheet, file, options) {
var cmd = 'xsltproc',
args = this.getArgs(options);

args.push(stylesheet);
args.push(file);

try {
cmd = which(cmd);
} catch (err) {
console.error(err); // code 127
return;
}

var xslt = spawn(cmd, args);

if (options && typeof options.profile !== 'undefined') {

xslt.stderr.on('data', function (data) {

var profilePath = options.profile === true ? 'profile.txt': options.profile;

fs.writeFile(profilePath, data, function (err) {
if (err) { throw err; }
});

});

}

if (options && typeof options.debug !== 'undefined') {
console.log(args);
}

return xslt;
};

/**
* Gating arguments
* @param options
* @returns {Array}
*/
exports.getArgs = function(options) {
var args = [];

// do XInclude processing on document input
if (options && typeof options.xinclude !== 'undefined') {
args.push('--xinclude');
}

// skip the DTD loading phase
if (options && typeof options.novalid !== 'undefined') {
args.push('--novalid');
}

// dump profiling informations
if (options && typeof options.profile !== 'undefined') {
args.push('--profile');
}

// save to a given file
if (options && typeof options.output !== 'undefined') {
args.push('--output', options.output);
}

// the input document character encoding
if (options && typeof options.encoding !== 'undefined') {
args.push('--encoding', options.encoding);
}

return args;
};
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "xsltproc",
"version": "0.0.1",
"description": "Wrapper for xsltproc.",
"homepage": "https://github.com/ilyar/xsltproc",
"bugs": "https://github.com/ilyar/xsltproc/issues",
"author": {
"name": "Ilya Rogov",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/ilyar/xsltproc"
},
"licenses": [
{
"type": "MIT"
}
],
"main": "lib/xsltproc.js",
"scripts": {
"test": "grunt test"
},
"dependencies": {
"which": "^1.0.5",
"log": "^1.4.0"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-watch": "~0.5.0",
"load-grunt-tasks": "~0.2.0",
"mocha": "~1.17.1",
"time-grunt": "~0.1.1",
"jshint-stylish": "~0.1.3",
"grunt-mocha-test": "~0.7.0",
"chai": "^1.9.0"
}
}
4 changes: 4 additions & 0 deletions test/fixtures/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<page title="Page title">
<content>Page content</content>
</page>
Loading

0 comments on commit 2786c1b

Please sign in to comment.