Esempio n. 1
0
 internal Menu(SquashFeatureDirectory root, string outputDirectory, string menuHeader)
 {
     _outputDirectory = outputDirectory;
     SetHeader(menuHeader, root);
     _content = GetMenuFor(root);
     SquashLogger.Info("Generating page menu");
 }
Esempio n. 2
0
        public void Squash(SquashConfiguration configuration)
        {
            var squashFeatureDirectory = new SquashFeatureDirectory(configuration.InputDirectory);

            var template      = new PageTemplate(squashFeatureDirectory, configuration.OutputDirectory, configuration.Title);
            var htmlGenerator = new HtmlGenerator(template, configuration.OutputDirectory, squashFeatureDirectory);

            htmlGenerator.ClearOutputDirectory();
            htmlGenerator.GenerateFiles();
            SquashLogger.Info("Done!");
        }
Esempio n. 3
0
        private void GetFeatureFiles()
        {
            var featureFiles = Directory.GetFiles(DirectoryName, "*.feature");

            SquashLogger.Info($"Got {featureFiles.Length} feature files for {DirectoryName}");

            foreach (var file in featureFiles)
            {
                var feature = new SquashFeature(file);
                FeatureFiles.Add(feature);
            }
        }
Esempio n. 4
0
        public void ClearOutputDirectory()
        {
            SquashLogger.Info("Clearing output directory");
            DirectoryInfo di = new DirectoryInfo(_outputDirectory);

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                dir.Delete(true);
            }
        }
Esempio n. 5
0
        private void GetDirectories()
        {
            var directories = Directory.GetDirectories(DirectoryName);

            SquashLogger.Info($"Got {directories.Length} directories for {DirectoryName}");
            foreach (var dir in directories)
            {
                var e   = dir.Split('\\');
                var ext = e[e.Length - 1] + "\\";
                var f   = new SquashFeatureDirectory(dir, DirectoryExtension + ext);
                if (f.Directories.Count > 0 || f.FeatureFiles.Count > 0)
                {
                    Directories.Add(f);
                }
            }
        }
Esempio n. 6
0
        internal PageTemplate(SquashFeatureDirectory squashFeatureDirectory, string outputDirectory, string menuHeader = "")
        {
            var menu = new Menu(squashFeatureDirectory, outputDirectory, menuHeader);

            // string style = File.ReadAllText("style.css");
            //string script = File.ReadAllText("script.js");

            var template = new Template(Templates.Template);

            template.Replace("menu", menu);
            template.Replace("templateStyle", minifiedCss);
            template.Replace("templateScript", minifiedJs);

            _template = template;
            SquashLogger.Info("Got page template");
        }
Esempio n. 7
0
        private void VerifySeparator(string filePath)
        {
            foreach (var separator in _validSeparators)
            {
                if (filePath.Contains(separator.ToString()))
                {
                    _separator = separator;
                    return;
                }
                if (Directory.Exists(filePath + separator))
                {
                    _separator = separator;
                    return;
                }
            }

            SquashLogger.Error("Cannot find file path separator");
        }
Esempio n. 8
0
        private void Create()
        {
            SetFeatureTitle();
            SetFeatureDescription();

            var scenario = new SquashScenario();

            while (_cabinet.PeekNextLine() != null)
            {
                var row = _cabinet.PeekNextLine();
                if (string.IsNullOrWhiteSpace(row))
                {
                    continue;
                }

                //tags
                if (row.StartsWith("@"))
                {
                    var newscenario = CreateScenarioWithTags();
                    SquashLogger.Debug($"Feature {Name} has scenario {newscenario.Name} with tags {string.Join(",",newscenario.Tags)}");
                    Scenarios.Add(newscenario);
                    continue;
                }

                //scenario
                if (row.StartsWith("Scenario:"))
                {
                    var newscenario = CreateScenario();
                    SquashLogger.Debug($"Feature {Name} has scenario {newscenario.Name}");
                    Scenarios.Add(newscenario);
                    continue;
                }

                //scenario
                if (row.StartsWith("Scenario Outline:"))
                {
                    var newscenario = CreateScenarioOutline();
                    SquashLogger.Debug($"Feature {Name} has scenario outline {newscenario.Name} with scenarios {string.Join(",", newscenario.Scenarios.Select(s => s.Name))}");
                    Scenarios.Add(newscenario);
                    continue;
                }
            }
        }
Esempio n. 9
0
        public bool Validate()
        {
            if (_separator == null)
            {
                SquashLogger.Error("File path separator is not defined");
                return(false);
            }

            if (!Directory.Exists(InputDirectory))
            {
                SquashLogger.Error("Input directory does not exist: \"" + InputDirectory + "\"");
                return(false);
            }

            if (!Directory.Exists(OutputDirectory))
            {
                SquashLogger.Error("Output directory does not exist: \"" + OutputDirectory + "\"");
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
        public SquashConfiguration(string configLocation)
        {
            if (!File.Exists(configLocation))
            {
                SquashLogger.Error("Configuration file does not exist");
                return;
            }

            var file = File.ReadAllText(configLocation);

            if (string.IsNullOrWhiteSpace(file))
            {
                SquashLogger.Error("File is empty");
                return;
            }

            SquashConfiguration config = null;

            try
            {
                config = JsonConvert.DeserializeObject <SquashConfiguration>(file);
            }
            catch (Exception ex)
            {
                SquashLogger.Error("Error parsing config file: " + ex.Message);
            }

            if (config == null)
            {
                SquashLogger.Error("Config file is not in the correct format");
                return;
            }

            Title           = config.Title;
            InputDirectory  = config.InputDirectory;
            OutputDirectory = config.OutputDirectory;

            Validate();
        }
Esempio n. 11
0
 public void GenerateFiles()
 {
     SquashLogger.Info("Generating files");
     GenerateFeatureFilesFor(_root);
 }