Skip to content

Commit

Permalink
More logging cleanup. Got the current dir detection better for the co…
Browse files Browse the repository at this point in the history
…de directory.
  • Loading branch information
jmarnold committed Apr 16, 2013
1 parent c196e2d commit 777731e
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 93 deletions.
66 changes: 65 additions & 1 deletion src/ripple.Testing/RippleFileSystemTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace ripple.Testing
{
[TestFixture]
public class RippleFileSystemTester
public class from_a_solution_dir
{
private string theSolutionDir;
private string theCurrentDir;
Expand Down Expand Up @@ -35,6 +35,20 @@ public void TearDown()
{
var fileSystem = new FileSystem();
fileSystem.DeleteDirectory(theCodeDir);

RippleFileSystem.Live();
}

[Test]
public void is_a_solution_directory()
{
RippleFileSystem.IsSolutionDirectory().ShouldBeTrue();
}

[Test]
public void is_not_the_code_dir()
{
RippleFileSystem.IsCodeDirectory().ShouldBeFalse();
}

[Test]
Expand All @@ -49,4 +63,54 @@ public void finds_the_code_dir()
RippleFileSystem.FindCodeDirectory().ShouldEqual(theCodeDir.ToFullPath());
}
}

[TestFixture]
public class from_the_code_dir
{
private string theSolutionDir;
private string theCodeDir;

[SetUp]
public void SetUp()
{
theCodeDir = ".".AppendPath("code");
theSolutionDir = theCodeDir.AppendPath("ripple");

var fileSystem = new FileSystem();
fileSystem.CreateDirectory(theCodeDir);
fileSystem.CreateDirectory(theSolutionDir);

fileSystem.WriteStringToFile(Path.Combine(theSolutionDir, SolutionFiles.ConfigFile), "");

RippleFileSystem.StubCurrentDirectory(theCodeDir);
RippleFileSystem.StopTraversingAt(theCodeDir);
}

[TearDown]
public void TearDown()
{
var fileSystem = new FileSystem();
fileSystem.DeleteDirectory(theCodeDir);

RippleFileSystem.Live();
}

[Test]
public void is_the_code_directory()
{
RippleFileSystem.IsCodeDirectory().ShouldBeTrue();
}

[Test]
public void is_not_a_solution_dir()
{
RippleFileSystem.IsSolutionDirectory().ShouldBeFalse();
}

[Test]
public void finds_the_code_dir()
{
RippleFileSystem.FindCodeDirectory().ShouldEqual(theCodeDir.ToFullPath());
}
}
}
21 changes: 21 additions & 0 deletions src/ripple/Commands/DescribeGraphCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using FubuCore.CommandLine;
using FubuCore.Descriptions;
using ripple.Model;

namespace ripple.Commands
{
public class DescribeGraphInput { }

[CommandDescription("Describes the current solution graph", Name = "describe-graph")]
public class DescribeGraphCommand : FubuCommand<DescribeGraphInput>
{
public override bool Execute(DescribeGraphInput input)
{
var graph = SolutionGraphBuilder.BuildForCurrentDirectory();
Console.WriteLine(graph.ToDescriptionText());

return true;
}
}
}
2 changes: 1 addition & 1 deletion src/ripple/Commands/LocalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override bool Execute(LocalInput input)
Console.WriteLine();

var requirements = input.ToRequirements();
var solutionGraph = SolutionGraphBuilder.BuildForRippleDirectory();
var solutionGraph = SolutionGraphBuilder.BuildForCurrentDirectory();

