Sha256: 2d3758b355bccbcb4424d8df5533034e97489aa21365d223edb2468769090c87
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
module I18nFlow::Util extend self def extract_args(text) text.to_s .gsub(/%%/, '') .scan(/%\{([^\}]+)\}/) .flatten .sort end def filepath_to_scope(filepath) *scopes, filename = filepath.split('/') *basename, locale, _ = filename.split('.') ([locale] + scopes + basename).compact.reject(&:empty?) end def scope_to_filepath(scopes) locale, *components = scopes [components.join('/'), locale, 'yml'].compact.reject(&:empty?).join('.') end def find_file_upward(*file_names) pwd = Dir.pwd base = Hash.new { |h, k| h[k] = pwd } file = {} while base.values.all? { |b| '.' != b && '/' != b } file_names.each do |name| file[name] = File.join(base[name], name) base[name] = File.dirname(base[name]) return file[name] if File.exists?(file[name]) end end nil end def parse_options(args) options = {} args.reject! do |arg| case arg when /^-([a-z0-9])$/i, /^--([a-z0-9][a-z0-9-]*)$/i options[$1] = true when /^--([a-z0-9][a-z0-9-]*)=(.+)$/i options[$1] = $2 else break end end options end end
Version data entries
5 entries across 5 versions & 1 rubygems