friends 0.48 → 0.49
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/CHANGELOG.md +14 -0
- data/lib/friends/commands/edit.rb +1 -1
- data/lib/friends/friend.rb +16 -7
- data/lib/friends/version.rb +1 -1
- data/test/add_event_helper.rb +54 -0
- data/test/commands/edit_spec.rb +31 -0
- data/test/helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 723092682f9f7d7c5cbd9079a5aaa4e2e413a4ea9ea4a60ef871abf9d8a8b391
|
|
4
|
+
data.tar.gz: e7f570b41f8c3e74dd19b4e540a804f4a585541a59efa29125e1f3c3000de213
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60573538a3ac488669c1f2eddff260823aafdd488f2972cd29f9081c06e37aa98d3afbbdb45c650fdb369e392e9cfb98e7a3b29a4ed5dbc09eb2cfeed7aa37d4
|
|
7
|
+
data.tar.gz: 4f8e7159b3c99406d74c8cc4ba48cbfc9fd82114db29ab93c9bc855d9016bdd6c9bb570cf776083660b573660f110e6991600a17225f9c5f0fcd3af118f48d0a
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
making a small donation (🙏) with the **Sponsor** button at the top of this page to
|
|
5
5
|
show you appreciate its continued development.
|
|
6
6
|
|
|
7
|
+
## [v0.49](https://github.com/JacobEvelyn/friends/tree/v0.49) (2020-04-02)
|
|
8
|
+
|
|
9
|
+
[Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.48...v0.49)
|
|
10
|
+
|
|
11
|
+
**Fixed bugs:**
|
|
12
|
+
|
|
13
|
+
- Multi-word editors no longer work with `friends edit` [\#251](https://github.com/JacobEvelyn/friends/issues/251)
|
|
14
|
+
- Punctuation swallowed after friend name with last initial [\#235](https://github.com/JacobEvelyn/friends/issues/235)
|
|
15
|
+
|
|
16
|
+
**Merged pull requests:**
|
|
17
|
+
|
|
18
|
+
- Improve name matching to not swallow punctuation [\#253](https://github.com/JacobEvelyn/friends/pull/253) ([JacobEvelyn](https://github.com/JacobEvelyn))
|
|
19
|
+
- Fix `friends edit` for multi-word EDITORs [\#252](https://github.com/JacobEvelyn/friends/pull/252) ([JacobEvelyn](https://github.com/JacobEvelyn))
|
|
20
|
+
|
|
7
21
|
## [v0.48](https://github.com/JacobEvelyn/friends/tree/v0.48) (2020-03-27)
|
|
8
22
|
|
|
9
23
|
[Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.47...v0.48)
|
|
@@ -9,7 +9,7 @@ command :edit do |edit|
|
|
|
9
9
|
puts "Opening \"#{filename}\" with \"#{editor}\"" unless global_options[:quiet]
|
|
10
10
|
|
|
11
11
|
# Mark the file for cleaning once the editor was closed correctly.
|
|
12
|
-
if Kernel.system(editor
|
|
12
|
+
if Kernel.system("#{editor} #{filename}")
|
|
13
13
|
@introvert = Friends::Introvert.new(filename: filename)
|
|
14
14
|
@clean_command = true
|
|
15
15
|
@dirty = true
|
data/lib/friends/friend.rb
CHANGED
|
@@ -16,9 +16,7 @@ module Friends
|
|
|
16
16
|
# @return [Regexp] the regex for capturing groups in deserialization
|
|
17
17
|
def self.deserialization_regex
|
|
18
18
|
# Note: this regex must be on one line because whitespace is important
|
|
19
|
-
# rubocop:disable Metrics/LineLength
|
|
20
|
-
/(#{SERIALIZATION_PREFIX})?(?<name>[^\(\[@]*[^\(\[@\s])(\s+\(#{NICKNAME_PREFIX}(?<nickname_str>.+)\))?(\s+\[(?<location_name>[^\]]+)\])?(\s+(?<tags_str>(#{TAG_REGEX}\s*)+))?/
|
|
21
|
-
# rubocop:enable Metrics/LineLength
|
|
19
|
+
/(#{SERIALIZATION_PREFIX})?(?<name>[^\(\[@]*[^\(\[@\s])(\s+\(#{NICKNAME_PREFIX}(?<nickname_str>.+)\))?(\s+\[(?<location_name>[^\]]+)\])?(\s+(?<tags_str>(#{TAG_REGEX}\s*)+))?/ # rubocop:disable Metrics/LineLength
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
# @return [Regexp] the string of what we expected during deserialization
|
|
@@ -134,12 +132,23 @@ module Friends
|
|
|
134
132
|
chunks, # Match a full name with the highest priority.
|
|
135
133
|
*@nicknames.map { |n| [n] },
|
|
136
134
|
|
|
137
|
-
# Match a first name followed by a last name initial, period
|
|
138
|
-
#
|
|
139
|
-
#
|
|
135
|
+
# Match a first name followed by a last name initial, period (that via
|
|
136
|
+
# lookahead is *NOT* a part of an ellipsis), and then (via lookahead)
|
|
137
|
+
# either:
|
|
138
|
+
# - other punctuation that would indicate we want to swallow the period
|
|
139
|
+
# (note that we do not include closing parentheses in this list because
|
|
140
|
+
# they could be part of an offset sentence), OR
|
|
141
|
+
# - anything, so long as the first alphabetical character afterwards is
|
|
142
|
+
# lowercase.
|
|
143
|
+
# This matches the "Jake E." part of something like "Jake E. and I went
|
|
144
|
+
# skiing." or "Jake E., Marie Curie, and I studied science." This
|
|
140
145
|
# allows us to correctly count the period as part of the name when it's
|
|
141
146
|
# in the middle of a sentence.
|
|
142
|
-
(
|
|
147
|
+
(
|
|
148
|
+
if chunks.size > 1
|
|
149
|
+
[chunks.first, "#{chunks.last[0]}\\.(?!\\.\\.)(?=([,!?;:—]+|(?-i)[^A-Z]+[a-z]))"]
|
|
150
|
+
end
|
|
151
|
+
),
|
|
143
152
|
|
|
144
153
|
# If the above doesn't match, we check for just the first name and then
|
|
145
154
|
# a last name initial. This matches the "Jake E" part of something like
|
data/lib/friends/version.rb
CHANGED
data/test/add_event_helper.rb
CHANGED
|
@@ -117,6 +117,60 @@ def description_parsing_specs(test_stdout: true)
|
|
|
117
117
|
it { stdout_only "#{capitalized_event} added: \"#{date}: Met Grace Hopper at 12.\"" }
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
|
+
|
|
121
|
+
describe "when followed by a period and a comma" do
|
|
122
|
+
let(:description) { "Met grace h., and others, at 12." }
|
|
123
|
+
|
|
124
|
+
it { line_added "- #{date}: Met **Grace Hopper**, and others, at 12." }
|
|
125
|
+
if test_stdout
|
|
126
|
+
it { stdout_only "#{capitalized_event} added: \"#{date}: Met Grace Hopper, and others, at 12.\"" } # rubocop:disable Metrics/LineLength
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe "when followed by a period, a comma, and a proper noun" do
|
|
131
|
+
let(:description) { "Met grace h., King James, and others at 12." }
|
|
132
|
+
|
|
133
|
+
it { line_added "- #{date}: Met **Grace Hopper**, King James, and others at 12." }
|
|
134
|
+
if test_stdout
|
|
135
|
+
it { stdout_only "#{capitalized_event} added: \"#{date}: Met Grace Hopper, King James, and others at 12.\"" } # rubocop:disable Metrics/LineLength
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
describe "when followed by a period and a complex series of sentence-ending punctuation" do
|
|
140
|
+
let(:description) { "Met someone—grace h.?! At 12." }
|
|
141
|
+
|
|
142
|
+
it { line_added "- #{date}: Met someone—**Grace Hopper**?! At 12." }
|
|
143
|
+
if test_stdout
|
|
144
|
+
it { stdout_only "#{capitalized_event} added: \"#{date}: Met someone—Grace Hopper?! At 12.\"" } # rubocop:disable Metrics/LineLength
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
describe "when followed by a period and a complex series of mid-sentence punctuation" do
|
|
149
|
+
let(:description) { "Met someone {grace h.}—at 12." }
|
|
150
|
+
|
|
151
|
+
it { line_added "- #{date}: Met someone {**Grace Hopper**}—at 12." }
|
|
152
|
+
if test_stdout
|
|
153
|
+
it { stdout_only "#{capitalized_event} added: \"#{date}: Met someone {Grace Hopper}—at 12.\"" } # rubocop:disable Metrics/LineLength
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe "when followed by a period as part of a sentence-ending ellipsis" do
|
|
158
|
+
let(:description) { "Met grace h... Great!" }
|
|
159
|
+
|
|
160
|
+
it { line_added "- #{date}: Met **Grace Hopper**... Great!" }
|
|
161
|
+
if test_stdout
|
|
162
|
+
it { stdout_only "#{capitalized_event} added: \"#{date}: Met Grace Hopper... Great!\"" }
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe "when followed by a period as part of a mid-sentence ellipsis" do
|
|
167
|
+
let(:description) { "Met grace h... at 12." }
|
|
168
|
+
|
|
169
|
+
it { line_added "- #{date}: Met **Grace Hopper**... at 12." }
|
|
170
|
+
if test_stdout
|
|
171
|
+
it { stdout_only "#{capitalized_event} added: \"#{date}: Met Grace Hopper... at 12.\"" }
|
|
172
|
+
end
|
|
173
|
+
end
|
|
120
174
|
end
|
|
121
175
|
|
|
122
176
|
describe "when description includes a friend's nickname (case insensitive)" do
|
data/test/commands/edit_spec.rb
CHANGED
|
@@ -36,6 +36,37 @@ clean_describe "edit" do
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
describe "when editor is multiple words" do
|
|
40
|
+
let(:editor) { "'cat -u'" }
|
|
41
|
+
|
|
42
|
+
describe "when output is quieted" do
|
|
43
|
+
let(:quiet) { "--quiet" }
|
|
44
|
+
|
|
45
|
+
it 'opens the file in the "editor"' do
|
|
46
|
+
stdout_only content
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "cleans the file" do
|
|
50
|
+
file_equals CONTENT # File is cleaned (no longer scrambled).
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe "when output is not quieted" do
|
|
55
|
+
let(:quiet) { nil }
|
|
56
|
+
|
|
57
|
+
# Since our "editor" is just `cat -u`, our STDOUT output will include both the opening
|
|
58
|
+
# message and the contents of the file.
|
|
59
|
+
it 'prints a message and opens the file in the "editor"' do
|
|
60
|
+
stdout_only "Opening \"#{filename}\" with \"#{editor.tr("'", '')}\""\
|
|
61
|
+
"\n#{content}File cleaned: \"#{filename}\""
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "cleans the file" do
|
|
65
|
+
file_equals CONTENT # File is cleaned (no longer scrambled).
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
39
70
|
describe "when editor does not exit successfully" do
|
|
40
71
|
let(:editor) { "'exit 1 #'" }
|
|
41
72
|
|
data/test/helper.rb
CHANGED
|
@@ -135,7 +135,7 @@ def line_added(expected)
|
|
|
135
135
|
n_initial_lines = File.read(filename).split("\n").size
|
|
136
136
|
subject
|
|
137
137
|
lines = File.read(filename).split("\n")
|
|
138
|
-
value(lines
|
|
138
|
+
value(lines).must_include expected # Output includes our line
|
|
139
139
|
value(lines.size).must_equal(n_initial_lines + 1) # Line was added, not changed.
|
|
140
140
|
end
|
|
141
141
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: friends
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.49'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jacob Evelyn
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-04-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chronic
|