Module: Idiom::ClassMethods

Included in:
Base
Defined in:
lib/idiom/base.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#find_and_translate_all(options = {}) ⇒ Object



153
154
155
156
157
158
159
160
# File 'lib/idiom/base.rb', line 153

def find_and_translate_all(options={})
  options.stringify_keys!
  
  source_files.each do |path|
    $stdout.puts "Processing #{path}"
    translate_file(path, options)
  end        
end

#source_filesObject



143
144
145
146
147
148
149
150
151
# File 'lib/idiom/base.rb', line 143

def source_files
  if @source =~ /\.(yml|pres)$/
    source_files = Dir[@source]
  else
    dir = File.expand_path(@source)
    source_files = Dir["#{dir}/**/*_en-US.pres"] + Dir["#{dir}/**/*_en-US.yml"]
    source_files.flatten
  end        
end

#translate(options = {}) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/idiom/base.rb', line 131

def translate(options={})
  options.stringify_keys!
  
  @source = options["source"]
  @destination = options["destination"]
  @use_dirs = options["use_dirs"]
  
  Timer.new.time do
    find_and_translate_all(options)
  end
end

#translate_file(path, options = {}) ⇒ Object



162
163
164
165
166
167
168
169
170
# File 'lib/idiom/base.rb', line 162

def translate_file(path, options={})
  options.stringify_keys!
  if path =~ /\.yml$/i
    Idiom::Yaml.new(options.merge({"source" => path})).generate
  end
  if path =~ /\.pres$/i
    Idiom::Yrb.new(options.merge({"source" => path})).generate
  end        
end