Skip to content

Commit

Permalink
Merge branch 'release/1.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktekinay committed Aug 27, 2015
2 parents a2ca3b1 + af47766 commit a4e93a3
Show file tree
Hide file tree
Showing 17 changed files with 365 additions and 95 deletions.
19 changes: 19 additions & 0 deletions Admin Classes/KajuFile.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Protected Class KajuFile

#tag Method, Flags = &h0
Sub ExportTo(fileOrFolder As FolderItem)
Validate()

dim data as JSONItem = DataToJSON
data.Compact = false
data.EscapeSlashes = false
Expand Down Expand Up @@ -148,6 +150,8 @@ Protected Class KajuFile

#tag Method, Flags = &h0
Sub SaveTo(f As FolderItem)
Validate()

dim master as JSONItem = ToJSON
master.Compact = false

Expand All @@ -171,6 +175,21 @@ Protected Class KajuFile
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub Validate()
//
// Make sure there are no duplicate versions
//
for i as integer = 0 to KajuData.Ubound
dim version as Kaju.UpdateInformation = KajuData( i )
if IndexOf( version.Version ) <> i then
raise new KajuException( "Duplicate version numbers", CurrentMethodName )
end if
next

End Sub
#tag EndMethod


#tag ComputedProperty, Flags = &h0
#tag Getter
Expand Down
6 changes: 3 additions & 3 deletions Kaju Admin App/Kaju Admin.xojo_project
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ Class=KajuFile;../Admin Classes/KajuFile.xojo_code;&h1A7FF7FF;&h0;false
AppMenuBar=MainMenuBar
MajorVersion=1
MinorVersion=6
SubVersion=0
SubVersion=1
NonRelease=0
Release=3
InfoVersion=Kaju Admin
LongVersion=v.1.6
ShortVersion=1.6
LongVersion=v.1.6.1
ShortVersion=1.6.1
WinCompanyName=MacTechnologies Consulting
WinInternalName=
WinProductName=
Expand Down
24 changes: 24 additions & 0 deletions Kaju Admin App/WndAdmin.xojo_window
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,10 @@ End
r = true
ContentsChanged = false

Exception err as KajuException
self.ContentsChanged= savedContentsChanged
ShowValidationError "Save failed!", err

Exception err as IOException
self.ContentsChanged = savedContentsChanged
MsgBox "Save failed!"
Expand Down Expand Up @@ -2685,6 +2689,18 @@ End
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub ShowValidationError(msg As String, err As RuntimeException)
dim mdlg as new MessageDialog
mdlg.Message = msg
mdlg.Explanation = err.Message
mdlg.CancelButton.Visible = false

call mdlg.ShowModalWithin self

End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub StoreFieldsToVersionRow()
if LastVersionRow = -1 or LastVersionRow >= lbVersions.ListCount then
Expand Down Expand Up @@ -3207,9 +3223,17 @@ End

MyKajuFile.ExportTo( f )

Exception err as KajuException
ShowValidationError "Could not export data.", err

Exception err As RuntimeException
if err isa EndException or err isa ThreadEndException then
raise err
end if

MsgBox "Could not export data."


End Sub
#tag EndEvent
#tag EndEvents
Expand Down
111 changes: 58 additions & 53 deletions Kaju Admin CLI/App.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Protected Class App
Inherits ConsoleApplication
#tag Event
Function Run(args() as String) As Integer
dim errCode as integer = kErrorNoError

RegisterSubApps

dim caller as string = args( 0 )
Expand All @@ -28,66 +30,69 @@ Inherits ConsoleApplication

if args.Ubound = 0 or parser.HelpRequested then
PrintMainHelp parser
return kErrorNoError
end if

//
// Adjust the args
//
for i as integer = 0 to appArgs.Ubound
args.Remove 0
next

//
// The first argument must be the subapp name
//
dim subappKey as string = args( 0 )
dim subapp as SubApplication = SubAppDictionary.Value( subappKey )