var logger = new RippleLogger();
var stepRunner = new Local.RippleStepRunner(new ProcessRunner(), new FileSystem(), logger, requirements);
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/Commands/OpenNugetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class OpenNugetCommand : FubuCommand<OpenNugetInput>
{
public override bool Execute(OpenNugetInput input)
{
var nuspec = SolutionGraphBuilder.BuildForRippleDirectory()
var nuspec = SolutionGraphBuilder.BuildForCurrentDirectory()
.FindNugetSpec(input.Name);

new FileSystem().LaunchEditor(nuspec.Filename);
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/Commands/SolutionInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface IOverrideFeeds

public class SolutionInput
{
private readonly Lazy<SolutionGraph> _graph = new Lazy<SolutionGraph>(SolutionGraphBuilder.BuildForRippleDirectory);
private readonly Lazy<SolutionGraph> _graph = new Lazy<SolutionGraph>(SolutionGraphBuilder.BuildForCurrentDirectory);

[Description("override the solution to be cleaned")]
[FlagAlias("solution", 'l')]
Expand Down Expand Up @@ -47,7 +47,7 @@ public IEnumerable<Solution> FindSolutions()
{
yield return _graph.Value[SolutionFlag];
}
else if (AllFlag || ".".ToFullPath() == RippleFileSystem.CodeDirectory())
else if (AllFlag || RippleFileSystem.IsCodeDirectory())
{
foreach (var solution in _graph.Value.AllSolutions)
{
Expand All @@ -56,9 +56,9 @@ public IEnumerable<Solution> FindSolutions()
}
else
{
if (new FileSystem().FileExists(".".ToFullPath(), SolutionFiles.ConfigFile))
if (RippleFileSystem.IsSolutionDirectory())
{
yield return SolutionBuilder.ReadFrom(".");
yield return SolutionBuilder.ReadFromCurrentDirectory();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/Commands/WhereAmICommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class WhereAmICommand : FubuCommand<WhereAmIInput>
{
public override bool Execute(WhereAmIInput input)
{
Console.WriteLine("The root code directory for ripple is " + RippleFileSystem.CodeDirectory());
Console.WriteLine("The root code directory for ripple is " + RippleFileSystem.FindCodeDirectory());
Console.WriteLine("ripple.exe is at " + RippleFileSystem.RippleExeLocation());

return true;
Expand Down
28 changes: 27 additions & 1 deletion src/ripple/Model/SolutionGraph.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using FubuCore;
using FubuCore.DependencyAnalysis;
using FubuCore.Descriptions;
using FubuCore.Util;
using System.Linq;
using ripple.Local;

namespace ripple.Model
{
public class SolutionGraph
public class SolutionGraph : DescribesItself
{
private readonly Lazy<IEnumerable<NugetSpec>> _allNugets;
private readonly Lazy<IList<Solution>> _orderedSolutions;
Expand Down Expand Up @@ -66,5 +68,29 @@ public IEnumerable<NugetSpec> FindFromDependencies(IEnumerable<Dependency> depen
{
return AllNugets().Where(x => dependencies.Any(d => d.Name == x.Name));
}

public void Describe(Description description)
{
description.Title = "Solution Graph at {0}".ToFormat(RippleFileSystem.FindCodeDirectory());

var solutions = description.AddList("Solutions", _orderedSolutions.Value.Select(x => new SolutionListItem(x)));
solutions.Label = "Solutions";
}

public class SolutionListItem : DescribesItself
{
private readonly Solution _solution;

public SolutionListItem(Solution solution)
{
_solution = solution;
}

public void Describe(Description description)
{
description.Title = _solution.Name;
description.ShortDescription = _solution.Path;
}
}
}
}
6 changes: 3 additions & 3 deletions src/ripple/Model/SolutionGraphBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace ripple.Model
{
public class SolutionGraphBuilder
{
public static SolutionGraph BuildForRippleDirectory()
public static SolutionGraph BuildForCurrentDirectory()
{
var builder = new SolutionGraphBuilder(new FileSystem());
var codeDirectory = RippleFileSystem.CodeDirectory();
var codeDirectory = RippleFileSystem.FindCodeDirectory();

return builder.ReadFrom(codeDirectory);
}
Expand All @@ -26,7 +26,7 @@ public SolutionGraph ReadFrom(string folder)
{
folder = findCorrectFolder(folder);

Console.WriteLine("Trying to read a Ripple SolutionGraph from " + folder);
RippleLog.Info("Trying to read a Ripple SolutionGraph from " + folder);

var solutions = readSolutions(folder);

Expand Down
Loading

0 comments on commit 777731e

Please sign in to comment.