Class: CommandTask
- Inherits:
-
Object
- Object
- CommandTask
- Defined in:
- lib/ModelGenerator/CommandTask.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#entity_name ⇒ Object
readonly
Returns the value of attribute entity_name.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#is_force_reset ⇒ Object
readonly
Returns the value of attribute is_force_reset.
-
#isreverse ⇒ Object
readonly
Returns the value of attribute isreverse.
-
#json_name_format_hash ⇒ Object
readonly
Returns the value of attribute json_name_format_hash.
-
#json_name_type_hash ⇒ Object
readonly
Returns the value of attribute json_name_type_hash.
-
#parent_class ⇒ Object
readonly
Returns the value of attribute parent_class.
-
#primary_key ⇒ Object
readonly
Returns the value of attribute primary_key.
-
#property_em_name_type_hash ⇒ Object
readonly
Returns the value of attribute property_em_name_type_hash.
-
#property_name_db_hash ⇒ Object
readonly
Returns the value of attribute property_name_db_hash.
-
#property_name_format_hash ⇒ Object
readonly
Returns the value of attribute property_name_format_hash.
-
#property_name_json_hash ⇒ Object
readonly
Returns the value of attribute property_name_json_hash.
-
#property_name_type_hash ⇒ Object
readonly
Returns the value of attribute property_name_type_hash.
Instance Method Summary collapse
- #cacheCommand ⇒ Object
-
#initialize(args) ⇒ CommandTask
constructor
A new instance of CommandTask.
- #parseCommand ⇒ Object
Constructor Details
#initialize(args) ⇒ CommandTask
Returns a new instance of CommandTask.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ModelGenerator/CommandTask.rb', line 19 def initialize(args) @command = args @isreverse = false @is_force_reset =false @property_name_type_hash = Hash.new @property_em_name_type_hash = Hash.new @property_name_format_hash = Hash.new @property_name_json_hash = Hash.new @json_name_type_hash = Hash.new @json_name_format_hash = Hash.new @property_name_db_hash = Hash.new @flags = Array.new end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
12 13 14 |
# File 'lib/ModelGenerator/CommandTask.rb', line 12 def command @command end |
#entity_name ⇒ Object (readonly)
Returns the value of attribute entity_name.
15 16 17 |
# File 'lib/ModelGenerator/CommandTask.rb', line 15 def entity_name @entity_name end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
11 12 13 |
# File 'lib/ModelGenerator/CommandTask.rb', line 11 def flags @flags end |
#is_force_reset ⇒ Object (readonly)
Returns the value of attribute is_force_reset.
14 15 16 |
# File 'lib/ModelGenerator/CommandTask.rb', line 14 def is_force_reset @is_force_reset end |
#isreverse ⇒ Object (readonly)
Returns the value of attribute isreverse.
13 14 15 |
# File 'lib/ModelGenerator/CommandTask.rb', line 13 def isreverse @isreverse end |
#json_name_format_hash ⇒ Object (readonly)
Returns the value of attribute json_name_format_hash.
9 10 11 |
# File 'lib/ModelGenerator/CommandTask.rb', line 9 def json_name_format_hash @json_name_format_hash end |
#json_name_type_hash ⇒ Object (readonly)
Returns the value of attribute json_name_type_hash.
8 9 10 |
# File 'lib/ModelGenerator/CommandTask.rb', line 8 def json_name_type_hash @json_name_type_hash end |
#parent_class ⇒ Object (readonly)
Returns the value of attribute parent_class.
17 18 19 |
# File 'lib/ModelGenerator/CommandTask.rb', line 17 def parent_class @parent_class end |
#primary_key ⇒ Object (readonly)
Returns the value of attribute primary_key.
16 17 18 |
# File 'lib/ModelGenerator/CommandTask.rb', line 16 def primary_key @primary_key end |
#property_em_name_type_hash ⇒ Object (readonly)
Returns the value of attribute property_em_name_type_hash.
5 6 7 |
# File 'lib/ModelGenerator/CommandTask.rb', line 5 def property_em_name_type_hash @property_em_name_type_hash end |
#property_name_db_hash ⇒ Object (readonly)
Returns the value of attribute property_name_db_hash.
10 11 12 |
# File 'lib/ModelGenerator/CommandTask.rb', line 10 def property_name_db_hash @property_name_db_hash end |
#property_name_format_hash ⇒ Object (readonly)
Returns the value of attribute property_name_format_hash.
6 7 8 |
# File 'lib/ModelGenerator/CommandTask.rb', line 6 def property_name_format_hash @property_name_format_hash end |
#property_name_json_hash ⇒ Object (readonly)
Returns the value of attribute property_name_json_hash.
7 8 9 |
# File 'lib/ModelGenerator/CommandTask.rb', line 7 def property_name_json_hash @property_name_json_hash end |
#property_name_type_hash ⇒ Object (readonly)
Returns the value of attribute property_name_type_hash.
4 5 6 |
# File 'lib/ModelGenerator/CommandTask.rb', line 4 def property_name_type_hash @property_name_type_hash end |
Instance Method Details
#cacheCommand ⇒ Object
180 181 182 183 184 185 186 187 |
# File 'lib/ModelGenerator/CommandTask.rb', line 180 def cacheCommand command_content=@command.join " " pwdPath=Dir.pwd file=File.new("#{pwdPath}/command","a") file << "ptgen " +command_content +"\n" file.chmod(0777) file.close end |
#parseCommand ⇒ Object
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/ModelGenerator/CommandTask.rb', line 34 def parseCommand property_begin =false json_begin =false db_begin =false if @command[0].include?(":") class_info=@command[0].delete(" ") entity_info_array=class_info.split(":") @entity_name=entity_info_array[0].capitalize+"Entity" @parent_class=entity_info_array[1].capitalize+"Entity" else @entity_name=@command[0].capitalize+"Entity" end property_name_array= Array.new json_name_array= Array.new db_name_array= Array.new @command.each do |param| if param[0] == "-" flag=param[1] case flag when "r" @flags << flag @isreverse = true property_begin= false json_begin = false db_begin = false when "l" @flags << flag property_begin = true json_begin = false db_begin =false when "s" @flags << flag json_begin = true property_begin = false db_begin = false when "d" @flags << flag db_begin = true json_begin = false property_begin = false when "n" @flags << flag property_begin= false json_begin = false db_begin = false when "f" @flags << flag @is_force_reset=true db_begin = false json_begin = false property_begin = false when "h" @flags << flag @is_force_reset=false db_begin = false json_begin = false property_begin = false when "a" param.each_char do |chr| if chr == 'l' @flags << chr property_begin = true elsif chr == 's' @flags << chr json_begin = true elsif chr == 'd' @flags << chr db_begin = true end end end else if property_begin == true property_info= param.split(":") name = "" type = "" type_name = "" format = "" if property_info.length >=1 then name=property_info[0].delete("*") end name = "entityId" if name == 'id' if property_info.length >=2 type=property_info[1] if type.include?("enum") type_info_array=type.split(".") type=type_info_array[0] type_name=type_info_array[1] end end if property_info.length >=3 then format=property_info[2] end @property_name_type_hash[name] = type if type_name.length >0 @property_em_name_type_hash[name] = type_name end @property_name_format_hash[name] = format property_name_array << name end if json_begin == true json_info= param.split(":") name = "" type = "" format = "" if json_info.length >=1 then name=json_info[0].delete("*") end if json_info.length >=2 then type=json_info[1] end if json_info.length >=3 then format=json_info[2] end @json_name_type_hash[name] = type @json_name_format_hash[name] = format json_name_array << name end if db_begin == true name = param.split(":") db_name_array << name[0] end end end index =0 property_name_array.each do |name| if index >= json_name_array.length @property_name_json_hash[name] = nil else @property_name_json_hash[name] = json_name_array[index] end if index >= db_name_array.length @property_name_db_hash[name] = nil else db_name= db_name_array[index] if db_name && db_name.length >=1 if db_name[0]=="*" @primary_key=name db_name = db_name.delete("*") end end @property_name_db_hash[name] = db_name end index+=1 end end |