Changeset 40351 in project


Ignore:
Timestamp:
08/21/21 01:41:10 (5 weeks ago)
Author:
Kon Lovett
Message:

isolate & comment symbol <-> string interpretation

Location:
release/5/semantic-version/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • release/5/semantic-version/trunk/README.svnwiki

    r39884 r40351  
    1010A rather busy Semantic Versioning library.
    1111
    12 == Usage
     12=== Usage
    1313
    1414<enscript highlight="scheme">
     
    1616</enscript>
    1717
    18 === version-punctuation
     18=== Core
     19
     20==== Usage
     21
     22<enscript highlight="scheme">
     23(import (semantic-version core))
     24</enscript>
     25
     26==== version-punctuation
    1927
    2028<parameter>(version-punctuation [STR]) -> string</parameter>
     
    2533; STR : {{string}} ; punctuation set, default is {{"._- +;:,"}}.
    2634
    27 === version-tail-zero
    28 
    29 <parameter>(version-tail-zero [IGN?]) -> boolean</parameter>
    30 
    31 Returns whether trailing 0's are ignored during comparision.
    32 
    33 ; IGN? : {{boolean}} ; ignore flag, default is {{#f}}.
    34 
    35 === make-version
     35==== make-version
    3636
    3737<procedure>(make-version CNT [ELM CHR]) --> semantic-version</procedure>
     
    4343; CHR : {{char}} ; version punctuation, default is {{(string-ref (version-punctuation) 0)}}.
    4444
    45 === version
     45==== check-version
     46==== error-version
     47
     48<procedure>(check-version LOC OBJ [NAM]) -> semantic-version</procedure>
     49<procedure>(error-version LOC OBJ [NAM])</procedure>
     50
     51Similar to ''check-errors'' procedures.
     52
     53==== version?
     54
     55<procedure>(version? OBJ) --> boolean</procedure>
     56
     57; OBJ : {{*}} ; object to test.
     58
     59==== version->list
     60
     61<procedure>(version->list VER) --> (list-of (or number string char))</procedure>
     62
     63Returns an "exploded" form, with version elements interleaved with punctuation
     64characeters.
     65
     66; VER : {{semantic-version}} ; version to list.
     67
     68==== list->version
     69
     70<procedure>(list->version LIS) --> semantic-version</procedure>
     71
     72Returns a version from an "exploded" form, see {{version->list}}.
     73
     74; LIS : {{(list-of (or number string symbol char))}} ; list of version components.
     75
     76==== string->version
     77
     78<procedure>(string->version STR) --> semantic-version</procedure>
     79
     80Return the parsed form of the STR. The source separator (punctuation) is
     81preserved, and restored by {{version->string}}.
     82
     83; STR : {{string}} ; string to convert.
     84
     85==== version->string
     86
     87<procedure>(version->string VER) --> string</procedure>
     88
     89Return the string form of the VER.
     90
     91; VER : {{semantic-version}} ; version to convert.
     92
     93=== Element
     94
     95==== Usage
     96
     97<enscript highlight="scheme">
     98(import (semantic-version element))
     99</enscript>
     100
     101==== version
    46102
    47103<procedure>(version ELM...) --> semantic-version</procedure>
     
    54110'''Note''' that the {{symbol}} printname is used internally.
    55111
    56 === check-version
    57 === error-version
    58 
    59 <procedure>(check-version LOC OBJ [NAM]) -> semantic-version</procedure>
    60 <procedure>(error-version LOC OBJ [NAM])</procedure>
    61 
    62 Similar to ''check-errors'' procedures.
    63 
    64 === version-copy
     112==== version-copy
    65113
    66114<procedure>(version-copy VER) --> semantic-version</procedure>
     
    70118; VER : {{semantic-version}} ; version to copy.
    71119
    72 === version?
    73 
    74 <procedure>(version? OBJ) --> boolean</procedure>
    75 
    76 ; OBJ : {{*}} ; object to test.
    77 
    78 === version-depth
     120==== version-depth
    79121
    80122<procedure>(version-depth VER) --> integer</procedure>
     
    84126; VER : {{semantic-version}} ; version to query.
    85127
    86 === version-elements
     128==== version-elements
    87129
    88130<procedure>(version-elements VER) --> (list-of (or number string))</procedure>
     
    92134; VER : {{semantic-version}} ; version to query.
    93135
    94 === version-separators
     136==== version-separators
    95137
    96138<procedure>(version-separators VER) --> (list-of char)</procedure>
     
    100142; VER : {{semantic-version}} ; version to query.
    101143
    102 === version->list
    103 
    104 <procedure>(version->list VER) --> (list-of (or number string char))</procedure>
    105 
    106 Returns an "exploded" form, with version elements interleaved with punctuation
    107 characeters.
    108 
    109 ; VER : {{semantic-version}} ; version to list.
    110 
    111 === list->version
    112 
    113 <procedure>(list->version LIS) --> semantic-version</procedure>
    114 
    115 Returns a version from an "exploded" form, see {{version->list}}.
    116 
    117 ; LIS : {{(list-of (or number string symbol char))}} ; list of version components.
    118 
    119 === version-compare
     144=== Compare
     145
     146==== Usage
     147
     148<enscript highlight="scheme">
     149(import (semantic-version compare))
     150</enscript>
     151
     152==== version-tail-zero
     153
     154<parameter>(version-tail-zero [IGN?]) -> boolean</parameter>
     155
     156Returns whether trailing 0's are ignored during comparision.
     157
     158; IGN? : {{boolean}} ; ignore flag, default is {{#f}}.
     159
     160==== version-compare
    120161
    121162<procedure>(version-compare VER1 VER2 [TAIL-ZERO?]) --> integer</procedure>
     
    132173Orders versions in the same manner as the ''chicken-install'' tool.
    133174
    134 === version<?
    135 === version=?
    136 === version>?
    137 === version<=?
    138 === version>=?
     175==== version<?
     176==== version=?
     177==== version>?
     178==== version<=?
     179==== version>=?
    139180
    140181<procedure>(version<? VER1 VER2 [TAIL-ZERO?]) --> boolean</procedure>
     
    146187See {{version-compare}}.
    147188
    148 === version-hash
     189==== version-hash
    149190
    150191<procedure>(version-hash VER [BND RND]) --> integer</procedure>
     
    156197; RND : {{integer}} ; randomization (salt), see SRFI 69.
    157198
    158 === version-comparator
     199==== version-comparator
    159200
    160201<procedure>(version-comparator) --> comparator</procedure>
     
    167208; {{comparator-ordering-predicate comparator}} : {{version<?}}
    168209
    169 === string->version
    170 
    171 <procedure>(string->version STR) --> semantic-version</procedure>
    172 
    173 Return the parsed form of the STR. The source separator (punctuation) is
    174 preserved, and restored by {{version->string}}.
    175 
    176 ; STR : {{string}} ; string to convert.
    177 
    178 === version->string
    179 
    180 <procedure>(version->string VER) --> string</procedure>
    181 
    182 Return the string form of the VER.
    183 
    184 ; VER : {{semantic-version}} ; version to convert.
    185 
    186 === version-depth+!
     210=== Operation
     211
     212==== Usage
     213
     214<enscript highlight="scheme">
     215(import (semantic-version operation))
     216</enscript>
     217
     218==== version-depth+!
    187219
    188220<procedure>(version-depth+! VER CNT [ELM CHR]) -> semantic-version</procedure>
     
    195227; CHR : {{char}} ; version punctuation, default is {{(string-ref (version-punctuation) 0)}}.
    196228
    197 === version-depth-!
     229==== version-depth-!
    198230
    199231<procedure>(version-depth-! VER CNT) -> semantic-version</procedure>
     
    205237; CNT : {{integer}} ; element count.
    206238
    207 === version-depth+
     239==== version-depth+
    208240
    209241<procedure>(version-depth+ VER CNT [ELM CHR]) --> semantic-version</procedure>
     
    216248; CHR : {{char}} ; version punctuation, default is {{(string-ref (version-punctuation) 0)}}.
    217249
    218 === version-depth-
     250==== version-depth-
    219251
    220252<procedure>(version-depth- VER CNT) --> semantic-version</procedure>
     
    226258; CNT : {{integer}} ; element count.
    227259
    228 === version-extend!
     260==== version-extend!
    229261
    230262<procedure>(version-extend! VER COMP...) -> semantic-version</procedure>
     
    236268; COMP : {{(list-of (or number string symbol char))}} ; version components.
    237269
    238 === version-extend
     270==== version-extend
    239271
    240272<procedure>(version-extend VER COMP...) --> semantic-version</procedure>
     
    246278; COMP : {{(list-of (or number string symbol char))}} ; version components.
    247279
    248 === version-inc!
     280==== version-inc!
    249281
    250282<procedure>(version-inc! VER [IDX AMT]) -> semantic-version</procedure>
     
    258290Currently only {{number}} elements may be targets.
    259291
    260 === version-dec!
     292==== version-dec!
    261293
    262294<procedure>(version-dec! VER [IDX AMT]) -> semantic-version</procedure>
     
    270302Currently only {{number}} elements may be targets.
    271303
    272 === version-inc
     304==== version-inc
    273305
    274306<procedure>(version-inc VER [IDX AMT]) --> semantic-version</procedure>
     
    282314Currently only {{number}} elements may be targets.
    283315
    284 === version-dec
     316==== version-dec
    285317
    286318<procedure>(version-dec VER [IDX AMT]) --> semantic-version</procedure>
     
    342374== Version history
    343375
     376; 0.0.3 : Separate modules.
    344377; 0.0.2 : Use record, {{make-version}} & {{semantic-version}} follow convention, rename accessors.
    345378; 0.0.1 : Release.
  • release/5/semantic-version/trunk/semantic-version-internals.scm

    r40343 r40351  
    130130;;
    131131
     132;allows string & list form interchange
     133(define-inline ( canon-compare-elm x) x #;(if (symbol? x) (symbol->string x) x))
     134
     135;allows string & list form interchange
    132136(define-inline (canon-list-elm x) (if (symbol? x) (symbol->string x) x))
    133137
     138;allows proper comparison
    134139(define-inline (canon-string-elm x) (or (string->number x) x))
  • release/5/semantic-version/trunk/semantic-version.compare.scm

    r40343 r40351  
    6666
    6767(define (version-compare ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
     68  ;
    6869  (define (tail-zeros ls) (if tail-zero? ls (drop-tailing-zeros ls)))
    69   (let loop ((p1 (tail-zeros (ver-parts (check-version 'version-compare ver1))))
    70              (p2 (tail-zeros (ver-parts (check-version 'version-compare ver2)))))
     70  ;
     71  (let loop ((p1 (tail-zeros (ver-parts (check-version 'version-compare ver1 'ver1))))
     72             (p2 (tail-zeros (ver-parts (check-version 'version-compare ver2 'ver2)))))
    7173    (cond
    7274      ((and (null? p1) (null? p2))  0)
     
    7981      ((number? (car p1))           -1)
    8082      ((number? (car p2))           1)
    81       ((string-compare3 (car p1) (car p2)) =>
     83      ((string-compare3 ( canon-compare-elm (car p1)) ( canon-compare-elm (car p2))) =>
    8284        (lambda (cmp)
    8385          (if (zero? cmp) (loop (cdr p1) (cdr p2))
  • release/5/semantic-version/trunk/semantic-version.egg

    r40343 r40351  
    33
    44((synopsis "Semantic Version Utilities")
    5  (version "0.0.3")
     5 (version "0.0.4")
    66 (category data)
    77 (author "Kon Lovett")
Note: See TracChangeset for help on using the changeset viewer.