//
// Substitute the caller for the subapp name
//
args( 0 ) = caller

//
// Get the options
//
dim subappParser as new OptionParser( subappKey, "" )
subapp.AddOptions subappParser
subappParser.Parse args

if subappParser.HelpRequested then
PrintSubAppHelp( subappKey, subapp, subappParser )
return kErrorNoError
end if

//
// Get the admin file
//
dim adminFile as FolderItem = parser.FileValue( kOptionFile )
if adminFile is nil then
print "No admin file specified"
return kErrorGeneralError
end if

dim r as integer
try
r = subapp.Execute( adminFile, subappParser )
catch err as RuntimeException
if err isa EndException or err isa ThreadEndException then
raise err
end if

print "Unexpected error: " + err.Message
r = kErrorGeneralError
end try
else

//
// Adjust the args
//
for i as integer = 0 to appArgs.Ubound
args.Remove 0
next

//
// The first argument must be the subapp name
//
dim subappKey as string = args( 0 )
dim subapp as SubApplication = SubAppDictionary.Value( subappKey )

//
// Substitute the caller for the subapp name
//
args( 0 ) = caller

//
// Get the options
//
dim subappParser as new OptionParser( subappKey, "" )
subapp.AddOptions subappParser
subappParser.Parse args

if subappParser.HelpRequested then
PrintSubAppHelp( subappKey, subapp, subappParser )

else

//
// Get the admin file
//
dim adminFile as FolderItem = parser.FileValue( kOptionFile )
if adminFile is nil then
print "No admin file specified"
errCode = kErrorGeneralError

else
try
errCode = subapp.Execute( adminFile, subappParser )
catch err as RuntimeException
if err isa EndException or err isa ThreadEndException then
raise err
end if

print "Unexpected error: " + err.Message
errCode = kErrorGeneralError
end try
end if

end if
end if

#if DebugBuild and TargetRemoteDebugger then
print "Press return to continue..."
call input
#endif

return r
return errCode

End Function
#tag EndEvent
Expand Down
8 changes: 4 additions & 4 deletions Kaju Admin CLI/Kaju Admin CLI.xojo_project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Type=Console
RBProjectVersion=2015.023
RBProjectVersion=2015.024
MinIDEVersion=20070100
Class=App;App.xojo_code;&h31FD87FF;&h0;false
Module=FormatCodePreferences;FormatCodePreferences.xojo_code;&h2977F6F1;&h0;false
Expand Down Expand Up @@ -34,12 +34,12 @@ Class=OptionParserException;../Other Classes/OptionParser/OptionParserException.
Class=OptionUnrecognizedKeyException;../Other Classes/OptionParser/OptionUnrecognizedKeyException.xojo_code;&h12104F75;&h797A37FF;false
MajorVersion=1
MinorVersion=6
SubVersion=0
SubVersion=1
NonRelease=0
Release=3
InfoVersion=
LongVersion=v.1.6
ShortVersion=1.6
LongVersion=v.1.6.1
ShortVersion=1.6.1
WinCompanyName=MacTechnologies Consulting
WinInternalName=kaju
WinProductName=Kaju CLI
Expand Down
13 changes: 11 additions & 2 deletions Kaju Admin CLI/Sub Applications/AddVersionApp.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ Inherits VersionHandlerSubApplication
#pragma unused version
#pragma unused saveFile

dim appName as string = options.StringValue( kOptionAppName )
dim versionString as string = options.StringValue( kOptionVersion )
dim appName as string = options.StringValue( kOptionAppName ).Trim
if appName = "" then
print "App name must be specified"
return App.kErrorGeneralError
end if

dim versionString as string = options.StringValue( kOptionVersion ).Trim
if file.IndexOf( versionString ) <> -1 then
print "Version " + versionString + " already exists"
return App.kErrorGeneralError
end if

dim u as new Kaju.UpdateInformation
u.Version = versionString
Expand Down
9 changes: 9 additions & 0 deletions Kaju Admin CLI/Sub Applications/EditVersionApp.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ Inherits VersionHandlerSubApplication
end if

