UNPKG

1.69 kBMarkdownView Raw
1
2**PARTIALLY PENDING** It can `$save( templateName )` newly written stubs into `./src/**/*` as "first draft"
3
4still untidy implementation
5
6```coffee
7
8it 'can detect a non existant LocalModule being injected', ipso (done, NewModuleName) ->
9
10 #
11 # when ./lib/**/* contains no file called new_module_name.coffee
12 # ------ === ---------------------------------------------------
13 #
14 # * a standin module is injected
15 # * a warning is displayed
16 # * NewModuleName.does() can still be used to define stubs
17 # * NewModuleName.$save( 'templateName' ) can use template
18 # defined in ~/.ipso/templates/templateName and the function stubs to
19 # create the new source file at ./src/relative/path/new_module_name.coffee
20 # ===
21 #
22
23 NewModuleName.does
24
25 function1: ->
26 function2: ->
27
28 NewModuleName.$save 'factory'
29
30
31```
32
33creates (using `~/.ipso/templates/factory`)
34
35```coffee
36
37lastInstance = undefined
38module.exports = ->
39
40 lastInstance = local =
41
42 function1: ->
43
44 function2: ->
45
46
47 return api =
48 function1: local.function1
49 function2: local.function2
50
51module.exports._test = -> lastInstance
52
53
54```
55
56After creating the next test will fail with
57```
58 1) MissingModule "after all" hook:
59 TypeError: Object function () {
60 var api, local;
61 lastInstance = local = {
62 function1: function() {},
63 function2: function() {}
64 };
65 return api = {
66 function1: local.function1,
67 function2: local.function2
68 };
69} has no method '$save'
70
71```
72
73because $save() no longer exists on the object being injected
74
75it uses IPSO_SRC env variable in target path assembly
76