Class: HmxClient::Command::Clone
Overview
Clone a partition or setup a partition from a clone
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#index ⇒ Object
clone.
-
#load ⇒ Object
clone:load.
Methods inherited from Base
#hmx, #initialize, #loadConfig!, namespace, #removeConfig, #storeConfig, #writeConfig
Methods included from Helpers
#display, #display_row, #display_tab, #display_table, #error, #getFromUser, #longest
Constructor Details
This class inherits a constructor from HmxClient::Command::Base
Instance Method Details
#index ⇒ Object
clone
Create a clone file for the current partition
13 14 15 16 17 18 19 20 21 |
# File 'lib/hmx/command/clone.rb', line 13 def index # Clone the type information # Clone these built in types (i.e. the content) # Clone other types as defined by the command line extraTypes = args types = [ 'sys.user', 'sys.config', 'sys.ent', 'sys.egroup', 'sys.trigger', 'sys.view' ] extraTypes.each { | et | types << et } types.each { | t | dumpTypeAndData(t) } end |
#load ⇒ Object
clone:load
Load a file that was created using hmx clone The file basically contains a series of types (documents separated by << >>) and data (separated by [[ ]])
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hmx/command/clone.rb', line 28 def load # We define the file as being the input file on the command line (--file-in) if (HmxClient::Command.fileIn.nil?) raise CommandFailed, "Usage: hmx clone:load --file-in=<filename>" end realFile = File.(HmxClient::Command.fileIn) File.open(realFile, 'r') { | f | currentDoc = '' isType = false while(line = f.gets) if (line[0] == '#') elsif (line[0] == '<' && line[1] == '<') currentDoc = '' isType = true elsif (line[0] == '>' && line[1] == '>') if isType print '.' hmx.doUpdateType([JSON.parse(currentDoc)]) end currentDoc = '' elsif (line[0] == '[' && line[1] == '[') currentDoc = '' isType = false elsif (line[0] == ']' && line[1] == ']') if (!isType) print 'x' hmx.doPutData([currentDoc]) end currentDoc = '' else currentDoc = currentDoc + line end end } puts "" puts "Done" end |