Sha256: 4f4865de48dd48b8e22a7fbf40ebcbebca30ea544bd0bf23d01e397f6d56fef2

Contents?: true

Size: 707 Bytes

Versions: 9

Compression:

Stored size: 707 Bytes

Contents

require 'inline'

module Merb
  module Global
    module DateProviders
      class Fork
        include Merb::Global::DateProviders::Base

        def localize(lang, date, format)
          pipe_rd, pipe_wr = IO.pipe
          pid = fork do
            pipe_rd.close
            setlocale(lang.to_s)
            pipe_wr.write(date.strftime(format))
            pipe_wr.flush
          end
          pipe_wr.close
          Process.wait(pid)
          pipe_rd.read
        end

        inline do |builder|
          builder.include '<locale.h>'
          builder.c <<C
void set_locale(const char *locale)
{
  setlocale(LC_ALL, locale);
}
C
        end
        private :set_locale
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
lastobelus-merb_global-0.0.10 lib/merb_global/date_providers/fork.rb
lastobelus-merb_global-0.0.11 lib/merb_global/date_providers/fork.rb
lastobelus-merb_global-0.0.12 lib/merb_global/date_providers/fork.rb
lastobelus-merb_global-0.0.13 lib/merb_global/date_providers/fork.rb
lastobelus-merb_global-0.0.14 lib/merb_global/date_providers/fork.rb
lastobelus-merb_global-0.0.8 lib/merb_global/date_providers/fork.rb
lastobelus-merb_global-0.0.9 lib/merb_global/date_providers/fork.rb
merb_global-0.0.6 lib/merb_global/date_providers/fork.rb
merb_global-0.0.7 lib/merb_global/date_providers/fork.rb