dayone_toolbox 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dayone_toolbox.rb +4 -0
- data/lib/dayone_toolbox/entry.rb +15 -5
- data/lib/dayone_toolbox/journal.rb +9 -4
- data/lib/dayone_toolbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 493c6091664b059b0fb53aef9971221880b28939
|
4
|
+
data.tar.gz: 92a01c368f6fc9ddf81c58ede4718b0e3a25a84d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 392919afbf8fb2b38d90719d5e8fd06a6cad7fdd0d4a6636baf829bff51be8b23affe04896ecf87f65657f0332d4c02e593c57ac96dfdb03120d60192f869d68
|
7
|
+
data.tar.gz: bbf664b0e1a388a7dc55e4ffa96754cd2db4a3f76b30cbc589174b4e12a16cd9675aed0b92a432fc5db75844929e2d3575481202c077b4bd804ae2a1162b76cc
|
data/lib/dayone_toolbox.rb
CHANGED
data/lib/dayone_toolbox/entry.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
|
2
|
-
require 'plist'
|
3
|
-
|
4
2
|
class DayoneToolbox::Entry
|
5
3
|
KEY_TAGS = 'Tags'
|
6
4
|
KEY_UUID = 'UUID'
|
@@ -28,10 +26,14 @@ class DayoneToolbox::Entry
|
|
28
26
|
end
|
29
27
|
|
30
28
|
|
31
|
-
attr_reader :file
|
29
|
+
attr_reader :file, :journal_dir
|
32
30
|
def initialize(file)
|
33
|
-
@file = file
|
34
|
-
@
|
31
|
+
@file = File.expand_path(file)
|
32
|
+
@journal_dir = nil
|
33
|
+
Pathname.new(file).ascend do |v|
|
34
|
+
@journal_dir = v.expand_path.to_s if v.basename.to_s.match('.dayone')
|
35
|
+
end
|
36
|
+
@hash = Plist.parse_xml(@file)
|
35
37
|
end
|
36
38
|
|
37
39
|
|
@@ -81,6 +83,14 @@ class DayoneToolbox::Entry
|
|
81
83
|
def weather=(attr) ; @hash[KEY_WEATHER] = attr ; end
|
82
84
|
def weather? ; @hash.has_key?(KEY_WEATHER) ; end
|
83
85
|
|
86
|
+
def photo
|
87
|
+
jpg = File.join("#{@journal_dir}", "photos/#{uuid}.jpg")
|
88
|
+
File.exist?(jpg) ? jpg.to_s : nil
|
89
|
+
end
|
90
|
+
|
91
|
+
def photo?
|
92
|
+
photo ? true : false
|
93
|
+
end
|
84
94
|
|
85
95
|
def custom_key(key)
|
86
96
|
@hash[key]
|
@@ -3,14 +3,19 @@ class DayoneToolbox::Journal
|
|
3
3
|
ENTRIES_DIR = 'entries/'
|
4
4
|
PHOTOS_DIR = 'photos/'
|
5
5
|
|
6
|
-
attr_reader :path, :entries_path, :photos_path
|
6
|
+
attr_reader :path, :expand_path, :entries_path, :photos_path
|
7
7
|
def initialize(dir_path)
|
8
8
|
@path = dir_path
|
9
|
-
@
|
10
|
-
@
|
9
|
+
@expand_path = File.expand_path(@path)
|
10
|
+
@entries_path = File.join(@expand_path, ENTRIES_DIR)
|
11
|
+
@photos_path = File.join(@expand_path, PHOTOS_DIR)
|
11
12
|
end
|
12
13
|
|
13
14
|
def entries
|
14
|
-
Dir.glob("#{@entries_path}**/*.doentry")
|
15
|
+
Dir.glob("#{@entries_path}**/*.doentry", File::FNM_CASEFOLD)
|
16
|
+
end
|
17
|
+
|
18
|
+
def photos
|
19
|
+
Dir.glob("#{@photos_path}**/*.jpg", File::FNM_CASEFOLD)
|
15
20
|
end
|
16
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dayone_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masato INOUE
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|