module Skk::Jisyo

Constants

JISYO_DIR
JISYO_URL
VERSION

Public Class Methods

path(suffix = "L") click to toggle source
# File lib/skk/jisyo.rb, line 23
def self.path(suffix = "L")
  "#{JISYO_DIR}/SKK-JISYO.#{suffix}"
end
paths() click to toggle source
# File lib/skk/jisyo.rb, line 27
def self.paths
  Settings.jisyo_list.map{|suffix| path(suffix) }
end
update(suffix = "L") click to toggle source
# File lib/skk/jisyo.rb, line 31
def self.update(suffix = "L")
  local_path = path(suffix)
  local_timestamp_path = "#{local_path}.timestamp"
  local_timestamp = File.read(local_timestamp_path) if File.exists?(local_timestamp_path)

  open(url(suffix)) do |remote_file|
    remote_timestamp = remote_file.last_modified.to_s
    if local_timestamp != remote_timestamp
      jisyo_data = remote_file.read
      File.open(local_path, "wb") do |local_file|
        local_file.write(jisyo_data)
      end
      File.write(local_timestamp_path, remote_timestamp)
      puts "#{path(suffix)}: #{jisyo_data.length} bytes (#{remote_timestamp})"
    else
      puts "#{path(suffix)} is not modified (#{remote_timestamp})"
    end
  end
end
update_all() click to toggle source
# File lib/skk/jisyo.rb, line 51
def self.update_all
  Settings.jisyo_list.each do |suffix|
    update(suffix)
  end
end
url(suffix = "L") click to toggle source
# File lib/skk/jisyo.rb, line 15
def self.url(suffix = "L")
  "#{JISYO_URL}/SKK-JISYO.#{suffix}"
end
urls() click to toggle source
# File lib/skk/jisyo.rb, line 19
def self.urls
  Settings.jisyo_list.map{|suffix| url(suffix) }
end