Module: Regexen
- Included in:
- Section
- Defined in:
- lib/galaxy/section.rb
Overview
Regexen module provides pattern Constants that are used by Sections to describe its data structure
Constant Summary collapse
- Name =
Defining basic regex patterns…
'([[:punct:]\w]+)'
- Sname =
' +?' + Name
- Fname =
first Name in line (may be preceded by spaces, or not)
'^ *?' + Name
- Num =
'(\d+(?:\.\d+)?)(?=\s)'
- Snum =
' +?' + Num
- Fnum =
'^ *?' + Num
- Int =
'(\d+)'
- Sint =
' +?' + Int
- Fint =
first int in line (may be preceded by spaces, or not)
'^ *?' + Int
- Line =
'([[:punct:]\w ]+)'
- Scargo =
' +?(COL|CAP|MAT|-)'
- Sstatus =
may need further refining for productivity
' +?(War|Peace|-|In_Battle|Out_Battle|In_Space|In_Orbit|Upgrade|Launched|Transfer_Status|Damaged|Wiped)'
- Group =
Different from actual Groups?! Have to check…
Sname + Snum * 4 + Scargo + Snum
- Header =
'\n\n\s*?([PIRVNDAWSCM#TQLOXY$EGF]\s+?)'
- Reports_header =
Defining section header/footer patterns
Name + ' Report for Galaxy PLUS' + Sname + ' Turn' + Sint + ' ' + Line + '$\s*' + Line
- Races_header =
+ ‘$$s*Size:’ + Snum + ‘s*Planets:’ + Snum + ‘s*Players:’+ Snum
'^\s*?Status of Players .+?' + Snum + ' votes\)' + Header
- Science_products_header =
'^\s*?' + Name + ' Sciences' + Header
- Ship_products_header =
'^\s*?' + Name + ' Ship Types' + Header
- Battle_planets_header =
'^\s*?Battle at \(#' + Int + '\) ' + Name
- Bombings_header =
'^\s*?Bombings' + Header
- Maps_header =
'^\s*Map around'
- Incoming_groups_header =
'^\s*?(Incoming) Groups' + Header
- Your_planets_header =
'^\s*?(Your) Planets' + Header
- Planets_header =
'^\s*?' + Name + ' Planets' + Header
- Production_planets_header =
'^\s*?Ships In Production' + Header
- Routes_header =
'^\s*?(Your) Routes' + Header
- Uninhabited_planets_header =
'^\s*?(Uninhabited) Planets' + Header
- Unidentified_planets_header =
'^\s*?(Unidentified) Planets' + Header
- Fleets_header =
'^\s*?(Your) Fleets' + Header
- Your_groups_header =
'^\s*?(Your) Groups' + Header
- Groups_header =
‘ Groups(?<!Your Groups)(?<!Unidentified Groups)s+?’ + Header
'^\s*?' + Name + ' Groups(?<!Your Groups)(?<!Unidentified Groups)\s+?'
- Battle_groups_header =
Groups_header
- Unidentified_groups_header =
'^\s*(Unidentified) Groups' + Header
'(\n\n)|(\z)'
- Races_record =
Defining data record patterns
Fname + Snum * 7 + Sstatus + Snum
- Science_products_record =
Fname + Snum * 4
- Ship_products_record =
Fname + Snum * 6
- Battle_planets_record =
Battles_line = ‘^’ + Line + ‘(fires on)’ + Line + ‘($)’
Battle_planets_header
- Battle_groups_record =
Fint + Group + Sint + Sstatus
- Bombings_record =
Fname + Sname + Sint + Sname + Snum * 2 + Sname + Snum * 4 + Sstatus
- Incoming_groups_record =
Fname + Sname + Snum * 3
- Unidentified_planets_record =
Fint + Snum * 2
- Uninhabited_planets_record =
Unidentified_planets_record + Sname + Snum * 4
- Planets_record =
Uninhabited_planets_record + Sname + Snum * 4
- Your_planets_record =
Planets_record
- Production_planets_record =
Fint + Sname * 2 + Snum * 3
- Routes_record =
Attention! routes_record captures column headers line
Fname + Sname * 4
- Fleets_record =
Fint + Sname + Sint + Sname * 2 + Snum * 2 + Sstatus
- Your_groups_record =
Fint + Sint + Group + Sname * 2 + Snum * 3 + Sname + Sstatus
- Groups_record =
Fint + Group + Sname + Snum * 2
- Unidentified_groups_record =
Fnum + Snum
- Default_header_proc =
Defining data processing Procs
lambda do |match, state| state[:race] = match[1] == 'Your' ? Race.lookup(state[:owner]) : Race.lookup(match[1]) if match[1] end