Example #1
0
			public void SetUp()
			{
				string nestedDependencyFilename = Path.Combine("a", "b", "variables.less");
				string nestedDependencyText = "@import \"dependency.less\";";
				
				dependencyFilename = Path.Combine("a", "b", "dependency.less");
				var dependencyText = "@color: #4D926F;";
				
				source = "@import \"variables.less\";#header {color: @color;}h2 {color: @color;}";
				expected = "#header{color:#4d926f}h2{color:#4d926f}";
				
				arguments = new Dictionary<string, object> {
					{
						"item",
						new Dictionary<string, object> {
							{ "filename", Path.Combine("a", "b", "c.less") }
						}
					}
				};
				
				fileSystem = Substitute.For<IFileSystem>();
				fileSystem.FileExists(nestedDependencyFilename).Returns(true);
				fileSystem.ReadStringFromFile(nestedDependencyFilename).Returns(nestedDependencyText);
				fileSystem.FileExists(dependencyFilename).Returns(true);
				fileSystem.ReadStringFromFile(dependencyFilename).Returns(dependencyText);
				
				lessFilter = new LessFilter(fileSystem);
			}
Example #2
0
            public void SetUp()
            {
                string nestedDependencyFilename = Path.Combine("a", "b", "variables.less");
                string nestedDependencyText     = "@import \"dependency.less\";";

                dependencyFilename = Path.Combine("a", "b", "dependency.less");
                var dependencyText = "@color: #4D926F;";

                source   = "@import \"variables.less\";#header {color: @color;}h2 {color: @color;}";
                expected = "#header{color:#4d926f}h2{color:#4d926f}";

                arguments = new Dictionary <string, object> {
                    {
                        "item",
                        new Dictionary <string, object> {
                            { "filename", Path.Combine("a", "b", "c.less") }
                        }
                    }
                };

                fileSystem = Substitute.For <IFileSystem>();
                fileSystem.FileExists(nestedDependencyFilename).Returns(true);
                fileSystem.ReadStringFromFile(nestedDependencyFilename).Returns(nestedDependencyText);
                fileSystem.FileExists(dependencyFilename).Returns(true);
                fileSystem.ReadStringFromFile(dependencyFilename).Returns(dependencyText);

                lessFilter = new LessFilter(fileSystem);
            }
Example #3
0
        public IFubuRazorView GetView(ViewDescriptor <IRazorTemplate> descriptor)
        {
            var viewId = descriptor.Template.As <IRazorTemplate>().GeneratedViewId.ToString();

            if (_inner.HasTemplate(viewId) && _lastModifiedCache[descriptor.Template.FilePath] == descriptor.Template.FilePath.LastModified())
            {
                return(GetView(x => (IFubuRazorView)x.Resolve(viewId)));
            }
            return(GetView(x => (IFubuRazorView)x.GetTemplate(_fileSystem.ReadStringFromFile(descriptor.Template.FilePath), viewId)));
        }
Example #4
0
        public void Save(Sln solution)
        {
            var solutionContents = _fileSystem.ReadStringFromFile(solution.FileName);
            var solutionBuilder  = new StringBuilder();
            var modifiers        = new List <ISolutionFileModifier>
            {
                new AddProjectsModifier(solution),
                new AddConfigurationsModifier(solution),
                new AppendLineModifier()
            };

            var lines = SplitSolution(solutionContents);

            lines.Each(line =>
            {
                var filteredModifiers = modifiers.Where(m => m.Matches(line));
                foreach (var m in filteredModifiers)
                {
                    if (!m.Modify(line, solutionBuilder))
                    {
                        break;
                    }
                }
            });

            _fileSystem.WriteStringToFile(solution.FileName, solutionBuilder.ToString());
        }
Example #5
0
        public JasmineConfiguration LoadFrom(string path)
        {
            var file     = path.ToFullPath();
            var contents = _fileSystem.ReadStringFromFile(file);
            var config   = new JasmineConfiguration(file);

            using (var reader = new StringReader(contents))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.IsEmpty())
                    {
                        continue;
                    }

                    if (line.StartsWith("include:"))
                    {
                        include(line, config);
                    }

                    else if (line.StartsWith("exclude:"))
                    {
                        exclude(line, config);
                    }
                }
            }

            return(config);
        }
