Rename to Octokit to be consistent with other API libs

GitHub is naming all of the libraries Octokit for their respective
platforms
This commit is contained in:
Haacked
2013-01-29 14:00:27 -08:00
parent 4370788c34
commit 997e955f38
124 changed files with 225 additions and 226 deletions
+58
View File
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Octokit
{
internal static class StringExtensions
{
public static bool IsBlank(this string value)
{
return string.IsNullOrWhiteSpace(value);
}
public static bool IsNotBlank(this string value)
{
return !string.IsNullOrWhiteSpace(value);
}
public static Uri FormatUri(this string pattern, params object[] args)
{
return new Uri(string.Format(CultureInfo.InvariantCulture, pattern, args), UriKind.Relative);
}
// :trollface:
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase",
Justification = "Ruby don't care. Ruby don't play that.")]
public static string ToRubyCase(this string propertyName)
{
Ensure.ArgumentNotNullOrEmptyString(propertyName, "s");
return string.Join("_", propertyName.SplitUpperCase()).ToLowerInvariant();
}
static IEnumerable<string> SplitUpperCase(this string source)
{
Ensure.ArgumentNotNullOrEmptyString(source, "source");
int wordStartIndex = 0;
var letters = source.ToCharArray();
var previousChar = char.MinValue;
// Skip the first letter. we don't care what case it is.
for (int i = 1; i < letters.Length; i++)
{
if (char.IsUpper(letters[i]) && !char.IsWhiteSpace(previousChar))
{
//Grab everything before the current character.
yield return new String(letters, wordStartIndex, i - wordStartIndex);
wordStartIndex = i;
}
previousChar = letters[i];
}
//We need to have the last word.
yield return new String(letters, wordStartIndex, letters.Length - wordStartIndex);
}
}
}