Class: Properties
- Inherits:
-
Object
- Object
- Properties
- Defined in:
- lib/kody/properties.rb
Class Method Summary collapse
Class Method Details
.create(project_path, content) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/kody/properties.rb', line 31 def self.create(project_path, content) file_name = "#{project_path}/#{App.specification.name}.properties" outFile = File.new(file_name, "w+") content.each do |property, value| outFile.puts("#{property.gsub("_", ".")}=#{value}") end outFile.close end |
.load(project_path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kody/properties.rb', line 5 def self.load(project_path) properties_filename = "#{App.specification.name}.properties" properties_path = "#{project_path}/#{properties_filename}" raise "Arquivo de propriedades do projeto não existe (#{properties_filename})." unless File.exists? properties_path App.logger.info "Loading property file #{properties_filename}..." properties = {} File.open(properties_path, 'r') do |properties_file| properties_file.read.each_line do |line| line.strip! if (line[0] != ?# and line[0] != ?=) i = line.index('=') if (i) properties[line[0..i - 1].strip] = line[i + 1..-1].strip else properties[line] = '' end end end end properties end |