Skip to content

Commit

Permalink
0.1.0 release (#1)
Browse files Browse the repository at this point in the history
Initial release
  • Loading branch information
neocotic authored Sep 21, 2016
1 parent 7fe3b1d commit 6812379
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
node_js:
- "0.10"
- "0.12"
- "4.0"
- "6.0"
- "4"
- "6"
script:
- npm test
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

If you have any questions about [OOPsy](https://github.com/Skelp/oopsy) please feel free to
If you have any questions about [Oopsy](https://github.com/Skelp/oopsy) please feel free to
[raise an issue](https://github.com/Skelp/oopsy/issues/new).

Please [search existing issues](https://github.com/Skelp/oopsy/issues) for the same feature and/or issue before raising
Expand All @@ -16,6 +16,14 @@ $ npm install
$ npm test
```

If you're using a version of [Node.js](https://nodejs.org) that is older than 0.12, then linting is not performed by
this step. Please consider upgrading to at least 0.12 or your pull request may fail on the CI build.

Likewise, [Node.js](https://nodejs.org) versions older than 0.10 will also not be able to compile the source code using
[Rollup](http://rollupjs.org) so the test suite will not be executed against any changes you've made to `lib/oopsy.js`.
For this reason, 0.10 is not supported from a development perspective, but our CI builds do run the test suite against
the pre-compiled code for this version to ensure that it works.

All pull requests should be made to the `develop` branch.

Don't forget to add your details to the list of
Expand Down
127 changes: 69 additions & 58 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@
*/

module.exports = function(grunt) {
var commonjs = require('rollup-plugin-commonjs')
var commonjs
var semver = require('semver')
var uglify = require('rollup-plugin-uglify')
var uglify

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

clean: {
build: [ 'dist/**' ]
},

eslint: {
target: [ 'lib/**/*.js', 'test/**/*.js' ]
},

mochaTest: {
test: {
options: {
Expand All @@ -46,51 +38,6 @@ module.exports = function(grunt) {
}
},

rollup: {
umdDevelopment: {
options: {
format: 'umd',
moduleId: 'oopsy',
moduleName: 'OOPsy',
sourceMap: true,
sourceMapRelativePaths: true,
plugins: function() {
return [
commonjs()
]
}
},
files: {
'dist/oopsy.js': 'lib/oopsy.js'
}
},
umdProduction: {
options: {
format: 'umd',
moduleId: 'oopsy',
moduleName: 'OOPsy',
sourceMap: true,
sourceMapRelativePaths: true,
banner: '/*! OOPsy v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | MIT License */',
plugins: function() {
return [
commonjs(),
uglify({
output: {
comments: function(node, comment) {
return comment.type === 'comment2' && /^\!/.test(comment.value)
}
}
})
]
}
},
files: {
'dist/oopsy.min.js': 'lib/oopsy.js'
}
}
},

watch: {
all: {
files: [ 'lib/**/*.js', 'test/**/*.js' ],
Expand All @@ -99,25 +46,89 @@ module.exports = function(grunt) {
}
})

require('load-grunt-tasks')(grunt)

var buildTasks = [ 'compile' ]
var compileTasks = []
var testTasks = [ 'compile', 'mochaTest' ]

if (semver.satisfies(process.version, '>=0.12')) {
commonjs = require('rollup-plugin-commonjs')
uglify = require('rollup-plugin-uglify')

compileTasks.push('clean', 'rollup')

grunt.config.merge({
clean: {
build: [ 'dist/**' ]
},

rollup: {
umdDevelopment: {
options: {
format: 'umd',
moduleId: 'oopsy',
moduleName: 'Oopsy',
sourceMap: true,
sourceMapRelativePaths: true,
plugins: function() {
return [
commonjs()
]
}
},
files: {
'dist/oopsy.js': 'lib/oopsy.js'
}
},
umdProduction: {
options: {
format: 'umd',
moduleId: 'oopsy',
moduleName: 'Oopsy',
sourceMap: true,
sourceMapRelativePaths: true,
banner: '/*! Oopsy v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | MIT License */',
plugins: function() {
return [
commonjs(),
uglify({
output: {
comments: function(node, comment) {
return comment.type === 'comment2' && /^\!/.test(comment.value)
}
}
})
]
}
},
files: {
'dist/oopsy.min.js': 'lib/oopsy.js'
}
}
}
})

grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-rollup')
} else {
grunt.log.writeln('"compile" task is disabled because Node.js version is <0.12! Please consider upgrading Node.js...')
grunt.log.writeln('"clean" and "rollup" tasks are disabled because Node.js version is <0.12! Please consider upgrading Node.js...')
}

if (semver.satisfies(process.version, '>=4')) {
buildTasks.unshift('eslint')
testTasks.unshift('eslint')

grunt.config.set('eslint', {
target: [ 'lib/**/*.js', 'test/**/*.js' ]
})

grunt.loadNpmTasks('grunt-eslint')
} else {
grunt.log.writeln('"eslint" task is disabled because Node.js version is <4! Please consider upgrading Node.js...')
}

grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-mocha-test')

grunt.registerTask('default', [ 'build' ])
grunt.registerTask('build', buildTasks)
grunt.registerTask('compile', compileTasks)
Expand Down
79 changes: 65 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.oooooo. .oooooo. ooooooooo.
d8P' `Y8b d8P' `Y8b `888 `Y88.
888 888 888 888 888 .d88' .oooo.o oooo ooo
888 888 888 888 888ooo88P' d88( "8 `88. .8'
888 888 888 888 888 `"Y88b. `88..8'
`88b d88' `88b d88' 888 o. )88b `888'
`Y8bood8P' `Y8bood8P' o888o 8""888P' .8'
.o..P'
`Y8P'

[OOPsy](https+://github.com/Skelp/oopsy) makes it easier to use the Object-Orientated Programming (OOP) model in
.oooooo.
d8P' `Y8b
888 888 .ooooo. oo.ooooo. .oooo.o oooo ooo
888 888 d88' `88b 888' `88b d88( "8 `88. .8'
888 888 888 888 888 888 `"Y88b. `88..8'
`88b d88' 888 888 888 888 o. )88b `888'
`Y8bood8P' `Y8bod8P' 888bod8P' 8""888P' .8'
888 .o..P'
o888o `Y8P'

[Oopsy](https://github.com/Skelp/oopsy) makes it easier to use the Object-Orientated Programming (OOP) model in
JavaScript.

[![Build Status](https://img.shields.io/travis/Skelp/oopsy/develop.svg?style=flat-square)](https://travis-ci.org/Skelp/oopsy)
Expand Down Expand Up @@ -42,11 +42,62 @@ If you want to simply download the file to be used in the browser you can find t

## API

TODO: Document
The API is extremely simple and is designed to make it as easy as possible to implement traditional inheritance.

``` javascript
Oopsy.extend([constructor][, prototype][, statics])
```

It is very flexible and can be used to extend *classes*:

``` javascript
var BaseObject = Oopsy.extend(function(options) {
this.options = options || {}
})

var ChildObject = BaseObject.extend({
getOption: function(name) {
return this.options[name]
},
setOption: function(name, value) {
this.options[name] = value
}
})

var Person = ChildObject.extend(function(name, options) {
Person.super_.call(this, options)

this.name = name

Person.people.push(this)
}, {
greet: function(name) {
return 'Hello ' + name + ', my name is ' + this.name
}
}, {
people: []
})
```

All constructors extended by Oopsy are given a static `super_` property which references the super constructor.

Also, this can be used to extend existing *classes* such as `EventEmitter`:

``` javascript
var EventEmitter = require('events').EventEmitter
var Oopsy = require('oopsy')

var BaseObject = Oopsy.extend(function() {
EventEmitter.call(this)
}, EventEmitter.prototype, EventEmitter)
```

However, this last approach has the caveats of `instanceof` not identifying this kind of inheritance and `super_` will
only reference the constructor that is extended.

## Bugs

If you have any problems with OOPsy or would like to see changes currently in development you can do so
If you have any problems with Oopsy or would like to see changes currently in development you can do so
[here](https://github.com/Skelp/oopsy/issues).

## Contributors
Expand All @@ -55,7 +106,7 @@ If you want to contribute, you're a legend! Information on how you can do so can
[CONTRIBUTING.md](https://github.com/Skelp/oopsy/blob/master/CONTRIBUTING.md). We want your suggestions and pull
requests!

A list of OOPsy contributors can be found in [AUTHORS.md](https://github.com/Skelp/oopsy/blob/master/AUTHORS.md).
A list of Oopsy contributors can be found in [AUTHORS.md](https://github.com/Skelp/oopsy/blob/master/AUTHORS.md).

## License

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oopsy",
"version": "0.1.0alpha",
"version": "0.1.0",
"description": "Simple OOP for JavaScript",
"homepage": "https://github.com/Skelp/oopsy",
"authors": [
Expand Down
16 changes: 8 additions & 8 deletions dist/oopsy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6812379

Please sign in to comment.