Class: Rubyfocus::LocalFetcher
- Defined in:
- lib/rubyfocus/fetchers/local_fetcher.rb
Constant Summary collapse
- LOCATION =
This is where the files are usually stored
File.join(ENV["HOME"], "/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Application Support/OmniFocus/OmniFocus.ofocus")
Instance Method Summary collapse
-
#base ⇒ Object
Fetches the contents of the base file.
-
#base_id ⇒ Object
Fetches the ID Of the base file.
-
#encode_with(coder) ⇒ Object
Save to disk.
-
#init_with(coder) ⇒ Object
Init from yaml.
-
#location ⇒ Object
————————————— Location file setters and getters.
- #location=(l) ⇒ Object
-
#patch(file) ⇒ Object
Fetches the contents of a given patch file.
-
#patches ⇒ Object
Fetches a list of every patch file.
Methods inherited from Fetcher
#can_patch?, #next_patch, #reset, #update_full, #update_once
Instance Method Details
#base ⇒ Object
Fetches the contents of the base file
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 16 def base @base ||= begin zip_file = Dir[File.join(self.location,"*.zip")].first if zip_file Zip::File.open(zip_file){ |z| z.get_entry("contents.xml").get_input_stream.read } else raise RuntimeError, "Rubyfocs::LocalFetcher looking for zip files at #{self.location}: none found." end end end |
#base_id ⇒ Object
Fetches the ID Of the base file
28 29 30 31 32 33 34 35 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 28 def base_id base_file = File.basename(Dir[File.join(self.location,"*.zip")].first) if base_file =~ /^\d+\=.*\+(.*)\.zip$/ $1 else raise RuntimeError, "Malformed patch file #{base_file}." end end |
#encode_with(coder) ⇒ Object
Save to disk
53 54 55 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 53 def encode_with(coder) coder.map = {"location" => @location} end |
#init_with(coder) ⇒ Object
Init from yaml
9 10 11 12 13 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 9 def init_with(coder) if coder["location"] @location = coder["location"] end end |
#location ⇒ Object
Location file setters and getters
59 60 61 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 59 def location @location || LOCATION end |
#location=(l) ⇒ Object
63 64 65 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 63 def location= l @location = l end |
#patch(file) ⇒ Object
Fetches the contents of a given patch file
43 44 45 46 47 48 49 50 |
# File 'lib/rubyfocus/fetchers/local_fetcher.rb', line 43 def patch(file) filename = File.join(self.location, file) if File.exists?(filename) Zip::File.open(filename){ |z| z.get_entry("contents.xml").get_input_stream.read } else raise ArgumentError, "Trying to fetch patch #{file}, but file does not exist." end end |