Module: Idiom::ClassMethods
- Included in:
- Base
- Defined in:
- lib/idiom/base.rb
Overview
:nodoc:
Instance Method Summary collapse
- #find_and_translate_all(options = {}) ⇒ Object
- #source_files ⇒ Object
- #translate(options = {}) ⇒ Object
- #translate_file(path, options = {}) ⇒ Object
Instance Method Details
#find_and_translate_all(options = {}) ⇒ Object
155 156 157 158 159 160 161 162 |
# File 'lib/idiom/base.rb', line 155 def find_and_translate_all(={}) .stringify_keys! source_files.each do |path| $stdout.puts "Processing #{path}" translate_file(path, ) end end |
#source_files ⇒ Object
145 146 147 148 149 150 151 152 153 |
# File 'lib/idiom/base.rb', line 145 def source_files if @source =~ /\.(yml|pres)$/ source_files = Dir[@source] else dir = File.(@source) source_files = Dir["#{dir}/**/*_en-US.pres"] + Dir["#{dir}/**/*_en-US.yml"] source_files.flatten end end |
#translate(options = {}) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/idiom/base.rb', line 133 def translate(={}) .stringify_keys! @source = ["source"] @destination = ["destination"] @use_dirs = ["use_dirs"] Timer.new.time do find_and_translate_all() end end |
#translate_file(path, options = {}) ⇒ Object
164 165 166 167 168 169 170 171 172 |
# File 'lib/idiom/base.rb', line 164 def translate_file(path, ={}) .stringify_keys! if path =~ /\.yml$/i Idiom::Yaml.new(.merge({"source" => path})).generate end if path =~ /\.pres$/i Idiom::Yrb.new(.merge({"source" => path})).generate end end |