friends 0.11 → 0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/CONTRIBUTING.md +5 -4
- data/README.md +5 -0
- data/bin/friends +14 -0
- data/lib/friends/activity.rb +11 -0
- data/lib/friends/friend.rb +7 -0
- data/lib/friends/introvert.rb +14 -0
- data/lib/friends/version.rb +1 -1
- data/test/activity_spec.rb +30 -0
- data/test/friend_spec.rb +9 -0
- data/test/introvert_spec.rb +35 -0
- 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: b6fbeed1512a5fb14b7a89e5afebe885e48817ea
|
4
|
+
data.tar.gz: e4fa97ba906eb037fc70da65704aa33a456e0a99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 883ef235fc6d26aec8bc03ac5a72794e643f1d7d501944a5e5c587bf0451ed55320562b1188161616cd88e1c952ddfccce746d8a369cf05a080d0bd6cda5b2d3
|
7
|
+
data.tar.gz: 51557fe1705cf9d812087c5b7b3d5397517f48232a56668267ce8000d94301b7208b430dbf9f97c67694a50ce09f4d079b6f57e9033b084f6f10a0fe928c788b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.12](https://github.com/JacobEvelyn/friends/tree/v0.12) (2016-01-16)
|
4
|
+
[Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.11...v0.12)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- Add examples for rename command in README [\#76](https://github.com/JacobEvelyn/friends/issues/76)
|
9
|
+
- Add change name command [\#68](https://github.com/JacobEvelyn/friends/issues/68)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Update README and CONTRIBUTING docs. Closes \#76 [\#77](https://github.com/JacobEvelyn/friends/pull/77) ([JacobEvelyn](https://github.com/JacobEvelyn))
|
14
|
+
- Add rename friend [\#75](https://github.com/JacobEvelyn/friends/pull/75) ([bloomyminded](https://github.com/bloomyminded))
|
15
|
+
|
3
16
|
## [v0.11](https://github.com/JacobEvelyn/friends/tree/v0.11) (2016-01-13)
|
4
17
|
[Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.10...v0.11)
|
5
18
|
|
data/CONTRIBUTING.md
CHANGED
@@ -18,7 +18,8 @@ that's great as well!
|
|
18
18
|
6. Make your changes. Add or modify tests if necessary!
|
19
19
|
(Run tests with `rake test`.) Do your best to conform to
|
20
20
|
existing style and commenting patterns.
|
21
|
-
7.
|
21
|
+
7. Update the `README.md` as necessary to include your changes.
|
22
|
+
8. Commit your changes
|
22
23
|
(`git commit -am "Add some feature"`). You should see
|
23
24
|
output from
|
24
25
|
[`overcommit`](https://github.com/brigade/overcommit) as
|
@@ -44,10 +45,10 @@ it runs commit hooks that looks something like this:
|
|
44
45
|
how! This practice is meant to keep the code clean but
|
45
46
|
it shouldn't be scary and it's totally fine to need
|
46
47
|
help!
|
47
|
-
|
48
|
-
|
48
|
+
9. Push your changes to GitHub, and open a Pull Request.
|
49
|
+
10. Your code will be reviewed and merged as quickly as
|
49
50
|
possible!
|
50
|
-
|
51
|
+
11. Check yourself out on the [contributors page](https://github.com/JacobEvelyn/friends/graphs/contributors)! Look at how cool you are!
|
51
52
|
|
52
53
|
If you have any questions at all or get stuck on any step,
|
53
54
|
don't hesitate to
|
data/README.md
CHANGED
@@ -82,6 +82,11 @@ And they can be removed as well:
|
|
82
82
|
$ friends remove nickname "Grace Hopper" "The Admiral"
|
83
83
|
Nickname removed: "Grace Hopper (a.k.a. Amazing Grace)"
|
84
84
|
```
|
85
|
+
##### Change a friend's name:
|
86
|
+
```
|
87
|
+
$ friends rename friend "Grace Hopper" "Grace Brewster Murray Hopper"
|
88
|
+
Name changed: "Grace Brewster Murray Hopper (a.k.a. Amazing Grace)"
|
89
|
+
```
|
85
90
|
##### Suggest a friend to do something with:
|
86
91
|
```
|
87
92
|
$ friends suggest
|
data/bin/friends
CHANGED
@@ -220,6 +220,20 @@ command :stats do |stats|
|
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
+
desc "Renames a friend"
|
224
|
+
command :rename do |rename|
|
225
|
+
rename.desc "Renames a friend"
|
226
|
+
rename.arg_name "NAME NEW_NAME"
|
227
|
+
rename.command :friend do |rename_friend|
|
228
|
+
rename_friend.action do |_, _, args|
|
229
|
+
friend = @introvert.rename_friend(old_name: args.first,
|
230
|
+
new_name: args[1])
|
231
|
+
@message = "Name changed: \"#{friend}\""
|
232
|
+
@dirty = true # Mark the file for cleaning.
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
223
237
|
# Before each command, clean up all arguments and create the global Introvert.
|
224
238
|
pre do |global_options, _, options|
|
225
239
|
@debug_mode = global_options[:debug]
|
data/lib/friends/activity.rb
CHANGED
@@ -124,6 +124,17 @@ module Friends
|
|
124
124
|
@description.delete!("\\")
|
125
125
|
end
|
126
126
|
|
127
|
+
# Updates a friend's old_name to their new_name
|
128
|
+
# @param [String] old_name
|
129
|
+
# @param [String] new_name
|
130
|
+
# @return [String] if name found in description
|
131
|
+
# @return [nil] if no change was made
|
132
|
+
def update_name(old_name:, new_name:)
|
133
|
+
description.gsub!(
|
134
|
+
Regexp.new("(?<=\\*\\*)#{old_name}(?=\\*\\*)"),
|
135
|
+
new_name)
|
136
|
+
end
|
137
|
+
|
127
138
|
# @param friend [Friend] the friend to test
|
128
139
|
# @return [Boolean] true iff this activity includes the given friend
|
129
140
|
def includes_friend?(friend:)
|
data/lib/friends/friend.rb
CHANGED
@@ -49,6 +49,13 @@ module Friends
|
|
49
49
|
@nicknames.uniq!
|
50
50
|
end
|
51
51
|
|
52
|
+
# Renames a friend, avoiding duplicates and stripping surrounding
|
53
|
+
# whitespace.
|
54
|
+
# @param new_name [String] the friend's new name
|
55
|
+
def rename(new_name)
|
56
|
+
@name = new_name
|
57
|
+
end
|
58
|
+
|
52
59
|
# @param nickname [String] the nickname to remove
|
53
60
|
# @return [Boolean] true if the nickname was present, false otherwise
|
54
61
|
def remove_nickname(nickname)
|
data/lib/friends/introvert.rb
CHANGED
@@ -75,6 +75,20 @@ module Friends
|
|
75
75
|
activity # Return the added activity.
|
76
76
|
end
|
77
77
|
|
78
|
+
# Rename an existing added friend.
|
79
|
+
# @param old_name [String] the name of the friend
|
80
|
+
# @param new_name [String] the new name of the friend
|
81
|
+
# @raise [FriendsError] if 0 of 2+ friends match the given name
|
82
|
+
# @return [Friend] the existing friend
|
83
|
+
def rename_friend(old_name:, new_name:)
|
84
|
+
friend = friend_with_name_in(old_name.strip)
|
85
|
+
@activities.each do |activity|
|
86
|
+
activity.update_name(old_name: friend.name, new_name: new_name.strip)
|
87
|
+
end
|
88
|
+
friend.rename(new_name.strip)
|
89
|
+
friend
|
90
|
+
end
|
91
|
+
|
78
92
|
# Add a nickname to an existing friend and write out the new friends file.
|
79
93
|
# @param name [String] the name of the friend
|
80
94
|
# @param nickname [String] the nickname to add to the friend
|
data/lib/friends/version.rb
CHANGED
data/test/activity_spec.rb
CHANGED
@@ -298,4 +298,34 @@ describe Friends::Activity do
|
|
298
298
|
[past_act, future_act].sort.must_equal [future_act, past_act]
|
299
299
|
end
|
300
300
|
end
|
301
|
+
|
302
|
+
describe "#update_name" do
|
303
|
+
let(:description) { "Lunch with **John Candy**." }
|
304
|
+
subject do
|
305
|
+
activity.update_name(old_name: "John Candy", new_name: "John Cleese")
|
306
|
+
end
|
307
|
+
|
308
|
+
it "renames the given friend in the description" do
|
309
|
+
subject.must_equal "Lunch with **John Cleese**."
|
310
|
+
end
|
311
|
+
|
312
|
+
describe "when the description contains a fragment of the old name" do
|
313
|
+
let(:description) { "Lunch with **John Candy** at Johnny's Diner." }
|
314
|
+
|
315
|
+
it "only replaces the name" do
|
316
|
+
subject.must_equal "Lunch with **John Cleese** at Johnny's Diner."
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
describe "when the description contains the complete old name" do
|
321
|
+
let(:description) { "Coffee with **John** at John's Studio." }
|
322
|
+
subject do
|
323
|
+
activity.update_name(old_name: "John", new_name: "Joe")
|
324
|
+
end
|
325
|
+
|
326
|
+
it "only replaces the actual name" do
|
327
|
+
subject.must_equal "Coffee with **Joe** at John's Studio."
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
301
331
|
end
|
data/test/friend_spec.rb
CHANGED
@@ -30,6 +30,15 @@ describe Friends::Friend do
|
|
30
30
|
it { subject.name.must_equal friend_name }
|
31
31
|
end
|
32
32
|
|
33
|
+
describe "#rename" do
|
34
|
+
subject { friend }
|
35
|
+
|
36
|
+
it "renames the friend" do
|
37
|
+
friend.rename("Ada Lovelace")
|
38
|
+
subject.name.must_equal "Ada Lovelace"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
33
42
|
describe "#serialize" do
|
34
43
|
subject { friend.serialize }
|
35
44
|
|
data/test/introvert_spec.rb
CHANGED
@@ -259,6 +259,41 @@ describe Friends::Introvert do
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
+
describe "#rename_friend" do
|
263
|
+
let(:new_name) { "David Bowie" }
|
264
|
+
subject do
|
265
|
+
introvert.rename_friend(old_name: friend_names.last, new_name: new_name)
|
266
|
+
end
|
267
|
+
|
268
|
+
it "replaces old name within activities to the new name" do
|
269
|
+
stub_friends(friends) do
|
270
|
+
stub_activities(activities) do
|
271
|
+
subject
|
272
|
+
introvert.activities.first.description.must_include new_name
|
273
|
+
introvert.activities.last.description.must_include new_name
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
describe "when given names with leading and trailing spaces" do
|
279
|
+
let(:new_name) { " David Bowie " }
|
280
|
+
let(:old_name) { friend_names.last + " " }
|
281
|
+
subject do
|
282
|
+
introvert.rename_friend(old_name: old_name, new_name: new_name)
|
283
|
+
end
|
284
|
+
|
285
|
+
it "correctly strips the spaces" do
|
286
|
+
stub_friends(friends) do
|
287
|
+
stub_activities(activities) do
|
288
|
+
subject
|
289
|
+
introvert.activities.first.description.must_include "David Bowie"
|
290
|
+
introvert.activities.last.description.must_include "David Bowie"
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
262
297
|
describe "#add_nickname" do
|
263
298
|
subject do
|
264
299
|
introvert.add_nickname(name: friend_names.first, nickname: "The Dude")
|
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.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Evelyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|