Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating setup to use a master index file

  • Loading branch information...
commit be7a8709c67932ce2d88e32523b89ea835e99ac8 1 parent 9120038
@rgerard authored
Showing with 38 additions and 10 deletions.
  1. +2 −2 README.md
  2. +27 −0 index.js
  3. +2 −2 package.json
  4. +7 −6 test/test_nfl.js
View
4 README.md
@@ -22,7 +22,7 @@ Or from source:
## Simple Examples
```javascript
-var sportsdata_nfl = require('index_nfl');
+var sportsdata_nfl = require('sportsdata').NFL;
// Init the object with the access level, version, apikey, year, and season you care about
sportsdata_nfl.init('t', 1, apikey, '2012', 'REG');
@@ -35,7 +35,7 @@ sportsdata_nfl.getSeasonSchedule(function(error, schedule) {
});
-var sportsdata_nba = require('index_nba');
+var sportsdata_nba = require('sportsdata').NBA;
// Init the object with the access level, version, apikey, seasonID, and season you care about
sportsdata_nba.init('t', 2, apikey, '2012', 'REG');
View
27 index.js
@@ -0,0 +1,27 @@
+// Copyright 2010-2012 Ryan Gerard
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var sportsdata_nfl = require('./index_nfl'),
+ sportsdata_nba = require('./index_nba');
+
+function createNfl() {
+ return sportsdata_nfl;
+}
+
+function createNba() {
+ return sportsdata_nba;
+}
+
+module.exports.NFL = createNfl();
+module.exports.NBA = createNba();
View
4 package.json
@@ -1,8 +1,8 @@
{
"name": "sportsdata",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Node module that wraps the SportsData API",
- "main": "index_nfl.js",
+ "main": "index.js",
"scripts": {
"test": "nodeunit test/"
},
View
13 test/test_nfl.js
@@ -1,10 +1,11 @@
-var mainIndex = require('../index_nfl'),
+var mainIndex = require('../index'),
+ nfl = mainIndex.NFL,
mockRequest = require('./mock_request');
module.exports = {
setUp: function (callback) {
// Replace the normal request object with a mock request object that returns real responses
- mainIndex.setRequest(mockRequest);
+ nfl.setRequest(mockRequest);
callback();
},
@@ -16,7 +17,7 @@ module.exports = {
test.expect(2);
// Get the NFL schedule for week 1
- mainIndex.getWeeklySchedule(1, function(err, body) {
+ nfl.getWeeklySchedule(1, function(err, body) {
test.ok(err === null, 'Error is not null! ' + err);
test.ok(body !== null, 'Body is null! ' + body);
test.done();
@@ -27,7 +28,7 @@ module.exports = {
test.expect(2);
// Get the NFL season schedule
- mainIndex.getSeasonSchedule(function(err, body) {
+ nfl.getSeasonSchedule(function(err, body) {
test.ok(err === null, 'Error is not null! ' + err);
test.ok(body !== null, 'Body is null! ' + body);
test.done();
@@ -38,7 +39,7 @@ module.exports = {
test.expect(2);
// Get the stats for Game 1 between DAL and NYG
- mainIndex.getGameStats(1, 'DAL', 'NYG', function(err, body) {
+ nfl.getGameStats(1, 'DAL', 'NYG', function(err, body) {
test.ok(err === null, 'Error is not null! ' + err);
test.ok(body !== null, 'Body is null! ' + body);
test.done();
@@ -49,7 +50,7 @@ module.exports = {
test.expect(2);
// Get the NFL weekly boxscore for Week 1
- mainIndex.getWeeklyBoxscore(1, function(err, body) {
+ nfl.getWeeklyBoxscore(1, function(err, body) {
test.ok(err === null, 'Error is not null! ' + err);
test.ok(body !== null, 'Body is null! ' + body);
test.done();
Please sign in to comment.
Something went wrong with that request. Please try again.