friends 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/bin/friends +5 -2
- data/lib/friends/introvert.rb +8 -1
- data/lib/friends/version.rb +1 -1
- data/test/introvert_spec.rb +6 -3
- 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: 7d0669a8ff237217895bb3647d19c2c3619c455f
|
4
|
+
data.tar.gz: b1df12a309fff583eef49f10c52175ec02b53cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 885edb6c2f561e23be58f81dec6cffcc22829cab66f0a3f3e482184dfb939f2391200cf52b2d870c68d00d198356f2c8da5a4645561759cccd945f369135d06c
|
7
|
+
data.tar.gz: 00f795cfd5f597f83dfb9c1d0a77b04f95eca041b7a2b97ab4d15e2d03aebd908cd4c95e7ae245f779debbfaac5827de2dcf58b9a1dd32eae6e08b2dc904f35e
|
data/README.md
CHANGED
@@ -76,16 +76,16 @@ Find your favorite friends:
|
|
76
76
|
```
|
77
77
|
$ friends list favorites
|
78
78
|
Your favorite friends:
|
79
|
-
1. George Washington Carver
|
80
|
-
2. Grace Hopper
|
81
|
-
3. Marie Curie
|
79
|
+
1. George Washington Carver (2 activities)
|
80
|
+
2. Grace Hopper (1)
|
81
|
+
3. Marie Curie (1)
|
82
82
|
```
|
83
83
|
Or get a specific number of favorites:
|
84
84
|
```
|
85
85
|
$ friends list favorites --limit 2
|
86
86
|
Your favorite friends:
|
87
|
-
1. George Washington Carver
|
88
|
-
2. Grace Hopper
|
87
|
+
1. George Washington Carver (2 activities)
|
88
|
+
2. Grace Hopper (1)
|
89
89
|
```
|
90
90
|
|
91
91
|
### Global options:
|
data/bin/friends
CHANGED
@@ -52,8 +52,11 @@ command :list do |c|
|
|
52
52
|
puts "Your best friend is #{favorites.first}"
|
53
53
|
else
|
54
54
|
puts "Your favorite friends:"
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
num_str_size = favorites.size.to_s.size + 1
|
57
|
+
favorites.each.with_index(1) do |name, rank|
|
58
|
+
puts "#{"#{rank}.".ljust(num_str_size)} #{name}"
|
59
|
+
end
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
data/lib/friends/introvert.rb
CHANGED
@@ -110,7 +110,14 @@ module Friends
|
|
110
110
|
# If we need to, trim the list.
|
111
111
|
results = results.take(limit) unless limit.nil?
|
112
112
|
|
113
|
-
results.
|
113
|
+
# max_str_size = results.first.n_activities.to_s.size
|
114
|
+
# results.map { |friend| "#{friend.n_activities.to_s.rjust(max_str_size)} #{friend.name}" }
|
115
|
+
max_str_size = results.map(&:name).map(&:size).max
|
116
|
+
results.map.with_index(0) do |friend, index|
|
117
|
+
name = friend.name.ljust(max_str_size)
|
118
|
+
parenthetical = "(#{friend.n_activities}#{' activities' if index == 0})"
|
119
|
+
"#{name} #{parenthetical}"
|
120
|
+
end
|
114
121
|
end
|
115
122
|
|
116
123
|
# List all activity details.
|
data/lib/friends/version.rb
CHANGED
data/test/introvert_spec.rb
CHANGED
@@ -237,10 +237,13 @@ describe Friends::Introvert do
|
|
237
237
|
describe "when limit is nil" do
|
238
238
|
let(:limit) { nil }
|
239
239
|
|
240
|
-
it "returns all friends in order of favoritism" do
|
240
|
+
it "returns all friends in order of favoritism with activity counts" do
|
241
241
|
introvert.stub(:friends, friends) do
|
242
242
|
introvert.stub(:activities, activities) do
|
243
|
-
subject.must_equal [
|
243
|
+
subject.must_equal [
|
244
|
+
"Betsy Ross (2 activities)",
|
245
|
+
"George Washington Carver (1)"
|
246
|
+
]
|
244
247
|
end
|
245
248
|
end
|
246
249
|
end
|
@@ -252,7 +255,7 @@ describe Friends::Introvert do
|
|
252
255
|
it "returns the number of favorites requested" do
|
253
256
|
introvert.stub(:friends, friends) do
|
254
257
|
introvert.stub(:activities, activities) do
|
255
|
-
subject.must_equal ["Betsy Ross"]
|
258
|
+
subject.must_equal ["Betsy Ross (2 activities)"]
|
256
259
|
end
|
257
260
|
end
|
258
261
|
end
|
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.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Evelyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|