rb-dayone 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +16 -0
- data/Manifest +11 -17
- data/README.md +89 -37
- data/bin/dayone +30 -143
- data/lib/rb-dayone.rb +17 -12
- data/lib/rb-dayone/entry.rb +41 -11
- data/lib/rb-dayone/entry_importer.rb +51 -36
- data/lib/rb-dayone/location.rb +74 -0
- data/lib/rb-dayone/plist_reader.rb +1 -3
- data/lib/rb-dayone/search.rb +15 -7
- data/rb-dayone.gemspec +5 -17
- data/version.txt +1 -1
- metadata +20 -43
- data/History.rdoc +0 -76
- data/spec/data/entries/748AD5D252F44149920485B0CEA478E3.doentry +0 -14
- data/spec/data/entries/F13723CDFD454481B24312DCD627BFD7.doentry +0 -14
- data/spec/data/foo.doentry +0 -1
- data/spec/data/locations/location-auto/location +0 -1
- data/spec/data/locations/location-specified/location +0 -1
- data/spec/data/sample.doentry +0 -12
- data/spec/data/sample.plist +0 -0
- data/spec/data/utf.doentry +0 -12
- data/spec/dayone_spec.rb +0 -34
- data/spec/entry_importer_spec.rb +0 -69
- data/spec/entry_spec.rb +0 -57
- data/spec/plist_reader_spec.rb +0 -18
- data/spec/search_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -15
data/History.rdoc
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
== 0.4.1 / 2012-11-14
|
2
|
-
|
3
|
-
* [FIXED] rb-dayone was looking in the wrong place for preferences
|
4
|
-
* [FIXED] new preference files not json-parseable. Swapped to XML/Nokogiri
|
5
|
-
|
6
|
-
== 0.4.0 / 2012-10-22
|
7
|
-
|
8
|
-
* Added image support
|
9
|
-
|
10
|
-
== 0.3.3 / 2012-08-17
|
11
|
-
|
12
|
-
* [FIXED] LibXML will now accept UTF-8 characters in journal entries.
|
13
|
-
* Added the command "repair" to the dayone binary, which will at least repair *my* damage.
|
14
|
-
* Added the command "verify" to the dayone binary, which I at least find helpful.
|
15
|
-
* Added a post-install note telling people upgrading from <= 0.2.0 to repair.
|
16
|
-
|
17
|
-
== 0.3.2 / 2012-08-16
|
18
|
-
|
19
|
-
* Switched from REXML to LibXML-ruby for XML parsing. Now accepts ampersands in entries, as well as UTF-8. Rejoice!
|
20
|
-
|
21
|
-
== 0.3.1 / 2012-08-16
|
22
|
-
|
23
|
-
* [FIXED] Minor bugfixes
|
24
|
-
* [FIXED] REXML will no longer kill the whole program if it can't parse a journal file.
|
25
|
-
|
26
|
-
== 0.3.0 / 2012-08-16
|
27
|
-
|
28
|
-
* [FIXED] Fixed several bugs in Builder xml output, including:
|
29
|
-
* Output of trailing <target />
|
30
|
-
* Output of malformed DOCTYPE
|
31
|
-
* You can now import existing DayOne entries and search them
|
32
|
-
|
33
|
-
== 0.2.0 / 2012-08-14
|
34
|
-
|
35
|
-
* Now auto-detects DayOne journal location from your plist file
|
36
|
-
|
37
|
-
== 0.1.7 / 2012-08-13
|
38
|
-
|
39
|
-
* The dayone binary can now add entries to your journal
|
40
|
-
* [FIXED] Managed to break the gem's include in 0.1.6, and because I'm a terrible amateur at all this, didn't pick up on it.
|
41
|
-
|
42
|
-
== 0.1.6 / 2012-08-13
|
43
|
-
|
44
|
-
* Updated documentation so YARD would generate nice rdocs
|
45
|
-
* dayone binary now uses the Commander gem
|
46
|
-
* Now using a Manifest file rather than globbing in whole directories
|
47
|
-
|
48
|
-
== 0.1.5 / 2012-08-12
|
49
|
-
|
50
|
-
* [FIXED] Ouch, horrid horrid gemspec and readme. Let's make them prettier.
|
51
|
-
|
52
|
-
== 0.1.4 / 2012-08-12
|
53
|
-
|
54
|
-
* Added a couple more tests for better coverage
|
55
|
-
|
56
|
-
== 0.1.3 / 2012-08-12
|
57
|
-
|
58
|
-
* Removed the SimpleXML class, now using the Builder gem
|
59
|
-
|
60
|
-
== 0.1.2 / 2012-08-12
|
61
|
-
|
62
|
-
* [FIXED] Actual testing on my own system
|
63
|
-
|
64
|
-
== 0.1.1 / 2012-08-07
|
65
|
-
|
66
|
-
* [FIXED] DayOne constants are now `attr_accessors` - set them yourself if you wish!
|
67
|
-
|
68
|
-
== 0.1.0 / 2012-08-06
|
69
|
-
|
70
|
-
* Added binary
|
71
|
-
* Support for DayOne locations
|
72
|
-
* Uploaded to github!
|
73
|
-
|
74
|
-
== 0.0.1 / 2012-08-05
|
75
|
-
|
76
|
-
* Started development
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>Creation Date</key>
|
6
|
-
<date>2012-08-16T08:42:17Z</date>
|
7
|
-
<key>Entry Text</key>
|
8
|
-
<string>Yes, this is foo.</string>
|
9
|
-
<key>Starred</key>
|
10
|
-
<false/>
|
11
|
-
<key>UUID</key>
|
12
|
-
<string>748AD5D252F44149920485B0CEA478E3</string>
|
13
|
-
</dict>
|
14
|
-
</plist>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>Creation Date</key>
|
6
|
-
<date>2012-08-16T08:42:19Z</date>
|
7
|
-
<key>Entry Text</key>
|
8
|
-
<string>Hello bar.</string>
|
9
|
-
<key>Starred</key>
|
10
|
-
<true/>
|
11
|
-
<key>UUID</key>
|
12
|
-
<string>F13723CDFD454481B24312DCD627BFD7</string>
|
13
|
-
</dict>
|
14
|
-
</plist>
|
data/spec/data/foo.doentry
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
foo
|
@@ -1 +0,0 @@
|
|
1
|
-
auto
|
@@ -1 +0,0 @@
|
|
1
|
-
sample location
|
data/spec/data/sample.doentry
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>Entry Text</key>
|
6
|
-
<string>Hello, world!</string>
|
7
|
-
<key>Starred</key>
|
8
|
-
<true/>
|
9
|
-
<key>Creation Date</key>
|
10
|
-
<date>1997-08-29T02:14:0Z</date>
|
11
|
-
</dict>
|
12
|
-
</plist>
|
data/spec/data/sample.plist
DELETED
Binary file
|
data/spec/data/utf.doentry
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>Entry Text</key>
|
6
|
-
<string>æ</string>
|
7
|
-
<key>Starred</key>
|
8
|
-
<true/>
|
9
|
-
<key>Creation Date</key>
|
10
|
-
<date>1997-08-29T02:14:0Z</date>
|
11
|
-
</dict>
|
12
|
-
</plist>
|
data/spec/dayone_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
describe DayOne do
|
4
|
-
describe "#journal_location" do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
DayOne::journal_location = nil
|
8
|
-
DayOne::instance_variable_set('@journal_file',nil)
|
9
|
-
end
|
10
|
-
|
11
|
-
def location str
|
12
|
-
spec_data("locations", "location-#{str}")
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should return the value given by the +location+ file" do
|
16
|
-
DayOne::dayone_folder = location('specified')
|
17
|
-
DayOne::journal_location.should == 'sample location'
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return a default value when +location+ is 'auto'" do
|
21
|
-
reader = double('ReaderMock')
|
22
|
-
reader.should_receive(:journal_location).and_return('foo')
|
23
|
-
DayOne.plist_reader = reader
|
24
|
-
DayOne::dayone_folder = location('auto')
|
25
|
-
DayOne::journal_location.should == File.expand_path('foo')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should return a default value if +location+ doesn't exist" do
|
29
|
-
DayOne.plist_reader = {'NSNavLastRootDirectory' => 'foo'}
|
30
|
-
DayOne::dayone_folder = location('unspecified')
|
31
|
-
DayOne::journal_location.should == File.expand_path('foo')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/spec/entry_importer_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
#encoding: UTF-8
|
2
|
-
|
3
|
-
require './spec/spec_helper'
|
4
|
-
|
5
|
-
describe DayOne::EntryImporter do
|
6
|
-
let(:sample_entry){ DayOne::EntryImporter::from_file spec_data('sample.doentry') }
|
7
|
-
|
8
|
-
describe "#initialize" do
|
9
|
-
it "should accept a string or file" do
|
10
|
-
ei = DayOne::EntryImporter.new('foo')
|
11
|
-
ei.data.should == 'foo'
|
12
|
-
|
13
|
-
file_ei = DayOne::EntryImporter::from_file spec_data('foo.doentry')
|
14
|
-
file_ei.data.should == 'foo'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#[]" do
|
19
|
-
|
20
|
-
def wrap str
|
21
|
-
<<-end
|
22
|
-
<plist>
|
23
|
-
<dict>
|
24
|
-
<key>element</key>
|
25
|
-
<string>#{str}</string>
|
26
|
-
</dict>
|
27
|
-
</plist>
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should parse strings" do
|
32
|
-
sample_entry['Entry Text'].should == 'Hello, world!'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should parse booleans" do
|
36
|
-
sample_entry['Starred'].should == true
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should parse dates" do
|
40
|
-
sample_entry['Creation Date'].should == Time.new(1997, 8, 29, 2, 14, 0)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should accept ampersands" do
|
44
|
-
importer = DayOne::EntryImporter.new(wrap('&'))
|
45
|
-
importer['element'].should == '&'
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should accept UTF-8" do
|
49
|
-
importer = DayOne::EntryImporter.new(wrap('æ'))
|
50
|
-
importer['element'].should == 'æ'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should accept UTF-8 from file" do
|
54
|
-
importer = DayOne::EntryImporter.from_file spec_data('utf.doentry')
|
55
|
-
importer['Entry Text'].should == 'æ'
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#to_entry" do
|
61
|
-
it "should make a valid entry" do
|
62
|
-
entry = sample_entry.to_entry
|
63
|
-
entry.entry_text.should == 'Hello, world!'
|
64
|
-
entry.starred.should be_true
|
65
|
-
entry.creation_date.year.should == 1997
|
66
|
-
entry.should be_saved
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/spec/entry_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
describe DayOne::Entry do
|
5
|
-
before :each do
|
6
|
-
setup_working
|
7
|
-
end
|
8
|
-
|
9
|
-
after :each do
|
10
|
-
clean_working
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#to_xml" do
|
14
|
-
|
15
|
-
let(:sample_entry){ DayOne::Entry.new('foo', starred:true) }
|
16
|
-
|
17
|
-
it "should give a default entry" do
|
18
|
-
e = subject.to_xml
|
19
|
-
e.should match %r|<key>Entry Text</key>\s*<string></string>|
|
20
|
-
e.should match %r|<key>Starred</key>\s*<false/>|
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should set from initialize" do
|
24
|
-
sample_entry.starred.should be_true
|
25
|
-
sample_entry.entry_text.should == 'foo'
|
26
|
-
sample_entry.should_not be_saved
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should act properly when starred" do
|
30
|
-
sample_entry.to_xml.should match %r|<key>Starred</key>\s*<true/>|
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#create!" do
|
35
|
-
it "should correctly create a .doentry file" do
|
36
|
-
|
37
|
-
|
38
|
-
e = subject
|
39
|
-
e.entry_text = "Hello, world!"
|
40
|
-
e.create!
|
41
|
-
|
42
|
-
file_location = Dir[spec_data('working', 'entries', '*.doentry')][0]
|
43
|
-
file_location.should_not be_nil
|
44
|
-
|
45
|
-
contents = File.read(file_location)
|
46
|
-
contents.should == e.to_xml
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#xml_valid?" do
|
51
|
-
it "should handle weird XML characters" do
|
52
|
-
e = subject
|
53
|
-
e.entry_text = "Hello <&> Goodbye"
|
54
|
-
e.should be_xml_valid
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/spec/plist_reader_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
describe DayOne::PlistReader do
|
4
|
-
describe "#initialize" do
|
5
|
-
it "should default to the normal preference file" do
|
6
|
-
File.should exist(subject.path)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#body" do
|
11
|
-
it "should correctly parse binary plists" do
|
12
|
-
reader = DayOne::PlistReader.new(File.join(File.dirname(__FILE__),'data', 'sample.plist'))
|
13
|
-
|
14
|
-
reader.key('foo').should == 'bar'
|
15
|
-
expect(reader.key('bing')).to be_nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/search_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
describe DayOne::Search do
|
2
|
-
describe "#initialize" do
|
3
|
-
it "should create a Search object, uninitialized" do
|
4
|
-
subject.entry_text.should == ''
|
5
|
-
subject.starred.should be_nil
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#results" do
|
10
|
-
before :all do
|
11
|
-
DayOne::journal_location = spec_data
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should find all posts when no search criteria are applied" do
|
15
|
-
subject.results.size.should == 2
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should find posts when searching by string" do
|
19
|
-
search = DayOne::Search.new entry_text: 'foo'
|
20
|
-
search.results.size.should == 1
|
21
|
-
search[0].entry_text.should == "Yes, this is foo."
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should find posts when searching by starred" do
|
25
|
-
search = DayOne::Search.new starred:true
|
26
|
-
search.results.size.should == 1
|
27
|
-
search[0].entry_text.should == "Hello bar."
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should find posts when searching by string and starred" do
|
31
|
-
search = DayOne::Search.new entry_text: 'foo', starred:true
|
32
|
-
search.results.should be_empty
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require './lib/rb-dayone'
|
2
|
-
|
3
|
-
def spec_data *path
|
4
|
-
File.join(File.dirname(__FILE__), 'data', *path)
|
5
|
-
end
|
6
|
-
|
7
|
-
def setup_working
|
8
|
-
FileUtils::mkdir_p spec_data('working/entries')
|
9
|
-
FileUtils::mkdir_p spec_data('working/photos')
|
10
|
-
DayOne::journal_location = spec_data('working')
|
11
|
-
end
|
12
|
-
|
13
|
-
def clean_working
|
14
|
-
FileUtils::rm_rf spec_data('working')
|
15
|
-
end
|