module NetCache

Public Instance Methods

create_repo_dir() click to toggle source
# File lib/calendar_days/net_cache.rb, line 33
def create_repo_dir
  unless repo_dir_exist?
    FileUtils.mkdir_p repo_dir
  end
end
download_repo() click to toggle source
# File lib/calendar_days/net_cache.rb, line 25
def download_repo
  ret = `curl -L '#{repo_uri}' -o '#{repo_file_fullpath}'; echo $?`.chomp.to_i
  ret
end
prepare_repo() click to toggle source
# File lib/calendar_days/net_cache.rb, line 52
def prepare_repo
  unless repo_exist?
    prepare_repo!
  else
    nil
  end
end
prepare_repo!() click to toggle source
# File lib/calendar_days/net_cache.rb, line 48
def prepare_repo!
  create_repo_dir
  download_repo
end
repo_dir() click to toggle source
# File lib/calendar_days/net_cache.rb, line 15
def repo_dir
  # "#{ENV['HOME']}/lib/ics"
  File.expand_path("~/lib/ics")
end
repo_dir_exist?() click to toggle source
# File lib/calendar_days/net_cache.rb, line 38
def repo_dir_exist?
  File.exist? repo_dir
end
repo_exist?() click to toggle source
# File lib/calendar_days/net_cache.rb, line 41
def repo_exist?
  File.exist? File.join(repo_dir, repo_file)
end
repo_file() click to toggle source
# File lib/calendar_days/net_cache.rb, line 19
def repo_file
  "Japanese32Holidays.ics"
end
repo_file_fullpath() click to toggle source
# File lib/calendar_days/net_cache.rb, line 22
def repo_file_fullpath
  File.join(repo_dir, repo_file)
end
repo_uri() click to toggle source

Description

ユーザは, repo_{uri,dir,file}, およびdownload_repoを実装すればよい.

# File lib/calendar_days/net_cache.rb, line 12
def repo_uri
  'http://files.apple.com/calendars/Japanese32Holidays.ics'
end