Example #6
0
        public void AddProject(string slnFile, CsProj project)
        {
            var solutionContents = _fileSystem.ReadStringFromFile(slnFile);
            var replacedContents = new StringBuilder();
            var appended         = false;

            var lines = SplitSolution(solutionContents);

            lines.Each(line =>
            {
                if (line.Equals("Global") && !appended)
                {
                    var projectGuid = "{" + project.ProjectGuid + "}";
                    var projectType = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\")";
                    replacedContents.AppendLine("{0} = \"{1}\", \"{2}\", \"{3}\"".ToFormat(projectType,
                                                                                           project.Name, project.RelativePath, projectGuid));
                    replacedContents.AppendLine("EndProject");
                    appended = true;
                }

                replacedContents.AppendLine(line);
            });

            _fileSystem.WriteStringToFile(slnFile, replacedContents.ToString());
        }
        public void SetUp()
        {
            thePlan = TemplatePlan.CreateClean("gitignore");

            _contents = new Lazy <string[]>(() =>
            {
                return(fileSystem.ReadStringFromFile("gitignore", ".gitignore").SplitOnNewLine().ToArray());
            });
        }
        public bool ShouldExtract()
        {
            if (!_fileSystem.FileExists(PathToVersionDeclarationFile) || !_fileSystem.FileExists(PathToDriver))
            {
                return(true);
            }

            var currentVersion = new Version(_fileSystem.ReadStringFromFile(PathToVersionDeclarationFile));

            return(currentVersion < _embeddedDriver.Version);
        }
Example #9
0
        public void Execute(TemplatePlanContext context)
        {
            var fileSet = new FileSet
            {
                DeepSearch = false,
                Include    = "*.*",
                Exclude    = "*.exe;*.dll;.git;{0};{1};".ToFormat(FubuIgnoreFile, AutoRunFubuRake.FubuRakeFile)
            };
            var fubuIgnore = FileSystem.Combine(context.TempDir, FubuIgnoreFile);

            if (_fileSystem.FileExists(fubuIgnore))
            {
                _fileSystem
                .ReadStringFromFile(fubuIgnore)
                .SplitOnNewLine()
                .Each(ignore =>
                {
                    fileSet.Exclude += "{0};".ToFormat(ignore);
                });
            }

            var excludedFiles = fileSet.ExcludedFilesFor(context.TempDir);

            _fileSystem
            .FindFiles(context.TempDir, fileSet)
            .Where(file => !excludedFiles.Contains(file))
            .Each(from =>
            {
                var destination = Path.Combine(context.TargetPath, _fileSystem.GetFileName(from));
                if (_fileSystem.FileExists(destination))
                {
                    _fileSystem.DeleteFile(destination);
                }
                _fileSystem.MoveFile(from, destination);
            });

            _fileSystem
            .ChildDirectoriesFor(context.TempDir)
            .Each(directory =>
            {
                var destinationName = _fileSystem.GetFileName(directory);
                if (destinationName == ".git")
                {
                    return;
                }

                var destination = Path.Combine(context.TargetPath, destinationName);
                if (_fileSystem.DirectoryExists(destination))
                {
                    _fileSystem.DeleteDirectory(destination);
                }
                _fileSystem.MoveDirectory(directory, destination);
            });
        }
Example #10
0
 public IEnumerable <ObjectBlock> Blocks()
 {
     return(_settings
            .Files
            .Where(x => _fileSystem.FileExists(x))
            .SelectMany(file =>
     {
         var contents = _fileSystem.ReadStringFromFile(file);
         return _reader.Read(contents).Blocks.OfType <ObjectBlock>();
     }));
 }
            public void SetUp()
            {
                var fakeFiles = CreateFakeFileList();

                expectedModificationTime = DateTime.UtcNow;

                log = Substitute.For <ILog>();

                fileSystem = Substitute.For <IFileSystem>();
                fileSystem.GetAllFiles("layouts").Returns(fakeFiles);
                fileSystem.ReadStringFromFile(Path.Combine("layouts", "a.html")).Returns("---\nnum: 1\n---\ntest 1");
                fileSystem.ReadStringFromFile(Path.Combine("layouts", "b.html")).Returns("test 2");
                fileSystem.ReadStringFromFile(Path.Combine("layouts", "b.yaml")).Returns("num: 2");
                fileSystem.GetLastWriteTimeUtc(Arg.Any <string>()).Returns(expectedModificationTime);

                configuration = Substitute.For <IConfiguration>();
                configuration.TextExtensions.Returns(new string[] { "html", "yaml" });

                fileSystemUnified = new FileSystemUnified(log, fileSystem, configuration);
            }
