Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
update release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yusanlou committed Apr 8, 2017
1 parent 96ffd4b commit ee4f772
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 9 deletions.
26 changes: 20 additions & 6 deletions Sources/commandService/DataService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ class listNode {
tail = tail!.next
}
}

func deleteNode() {

}

}

class linkNode {
Expand All @@ -103,9 +98,28 @@ class linkNode {

class Values {
let localizedString : String
let comment : String
var comment : String
var outPutStr : String
init(value:String,comment:String) {
self.localizedString = value
self.comment = comment
outPutStr = "/* */"
}

func appendClassComent(className:String,comStr:String) {
if !outPutStr.contains(className) {
var insertStr = " \(className):\(comStr) | "
outPutStr.insert(contentsOf: insertStr.characters, at: outPutStr.index(outPutStr.startIndex, offsetBy: 2))
print(outPutStr)

}
}

}

func isSameValues(_ value1:Values,value2:Values) -> Bool{
let judge1 = value1.localizedString == value2.localizedString
let judge2 = value1.comment == value2.comment

return (judge1 && judge2)
}
40 changes: 37 additions & 3 deletions Sources/commandService/commandTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ extension RegexStringsSearcher {
if strMatches.count > 1 {
commont = NSString(string: extracted).substring(with: strMatches[1].rangeAt(0))
}
let value = Values.init(value: localizedString, comment: "\(commont)")
value.appendClassComent(className: path.lastComponentWithoutExtension, comStr: commont)

let value = Values.init(value: localizedString, comment: "/* \(path.lastComponentWithoutExtension) : \(commont) */")
guard duplicateRemoval(path: path, value: value,className:path.lastComponentWithoutExtension) else {continue}

let judge = !extracts.contains{isSameValues($0, value2: value)}
guard judge else {continue}
/// over here, if localizedString is isAmbiguous,we analysis error
if localizedString.isAmbiguous {
errors.append(value)
Expand All @@ -67,6 +71,7 @@ extension RegexStringsSearcher {
}
if extracts.count > 0 {
if path.lastComponent.contains("swift") {

DataHandleManager.defaltManager.swift_listNode?.insert(values: extracts, className: path.lastComponent, path: path.description)
}else{
DataHandleManager.defaltManager.oc_listNode?.insert(values: extracts, className: path.lastComponent, path: path.description)
Expand All @@ -82,6 +87,35 @@ extension RegexStringsSearcher {

}

/**
Duplicate removal
- parameter value
- returns: if there is no same value return true
*/
func duplicateRemoval(path:Path,value:Values,className:String) -> Bool{

if path.lastComponent.contains("swift") {
return searchSame(link: DataHandleManager.defaltManager.swift_listNode!.head, value: value,className: className)
}
return searchSame(link: DataHandleManager.defaltManager.oc_listNode!.head, value: value,className:className)
}

// if there is no same value return true
func searchSame(link:linkNode?,value:Values,className:String) -> Bool{
guard let _link = link else {return true}
let judge = _link.values.contains{isSameValues($0, value2:value)}
if judge {
_link.values.forEach({ (v) in
if isSameValues(v, value2: value){
v.appendClassComent(className: className, comStr: v.comment)
}
})
return false
}
return searchSame(link: _link.next, value: value,className: className)
}

protocol RegexStringsWriter : StringsSearcher{
func writeToLocalizable (to path:Path)
Expand All @@ -103,7 +137,7 @@ extension RegexStringsWriter {
if let values = valuesOptial {
for value in values {
if !contentArr.contains(value.localizedString){
content += "\n\(value.comment)\n\(value.localizedString) = \(value.localizedString);\n"
content += "\n\(value.outPutStr)\n\(value.localizedString) = \(value.localizedString);\n"
}
}
}
Expand All @@ -117,7 +151,7 @@ extension RegexStringsWriter {
if let values = valuesOptial {
for value in values {
if !contentArr.contains(value.localizedString){
content += "\n\(value.comment)\n\(value.localizedString) = \(value.localizedString);\n"
content += "\n\(value.outPutStr)\n\(value.localizedString) = \(value.localizedString);\n"
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions Tests/CommandLineToolTests/CommandLineBehaviorSpectre.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ public func CommandLineToolSpectre() {
}
}

$0.describe("value test func "){
$0.it("'isSame' function"){

let value1 = Values.init(value: "1111", comment: "")
let value2 = Values.init(value: "11111", comment: "")

let judge1 = value1.localizedString == value2.localizedString
let judge2 = value1.comment == value2.comment
print(judge1&&judge2)
print(isSameValues(value1, value2:value2))
try expect(isSameValues(value1, value2:value2)).to.beFalse()

}
}


}
Expand Down

0 comments on commit ee4f772

Please sign in to comment.