Module: NetCache

Included in:
CalendarDays
Defined in:
lib/calendar_days/net_cache.rb

Instance Method Summary collapse

Instance Method Details

#create_repo_dirObject



33
34
35
36
37
# 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_repoObject



25
26
27
28
# 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_repoObject



52
53
54
55
56
57
58
# File 'lib/calendar_days/net_cache.rb', line 52

def prepare_repo
  unless repo_exist?
    prepare_repo!
  else
    nil
  end
end

#prepare_repo!Object



48
49
50
51
# File 'lib/calendar_days/net_cache.rb', line 48

def prepare_repo!
  create_repo_dir
  download_repo
end

#repo_dirObject



15
16
17
18
# 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?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/calendar_days/net_cache.rb', line 38

def repo_dir_exist?
  File.exist? repo_dir
end

#repo_exist?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/calendar_days/net_cache.rb', line 41

def repo_exist?
  File.exist? File.join(repo_dir, repo_file)
end

#repo_fileObject



19
20
21
# File 'lib/calendar_days/net_cache.rb', line 19

def repo_file
  "Japanese32Holidays.ics"
end

#repo_file_fullpathObject



22
23
24
# File 'lib/calendar_days/net_cache.rb', line 22

def repo_file_fullpath
  File.join(repo_dir, repo_file)
end

#repo_uriObject

Description

ユーザは, repo_uri,dir,file, およびdownload_repoを実装すればよい.



12
13
14
# File 'lib/calendar_days/net_cache.rb', line 12

def repo_uri
  'http://files.apple.com/calendars/Japanese32Holidays.ics'
end