├── TODO ├── README ├── Ikefile ├── LICENSE └── ike.io /TODO: -------------------------------------------------------------------------------- 1 | [x] task invocation 2 | [x] task chaining 3 | [x] descriptions 4 | [x] namespaces 5 | [x] default task 6 | [ ] dependencies 7 | [ ] sh 8 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ________________ 2 | ike: rake for io 3 | ---------------- 4 | 5 | This is how I'm learning Io. By writing code, y'know. 6 | 7 | >> chris@ozmm.org 8 | => http://github.com/defunkt/ike 9 | -------------------------------------------------------------------------------- /Ikefile: -------------------------------------------------------------------------------- 1 | task("test", 2 | "noop" println 3 | ) 4 | 5 | task("hello", "hello!" println) 6 | 7 | desc("Set a production environment.") 8 | task("production", 9 | "now you can " print 10 | ) 11 | 12 | task("predeploy", 13 | "predeploy tasks" println 14 | ) 15 | 16 | desc("Deploy a ya shniz") 17 | task("deploy", 18 | "deploy'd" println 19 | ) 20 | 21 | namespace("mongrel", 22 | desc("Restart mongrels") 23 | task("restart", 24 | "nicely done" println 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Chris Wanstrath 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | Software), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /ike.io: -------------------------------------------------------------------------------- 1 | //// 2 | // ike: io make 3 | Ike := Object clone do( 4 | tasks := list() 5 | nextDesc := nil 6 | logging := false 7 | currentNamespace := nil 8 | ) 9 | 10 | Ike do( 11 | //// 12 | // Task object 13 | Task := Object clone do( 14 | with := method(name, body, desc, 15 | self setSlot("name", name) 16 | self setSlot("body", body) 17 | self setSlot("desc", desc) 18 | self setSlot("dependency") 19 | self 20 | ) 21 | 22 | invoke := method(doMessage(body)) 23 | 24 | after := method(dependency, 25 | self dependency = dependency 26 | ) 27 | ) 28 | 29 | //// 30 | // api 31 | task := method(name, 32 | if(currentNamespace) then(name = "#{currentNamespace}:#{name}" interpolate) 33 | tasks << Ike Task clone with(name, call message arguments last, nextDesc) 34 | nextDesc = nil 35 | ) 36 | 37 | desc := method(description, 38 | nextDesc = description 39 | ) 40 | 41 | namespace := method(space, 42 | currentNamespace = space 43 | call message argAt(1) doInContext(Ike) 44 | currentNamespace = nil 45 | ) 46 | 47 | invoke := method(target, 48 | log("Invoking `#{target}`") 49 | task := tasks detect(name == target) 50 | if(target == "default" and task isNil) then(return noDefault) 51 | task ?invoke or invoke("default") 52 | ) 53 | 54 | //// 55 | // guts 56 | log := method(line, 57 | if(logging) then(("=> " .. line interpolate(call sender)) println) 58 | ) 59 | 60 | showTasks := method( 61 | longest := tasks map(name size) max 62 | space := " #" 63 | 64 | tasks foreach(task, 65 | // rake style hiding of tasks without descriptions 66 | if(task desc isNil) then(continue) 67 | 68 | ("ike " .. task name) print 69 | diff := longest - task name size 70 | " " repeated(diff + 7) print " # " print 71 | task desc println 72 | ) 73 | ) 74 | 75 | noDefault := method( 76 | "Please define a default task, like this: task(\"default\", stuff)" println 77 | ) 78 | 79 | help := method("Help en route." println) 80 | 81 | version := method("version -50" println) 82 | ) 83 | 84 | //// 85 | // ext 86 | List << := method(other, append(other)) 87 | 88 | //// 89 | // setup our dsl 90 | list("task", "desc", "namespace") foreach(slot, 91 | setSlot(slot, method(call delegateTo(Ike)) 92 | ) 93 | ) 94 | 95 | //// 96 | // built-in tasks 97 | task("-T", Ike showTasks) 98 | task("-h", Ike help) 99 | task("--help", Ike help) 100 | task("-v", Ike version) 101 | task("--version", Ike version) 102 | 103 | //// 104 | // load the ikefile 105 | doFile("Ikefile") 106 | 107 | //// 108 | // execute 109 | if( 110 | System args size == 1, 111 | Ike invoke("default"), 112 | System args slice(1) foreach(a, Ike invoke(a)) 113 | ) 114 | --------------------------------------------------------------------------------