Skip to content
This repository has been archived by the owner on Apr 6, 2018. It is now read-only.

Commit

Permalink
Rename method 'compile' to 'process'
Browse files Browse the repository at this point in the history
  • Loading branch information
necolas committed Jan 3, 2014
1 parent a83e9cb commit b4f488c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -76,7 +76,7 @@ Optionally pass an array of the browsers you want autoprefixer to know about.
See the [autoprefixer](https://github.com/ai/autoprefixer) documentation for
more details.

### suit([browsers]).compile(css)
### suit([browsers]).process(css)

Process a string of CSS. Returns a string.

Expand All @@ -97,10 +97,10 @@ var suit = require('rework-suit');
var css = fs.readFileSync('build/build.css', 'utf8').toString();

// process the CSS
var compiled = suit(['> 2%']).compile(css)
var processed = suit(['> 2%']).process(css)

// write to disk
fs.writeFileSync('build/build.css', compiled);
fs.writeFileSync('build/build.css', processed);
```

As a Rework plugin:
Expand All @@ -115,12 +115,12 @@ var suit = require('rework-suit');
var css = fs.readFileSync('build/build.css', 'utf8').toString();

// process the CSS with Rework
var compiled = rework(css)
var processed = rework(css)
.use(suit(['> 2%']).rework)
.toString();

// write to disk
fs.writeFileSync('build/build.css', compiled);
fs.writeFileSync('build/build.css', processed);
```

## Testing
Expand Down
7 changes: 3 additions & 4 deletions index.js
Expand Up @@ -36,14 +36,13 @@ function suit(browsers) {
}

/**
* Compile CSS using Rework rework plugins to a rework instance; export as a
* rework plugin
* Process CSS using Rework
*
* @param {String} css the source CSS
* @param {String} css
* @return {String}
*/

suit.compile = function (css) {
suit.process = function (css) {
if (typeof css !== 'string') {
throw new Error('rework-suit: `compile(css)` The argument must be a String');
}
Expand Down
32 changes: 16 additions & 16 deletions test/test.js
Expand Up @@ -16,54 +16,54 @@ describe('suit()', function () {
'safari >=6'
];

describe('.compile()', function () {
describe('.process()', function () {
it('throws an error when there is no input String', function () {
var compiled = function () {
return suit().compile();
var processed = function () {
return suit().process();
};
expect(compiled).to.throw(Error);
expect(processed).to.throw(Error);
});

it('generates the expected output with default browser config', function () {
var compiled = suit().compile(original);
var processed = suit().process(original);

// for debugging
fs.outputFileSync('test/tmp/compiled-default.css', compiled);
fs.outputFileSync('test/tmp/processed-default.css', processed);

expect(compiled).to.equal(expectedDefault);
expect(processed).to.equal(expectedDefault);
});

it('generates the expected output with custom browser config', function () {
var compiled = suit(browsers).compile(original);
var processed = suit(browsers).process(original);

// for debugging
fs.outputFileSync('test/tmp/compiled-custom.css', compiled);
fs.outputFileSync('test/tmp/processed-custom.css', processed);

expect(compiled).to.equal(expectedCustom);
expect(processed).to.equal(expectedCustom);
});
});

describe('.rework()', function () {
it('generates the expected output with default browser config', function () {
var compiled = rework(original)
var processed = rework(original)
.use(suit().rework)
.toString();

// for debugging
fs.outputFileSync('test/tmp/compiled-rework-default.css', compiled);
fs.outputFileSync('test/tmp/processed-rework-default.css', processed);

expect(compiled).to.equal(expectedDefault);
expect(processed).to.equal(expectedDefault);
});

it('generates the expected output with custom browser config', function () {
var compiled = rework(original)
var processed = rework(original)
.use(suit(browsers).rework)
.toString();

// for debugging
fs.outputFileSync('test/tmp/compiled-rework-custom.css', compiled);
fs.outputFileSync('test/tmp/processed-rework-custom.css', processed);

expect(compiled).to.equal(expectedCustom);
expect(processed).to.equal(expectedCustom);
});
});

Expand Down

0 comments on commit b4f488c

Please sign in to comment.