Package ru.aristar.jnuget

Examples of ru.aristar.jnuget.Version


    public int compare(PackageEntry o1, PackageEntry o2) {
        int idCompare = super.compare(o1, o2);
        if (idCompare != 0) {
            return idCompare;
        }
        Version v1 = o1.getProperties().getVersion();
        Version v2 = o2.getProperties().getVersion();
        if (v1 == null && v2 == null) {
            return 0;
        }

        if (v1 == null) {
View Full Code Here


     * @param source Файл спецификации
     * @return Папка назначения для пакета
     */
    private File verifyPackageDestination(File rootFolder, NuspecFile source) {
        String id = source.getId();
        Version version = source.getVersion();
        File packageFolder = new File(rootFolder, id.toLowerCase());
        File versionFolder = new File(packageFolder, version.toString());
        if (!versionFolder.exists()) {
            versionFolder.mkdirs();
        }
        return versionFolder;
    }
View Full Code Here

            String packageId = pack.getId().toLowerCase();
            // Указанный пакет еще учитывался
            if (!map.containsKey(packageId)) {
                map.put(packageId, pack);
            } else { // Пакет уже попадался, сравниваем версии
                Version saved = map.get(packageId).getVersion();
                // Версия пакета новее, чем сохраненная
                if (saved.compareTo(pack.getVersion()) < 0) {
                    map.put(packageId, pack);
                }
            }
        }
        return map.values();
View Full Code Here

     */
    public Nupkg getLastVersion(String id) {
        id = id.toLowerCase();
        SortedMap<Version, Nupkg> group = treeMap.get(id);
        if (group != null) {
            Version key = group.lastKey();
            return group.get(key);
        } else {
            return null;
        }
    }
View Full Code Here

        }

        @Override
        public Nupkg next() {
            SortedMap<Version, Nupkg> packageGroup = iterator.next();
            Version key = packageGroup.lastKey();
            final Nupkg nupkg = packageGroup.get(key);
            return nupkg;
        }
View Full Code Here

     * @throws NugetFormatException некорректная строка выражения
     */
    static VersionEq parse(Queue<String> tokens) throws NugetFormatException {
        assertToken(tokens.poll(), "eq");
        assertToken(tokens.poll(), "'");
        Version version = Version.parse(tokens.poll());
        assertToken(tokens.poll(), "'");
        return new VersionEq(version);
    }
View Full Code Here

     */
    private List<Nupkg> createNupkgList(String packageId, String... versions) throws NugetFormatException {
        ArrayList<Nupkg> packages = new ArrayList<>();
        Expectations expectations = new Expectations();
        for (String versionString : versions) {
            Version version = Version.parse(versionString);
            final String mockName = packageId + ":" + version;
            final Nupkg nupkg = context.mock(Nupkg.class, mockName);
            packages.add(nupkg);
            expectations.atLeast(0).of(nupkg).getId();
            expectations.will(returnValue(packageId));
View Full Code Here

        @Override
        public Object invoke(Invocation invocation) throws Throwable {
            Object firstArgument = invocation.getParameter(0);
            String id = ((Nupkg) firstArgument).getId();
            Version version = ((Nupkg) firstArgument).getVersion();
            versions.add(version);
            packageIds.add(id);
            return null;
        }
View Full Code Here

     * @throws NugetFormatException некорректное значение тестовой версии
     */
    @Test
    public void testToString() throws NugetFormatException {
        //GIVEN
        final Version version = Version.parse("1.2.3");
        //WHEN
        VersionEq versionEq = new VersionEq(version);
        //THEN
        assertThat(versionEq.toString(), is(equalTo("Version eq '1.2.3'")));
    }
View Full Code Here

    public static VersionRange parse(String versionRangeString) throws NugetFormatException {
        if (versionRangeString == null || versionRangeString.isEmpty()) {
            return new VersionRange();
        }
        if (Version.isValidVersionString(versionRangeString)) {
            Version version = Version.parse(versionRangeString);
            return new VersionRange(version, BorderType.INCLUDE, null, null);
        }

        Pattern fixedVersionPattern = Pattern.compile("^" + FIXED_VERSION_RANGE_PATTERN + "$");
        Matcher fixedVersionMatcher = fixedVersionPattern.matcher(versionRangeString);
        if (fixedVersionMatcher.matches()) {
            Version version = Version.parse(fixedVersionMatcher.group(1));
            return new VersionRange(version, BorderType.INCLUDE, version, BorderType.INCLUDE);
        }

        Pattern pattern = Pattern.compile("^" + FULL_VERSION_RANGE_PATTERN + "$");
        Matcher matcher = pattern.matcher(versionRangeString);
        if (matcher.matches()) {
            Version lowVersion = null;
            BorderType lowBorder = null;
            String lowVersionString = matcher.group("left");
            if (!lowVersionString.isEmpty()) {
                lowVersion = Version.parse(lowVersionString);
                lowBorder = BorderType.getBorderType(matcher.group("leftBorder"));
            }
            Version topVersion = null;
            BorderType topBorder = null;
            String topVersionString = matcher.group("right");
            if (!topVersionString.isEmpty()) {
                topVersion = Version.parse(topVersionString);
                topBorder = BorderType.getBorderType(matcher.group("rightBorder"));
View Full Code Here

TOP

Related Classes of ru.aristar.jnuget.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.