## More semver functionality

So the main functionality I need from the semver package that I am writing, is the "satisfies" functionality. This is the function, that can define if a certain version string pattern is within a set of ranges of different versions.

For example, I want to know if version 1.2.* is satisfied with the following ranges: <=1.2.3 or >1.2.0 or between 1.4.1 and 1.4.6. But before I get there I need some more supporting functions. I my last entry, I had implemented some of the basics, and now I have completed a few more

Here are the list of new functions implemented:

- {major} - Return the Major of a semver string
- {minor} - Return the Minor of a semver string
- {patch} - Return the Patch of a semver string
- {gte} - Greater than or equal
- {lte} - Less than or equal
- {eq} - Equal to
- {neq} - Not equal to
- {cmp} - Compare semver strings using operators

So here is a short demo of each of them:

First save the following anonymous plsql block into a file called test_semver.sql

```
set serverout on
declare
l_semver varchar2(150) := '1.2.3';
l_semver_2 varchar2(150) := '1.2.2';
procedure s(s_in varchar2)
as
begin
dbms_output.put_line(s_in);
end;
begin
s('Testing Major, Minor and Patch functions, against 1.2.3');
s('Major is: ' || semver_ninja.major(l_semver));
s('Minor is: ' || semver_ninja.minor(l_semver));
s('Patch is: ' || semver_ninja.patch(l_semver));
s('Testing if 1.2.3 is greater than or equal to 1.2.3');
if semver_ninja.gte('1.2.3', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.4 is greater than or equal to 1.2.3');
if semver_ninja.gte('1.2.4', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.2 is greater than or equal to 1.2.3');
if semver_ninja.gte('1.2.2', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.3 is less than or equal to 1.2.3');
if semver_ninja.lte('1.2.3', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.2 is less than or equal to 1.2.3');
if semver_ninja.lte('1.2.2', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.4 is less than or equal to 1.2.3');
if semver_ninja.lte('1.2.4', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.2 is equal to 1.2.3');
if semver_ninja.eq('1.2.2', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.3 is equal to 1.2.3');
if semver_ninja.eq('1.2.3', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.2 is not equal to 1.2.3');
if semver_ninja.neq('1.2.2', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing if 1.2.3 is not equal to 1.2.3');
if semver_ninja.neq('1.2.3', '1.2.3') then
s('True');
else
s('False');
end if;
s('Testing cmp with different operators:');
s('1.2.3 = 1.2.3');
if semver_ninja.cmp('1.2.3', '=', '1.2.3') then
s('True');
else
s('False');
end if;
s('1.2.4 > 1.2.3');
if semver_ninja.cmp('1.2.4', '>', '1.2.3') then
s('True');
else
s('False');
end if;
end;
/
```

Next run that script from the user, where you have installed the semver_ninja package under.

```
SQL> @test_semver.sql
Testing Major, Minor and Patch functions, against 1.2.3
Major is: 1
Minor is: 2
Patch is: 3
Testing if 1.2.3 is greater than or equal to 1.2.3
True
Testing if 1.2.4 is greater than or equal to 1.2.3
True
Testing if 1.2.2 is greater than or equal to 1.2.3
False
Testing if 1.2.3 is less than or equal to 1.2.3
True
Testing if 1.2.2 is less than or equal to 1.2.3
True
Testing if 1.2.4 is less than or equal to 1.2.3
False
Testing if 1.2.2 is equal to 1.2.3
False
Testing if 1.2.3 is equal to 1.2.3
True
Testing if 1.2.2 is not equal to 1.2.3
True
Testing if 1.2.3 is not equal to 1.2.3
False
Testing cmp with different operators:
1.2.3 = 1.2.3
True
1.2.4 > 1.2.3
True
PL/SQL procedure successfully completed.
SQL>
```

Now I'm pretty close to having all the functions I need to implement the satisfies function. All that is missing now, are a range-string-finder function, and a procedure to parse the range syntax as defined by semver definition (Hyphen Ranges, X-Ranges, Tilde Ranges and Caret Ranges).