Skip to content

Commit

Permalink
Move to inilike 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Oct 17, 2015
1 parent f7d640b commit 0198ad0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 40 deletions.
4 changes: 2 additions & 2 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "Desktop Entry Specification implementation",
"license" : "BSL-1.0",
"copyright": "Copyright © 2015, Roman Chistokhodov",
"authors": ["Roman Chistokhodov", "h2so5"],
"authors": ["Roman Chistokhodov"],
"dependencies": {
"inilike": "~>0.2.1",
"inilike": "~>0.3.0",
"standardpaths": "~>0.2.0"
},
"targetName" : "desktopfile",
Expand Down
2 changes: 1 addition & 1 deletion dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"fileVersion": 1,
"versions": {
"standardpaths": "0.2.0",
"inilike": "0.2.2"
"inilike": "0.3.0"
}
}
3 changes: 2 additions & 1 deletion examples/desktoptest/dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"fileVersion": 1,
"versions": {
"desktopfile": "0.5.0",
"standardpaths": "0.2.0",
"inilike": "0.2.2"
"inilike": "0.3.0"
}
}
2 changes: 1 addition & 1 deletion examples/desktoputil/dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"fileVersion": 1,
"versions": {
"standardpaths": "0.2.0",
"inilike": "0.2.2"
"inilike": "0.3.0"
}
}
11 changes: 11 additions & 0 deletions examples/desktoputil/source/app.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import std.stdio;
import desktopfile;
import std.getopt;
import std.process;

@safe string currentLocale() nothrow
{
try {
return environment.get("LC_CTYPE", environment.get("LC_ALL", environment.get("LANG")));
}
catch(Exception e) {
return null;
}
}

void main(string[] args)
{
Expand Down
36 changes: 1 addition & 35 deletions source/desktopfile.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ private {
import std.array;
import std.conv;
import std.exception;
import std.file;
import std.path;
import std.process;
import std.range;
Expand Down Expand Up @@ -477,40 +476,6 @@ public:
assert(df.desktopEntry() !is null);
}

/**
* Tells whether the string is valid dekstop entry key.
* Note: This does not include characters presented in locale names. Use $(B separateFromLocale) to get non-localized key to pass it to this function
*/
@nogc @safe override bool isValidKey(string key) pure nothrow const
{
/**
* Tells whether the character is valid for entry key.
* Note: This does not include characters presented in locale names.
*/
@nogc @safe static bool isValidKeyChar(char c) pure nothrow {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-';
}

if (key.empty) {
return false;
}
for (size_t i = 0; i<key.length; ++i) {
if (!isValidKeyChar(key[i])) {
return false;
}
}
return true;
}

///
unittest
{
auto desktopFile = new DesktopFile;
assert(desktopFile.isValidKey("Generic-Name"));
assert(!desktopFile.isValidKey("Name$"));
assert(!desktopFile.isValidKey(""));
}

/**
* Type of desktop entry.
* Returns: Type of desktop entry.
Expand Down Expand Up @@ -1125,6 +1090,7 @@ private:
///
unittest
{
import std.file;
//Test DesktopFile
string desktopFileContents =
`[Desktop Entry]
Expand Down

0 comments on commit 0198ad0

Please sign in to comment.