@@ -417,49 +417,45 @@ defmodule Version do
417
417
defp to_condition ( [ :'>' , version | _ ] ) do
418
418
{ major , minor , patch , pre } = parse_condition ( version )
419
419
420
- { :andalso , { :not , { :is_binary , :'$1' } } ,
421
- { :orelse , { :'>' , { { :'$1' , :'$2' , :'$3' } } ,
422
- { :const , { major , minor , patch } } } ,
423
- { :andalso , { :'==' , { { :'$1' , :'$2' , :'$3' } } ,
424
- { :const , { major , minor , patch } } } ,
425
- { :orelse , { :andalso , { :'==' , { :length , :'$4' } , 0 } ,
426
- { :'/=' , length ( pre ) , 0 } } ,
427
- { :andalso , { :'/=' , length ( pre ) , 0 } ,
428
- { :orelse , { :'>' , { :length , :'$4' } , length ( pre ) } ,
429
- { :andalso , { :'==' , { :length , :'$4' } , length ( pre ) } ,
430
- { :'>' , :'$4' , { :const , pre } } } } } } } } }
420
+ { :orelse , { :'>' , { { :'$1' , :'$2' , :'$3' } } ,
421
+ { :const , { major , minor , patch } } } ,
422
+ { :andalso , { :'==' , { { :'$1' , :'$2' , :'$3' } } ,
423
+ { :const , { major , minor , patch } } } ,
424
+ { :orelse , { :andalso , { :'==' , { :length , :'$4' } , 0 } ,
425
+ { :'/=' , length ( pre ) , 0 } } ,
426
+ { :andalso , { :'/=' , length ( pre ) , 0 } ,
427
+ { :orelse , { :'>' , { :length , :'$4' } , length ( pre ) } ,
428
+ { :andalso , { :'==' , { :length , :'$4' } , length ( pre ) } ,
429
+ { :'>' , :'$4' , { :const , pre } } } } } } } }
431
430
end
432
431
433
432
defp to_condition ( [ :'>=' , version | _ ] ) do
434
433
matchable = parse_condition ( version )
435
434
436
- { :orelse , { :andalso , { :not , { :is_binary , :'$1' } } ,
437
- { :'==' , :'$_' , { :const , matchable } } } ,
438
- to_condition ( [ :'>' , version ] ) }
435
+ { :orelse , { :'==' , :'$_' , { :const , matchable } } ,
436
+ to_condition ( [ :'>' , version ] ) }
439
437
end
440
438
441
439
defp to_condition ( [ :'<' , version | _ ] ) do
442
440
{ major , minor , patch , pre } = parse_condition ( version )
443
441
444
- { :andalso , { :not , { :is_binary , :'$1' } } ,
445
- { :orelse , { :'<' , { { :'$1' , :'$2' , :'$3' } } ,
446
- { :const , { major , minor , patch } } } ,
447
- { :andalso , { :'==' , { { :'$1' , :'$2' , :'$3' } } ,
448
- { :const , { major , minor , patch } } } ,
449
- { :orelse , { :andalso , { :'/=' , { :length , :'$4' } , 0 } ,
450
- { :'==' , length ( pre ) , 0 } } ,
451
- { :andalso , { :'/=' , { :length , :'$4' } , 0 } ,
452
- { :orelse , { :'<' , { :length , :'$4' } , length ( pre ) } ,
453
- { :andalso , { :'==' , { :length , :'$4' } , length ( pre ) } ,
454
- { :'<' , :'$4' , { :const , pre } } } } } } } } }
442
+ { :orelse , { :'<' , { { :'$1' , :'$2' , :'$3' } } ,
443
+ { :const , { major , minor , patch } } } ,
444
+ { :andalso , { :'==' , { { :'$1' , :'$2' , :'$3' } } ,
445
+ { :const , { major , minor , patch } } } ,
446
+ { :orelse , { :andalso , { :'/=' , { :length , :'$4' } , 0 } ,
447
+ { :'==' , length ( pre ) , 0 } } ,
448
+ { :andalso , { :'/=' , { :length , :'$4' } , 0 } ,
449
+ { :orelse , { :'<' , { :length , :'$4' } , length ( pre ) } ,
450
+ { :andalso , { :'==' , { :length , :'$4' } , length ( pre ) } ,
451
+ { :'<' , :'$4' , { :const , pre } } } } } } } }
455
452
end
456
453
457
454
defp to_condition ( [ :'<=' , version | _ ] ) do
458
455
matchable = parse_condition ( version )
459
456
460
- { :orelse , { :andalso , { :not , { :is_binary , :'$1' } } ,
461
- { :'==' , :'$_' , { :const , matchable } } } ,
462
- to_condition ( [ :'<' , version ] ) }
457
+ { :orelse , { :'==' , :'$_' , { :const , matchable } } ,
458
+ to_condition ( [ :'<' , version ] ) }
463
459
end
464
460
465
461
defp to_condition ( current , [ ] ) do
491
487
492
488
defimpl String.Chars , for: Version do
493
489
def to_string ( version ) do
494
- pre = if pre = version . pre , do: "-#{ pre } "
490
+ pre = unless Enum . empty? ( pre = version . pre ) , do: "-#{ pre } "
495
491
build = if build = version . build , do: "+#{ build } "
496
492
"#{ version . major } .#{ version . minor } .#{ version . patch } #{ pre } #{ build } "
497
493
end
0 commit comments