Sha256: 55848022ae1c381e82a8dda6469aad1d1d87c7cba3d46449ce9182798e26bd1d
Contents?: true
Size: 650 Bytes
Versions: 1
Compression:
Stored size: 650 Bytes
Contents
class RubyReadsPHP attr_accessor :constants def initialize self.constants = {} end def self.read(file_name) rrp = self.new rrp.parse(file_name) end def parse(file_name) file_name << '.php' unless file_name.match(/.php/) file = File.new(file_name, "r") data = parse_file(file) self end def parse_file(file) constant_regex = /define\((\s)*('|")((\w|\s)+)('|")(\s)*,(\s)*('|")?((\w|\s)*)('|")(\s)*\);/ while (line = file.gets) if line.match(constant_regex) contant_key = line[constant_regex, 3] constant_value = line[constant_regex, 9] constants[contant_key] = constant_value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mattfawcett-ruby-reads-php-1.0.0 | lib/ruby_reads_php.rb |