<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Xml;
using FubuCore;

namespace Ripple2Paket
{
    internal class Program
    {
        private static bool success;

        public static int Main(string[] args)
        {
            var directory = args.FirstOrDefault();
            if (directory.IsEmpty()) throw new Exception("You must specify the codebase directory");

            if (!Directory.Exists(directory))
            {
                throw new Exception("The specified codebase directory {0} could not be found".ToFormat(directory));
            }
            
            copyPaketExe(directory);
            return 0;
            var ripple = new XmlDocument();
            ripple.Load(directory.AppendPath("ripple.config"));

            var feeds = findFeeds(ripple);
            var nugets = findNugets(ripple);


            

            var dependencies = readRippleDependencies(directory);

            
            
            
            removeRippleFiles(directory);

            writePaketDependencies(directory, feeds, nugets);
            var cmd = writeInstallationCmd(directory, dependencies);

            executeInstallation(cmd);

            return 0;
        }

        private static void executeInstallation(string cmd)
        {
            throw new NotImplementedException();
        }

        private static string writeInstallationCmd(string directory, IEnumerable<ProjectDependency> dependencies)
        {
            throw new NotImplementedException();
        }

        private static void copyPaketExe(string directory)
        {
            var paketPath = AppDomain.CurrentDomain.BaseDirectory.AppendPath("paket.exe");
            Console.WriteLine("Copying paket.exe to " + directory);
            new FileSystem().CopyToDirectory(paketPath, directory);
        }

        private static IEnumerable<ProjectDependency> readRippleDependencies(string directory)
        {
            throw new NotImplementedException();
        }

        private static void removeRippleFiles(string directory)
        {
            throw new NotImplementedException();
        }

        private static void writePaketDependencies(string directory, IEnumerable<string> feeds, IEnumerable<Nuget> nugets)
        {
            throw new NotImplementedException();
        }

        private static IEnumerable<Nuget> findNugets(XmlDocument ripple)
        {
            throw new NotImplementedException();
        }

        private static IEnumerable<string> findFeeds(XmlDocument ripple)
        {
            throw new NotImplementedException();
        }
    }

    public class Nuget
    {
        public string Name;
        public string Version;
        public bool Floated;
    }<commit_msg>Can read ripple feeds and nugets from ripple.config<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Xml;
using FubuCore;

namespace Ripple2Paket
{
    internal class Program
    {
        private static bool success;

        public static int Main(string[] args)
        {
            var directory = args.FirstOrDefault();
            if (directory.IsEmpty()) throw new Exception("You must specify the codebase directory");

            if (!Directory.Exists(directory))
            {
                throw new Exception("The specified codebase directory {0} could not be found".ToFormat(directory));
            }
            
            copyPaketExe(directory);
            
            var ripple = new XmlDocument();
            ripple.Load(directory.AppendPath("ripple.config"));
            
            var feeds = findFeeds(ripple).ToArray();

 
            var nugets = findNugets(ripple).ToArray();


            nugets.Each(x => Console.WriteLine(x));
            Console.ReadLine();

            return 0;

            var dependencies = readRippleDependencies(directory);

            
            
            
            removeRippleFiles(directory);

            writePaketDependencies(directory, feeds, nugets);
            var cmd = writeInstallationCmd(directory, dependencies);

            executeInstallation(cmd);

            return 0;
        }

        private static void executeInstallation(string cmd)
        {
            throw new NotImplementedException();
        }

        private static string writeInstallationCmd(string directory, IEnumerable<ProjectDependency> dependencies)
        {
            throw new NotImplementedException();
        }

        private static void copyPaketExe(string directory)
        {
            var paketPath = AppDomain.CurrentDomain.BaseDirectory.AppendPath("paket.exe");
            Console.WriteLine("Copying paket.exe to " + directory);
            new FileSystem().CopyToDirectory(paketPath, directory);
        }

        private static IEnumerable<ProjectDependency> readRippleDependencies(string directory)
        {
            throw new NotImplementedException();
        }

        private static void removeRippleFiles(string directory)
        {
            throw new NotImplementedException();
        }

        private static void writePaketDependencies(string directory, IEnumerable<string> feeds, IEnumerable<Nuget> nugets)
        {
            throw new NotImplementedException();
        }

        private static IEnumerable<Nuget> findNugets(XmlDocument ripple)
        {
            foreach (XmlElement element in ripple.DocumentElement.SelectNodes("//Dependency"))
            {
                yield return new Nuget
                {
                    Name = element.GetAttribute("Name"),
                    Version = element.GetAttribute("Version"),
                    Floated = element.GetAttribute("Mode") == "Float"
                };
            }
        }

        private static IEnumerable<string> findFeeds(XmlDocument ripple)
        {
            foreach (XmlElement elem in ripple.DocumentElement.SelectNodes("//Feed"))
            {
                yield return elem.GetAttribute("Url");
            }
        }
    }

    public class Nuget
    {
        public string Name;
        public string Version;
        public bool Floated;


        public override string ToString()
        {
            return string.Format("name: {0}, version: {1}, floated: {2}", Name, Version, Floated);
        }
    }
{'fraction_non_alphanumeric': 0.07857252259151477, 'fraction_numerical': 0.0016847909327615256, 'mean_word_length': 1.9995406522737713, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3192179', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1515, 'n_words': 388}