Class: EASYFPM::Mapping
- Inherits:
-
Object
- Object
- EASYFPM::Mapping
- Defined in:
- lib/easyfpm/mapping.rb
Constant Summary collapse
- @@regexpStruct =
Waited format:
#A comment src-dir => newdir src-file => newdir/new-file
New path can’t start with /
{}
Instance Attribute Summary collapse
-
#hashmap ⇒ Object
readonly
Returns the value of attribute hashmap.
Instance Method Summary collapse
-
#initialize(mappingfile) ⇒ Mapping
constructor
A new instance of Mapping.
Constructor Details
#initialize(mappingfile) ⇒ Mapping
Returns a new instance of Mapping.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/easyfpm/mapping.rb', line 30 def initialize(mappingfile) file = File.open(mappingfile, 'r') @hashmap={} while !file.eof? line = file.readline #We ignore the empty lines next if @@regexpStruct[:emptyline].match(line) #We ignore the comment lines next if @@regexpStruct[:commentline].match(line) linematch = @@regexpStruct[:mappingline].match(line) if linematch #We are on a mapping line #Verifying that new path don't start with / raise EASYFPM::InvalidConfiguration, "New path can't start with / mapping file #{mappingfile}:\n\t#{line}" if linematch[2][0] == "/" @hashmap[linematch[1]]=linematch[2] else raise EASYFPM::InvalidConfiguration, "The following line is not recognized in mapping file #{mappingfile}:\n\t#{line}" end end end |
Instance Attribute Details
#hashmap ⇒ Object (readonly)
Returns the value of attribute hashmap.
28 29 30 |
# File 'lib/easyfpm/mapping.rb', line 28 def hashmap @hashmap end |