Skip to content

Commit

Permalink
First public release
Browse files Browse the repository at this point in the history
  • Loading branch information
zewish committed Jul 29, 2015
0 parents commit e995587
Show file tree
Hide file tree
Showing 9 changed files with 447 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
bower_components
gulpfile.js
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2015 Resin.io, Inc. https://resin.io

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Resin Event Log

Resin event logging facility.

## Installing

```sh
$ npm install resin-event-log
```

```sh
$ bower install resin-event-log
```

## Development mode

The following command will watch for any changes you make:

```sh
$ gulp watch
```
90 changes: 90 additions & 0 deletions bin/resin-event-log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
(function() {
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
return define(['lodash', '../bower_components/node-uuid/uuid'], factory);
} else if (typeof exports === 'object') {
return module.exports = factory(require('lodash'), require('node-uuid'));
}
})(this, function(_, uuid) {
var EVENTS, HOOKS;
EVENTS = {
user: ['login', 'logout', 'signup', 'passwordCreate', 'passwordEdit', 'emailEdit'],
publicKey: ['create', 'delete'],
application: ['create', 'open', 'delete', 'osDownload'],
environmentVariable: ['create', 'edit', 'delete'],
device: ['open', 'rename', 'delete', 'terminalOpen', 'terminalClose'],
deviceEnvironmentVariable: ['create', 'edit', 'delete']
};
HOOKS = {
beforeStart: function(userId, interactionUuid) {},
afterStart: function(userId, interactionUuid) {},
beforeEnd: function() {},
afterEnd: function() {},
beforeCreate: function(type, jsonData, applicationId, deviceId) {},
afterCreate: function(type, jsonData, applicationId, deviceId) {}
};
return function(PinejsClient, subsystem, hooks) {
var exported;
if (!subsystem) {
throw Error('subsystem is required to start events interaction.');
}
hooks = _.merge(HOOKS, hooks);
exported = {
subsystem: subsystem,
start: function(userId, interactionUuid) {
hooks.beforeStart.apply(this, arguments);
if (!userId) {
throw Error('userId is required to start events interaction.');
}
this.userId = userId;
this.interactionUuid = interactionUuid || uuid();
return hooks.afterStart.call(this, this.userId, this.interactionUuid);
},
end: function() {
hooks.beforeEnd.apply(this);
this.userId = null;
this.interactionUuid = null;
return hooks.afterEnd.apply(this);
},
create: function(type, jsonData, applicationId, deviceId) {
var args;
args = arguments;
hooks.beforeCreate.apply(this, args);
return PinejsClient.post({
resource: 'event',
body: {
user: this.userId,
interaction_uuid: this.interactionUuid,
application_id: applicationId,
device_id: deviceId,
type: "[" + this.subsystem + "] " + type,
json_data: jsonData
}
}).then((function(_this) {
return function() {
return hooks.afterCreate.apply(_this, args);
};
})(this));
}
};
_.forEach(EVENTS, function(events, base) {
if (exported[base] == null) {
exported[base] = {};
}
return _.forEach(events, function(event) {
return exported[base][event] = function(jsonData, applicationId, deviceId) {
if (applicationId == null) {
applicationId = null;
}
if (deviceId == null) {
deviceId = null;
}
return exported.create(_.startCase(base + " " + event), jsonData, applicationId, deviceId);
};
});
});
return exported;
};
});

}).call(this);
20 changes: 20 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "resin-event-log",
"main": "bin/resin-event-log.js",
"version": "0.0.3",
"authors": [
"Iskren Slavov <iskren.s@resin.io>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"lodash": "~3.*.*",
"node-uuid": "~1.*.*"
}
}
127 changes: 127 additions & 0 deletions coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"coffeescript_error": {
"level": "error"
},
"arrow_spacing": {
"name": "arrow_spacing",
"level": "error"
},
"no_tabs": {
"name": "no_tabs",
"level": "ignore"
},
"no_trailing_whitespace": {
"name": "no_trailing_whitespace",
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": false
},
"max_line_length": {
"name": "max_line_length",
"value": 120,
"level": "error",
"limitComments": false
},
"line_endings": {
"name": "line_endings",
"level": "ignore",
"value": "unix"
},
"no_trailing_semicolons": {
"name": "no_trailing_semicolons",
"level": "error"
},
"indentation": {
"name": "indentation",
"value": 1,
"level": "error"
},
"camel_case_classes": {
"name": "camel_case_classes",
"level": "error"
},
"colon_assignment_spacing": {
"name": "colon_assignment_spacing",
"level": "error",
"spacing": {
"left": 0,
"right": 1
}
},
"no_implicit_braces": {
"name": "no_implicit_braces",
"level": "ignore",
"strict": false
},
"no_plusplus": {
"name": "no_plusplus",
"level": "ignore"
},
"no_throwing_strings": {
"name": "no_throwing_strings",
"level": "error"
},
"no_backticks": {
"name": "no_backticks",
"level": "error"
},
"no_implicit_parens": {
"name": "no_implicit_parens",
"strict": false,
"level": "ignore"
},
"no_empty_param_list": {
"name": "no_empty_param_list",
"level": "error"
},
"no_stand_alone_at": {
"name": "no_stand_alone_at",
"level": "error"
},
"space_operators": {
"name": "space_operators",
"level": "error"
},
"duplicate_key": {
"name": "duplicate_key",
"level": "error"
},
"empty_constructor_needs_parens": {
"name": "empty_constructor_needs_parens",
"level": "error"
},
"cyclomatic_complexity": {
"name": "cyclomatic_complexity",
"value": 10,
"level": "ignore"
},
"newlines_after_classes": {
"name": "newlines_after_classes",
"value": 1,
"level": "error"
},
"no_unnecessary_fat_arrows": {
"name": "no_unnecessary_fat_arrows",
"level": "error"
},
"missing_fat_arrows": {
"name": "missing_fat_arrows",
"level": "ignore"
},
"non_empty_constructor_needs_parens": {
"name": "non_empty_constructor_needs_parens",
"level": "ignore"
},
"no_unnecessary_double_quotes": {
"name": "no_unnecessary_double_quotes",
"level": "error"
},
"no_debugger": {
"name": "no_debugger",
"level": "warn"
},
"no_interpolation_in_single_quotes": {
"name": "no_interpolation_in_single_quotes",
"level": "error"
}
}
34 changes: 34 additions & 0 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
path = require('path')
gulp = require('gulp')
gutil = require('gulp-util')
coffeelint = require('gulp-coffeelint')
coffee = require('gulp-coffee')
runSequence = require('run-sequence')

