Skip to content

Commit

Permalink
Updated to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Malakoff committed Sep 17, 2012
1 parent 20a7693 commit 3ef6a76
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 110 deletions.
39 changes: 12 additions & 27 deletions README.md
@@ -1,16 +1,23 @@
Lifecycle.js provides conventions and helpers to manage the life cycles of Javascript instances.

#Download Latest (1.1.2):

You can get the library here:
Please see the [release notes](https://github.com/kmalakoff/lifecycle/blob/master/RELEASE_NOTES.md) for upgrade pointers.

* [Development version][1]
* [Production version][2]
* [Development version](https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.js)
* [Production version](https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.min.js)

###Module Loading

Lifecycle.js is compatible with RequireJS, CommonJS, Brunch and AMD module loading. Module names:

* 'lifecycle' - lifecycle.js.

Introduction
------------
If you need to write code that manages the lifecycle of some javascript objects, but you don't know ahead of time what type of lifecycle model they implement, Lifecycle.js is for you!

A good example of this is [Backbone.Articulation][3]. Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)
A good example of this is [Backbone.Articulation](https://github.com/kmalakoff/backbone-articulation). Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)

# LC.own and LC.disown
Manages the lifecycle of individual instances, objects, arrays, and object properties that comply with some lifecycle conventions:
Expand Down Expand Up @@ -87,23 +94,6 @@ instance.release(); // ref_count = 1
instance.release(); // ref_count = 0 and __destroy() called
```

# Release Notes

###1.0.2

- converted back to CoffeeScript

- build using easy-bake

- added packaging tests

- added extend() functionality for JavaScript and CoffeeScript class usability

- changed convention from _destroy() to __destroy() given that some libraries (like KnockoutJS) use _destroy for other purposes

- removed Lifecycle alias


Building, Running and Testing the library
-----------------------

Expand All @@ -114,9 +104,4 @@ Building, Running and Testing the library

###Commands:

Look at: https://github.com/kmalakoff/easy-bake

[1]: https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.js
[2]: https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.min.js
[3]: https://github.com/kmalakoff/backbone-articulation

Look at: https://github.com/kmalakoff/easy-bake
11 changes: 10 additions & 1 deletion RELEASE_NOTES.md
Expand Up @@ -3,4 +3,13 @@ Please refer to the following release notes when upgrading your version of Lifec
## 1.0.2

* renamed _destroy to __destroy to avoid conflicts.
* added AMD loader.
* added AMD loader.

## 1.0.1

* converted back to CoffeeScript
* build using easy-bake
* added packaging tests
* added extend() functionality for JavaScript and CoffeeScript class usability
* changed convention from _destroy() to __destroy() given that some libraries (like KnockoutJS) use _destroy for other purposes
* removed Lifecycle alias
39 changes: 12 additions & 27 deletions packages/npm/README.md
@@ -1,16 +1,23 @@
Lifecycle.js provides conventions and helpers to manage the life cycles of Javascript instances.

#Download Latest (1.1.2):

You can get the library here:
Please see the [release notes](https://github.com/kmalakoff/lifecycle/blob/master/RELEASE_NOTES.md) for upgrade pointers.

* [Development version][1]
* [Production version][2]
* [Development version](https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.js)
* [Production version](https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.min.js)

###Module Loading

Lifecycle.js is compatible with RequireJS, CommonJS, Brunch and AMD module loading. Module names:

* 'lifecycle' - lifecycle.js.

Introduction
------------
If you need to write code that manages the lifecycle of some javascript objects, but you don't know ahead of time what type of lifecycle model they implement, Lifecycle.js is for you!

A good example of this is [Backbone.Articulation][3]. Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)
A good example of this is [Backbone.Articulation](https://github.com/kmalakoff/backbone-articulation). Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)

# LC.own and LC.disown
Manages the lifecycle of individual instances, objects, arrays, and object properties that comply with some lifecycle conventions:
Expand Down Expand Up @@ -87,23 +94,6 @@ instance.release(); // ref_count = 1
instance.release(); // ref_count = 0 and __destroy() called
```

# Release Notes

###1.0.2

- converted back to CoffeeScript

- build using easy-bake

- added packaging tests

- added extend() functionality for JavaScript and CoffeeScript class usability

- changed convention from _destroy() to __destroy() given that some libraries (like KnockoutJS) use _destroy for other purposes

- removed Lifecycle alias


Building, Running and Testing the library
-----------------------

Expand All @@ -114,9 +104,4 @@ Building, Running and Testing the library

###Commands:

Look at: https://github.com/kmalakoff/easy-bake

[1]: https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.js
[2]: https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.min.js
[3]: https://github.com/kmalakoff/backbone-articulation

Look at: https://github.com/kmalakoff/easy-bake
43 changes: 42 additions & 1 deletion test/core/test-amd.coffee
Expand Up @@ -16,7 +16,7 @@ clone = (obj) ->
(result[key]=obj[key] if obj.hasOwnProperty(key)) for key of obj
return result

$(document).ready( ->
$(->
module("lifecycle-amd.js")

# library and dependencies
Expand Down Expand Up @@ -241,5 +241,46 @@ $(document).ready( ->
raises((->instance.release()), null, 'LC.RefCounting: ref_count is corrupt')
equal(instance.is_alive, false, 'is gone')
)

test('ref countable (coffeescript)', ->

class MyClass extends LC.RefCountable
constructor: ->
super
@is_alive = true

__destroy: ->
@is_alive = false

instance = new MyClass()
equal(instance.is_alive, true, 'is alive')

equal(instance.refCount(), 1, '1 reference')
equal(instance.retain(), instance, 'chaining')
equal(instance.refCount(), 2, '2 references')
equal(instance.retain(), instance, 'chaining')
equal(instance.refCount(), 3, '3 references')
equal(instance.is_alive, true, 'is alive')

equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 2, '2 references')
equal(instance.is_alive, true, 'is alive')
equal(instance.retain(), instance, 'chaining')
equal(instance.refCount(), 3, '3 references')
equal(instance.is_alive, true, 'is alive')

equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 2, '2 references')
equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 1, '1 reference')
equal(instance.is_alive, true, 'is alive')

equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 0, '0 references')
equal(instance.is_alive, false, 'is gone')

