Skip to content

Commit

Permalink
Merge pull request #3 from rashidkpc/master
Browse files Browse the repository at this point in the history
Move test server to port 8001
  • Loading branch information
Rashid Khan committed Feb 14, 2014
2 parents b890858 + 4c54980 commit a4274ab
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 12 deletions.
19 changes: 12 additions & 7 deletions src/courier/mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ define(function (require) {
*
* @class Mapper
*/
function Mapper(index, type) {
this.indices = function () {
function Mapper(client) {

/**
* Gets an object containing all fields with their mappings
* @param {dataSource} [dataSource]
* @param {Function} [callback] A function to be executed with the results.
* @param {String} [type]
* @return {Object} A hash containing fields and their related mapping
*/
this.getFields = function (dataSource, callback, type) {
client.indices.getFieldMapping({index: dataSource.index}, callback);
};

this.getFields = function () {

};

this.getFieldType = function (field, type) {
this.getFieldType = function (dataSource, field, type) {
return field, type;
};

}

return Mapper;
Expand Down
6 changes: 5 additions & 1 deletion src/kibana/controllers/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define(function (require) {
type: '@'
},
template: '<strong style="float:left">{{count}} :&nbsp;</strong><pre>{{json}}</pre>',
controller: function ($rootScope, $scope) {
controller: function ($rootScope, $scope, courier) {
$scope.count = 0;

var source = $rootScope.dataSource.extend()
Expand All @@ -33,6 +33,10 @@ define(function (require) {
$scope.json = JSON.stringify(resp.hits, null, ' ');
});

courier.mapper.getFields($rootScope.dataSource, function (data) {
$scope.json = data;
});

$scope.$watch('type', source.type);
}
};
Expand Down
3 changes: 2 additions & 1 deletion tasks/config/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
'<%= src %>',
'<%= root %>/node_modules/mocha',
'<%= root %>/node_modules/expect.js'
]
],
port: 8001
}
}
};
2 changes: 1 addition & 1 deletion tasks/config/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
log: true,
logErrors: true,
urls: [
'http://localhost:8000/'
'http://localhost:8001/'
],
run: false
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Lint and build CSS
module.exports = function(grunt) {
grunt.registerTask('default', ['jshint:source']);
grunt.registerTask('default', ['jshint:source','test']);
};
3 changes: 2 additions & 1 deletion test/unit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
})
require([
'/specs/courier.js',
'/specs/data_source.js'
'/specs/data_source.js',
'/specs/mapper.js'
], function () {
window.mochaRunner = mocha.run().on('end', function(){
window.mochaResults = this.stats;
Expand Down
48 changes: 48 additions & 0 deletions test/unit/specs/mapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
define(function (require) {
var elasticsearch = require('../bower_components/elasticsearch/elasticsearch.js');
var _ = require('lodash');
var Courier = require('courier/courier');
var DataSource = require('courier/data_source/data_source');
var Mapper = require('courier/mapper');
var client = new elasticsearch.Client({
host: 'localhost:9200',
});

describe('Mapper Module', function () {

it('provides a constructor for the Mapper class', function () {
var mapper = new Mapper(client);
expect(mapper).to.be.a(Mapper);
});

it('has a function called getFields that returns an object', function () {
/*
var courier = new Courier({
client: client
});
var dataSource = courier.createSource('search')
.index('_all')
.size(5);
var mapper = new Mapper(client);
var callback = function(data) {
console.log(data);
};
expect(mapper.getFields(dataSource,callback)).to.eql({
foo: {
type: 'string'
},
"foo.bar": {
type: 'long'
}
});
*/
});


});

});

0 comments on commit a4274ab

Please sign in to comment.