OPTIONS =
config:
coffeelint: path.join(__dirname, 'coffeelint.json')
files:
coffee: [ 'src/*.coffee' ]
app: 'src/*.coffee'
javascript: 'bin/*.js'
directories:
build: './bin'

gulp.task 'coffee', ->
gulp.src(OPTIONS.files.app)
.pipe(coffee()).on('error', gutil.log)
.pipe(gulp.dest(OPTIONS.directories.build))

gulp.task 'lint', ->
gulp.src(OPTIONS.files.coffee)
.pipe(coffeelint({
optFile: OPTIONS.config.coffeelint
}))
.pipe(coffeelint.reporter())

gulp.task 'build', (callback) ->
runSequence([ 'lint' ], [ 'coffee' ], callback)

gulp.task 'watch', [ 'build' ], ->
gulp.watch([ OPTIONS.files.coffee ], [ 'build' ])
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "resin-event-log",
"version": "0.0.3",
"description": "",
"main": "bin/resin-event-log.js",
"dependencies": {
"lodash": "^3.*.*",
"node-uuid": "^1.*.*"
},
"devDependencies": {
"coffee-script": "^1.9.3",
"gulp": "^3.9.0",
"gulp-coffee": "^2.3.1",
"gulp-coffeelint": "^0.5.0",
"gulp-util": "^3.0.6",
"run-sequence": "^1.1.1"
},
"repository": {
"type": "git",
"url": "git@github.com:resin-io/resin-event-log.git"
},
"author": "Iskren Slavov <iskren@resin.io>",
"license": "MIT",
"homepage": "https://github.com/resin-io/resin-event-log"
}
Loading

0 comments on commit e995587

Please sign in to comment.