github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

osteele / fluently

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Fluent programming (chained method calls) for JavaScript. — Read more

  cancel

http://osteele.com/sources/javascript/fluently/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

add jsspec as submodule 
osteele (author)
Sun Apr 13 04:23:51 -0700 2008
commit  cdfe1131ff07aea2d2b9c0f4b97ec43b55a0a100
tree    8b5778fe48c681eb847d4117a9e298b3d3c6b8ff
parent  72a92d5a0f7bc822450a25171b362bfc26a61192
fluently /
name age
history
message
file .gitignore Loading commit data...
file .gitmodules
file MIT-LICENSE
file README
file Rakefile
file VERSION
file agenda.txt
directory examples/
file fluently.js
submodule jsspec - f5758f9
directory specs/
README
= About

Fluently is a JavaScript toolkit for creating FluentInterfaces[http://martinfowler.com/bliki/FluentInterface.html].

I use this to define the mocks, stubs, and expectations in LzTestKit[http://osteele.com/sources/openlaszlo/lztestkit].

= Status

Alpha.  I use this in other projects, but it's got a known bug (chained modifiers
ignore all but the last one), and the API isn't final.

= Examples

With Fluently, you can do this:
    var o = Fluently.make(function(define) {
      define('fn1', function() {console.info('called fn1')});
      define('fn2', function() {console.info('called fn2')});
      define('fn3', function() {return 3});
    });
to define an object with chained methods, that can be invoked thus:
  o.fn1().fn2() // calls fn1 and then fn2
  o.fn2().fn1() // calls fn2 and then fn1
  o.fn1().fn3() // returns 3 (an explicit 'return' breaks the chain)

You can also define modifiers, and aliases:
    var o = Fluently.make(function(define) {
      define('fn1', function() {console.info('called fn1')});
      define('fn2', function() {console.info('called fn2')});
      define.empty('and');
      define.alias('fn3', 'fn1');
      define.modifier('not');
    });
  
  o.fn3(); // same as o.fn1()
  o.fn1().and.fn2() // same as o.fn1().fn2()
  o.fn1().and.not.fn2() // options.not is set when fn2 is called

I've extracted a couple of files, from LzTestKit, into the 
examples[http://osteele.com/sources/javascript/fluently/examples/]
directory.  These don't run on their own, but at least they show the
code in use.

You can also see a range of examples by viewing the 
specs[http://osteele.com/sources/javascript/fluently/specs/fluently-specs.js].

= Download

Get it here: {download-location}.

= License

Fluently is licensed under the MIT License.

This package includes a distribution of jsspec, which is licensed under the LGPL.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server