Skip to content

Commit

Permalink
Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
UIMSolutions committed May 4, 2024
1 parent 5c9734b commit 979b2d5
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 61 deletions.
11 changes: 3 additions & 8 deletions caches/uim/caches/classes/caches/cache.d
Expand Up @@ -57,8 +57,7 @@ class DCache : ICache {
}

this(string newName) {
this();
this.name(newName);
this().name(newName);
}

bool initialize(Json[string] initData = null) {
Expand Down Expand Up @@ -245,13 +244,9 @@ class DCache : ICache {
* ```
* Cache.writeMany(["cached_data_1": 'data 1", "cached_data_2": 'data 2"], "long_term");
* ```
* Params:
* range mydata An array or Traversable of data to be stored in the cache
* @param string configName Optional string configuration name to write to. Defaults to "default"
* returns = True on success, false on failure
*/
/* static bool writeMany(Range mydata, string configName = "default") {
return pool(configName).setMultiple(mydata);
/* static bool writeMany(Json[data] dataToStore, string configName = "default") {
return pool(configName).set(dataToStore);
} */

/**
Expand Down
2 changes: 1 addition & 1 deletion caches/uim/caches/classes/engines/apcu.d
Expand Up @@ -27,7 +27,7 @@ class DApcuCacheEngine : DCacheEngine {

/* override bool set(string itemKey, Json dataToCache, long timeToLive = 0) {
auto aKey = _key(itemKey);
auto myDuration = this.duration(timeToLive);
auto myDuration = duration(timeToLive);
return apcu_store(aKey, dataToCache, myDuration);
} */
Expand Down
11 changes: 4 additions & 7 deletions caches/uim/caches/classes/engines/memory.d
Expand Up @@ -242,14 +242,11 @@ Json getOption(int myname) {
* remember that the Memory pecl extension does not support cache expiry
* times greater than 30 days in the future. Any duration greater than 30 days
* will be treated as real Unix time value rather than an offset from current time.
* Params:
* string aKey Identifier for the data
* @param Json aValue Data to be cached
* /
override bool set(string aKey, Json aValue, long timeToLive = 0) {
myduration = this.duration(myttl);
override bool set(string itemKey, Json dataToCache, long timeToLive = 0) {
myduration = duration(timeToLive);
return _Memory.set(_key(aKey), myvalue, myduration);
return _Memory.set(_key(itemKey), dataToCache, myduration);
}
/**
Expand All @@ -264,7 +261,7 @@ override bool set(Json[string] values, long timeToLive = 0) {
auto cacheData = null;
myvalues.byKeyValue
.each!(kv => cacheData[_key(kv.key)] = kv.value);
auto duration = this.duration(myttl);
auto duration = duration(myttl);
return _Memory.setMulti(cacheData, duration);
}
Expand Down
4 changes: 2 additions & 2 deletions caches/uim/caches/classes/engines/redis.d
Expand Up @@ -69,7 +69,7 @@ class DRedisCacheEngine : DCacheEngine {
_redis = new DRedis();
if (!configuration.isEmpty("unix_socket")) {
result = _redis.connect(configuration.get("unix_socket"]);
} elseif (configuration.get("persistent"].isEmpty) {
} elseif (configuration.isEmpty("persistent")) {
result = _redis.connect(
configuration.get("server"],
configuration.get("port"].toInt,
Expand Down Expand Up @@ -104,7 +104,7 @@ class DRedisCacheEngine : DCacheEngine {
auto myKey = _key(dataId);
auto serializedData = this.serialize(dataToCache);
auto myDuration = this.duration(timeToLive);
auto myDuration = duration(timeToLive);
return myDuration == 0
: _redis.set(myKey, serializedData)
: _redis.setEx(myKey, myDuration, serializedData);
Expand Down
14 changes: 7 additions & 7 deletions collections/uim/collections/classes/iterators/zip.d
Expand Up @@ -46,7 +46,7 @@ class DZipIterator : ICollection {
* @param callable|null aCallable The auto to use for zipping the elements of each iterator.
* /
this(array sets, ?callable aCallable = null) {
this.multipleIterator = new DMultipleIterator(
_multipleIterator = new DMultipleIterator(
MultipleIterator.MIT_NEED_ALL | MultipleIterator.MIT_KEYS_NUMERIC
);
Expand All @@ -55,7 +55,7 @@ class DZipIterator : ICollection {
sets.each!((set) {
anIterator = (new DCollection(set)).unwrap();
_iterators ~= anIterator;
this.multipleIterator.attachIterator(anIterator);
_multipleIterator.attachIterator(anIterator);
});
}
Expand All @@ -64,7 +64,7 @@ class DZipIterator : ICollection {
* iterators with the same positional index.
* /
Json current() {
current = this.multipleIterator.current();
current = _multipleIterator.current();
if (_callback) {
return call_user_func_array(_callback, current);
}
Expand All @@ -74,10 +74,10 @@ class DZipIterator : ICollection {
return _multipleIterator.key();
}
void next() {
this.multipleIterator.next();
_multipleIterator.next();
}
void rewind()) {
this.multipleIterator.rewind();
_multipleIterator.rewind();
}
bool valid() {
return _multipleIterator.valid();
Expand All @@ -94,11 +94,11 @@ class DZipIterator : ICollection {
* array data Data array.
* /
void __unserialize(array data) {
this.multipleIterator = new DMultipleIterator(
_multipleIterator = new DMultipleIterator(
MultipleIterator.MIT_NEED_ALL | MultipleIterator.MIT_KEYS_NUMERIC
);
_iterators = someData;
_iterators.each!(iterator => this.multipleIterator.attachIterator(iterator));
_iterators.each!(iterator => _multipleIterator.attachIterator(iterator));
} */
}
6 changes: 3 additions & 3 deletions commands/uim/commands/classes/commands/i18n/i18n.d
Expand Up @@ -31,11 +31,11 @@ class DI18nCommand : DCommand {
.toLower;
code = null;
switch (choice) {
case "e" : code = this.executeCommand(I18nExtractCommand.classname, [], aConsoleIo);
case "e" : code = executeCommand(I18nExtractCommand.classname, [], aConsoleIo);
break;
case "i" : code = this.executeCommand(I18nInitCommand.classname, [], aConsoleIo);
case "i" : code = executeCommand(I18nInitCommand.classname, [], aConsoleIo);
break;
case "h" : aConsoleIo.writeln(this.getOptionParser().help());
case "h" : aConsoleIo.writeln(getOptionParser().help());
break;
case "q" : // Do nothing
break;
Expand Down
2 changes: 1 addition & 1 deletion commands/uim/commands/classes/commands/i18n/i18nextract.d
Expand Up @@ -76,7 +76,7 @@ class DI18nExtractCommand : DCommand {
string response = aConsoleIo.ask(message, defaultPaths[defaultPathIndex] ?? "D");
if (strtoupper(response) == "Q") {
aConsoleIo.writeErrorMessages("Extract Aborted");
this.abort();
abort();
}
if (strtoupper(response) == "D" && count(_paths)) {
aConsoleIo.writeln();
Expand Down
22 changes: 8 additions & 14 deletions consoles/uim/consoles/classes/consoles/io.d
Expand Up @@ -163,26 +163,20 @@ class DConsoleIo {
int info(string[] outputMessages, int newLinesToAppend = 1, int outputLevel = NORMAL) {
string messageType = "info";
auto myOutputMessages = this.wrapMessageWithType(messageType, outputMessages);
auto myOutputMessages = wrapMessageWithType(messageType, outputMessages);
return _writeln(myOutputMessages, newLinesToAppend, level);
}
/**
* Convenience method for out() that wraps message between <comment> tag
* Params:
* @param int newLinesToAppend Number of newLinesToAppend to append
* @param int level The message`s output level, see above.
* /
// Convenience method for out() that wraps message between <comment> tag
int comment(string[] outputMessages...) {
return comment(outputMessages.dup);
}
int comment(string[] outputMessages, int newLinesToAppendToAppend = 1, int level = self.NORMAL) {
string messageType = "comment";
message = this.wrapMessageWithType(messageType, message);
int comment(string[] outputMessages, int newLinesToAppendToAppend = 1, int outputLevel = self.NORMAL) {
auto message = wrapMessageWithType("comment", message);
return _writeln(message, newLinesToAppend, level);
return _writeln(message, newLinesToAppend, outputLevel);
}
/**
Expand All @@ -193,7 +187,7 @@ class DConsoleIo {
* /
int warning(string[] amessage, int newLinesToAppend = 1) {
string messageType = "warning";
message = this.wrapMessageWithType(messageType, message);
message = wrapMessageWithType(messageType, message);
return _writeErrorMessages(message, newLinesToAppend);
}
Expand All @@ -206,7 +200,7 @@ class DConsoleIo {
* /
int error(string[] messagesToOutput, int newLinesToAppend = 1) {
string messageType = "error";
auto message = this.wrapMessageWithType(messageType, messagesToOutput);
auto message = wrapMessageWithType(messageType, messagesToOutput);
return _writeErrorMessages(message, newLinesToAppend);
}
Expand All @@ -219,7 +213,7 @@ class DConsoleIo {
* /
int success(string[] messagesToOutput, int newLinesToAppend = 1, int outputLevel = self.NORMAL) {
string messageType = "success";
message = this.wrapMessageWithType(messageType, message);
message = wrapMessageWithType(messageType, message);
return _writeln(message, newLinesToAppend, outputLevel);
}
Expand Down
7 changes: 5 additions & 2 deletions views/uim/views/classes/views/view.d
Expand Up @@ -496,8 +496,11 @@ static string contentType() {
* callable myblock The block of code that you want to cache the output of.
* /
string cache(callable myblock, Json[string] options = null) {
Json[string] options = options.update["key": "", "config": _elementCache];
if (options["key"].isEmpty) {
Json[string] options = options.merge([
"key": Json(""),
"config": Json(_elementCache)]);
if (options.isEmpty("key")) {
throw new DInvalidArgumentException("Cannot cache content with an empty key");
}
result = Cache.read(options["key"], options["config"]);
Expand Down
27 changes: 11 additions & 16 deletions views/uim/views/helpers/form.d
Expand Up @@ -806,11 +806,10 @@ class DFormHelper : DHelper {
mymodelName = Inflector.humanize(
Inflector.singularize(_View.getRequest().getParam("controller"))
);
if (!myisCreate) {
mylegend = __d("uim", "Edit {0}", mymodelName);
} else {
mylegend = __d("uim", "New {0}", mymodelName);
}
mylegend = !myisCreate
? __d("uim", "Edit {0}", mymodelName)
: __d("uim", "New {0}", mymodelName);
}
if (myfieldset != false) {
if (mylegend) {
Expand Down Expand Up @@ -943,11 +942,11 @@ class DFormHelper : DHelper {
return myinput;
}
mylabel = _getLabel(fieldName, compact("input", "label", "error", "nestedInput") + options);
if (mynestedInput) {
result = _groupTemplate(compact("label", "error", "options"));
} else {
result = _groupTemplate(compact("input", "label", "error", "options"));
}
result = mynestedInput
? _groupTemplate(compact("label", "error", "options"))
: _groupTemplate(compact("input", "label", "error", "options"));
result = _inputContainerTemplate([
"content": result,
"error": myerror,
Expand All @@ -962,13 +961,9 @@ class DFormHelper : DHelper {
return result;
}
/**
* Generates an group template element
* Params:
* Json[string] options The options for group template
* /
// Generates an group template element
protected string _groupTemplate(Json[string] options) {
mygroupTemplate = options["options"]["type"] ~ "FormGroup";
string mygroupTemplate = options["options"]["type"] ~ "FormGroup";
if (!this.templater().get(mygroupTemplate)) {
mygroupTemplate = "formGroup";
}
Expand Down

0 comments on commit 979b2d5

Please sign in to comment.