Example #12
0
			public void SetUp()
			{
				string fakeConfigFile = @"property_one: one";

				string fakeRulesFile = @"Compile(""*"", (context) => {
	// Do Nothing
});
Route(""*"", (context) => {
	return string.Empty;
});
Layout(""*"", ""layout-filter"");";
				
				log = Substitute.For<ILog>();
				fileSystem = Substitute.For<IFileSystem>();
				fileSystem.FileExists("config.yaml").Returns(true);
				fileSystem.ReadStringFromFile("config.yaml").Returns(fakeConfigFile);
				fileSystem.FileExists("Rules").Returns(true);
				fileSystem.ReadStringFromFile("Rules").Returns(fakeRulesFile);
				
				loader = new Loader(log, fileSystem);
			}
Example #13
0
            public void SetUp()
            {
                string fakeConfigFile = @"property_one: one";

                string fakeRulesFile = @"Compile(""*"", (context) => {
                // Do Nothing
                });
                Route(""*"", (context) => {
                return string.Empty;
                });
                Layout(""*"", ""layout-filter"");";

                log = Substitute.For<ILog>();
                fileSystem = Substitute.For<IFileSystem>();
                fileSystem.FileExists("config.yaml").Returns(true);
                fileSystem.ReadStringFromFile("config.yaml").Returns(fakeConfigFile);
                fileSystem.FileExists("Rules").Returns(true);
                fileSystem.ReadStringFromFile("Rules").Returns(fakeRulesFile);

                loader = new Loader(log, fileSystem);
            }
Example #14
0
        public void ParseFile(string file)
        {
            var fileContent = _fileSystem.ReadStringFromFile(file);

            var replacedFileContent = _keywordReplacer.Replace(fileContent);
            if (fileContent != replacedFileContent)
            {
                _fileSystem.WriteStringToFile(file, replacedFileContent);
            }

            var newFileName = _keywordReplacer.Replace(file);
            if (file != newFileName)
            {
                Console.WriteLine("{0} -> {1}", file, Path.GetFileName(newFileName));
                _fileSystem.MoveFile(file, newFileName);
            }
        }
        private IEnumerable <Template> readTemplates(TemplateType templateType)
        {
            var directory = _templateDirectories[templateType];

            foreach (var templateDirectory in Directory.GetDirectories(directory, "*", SearchOption.TopDirectoryOnly))
            {
                var template = new Template
                {
                    Name = Path.GetFileName(templateDirectory),
                    Path = templateDirectory,
                    Type = templateType
                };

                var descriptionFile = templateDirectory.AppendPath(DescriptionFile);
                if (FileSystem.FileExists(descriptionFile))
                {
                    template.Description = FileSystem.ReadStringFromFile(descriptionFile);
                }

                yield return(template);
            }
        }
Example #16
0
 public string GetFileContents(string filename)
 {
     return(fileSystem.ReadStringFromFile(Path.Combine(path, filename)));
 }
Example #17
0
 public string ReadAll()
 {
     return(FileSystem.ReadStringFromFile(_path));
 }
Example #18
0
 public static string ReadStringFromFile(this IFileSystem fileSystem, params string[] pathParts)
 {
     return(fileSystem.ReadStringFromFile(FileSystem.Combine(pathParts)));
 }
			public void SetUp()
			{
				var fakeFiles = CreateFakeFileList();
				expectedModificationTime = DateTime.UtcNow;
				
				log = Substitute.For<ILog>();
				
				fileSystem = Substitute.For<IFileSystem>();
				fileSystem.GetAllFiles("layouts").Returns(fakeFiles);
				fileSystem.ReadStringFromFile(Path.Combine("layouts", "a.html")).Returns("---\nnum: 1\n---\ntest 1");
				fileSystem.ReadStringFromFile(Path.Combine("layouts", "b.html")).Returns("test 2");
				fileSystem.ReadStringFromFile(Path.Combine("layouts", "b.yaml")).Returns("num: 2");
				fileSystem.GetLastWriteTimeUtc(Arg.Any<string>()).Returns(expectedModificationTime);
				
				configuration = Substitute.For<IConfiguration>();
				configuration.TextExtensions.Returns(new string[] { "html", "yaml" });
				
				fileSystemUnified = new FileSystemUnified(log, fileSystem, configuration);
			}
Example #20
0
 private string readFile()
 {
     return(_files.ReadStringFromFile(_fileName));
 }
Example #21
0
 public string ReadContentsFrom(string file)
 {
     return(_fileSystem.ReadStringFromFile(file));
 }