Module: DayOneKindle::DayOne

Defined in:
lib/dayone-kindle/day_one.rb

Defined Under Namespace

Classes: Entry

Class Method Summary collapse

Class Method Details

.journal_locationObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/dayone-kindle/day_one.rb', line 3

def self.journal_location
  @journal_location ||= begin
    prefs_file = File.join(ENV['HOME'], 'Library/Group Containers/5U8NS4GX82.dayoneapp/Data/Preferences/dayone.plist')
    raise 'DayOne preference file not found' unless File.exists?(prefs_file)

    prefs = File.read(prefs_file)
    match = prefs.match(/<key>JournalPackageURL<\/key>\n\t<string>([^<>]+)<\/string>/)
    raise 'DayOne journal not found' unless match && match[1]
    match[1]
  end
end