public
Description: Fluent programming (chained method calls) for JavaScript.
Homepage: http://osteele.com/sources/javascript/fluently/
Clone URL: git://github.com/osteele/fluently.git
modifier -> option
osteele (author)
Thu Feb 14 11:45:23 -0800 2008
commit  9380b521762bdfabe5ae3c0bb09c37bcb6193a13
tree    3c8662adc9c8be864fb7abb135160339c82e7b70
parent  21bd19dc9aa7186007aa252536ed8b27f7ffa7ab
0
...
2
3
4
 
 
 
 
 
 
 
 
 
5
6
7
...
26
27
28
29
30
31
32
33
34
35
 
36
37
38
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
35
36
37
 
 
38
39
40
41
 
42
43
44
45
0
@@ -2,6 +2,15 @@
0
 
0
 Fluently is a JavaScript toolkit for creating FluentInterfaces[http://martinfowler.com/bliki/FluentInterface.html].
0
 
0
+I use this to define the mocks, stubs, and expectations in LzTestKit[http://osteele.com/sources/openlaszlo/lztestkit].
0
+
0
+= Status
0
+
0
+Alpha. I use this in other projects, but it's got a known bug (chained modifiers
0
+ignore all but the last one), and the API isn't final.
0
+
0
+= Examples
0
+
0
 With Fluently, you can do this:
0
     var o = Fluently.make(function(define) {
0
       define('fn1', function() {console.info('called fn1')});
0
@@ -26,13 +35,11 @@ You can also define modifiers, and aliases:
0
   o.fn1().and.fn2() // same as o.fn1().fn2()
0
   o.fn1().and.not.fn2() // options.not is set when fn2 is called
0
 
0
-I use this to define the mocks, stubs, and expectations in LzTestKit[http://osteele.com/sources/openlaszlo/lztestkit].
0
-
0
 I've extracted a couple of files, from LzTestKit, into the examples[http://osteele.com/sources/javascript/fluently/examples/]
0
 directory. These don't run on their own, but at least they show the
0
 code in use.
0
 
0
-You can also see a range of examples by viewing the sources to the specs[http://osteele.com/sources/javascript/fluently/specs/].
0
+You can also see a range of examples by viewing the specs[http://osteele.com/sources/javascript/fluently/specs/fluently-specs.js].
0
 
0
 = Download
0
 
...
16
17
18
19
20
21
 
 
22
23
24
...
16
17
18
 
 
 
19
20
21
22
23
0
@@ -16,9 +16,8 @@ end
0
 
0
 task :publish => [:package, :docs] do
0
   target = "osteele.com:osteele.com/sources/javascript/fluently"
0
- sh "rsync pkg/* #{target}"
0
- sh "rsync build/index.html #{target}/index.html"
0
- sh "rsync -a #{PACKAGE_FILES.join(' ')} #{target}"
0
+ sh "rsync -av --delete . #{target} --exclude build"
0
+ sh "scp build/index.html #{target}/index.html"
0
 end
0
 
0
 task :clean do
...
1
 
...
 
1
0
@@ -1 +1 @@
0
-0.1
0
+0.2
...
4
5
6
7
8
9
10
...
4
5
6
 
7
8
9
0
@@ -4,7 +4,6 @@
0
 - examples
0
 
0
 * API
0
-- define empty alias with define.alias
0
 - default modifier table, retrieved via this
0
 - define a set of objects
0
 
...
8
9
10
11
12
13
14
 
15
16
17
18
19
20
21
22
23
 
24
25
26
27
 
28
29
30
...
8
9
10
 
 
 
 
11
12
13
14
15
16
 
 
 
 
17
18
19
20
 
21
22
23
24
0
@@ -8,23 +8,17 @@ var Fluently = {
0
             finalizers = [],
0
             modifiers;
0
 
0
- define.alias = function(target, source) {
0
- path(target).set(host[source]);
0
- }
0
- define.synonym = function(target, source) {
0
+ define.alias = define.synonym = function(target, source) {
0
             if (arguments.length < 2)
0
                 host[target] = host;
0
             else
0
                 path(target).set(host[source]);
0
         }
0
- define.empty = function(name) {
0
- host[name] = host;
0
- }
0
- define.modifier = function(name) {
0
+ define.option = function(name) {
0
             modifiers[name] = false;
0
             defineSetter(name, modifiers, name, true);
0
         }
0
- define.modifier.dictionary = function(object) {
0
+ define.option.dictionary = function(object) {
0
             modifiers = object;
0
         }
0
 
...
24
25
26
27
 
28
29
30
...
33
34
35
36
 
37
38
39
...
57
58
59
60
61
62
 
 
 
63
64
65
...
24
25
26
 
27
28
29
30
...
33
34
35
 
36
37
38
39
...
57
58
59
 
 
 
60
61
62
63
64
65
0
@@ -24,7 +24,7 @@ describe('Definitions', {
0
         var chain = Fluently.make(function(define) {
0
             define('a', function() {return 1});
0
             define('b', function() {return 2});
0
- define.empty('self');
0
+ define.alias('self');
0
             define.alias('alias_a', 'a');
0
             define.alias('alias_b', 'b');
0
         });
0
@@ -33,7 +33,7 @@ describe('Definitions', {
0
         value_of(chain.alias_b()).should_be(2);
0
         value_of(chain.self.alias_a()).should_be(1);
0
     },
0
- 'should apply modifiers': function() {
0
+ 'should apply options': function() {
0
         var trace;
0
         var options = {};
0
         options.reset = function() {
0
@@ -57,9 +57,9 @@ describe('Definitions', {
0
             trace += spans.join('');
0
         }
0
         var chain = Fluently.make(function(define) {
0
- define.modifier.dictionary(options);
0
- define.modifier('o1');
0
- define.modifier('o2');
0
+ define.option.dictionary(options);
0
+ define.option('o1');
0
+ define.option('o2');
0
             define('reset', function() {trace = ''; options.reset()});
0
             define('a', function() {t('a')});
0
             define('b', function() {t('b')});

Comments

    No one has commented yet.