friends 0.53 → 0.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -2
- data/Gemfile +1 -1
- data/README.md +23 -1
- data/lib/friends/commands/add.rb +10 -1
- data/lib/friends/commands/list.rb +5 -2
- data/lib/friends/commands/remove.rb +9 -0
- data/lib/friends/introvert.rb +46 -10
- data/lib/friends/location.rb +39 -7
- data/lib/friends/version.rb +1 -1
- data/test/commands/add/alias_spec.rb +74 -0
- data/test/commands/edit_spec.rb +1 -0
- data/test/commands/list/locations_spec.rb +14 -0
- data/test/commands/remove/alias_spec.rb +68 -0
- data/test/commands/stats_spec.rb +1 -1
- data/test/helper.rb +2 -0
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 555bc2e9643af62a0c4afb4d070d59de4ef54060d553e17d9eaa563bae82f1b5
|
4
|
+
data.tar.gz: a4f705f276a41c147aab67333c1ffec0ccc7bbba1ab454b9a014b7affa66f017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d8ca490b127f8a60e97e3dacd4cbc893ee33ad8959d8e3bf2c53289154a58e76714958dc29e297e74ff024ac86f3bbfb1e168e5eccc9bd37f178c6c41d903e7
|
7
|
+
data.tar.gz: 14159aa7682fd24ad0cab80d558b91a234eb6d5d52904828c45f6de595b281364da52080288c782b50488cf5ec40a30d36fc2c8e64a251c33924ac8d299fc0df
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,19 @@
|
|
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.54](https://github.com/JacobEvelyn/friends/tree/v0.54) (2020-10-29)
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.53...v0.54)
|
10
|
+
|
11
|
+
**Implemented enhancements:**
|
12
|
+
|
13
|
+
- Add location nicknames [\#242](https://github.com/JacobEvelyn/friends/issues/242)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Add location alias [\#269](https://github.com/JacobEvelyn/friends/pull/269) ([RenCloud](https://github.com/RenCloud))
|
18
|
+
- Update codecov requirement from ~\> 0.1.14 to ~\> 0.2.0 [\#267](https://github.com/JacobEvelyn/friends/pull/267) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
19
|
+
|
7
20
|
## [v0.53](https://github.com/JacobEvelyn/friends/tree/v0.53) (2020-07-06)
|
8
21
|
|
9
22
|
[Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.52...v0.53)
|
@@ -83,7 +96,7 @@ show you appreciate its continued development.
|
|
83
96
|
|
84
97
|
**Implemented enhancements:**
|
85
98
|
|
86
|
-
- Change trigger for implicit location from `moved to
|
99
|
+
- Change trigger for implicit location from `moved to _LOCATION_` to `to _LOCATION_` [\#245](https://github.com/JacobEvelyn/friends/pull/245) ([shen-sat](https://github.com/shen-sat))
|
87
100
|
|
88
101
|
**Closed issues:**
|
89
102
|
|
@@ -368,7 +381,7 @@ show you appreciate its continued development.
|
|
368
381
|
|
369
382
|
**Implemented enhancements:**
|
370
383
|
|
371
|
-
- Add `--since
|
384
|
+
- Add `--since <date>` and `--until <date>` flags, and remove extraneous months from `graph` [\#153](https://github.com/JacobEvelyn/friends/issues/153)
|
372
385
|
- Add integration tests for bin/friends? [\#127](https://github.com/JacobEvelyn/friends/issues/127)
|
373
386
|
|
374
387
|
**Merged pull requests:**
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,7 @@ lots of help), and give feedback! This project is
|
|
37
37
|
- [`add tag`](#add-tag)
|
38
38
|
- [`add location`](#add-location)
|
39
39
|
- [`add nickname`](#add-nickname)
|
40
|
+
- [`add alias`](#add-alias)
|
40
41
|
- [Adding a default location](#adding-a-default-location)
|
41
42
|
- [`clean`](#clean)
|
42
43
|
- [`graph`](#graph)
|
@@ -54,6 +55,7 @@ lots of help), and give feedback! This project is
|
|
54
55
|
- `remove`
|
55
56
|
- [`remove tag`](#remove-tag)
|
56
57
|
- [`remove nickname`](#remove-nickname)
|
58
|
+
- [`remove alias`](#remove-alias)
|
57
59
|
- `rename`
|
58
60
|
- [`rename friend`](#rename-friend)
|
59
61
|
- [`rename location`](#rename-location)
|
@@ -291,11 +293,13 @@ $ friends add activity Got lunch with Earnest H and Earnest S. in the park. Man,
|
|
291
293
|
Activity added: "2017-05-01: Got lunch with Earnest Hemingway and Earnest Shackleton in the park. Man, I like Earnest Hemingway but really love Earnest Shackleton."
|
292
294
|
```
|
293
295
|
|
294
|
-
And locations will be matched as well:
|
296
|
+
And locations or their aliases will be matched as well:
|
295
297
|
|
296
298
|
```bash
|
297
299
|
$ friends add activity Went swimming near atlantis with George.
|
298
300
|
Activity added: "2017-01-06: Went swimming near Atlantis with George Washington Carver."
|
301
|
+
$ friends add activity Had lunch in nyc with George.
|
302
|
+
Activity added: "2017-01-06: Had lunch in New York City with George Washington Carver."
|
299
303
|
```
|
300
304
|
|
301
305
|
Tags will be colored if they're provided (though this README can't display
|
@@ -411,6 +415,15 @@ $ friends add nickname "Grace Hopper" "Amazing Grace"
|
|
411
415
|
Nickname added: "Grace Hopper (a.k.a. The Admiral a.k.a. Amazing Grace)"
|
412
416
|
```
|
413
417
|
|
418
|
+
#### `add alias`
|
419
|
+
|
420
|
+
```bash
|
421
|
+
$ friends add alias "New York City" "NYC"
|
422
|
+
Alias added: "New York City (a.k.a. NYC)
|
423
|
+
$ friends add alias "New York City" "Big Apple"
|
424
|
+
Alias added: "New York City (a.k.a. NYC a.k.a. Big Apple)"
|
425
|
+
```
|
426
|
+
|
414
427
|
#### Setting a default location
|
415
428
|
|
416
429
|
When an activity includes the phrase to \_LOCATION\_ (e.g., Took a plane to \_Paris\_), all future activities that have no explicit location will be associated with that location:
|
@@ -876,6 +889,15 @@ $ friends remove nickname "Grace Hopper" "The Admiral"
|
|
876
889
|
Nickname removed: "Grace Hopper (a.k.a. Amazing Grace)"
|
877
890
|
```
|
878
891
|
|
892
|
+
#### `remove alias`
|
893
|
+
|
894
|
+
Removes a specific alias from a location:
|
895
|
+
|
896
|
+
```bash
|
897
|
+
$ friends remove alias "New York City" "Big Apple"
|
898
|
+
Alias removed: "New York City (a.k.a. NYC)"
|
899
|
+
```
|
900
|
+
|
879
901
|
#### `rename friend`
|
880
902
|
|
881
903
|
```bash
|
data/lib/friends/commands/add.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
desc "Adds a friend (or nickname), activity, note, or location"
|
3
|
+
desc "Adds a friend (or nickname), activity, note, or location (or alias)"
|
4
4
|
command :add do |add|
|
5
5
|
add.desc "Adds a friend"
|
6
6
|
add.arg_name "NAME"
|
@@ -40,6 +40,15 @@ command :add do |add|
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
add.desc "Adds an alias to a location"
|
44
|
+
add.arg_name "LOCATION ALIAS"
|
45
|
+
add.command :alias do |add_alias|
|
46
|
+
add_alias.action do |_, _, args|
|
47
|
+
@introvert.add_alias(name: args.first.to_s.strip, nickname: args[1].to_s.strip)
|
48
|
+
@dirty = true # Mark the file for cleaning.
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
add.desc "Adds a tag to a friend"
|
44
53
|
add.arg_name "NAME @TAG"
|
45
54
|
add.command :tag do |add_tag|
|
@@ -73,8 +73,11 @@ command :list do |list|
|
|
73
73
|
|
74
74
|
list.desc "List all locations"
|
75
75
|
list.command :locations do |list_locations|
|
76
|
-
list_locations.
|
77
|
-
|
76
|
+
list_locations.switch [:verbose],
|
77
|
+
negatable: false,
|
78
|
+
desc: "Output location aliases"
|
79
|
+
list_locations.action do |_, options|
|
80
|
+
@introvert.list_locations(verbose: options[:verbose])
|
78
81
|
end
|
79
82
|
end
|
80
83
|
|
@@ -11,6 +11,15 @@ command :remove do |remove|
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
remove.desc "Removes an alias from a location"
|
15
|
+
remove.arg_name "LOCATION ALIAS"
|
16
|
+
remove.command :alias do |remove_alias|
|
17
|
+
remove_alias.action do |_, _, args|
|
18
|
+
@introvert.remove_alias(name: args.first.to_s.strip, nickname: args[1].to_s.strip)
|
19
|
+
@dirty = true # Mark the file for cleaning.
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
14
23
|
remove.desc "Removes a tag from a friend"
|
15
24
|
remove.arg_name "NAME @TAG"
|
16
25
|
remove.command :tag do |remove_tag|
|
data/lib/friends/introvert.rb
CHANGED
@@ -212,6 +212,31 @@ module Friends
|
|
212
212
|
@output << "Nickname added: \"#{friend}\""
|
213
213
|
end
|
214
214
|
|
215
|
+
# Add an alias to an existing location.
|
216
|
+
# @param name [String] the name of the location
|
217
|
+
# @param nickname [String] the alias to add to the location
|
218
|
+
# @raise [FriendsError] if 0 or 2+ locations match the given name
|
219
|
+
# @raise [FriendsError] if the alias is already taken
|
220
|
+
def add_alias(name:, nickname:)
|
221
|
+
raise FriendsError, "Expected \"[Location Name]\" \"[Alias]\"" if name.empty?
|
222
|
+
raise FriendsError, "Alias cannot be blank" if nickname.empty?
|
223
|
+
|
224
|
+
collision = @locations.find do |loc|
|
225
|
+
loc.name.casecmp(nickname).zero? || loc.aliases.any? { |a| a.casecmp(nickname).zero? }
|
226
|
+
end
|
227
|
+
|
228
|
+
if collision
|
229
|
+
raise FriendsError,
|
230
|
+
"The location alias \"#{nickname}\" is already taken by "\
|
231
|
+
"\"#{collision}\""
|
232
|
+
end
|
233
|
+
|
234
|
+
location = thing_with_name_in(:location, name)
|
235
|
+
location.add_alias(nickname)
|
236
|
+
|
237
|
+
@output << "Alias added: \"#{location}\""
|
238
|
+
end
|
239
|
+
|
215
240
|
# Add a tag to an existing friend.
|
216
241
|
# @param name [String] the name of the friend
|
217
242
|
# @param tag [String] the tag to add to the friend, of the form: "@tag"
|
@@ -250,6 +275,21 @@ module Friends
|
|
250
275
|
@output << "Nickname removed: \"#{friend}\""
|
251
276
|
end
|
252
277
|
|
278
|
+
# Remove an alias from an existing location.
|
279
|
+
# @param name [String] the name of the location
|
280
|
+
# @param nickname [String] the alias to remove from the location
|
281
|
+
# @raise [FriendsError] if 0 or 2+ locations match the given name
|
282
|
+
# @raise [FriendsError] if the location does not have the given alias
|
283
|
+
def remove_alias(name:, nickname:)
|
284
|
+
raise FriendsError, "Expected \"[Location Name]\" \"[Alias]\"" if name.empty?
|
285
|
+
raise FriendsError, "Alias cannot be blank" if nickname.empty?
|
286
|
+
|
287
|
+
location = thing_with_name_in(:location, name)
|
288
|
+
location.remove_alias(nickname)
|
289
|
+
|
290
|
+
@output << "Alias removed: \"#{location}\""
|
291
|
+
end
|
292
|
+
|
253
293
|
# List all friend names in the friends file.
|
254
294
|
# @param location_name [String] the name of a location to filter by, or nil
|
255
295
|
# for unfiltered
|
@@ -297,8 +337,8 @@ module Friends
|
|
297
337
|
end
|
298
338
|
|
299
339
|
# List all location names in the friends file.
|
300
|
-
def list_locations
|
301
|
-
@locations.each { |
|
340
|
+
def list_locations(verbose:)
|
341
|
+
(verbose ? @locations.map(&:to_s) : @locations.map(&:name)).each { |line| @output << line }
|
302
342
|
end
|
303
343
|
|
304
344
|
# @param from [Array] containing any of: ["activities", "friends", "notes"]
|
@@ -429,16 +469,16 @@ module Friends
|
|
429
469
|
#
|
430
470
|
# The returned hash uses the following format:
|
431
471
|
# {
|
432
|
-
# /regex/ =>
|
472
|
+
# /regex/ => location
|
433
473
|
# }
|
434
474
|
#
|
435
475
|
# This hash is sorted (because Ruby's hashes are ordered) by decreasing
|
436
476
|
# regex key length, so the key /Paris, France/ appears before /Paris/.
|
437
477
|
#
|
438
|
-
# @return [Hash{Regexp =>
|
478
|
+
# @return [Hash{Regexp => location}]
|
439
479
|
def regex_location_map
|
440
480
|
@locations.each_with_object({}) do |location, hash|
|
441
|
-
hash[
|
481
|
+
location.regexes_for_name.each { |regex| hash[regex] = location }
|
442
482
|
end.sort_by { |k, _| -k.to_s.size }.to_h
|
443
483
|
end
|
444
484
|
|
@@ -751,11 +791,7 @@ module Friends
|
|
751
791
|
# @raise [FriendsError] if 0 or 2+ friends match the given text
|
752
792
|
def thing_with_name_in(type, text)
|
753
793
|
things = instance_variable_get("@#{type}s").select do |thing|
|
754
|
-
|
755
|
-
thing.regexes_for_name.any? { |regex| regex.match(text) }
|
756
|
-
else
|
757
|
-
thing.regex_for_name.match(text)
|
758
|
-
end
|
794
|
+
thing.regexes_for_name.any? { |regex| regex.match(text) }
|
759
795
|
end
|
760
796
|
|
761
797
|
# If there's more than one match with fuzzy regexes but exactly one thing
|
data/lib/friends/location.rb
CHANGED
@@ -10,11 +10,12 @@ module Friends
|
|
10
10
|
extend Serializable
|
11
11
|
|
12
12
|
SERIALIZATION_PREFIX = "- "
|
13
|
+
ALIAS_PREFIX = "a.k.a. "
|
13
14
|
|
14
15
|
# @return [Regexp] the regex for capturing groups in deserialization
|
15
16
|
def self.deserialization_regex
|
16
17
|
# Note: this regex must be on one line because whitespace is important
|
17
|
-
/(#{SERIALIZATION_PREFIX})?(?<name>.+)
|
18
|
+
/(#{SERIALIZATION_PREFIX})?(?<name>[^\(]*[^\(\s])(\s+\(#{ALIAS_PREFIX}(?<alias_str>.+)\))?/
|
18
19
|
end
|
19
20
|
|
20
21
|
# @return [Regexp] the string of what we expected during deserialization
|
@@ -23,21 +24,52 @@ module Friends
|
|
23
24
|
end
|
24
25
|
|
25
26
|
# @param name [String] the name of the location
|
26
|
-
def initialize(name:)
|
27
|
+
def initialize(name:, alias_str: nil)
|
27
28
|
@name = name
|
29
|
+
@aliases = alias_str&.split(" #{ALIAS_PREFIX}") || []
|
28
30
|
end
|
29
31
|
|
30
32
|
attr_accessor :name
|
33
|
+
attr_reader :aliases
|
31
34
|
|
32
35
|
# @return [String] the file serialization text for the location
|
33
36
|
def serialize
|
34
|
-
"#{SERIALIZATION_PREFIX}#{
|
37
|
+
Paint.unpaint("#{SERIALIZATION_PREFIX}#{self}")
|
35
38
|
end
|
36
39
|
|
37
|
-
# @return [
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
# @return [String] a string representing the location's name and aliases
|
41
|
+
def to_s
|
42
|
+
unless @aliases.empty?
|
43
|
+
alias_str = " (" +
|
44
|
+
@aliases.map do |nickname|
|
45
|
+
"#{ALIAS_PREFIX}#{Paint[nickname, :bold, :yellow]}"
|
46
|
+
end.join(" ") + ")"
|
47
|
+
end
|
48
|
+
|
49
|
+
"#{Paint[@name, :bold]}#{alias_str}"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Add an alias, ignoring duplicates.
|
53
|
+
# @param nickname [String] the alias to add
|
54
|
+
def add_alias(nickname)
|
55
|
+
@aliases << nickname
|
56
|
+
@aliases.uniq!
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param nickname [String] the alias to remove
|
60
|
+
# @raise [FriendsError] if the location does not have the given alias
|
61
|
+
def remove_alias(nickname)
|
62
|
+
unless @aliases.include? nickname
|
63
|
+
raise FriendsError, "Alias \"#{nickname}\" not found for \"#{name}\""
|
64
|
+
end
|
65
|
+
|
66
|
+
@aliases.delete(nickname)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [Array] a list of all regexes to match the name in a string
|
70
|
+
# NOTE: Only full names and aliases
|
71
|
+
def regexes_for_name
|
72
|
+
[name, *@aliases].map { |str| Friends::RegexBuilder.regex(str) }
|
41
73
|
end
|
42
74
|
|
43
75
|
# The number of activities this location is in. This is for internal use
|
data/lib/friends/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "./test/helper"
|
4
|
+
|
5
|
+
clean_describe "add alias" do
|
6
|
+
subject { run_cmd("add alias #{location_name} #{nickname}") }
|
7
|
+
|
8
|
+
let(:content) { CONTENT }
|
9
|
+
|
10
|
+
describe "when location name and alias are blank" do
|
11
|
+
let(:location_name) { nil }
|
12
|
+
let(:nickname) { nil }
|
13
|
+
|
14
|
+
it "prints an error message" do
|
15
|
+
stderr_only 'Error: Expected "[Location Name]" "[Alias]"'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "when location name has no matches" do
|
20
|
+
let(:location_name) { "Garbage" }
|
21
|
+
let(:nickname) { "Big Apple Pie" }
|
22
|
+
|
23
|
+
it "prints an error message" do
|
24
|
+
stderr_only 'Error: No location found for "Garbage"'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when location alias has more than one match" do
|
29
|
+
let(:location_name) { "'New York City'" }
|
30
|
+
let(:nickname) { "'Big Apple'" }
|
31
|
+
before do
|
32
|
+
run_cmd("add location Manhattan")
|
33
|
+
run_cmd("add alias Manhattan 'Big Apple'")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "prints an error message" do
|
37
|
+
stderr_only "Error: The location alias "\
|
38
|
+
'"Big Apple" is already taken by "Manhattan (a.k.a. Big Apple)"'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when location name has one match" do
|
43
|
+
let(:location_name) { "'New York City'" }
|
44
|
+
|
45
|
+
describe "when alias is blank" do
|
46
|
+
let(:nickname) { "' '" }
|
47
|
+
|
48
|
+
it "prints an error message" do
|
49
|
+
stderr_only "Error: Alias cannot be blank"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "when alias is nil" do
|
54
|
+
let(:nickname) { nil }
|
55
|
+
|
56
|
+
it "prints an error message" do
|
57
|
+
stderr_only "Error: Alias cannot be blank"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "when alias is not blank" do
|
62
|
+
let(:nickname) { "'Big Apple'" }
|
63
|
+
|
64
|
+
it "adds alias to location" do
|
65
|
+
line_changed "- New York City (a.k.a. NYC a.k.a. NY)",
|
66
|
+
"- New York City (a.k.a. NYC a.k.a. NY a.k.a. Big Apple)"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "prints an output message" do
|
70
|
+
stdout_only 'Alias added: "New York City (a.k.a. NYC a.k.a. NY a.k.a. Big Apple)"'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/test/commands/edit_spec.rb
CHANGED
@@ -31,7 +31,21 @@ clean_describe "list locations" do
|
|
31
31
|
Paris
|
32
32
|
Atlantis
|
33
33
|
Martha's Vineyard
|
34
|
+
New York City
|
34
35
|
OUTPUT
|
35
36
|
end
|
37
|
+
|
38
|
+
describe "--verbose" do
|
39
|
+
subject { run_cmd("list locations --verbose") }
|
40
|
+
|
41
|
+
it "lists locations in file order with details" do
|
42
|
+
stdout_only <<-OUTPUT
|
43
|
+
Paris
|
44
|
+
Atlantis
|
45
|
+
Martha's Vineyard
|
46
|
+
New York City (a.k.a. NYC a.k.a. NY)
|
47
|
+
OUTPUT
|
48
|
+
end
|
49
|
+
end
|
36
50
|
end
|
37
51
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "./test/helper"
|
4
|
+
|
5
|
+
clean_describe "remove alias" do
|
6
|
+
subject { run_cmd("remove alias #{location_name} #{nickname}") }
|
7
|
+
|
8
|
+
let(:content) { CONTENT }
|
9
|
+
|
10
|
+
describe "when location and nickname are nil" do
|
11
|
+
let(:location_name) { nil }
|
12
|
+
let(:nickname) { nil }
|
13
|
+
|
14
|
+
it "prints an error message" do
|
15
|
+
stderr_only 'Error: Expected "[Location Name]" "[Alias]"'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "when location name has no matches" do
|
20
|
+
let(:location_name) { "Garbage" }
|
21
|
+
let(:nickname) { "'Big Apple Pie'" }
|
22
|
+
|
23
|
+
it "prints an error message" do
|
24
|
+
stderr_only 'Error: No location found for "Garbage"'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when location name has one match" do
|
29
|
+
let(:location_name) { "'New York City'" }
|
30
|
+
|
31
|
+
describe "when alias is nil" do
|
32
|
+
let(:nickname) { nil }
|
33
|
+
it "prints an error message" do
|
34
|
+
stderr_only "Error: Alias cannot be blank"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "when alias is not present on location" do
|
39
|
+
let(:nickname) { "Gotham" }
|
40
|
+
it "prints an error message" do
|
41
|
+
stderr_only 'Error: Alias "Gotham" not found for "New York City"'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when alias is present on location" do
|
46
|
+
let(:nickname) { "'NYC'" }
|
47
|
+
|
48
|
+
it "removes alias from location" do
|
49
|
+
line_changed(
|
50
|
+
"- New York City (a.k.a. NYC a.k.a. NY)",
|
51
|
+
"- New York City (a.k.a. NY)"
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "removes parenthetical from file when location has no more nicknames" do
|
56
|
+
run_cmd("remove alias #{location_name} 'NY'")
|
57
|
+
line_changed(
|
58
|
+
"- New York City (a.k.a. NYC)",
|
59
|
+
"- New York City"
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "prints an output message" do
|
64
|
+
stdout_only 'Alias removed: "New York City (a.k.a. NY)"'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/test/commands/stats_spec.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -48,6 +48,7 @@ CONTENT = <<-FILE
|
|
48
48
|
### Locations:
|
49
49
|
- Atlantis
|
50
50
|
- Martha's Vineyard
|
51
|
+
- New York City (a.k.a. NYC a.k.a. NY)
|
51
52
|
- Paris
|
52
53
|
FILE
|
53
54
|
|
@@ -77,6 +78,7 @@ SCRAMBLED_CONTENT = <<-FILE
|
|
77
78
|
- Paris
|
78
79
|
- Atlantis
|
79
80
|
- Martha's Vineyard
|
81
|
+
- New York City (a.k.a. NYC a.k.a. NY)
|
80
82
|
FILE
|
81
83
|
|
82
84
|
# Define these methods so they can be referenced in the methods below. They'll be overridden in
|
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.54'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Evelyn
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/friends/version.rb
|
164
164
|
- test/add_event_helper.rb
|
165
165
|
- test/commands/add/activity_spec.rb
|
166
|
+
- test/commands/add/alias_spec.rb
|
166
167
|
- test/commands/add/friend_spec.rb
|
167
168
|
- test/commands/add/location_spec.rb
|
168
169
|
- test/commands/add/nickname_spec.rb
|
@@ -179,6 +180,7 @@ files:
|
|
179
180
|
- test/commands/list/locations_spec.rb
|
180
181
|
- test/commands/list/notes_spec.rb
|
181
182
|
- test/commands/list/tags_spec.rb
|
183
|
+
- test/commands/remove/alias_spec.rb
|
182
184
|
- test/commands/remove/nickname_spec.rb
|
183
185
|
- test/commands/remove/tag_spec.rb
|
184
186
|
- test/commands/rename/friend_spec.rb
|
@@ -212,13 +214,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
214
|
- !ruby/object:Gem::Version
|
213
215
|
version: '0'
|
214
216
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
216
|
-
signing_key:
|
217
|
+
rubygems_version: 3.1.4
|
218
|
+
signing_key:
|
217
219
|
specification_version: 4
|
218
220
|
summary: Spend time with the people you care about.
|
219
221
|
test_files:
|
220
222
|
- test/add_event_helper.rb
|
221
223
|
- test/commands/add/activity_spec.rb
|
224
|
+
- test/commands/add/alias_spec.rb
|
222
225
|
- test/commands/add/friend_spec.rb
|
223
226
|
- test/commands/add/location_spec.rb
|
224
227
|
- test/commands/add/nickname_spec.rb
|
@@ -235,6 +238,7 @@ test_files:
|
|
235
238
|
- test/commands/list/locations_spec.rb
|
236
239
|
- test/commands/list/notes_spec.rb
|
237
240
|
- test/commands/list/tags_spec.rb
|
241
|
+
- test/commands/remove/alias_spec.rb
|
238
242
|
- test/commands/remove/nickname_spec.rb
|
239
243
|
- test/commands/remove/tag_spec.rb
|
240
244
|
- test/commands/rename/friend_spec.rb
|