else // Just a key

//
// If the key is version, make sure it's not a duplicate
//
if key = "version" and value.Trim <> version.Version.Trim and file.IndexOf( value ) <> -1 then
print "Can't set Version to " + value + " since that version already exists"
return App.kErrorGeneralError
end if

try
version.SetByName( key ) = value
keyFound = true
Expand Down
56 changes: 55 additions & 1 deletion Kaju Admin CLI/Sub Applications/ListVersionsApp.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Inherits FileHandlerSubApplication
o.AddAllowedValue "cr", "lf", "crlf", "null"

parser.AddOption o

o = new Option( "", kOptionInclude, "Include versions matching this regex pattern (can use more than one)", Option.OptionType.String )
o.IsArray = true
parser.AddOption o

o = new Option( "", kOptionExclude, "Exclude versions matching this regex pattern (can use more than one)", Option.OptionType.String )
o.IsArray = true
parser.AddOption o
End Sub
#tag EndEvent

Expand All @@ -28,10 +36,50 @@ Inherits FileHandlerSubApplication
Function Run(file As KajuFile, adminFile As FolderItem, options As OptionParser) As Integer
#pragma unused adminFile

dim includeOption as Option = options.OptionValue( kOptionInclude )
dim excludeOption as Option = options.OptionValue( kOptionExclude )

dim emptyArray() as variant

dim includers() as variant = if( includeOption.Value.IsNull, emptyArray, options.OptionValue( kOptionInclude ).Value )
dim excluders() as variant = if( excludeOption.Value.IsNull, emptyArray, options.OptionValue( kOptionExclude ).Value )

dim rxInclude as RegEx
if includers.Ubound <> -1 then
dim patterns() as string
for each pattern as string in includers
patterns.Append pattern
next

rxInclude = new RegEx
rxInclude.SearchPattern = "(?:" + join( patterns, ") | (?:" ) + ")"
end if

dim rxExclude as RegEx
if excluders.Ubound <> -1 then
dim patterns() as string
for each pattern as string in excluders
patterns.Append pattern
next

rxExclude = new RegEx
rxExclude.SearchPattern = "(?:" + join( patterns, ") | (?:" ) + ")"
end if

dim versions() as string
for i as integer = 0 to file.KajuData.Ubound
dim data as Kaju.UpdateInformation = file.KajuData( i )
versions.Append data.Version
dim version as string = data.Version

select case true
case rxInclude isa RegEx and rxInclude.Search( version ) is nil
// Skip it
case rxExclude isa RegEx and rxExclude.Search( version ) isa RegExMatch
// Skip it

case else
versions.Append version
end select
next

dim eol as string = options.StringValue( kOptionEOL, "" )
Expand Down Expand Up @@ -63,6 +111,12 @@ Inherits FileHandlerSubApplication
#tag Constant, Name = kOptionEOL, Type = String, Dynamic = False, Default = \"eol", Scope = Private
#tag EndConstant

#tag Constant, Name = kOptionExclude, Type = String, Dynamic = False, Default = \"exclude", Scope = Private
#tag EndConstant

#tag Constant, Name = kOptionInclude, Type = String, Dynamic = False, Default = \"include", Scope = Private
#tag EndConstant


#tag ViewBehavior
#tag ViewProperty
Expand Down
2 changes: 1 addition & 1 deletion Kaju Classes/Kaju.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ Protected Module Kaju
#tag Constant, Name = kUpdatePacketMarker, Type = String, Dynamic = False, Default = \"KAJU ", Scope = Protected
#tag EndConstant

#tag Constant, Name = Version, Type = String, Dynamic = False, Default = \"1.6", Scope = Protected
#tag Constant, Name = Version, Type = String, Dynamic = False, Default = \"1.6.1", Scope = Protected
#tag EndConstant


Expand Down
Loading

0 comments on commit a4e93a3

Please sign in to comment.