Module: NetCache
- Included in:
- CalendarDays
- Defined in:
- lib/calendar_days/net_cache.rb
Instance Method Summary collapse
- #create_repo_dir ⇒ Object
- #download_repo ⇒ Object
- #prepare_repo ⇒ Object
- #prepare_repo! ⇒ Object
- #repo_dir ⇒ Object
- #repo_dir_exist? ⇒ Boolean
- #repo_exist? ⇒ Boolean
- #repo_file ⇒ Object
- #repo_file_fullpath ⇒ Object
-
#repo_uri ⇒ Object
Description ユーザは, repo_uri,dir,file, およびdownload_repoを実装すればよい.
Instance Method Details
#create_repo_dir ⇒ Object
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_repo ⇒ Object
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_repo ⇒ Object
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_dir ⇒ Object
15 16 17 18 |
# File 'lib/calendar_days/net_cache.rb', line 15 def repo_dir # "#{ENV['HOME']}/lib/ics" File.("~/lib/ics") end |
#repo_dir_exist? ⇒ 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
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_file ⇒ Object
19 20 21 |
# File 'lib/calendar_days/net_cache.rb', line 19 def repo_file "Japanese32Holidays.ics" end |
#repo_file_fullpath ⇒ Object
22 23 24 |
# File 'lib/calendar_days/net_cache.rb', line 22 def repo_file_fullpath File.join(repo_dir, repo_file) end |
#repo_uri ⇒ Object
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 |