raises((->instance.release()), null, 'LC.RefCounting: ref_count is corrupt')
equal(instance.is_alive, false, 'is gone')
)
)
)
43 changes: 42 additions & 1 deletion test/core/test.coffee
Expand Up @@ -19,7 +19,7 @@ clone = (obj) ->
###############
# Start Tests
###############
$(document).ready(->
$(->
module("Lifecycle.js")

# import Lifecycle
Expand Down Expand Up @@ -245,4 +245,45 @@ $(document).ready(->
raises((->instance.release()), null, 'LC.RefCounting: ref_count is corrupt')
equal(instance.is_alive, false, 'is gone')
)

test('ref countable (coffeescript)', ->

class MyClass extends LC.RefCountable
constructor: ->
super
@is_alive = true

__destroy: ->
@is_alive = false

instance = new MyClass()
equal(instance.is_alive, true, 'is alive')

equal(instance.refCount(), 1, '1 reference')
equal(instance.retain(), instance, 'chaining')
equal(instance.refCount(), 2, '2 references')
equal(instance.retain(), instance, 'chaining')
equal(instance.refCount(), 3, '3 references')
equal(instance.is_alive, true, 'is alive')

equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 2, '2 references')
equal(instance.is_alive, true, 'is alive')
equal(instance.retain(), instance, 'chaining')
equal(instance.refCount(), 3, '3 references')
equal(instance.is_alive, true, 'is alive')

equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 2, '2 references')
equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 1, '1 reference')
equal(instance.is_alive, true, 'is alive')

equal(instance.release(), instance, 'chaining')
equal(instance.refCount(), 0, '0 references')
equal(instance.is_alive, false, 'is gone')

raises((->instance.release()), null, 'LC.RefCounting: ref_count is corrupt')
equal(instance.is_alive, false, 'is gone')
)
)
1 change: 0 additions & 1 deletion test/core/test.html
Expand Up @@ -10,7 +10,6 @@
<script type="text/javascript" src="../../lifecycle.js"></script>

<script type="text/javascript" src="build/test.js"></script>
<script type="text/javascript" src="build/test_coffeescript.js"></script>

</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion test/core/test.min.html
Expand Up @@ -10,7 +10,6 @@
<script type="text/javascript" src="../../lifecycle.min.js"></script>

<script type="text/javascript" src="build/test.js"></script>
<script type="text/javascript" src="build/test_coffeescript.js"></script>

</head>
<body>
Expand Down
51 changes: 0 additions & 51 deletions test/core/test_coffeescript.coffee

This file was deleted.

0 comments on commit 3ef6a76

Please sign in to comment.