/extra/update/util/util.factor
http://github.com/abeaumont/factor · Factor · 62 lines · 39 code · 17 blank · 6 comment · 2 complexity · f26a179260cde0e995a64f8334bba89f MD5 · raw file
- USING: kernel classes strings quotations words math math.parser arrays
- combinators.smart
- accessors
- system prettyprint splitting
- sequences combinators sequences.deep
- io
- io.launcher
- io.encodings.utf8
- calendar
- calendar.format ;
- IN: update.util
- ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- DEFER: to-strings
- : to-string ( obj -- str )
- dup class-of
- {
- { \ string [ ] }
- { \ quotation [ call( -- string ) ] }
- { \ word [ execute( -- string ) ] }
- { \ fixnum [ number>string ] }
- { \ array [ to-strings concat ] }
- }
- case ;
- : to-strings ( seq -- str )
- dup [ string? ] all?
- [ ]
- [ [ to-string ] map flatten ]
- if ;
- ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- : cpu- ( -- cpu ) cpu unparse "." split "-" join ;
- : platform ( -- string ) { [ os unparse ] cpu- } to-strings "-" join ;
- ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- : branch-name ( -- string ) "clean-" platform append ;
- ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- : gnu-make ( -- string )
- "make" ;
- ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- : git-id ( -- id )
- { "git" "show" } utf8 <process-reader> [ readln ] with-input-stream
- " " split second ;
- ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- : datestamp ( -- string )
- now
- [ { [ year>> ] [ month>> ] [ day>> ] [ hour>> ] [ minute>> ] } cleave ] output>array
- [ pad-00 ] map "-" join ;