Sha256: 395d03cb2f11097f6d1d90661bb00a815160227ef129cfce48b687847ad98b28
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module Analects CEDICT_URL = 'http://www.mdbg.net/chindict/export/cedict/cedict_1_0_ts_utf-8_mdbg.txt.gz' CHISE_IDS_URL = 'http://git.chise.org/git/chise/ids.git' UNIHAN_URL = '' HSK_URL = '' class Library attr_reader :options def initialize(options = {}) @options = options.freeze end def data_dir if options[:data_dir] Dir.mkdir(options[:data_dir]) unless File.exist?(options[:data_dir]) return options[:data_dir] end File.join(Dir.home, '.analects').tap do |dir| unless File.exist? dir Dir.mkdir dir end end end def cedict @cedict ||= Source.new( { data_file: 'cedict_1_0_ts_utf-8_mdbg.txt', retrieval: [ :http, :gunzip, :save ] }.merge(options_for :cedict) ) end def chise_ids @chise_ids ||= Source.new( { retrieval: :git }.merge(options_for :chise_ids) ) end def unihan @unihan ||= Source.new( { data_file: '' }.merge(options_for :chise_ids) ) end # def hsk # @hsk ||= Source.new( # ).merge(options_for :hsk) # end private def options_for(name) { name: name, url: Analects.const_get("#{name.to_s.upcase}_URL"), loader: Analects.const_get("#{Inflecto.camelize name}Loader"), data_dir: data_dir }.merge(options.fetch(name, {})) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
analects-0.2.1 | lib/analects/library.rb |
analects-0.2.0 | lib/analects/library.rb |