Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export function instead of object #23

Closed
s0ph1e opened this issue Mar 20, 2016 · 0 comments · Fixed by #24
Closed

Export function instead of object #23

s0ph1e opened this issue Mar 20, 2016 · 0 comments · Fixed by #24
Assignees
Milestone

Comments

@s0ph1e
Copy link
Member

s0ph1e commented Mar 20, 2016

Change

var scraper = require('website-scraper');
scraper.scrape(options);

to

var scrape = require('website-scraper');
scrape(options);
@s0ph1e s0ph1e self-assigned this Mar 20, 2016
@s0ph1e s0ph1e added this to the v1.0.0 milestone Mar 20, 2016
aivus added a commit that referenced this issue Mar 21, 2016
diff --git a/README.md b/README.md
index 1d0b28c..3efd63e 100644
--- a/README.md
+++ b/README.md
@@ -17,19 +17,19 @@ npm install website-scraper

 ## Usage
 ```javascript
-var scraper = require('website-scraper');
+var scrape = require('website-scraper');
 var options = {
   urls: ['http://nodejs.org/'],
   directory: '/path/to/save/',
 };

 // with callback
-scraper.scrape(options, function (error, result) {
+scrape(options, function (error, result) {
 	/* some code here */
 });

 // or with promise
-scraper.scrape(options).then(function (result) {
+scrape(options).then(function (result) {
 	/* some code here */
 });
 ```
@@ -70,8 +70,8 @@ and separate files into directories:
   - `css` for .css (full path `/path/to/save/css`)

 ```javascript
-var scraper = require('website-scraper');
-scraper.scrape({
+var scrape = require('website-scraper');
+scrape({
   urls: [
     'http://nodejs.org/',	// Will be saved with default filename 'index.html'
     {url: 'http://nodejs.org/about', filename: 'about.html'},
diff --git a/index.js b/index.js
index dd1cb08..426e8f2 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,5 @@
 var Scraper = require('./lib/scraper.js');

-module.exports.scrape = function (options, callback) {
+module.exports = function (options, callback) {
   return new Scraper(options).scrape(callback);
 };
\ No newline at end of file
diff --git a/test/functional/base-test.js b/test/functional/base-test.js
index e406e96..e656035 100644
--- a/test/functional/base-test.js
+++ b/test/functional/base-test.js
@@ -4,7 +4,7 @@ var fs = require('fs-extra');
 var path = require('path');
 var _ = require('underscore');
 var cheerio = require('cheerio');
-var scraper = require('../../index');
+var scrape = require('../../index');

 var testDirname = __dirname + '/.base';
 var mockDirname = __dirname + '/mocks/base';
@@ -65,7 +65,7 @@ describe('Functional base', function() {
 		// mocks for blog.html
 		nock('http://example.com/').get('/files/fail-1.png').replyWithError('something awful happened');

-		scraper.scrape(options).then(function(result) {
+		scrape(options).then(function(result) {
 			// should return right result
 			result.should.be.instanceOf(Array).and.have.length(3);
 			result.should.containEql({ url: 'http://example.com/', filename: 'index.html' });
diff --git a/test/functional/resources-without-ext-test.js b/test/functional/resources-without-ext-test.js
index 64abe53..0ce62ed 100644
--- a/test/functional/resources-without-ext-test.js
+++ b/test/functional/resources-without-ext-test.js
@@ -3,7 +3,7 @@ var nock = require('nock');
 var fs = require('fs-extra');
 var path = require('path');
 var _ = require('underscore');
-var scraper = require('../../index');
+var scrape = require('../../index');

 var testDirname = __dirname + '/.resources-without-ext';
 var mockDirname = __dirname + '/mocks/resources-without-ext';
@@ -49,7 +49,7 @@ describe('Functional resources without extensions', function() {
 		nock('http://google.com').get('/').replyWithFile(200, mockDirname + '/google.html');
 		nock('http://google.com').get('/google.png').reply(200, 'OK');

-		scraper.scrape(options).then(function() {
+		scrape(options).then(function() {
 			// should load css file and fonts from css file
 			fs.existsSync(testDirname + '/css').should.be.eql(true); // http://fonts.googleapis.com/css?family=Lato
 			fs.existsSync(testDirname + '/UyBMtLsHKBKXelqf4x7VRQ.woff2').should.be.eql(true);
s0ph1e added a commit that referenced this issue Mar 22, 2016
Export function instead of object. closes #23
aivus added a commit that referenced this issue Apr 16, 2016
aivus added a commit that referenced this issue Apr 16, 2016
s0ph1e pushed a commit that referenced this issue Apr 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant