friends 0.8 → 0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11ffd724b0c9aa013571f545c49efec501856191
4
- data.tar.gz: efb5fa9791decbb6eb8fb050a2e1d61bd4aa913a
3
+ metadata.gz: fd57717cc27c13b6520090e016a6ddf121aaf9b6
4
+ data.tar.gz: 2ab6ef28bcbc08fa2144ce1a77c7b5f1ca4c29ad
5
5
  SHA512:
6
- metadata.gz: a6f3e3b822d68ec469ecd11ece0d9ea96838f7c95be0fcf7cff6fe17f47eea9900ab66b3c649f2690f0552bb533ff188ae5aafbbcedf37a2ced7fe3b0bcf408e
7
- data.tar.gz: ed8468dea41326b0a221960bf9efe5b67707b840479a9a2a9be6014bc16e11fe490fc2786f337a1fa8f86b0fd45375a4d03d2b5f5a8944caf19b6ae4a1a5d559
6
+ metadata.gz: aa7c94b0e734e6bca501e94eafe6d4e6a40c3b00bf4c5c509b0dc8c0d08db38237cbe0027278203a8521c291513016b7d0716e312a612455478f1cf7982b8337
7
+ data.tar.gz: 42bd1f835bf0fe0aafbc6e843209d17e02f620626b94a4a0dc6b5cdab933a74ddac450d7c79eddda9c0f34c68426eb8e58835ea1e9b3f9dd4b342245a0449005
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.9](https://github.com/JacobEvelyn/friends/tree/v0.9) (2016-01-07)
4
+ [Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.8...v0.9)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Add command to retrieve basic stats [\#36](https://github.com/JacobEvelyn/friends/issues/36)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - Add stats command [\#55](https://github.com/JacobEvelyn/friends/pull/55) ([JacobEvelyn](https://github.com/JacobEvelyn))
13
+
3
14
  ## [v0.8](https://github.com/JacobEvelyn/friends/tree/v0.8) (2016-01-06)
4
15
  [Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.7...v0.8)
5
16
 
@@ -4,10 +4,10 @@ These are steps for the maintainer to take to release a new version of this gem.
4
4
 
5
5
  1. On the `master` branch, update the `VERSION` constant in
6
6
  `lib/friends/version.rb`.
7
- 2. Commit the change (`git commit -m 'Bump to vX.X'`).
7
+ 2. Commit the change (`git add -A && git commit -m 'Bump to vX.X'`).
8
8
  3. Add a tag (`git tag -am "vX.X" vX.X`).
9
9
  4. `git push && git push --tags`
10
- 5. `github_changelog_generator && git commit -m 'Update CHANGELOG for vX.X'`
10
+ 5. `github_changelog_generator && git add -A && git commit -m 'Update CHANGELOG for vX.X'`
11
11
  6. `git push`
12
12
  7. `gem build friends.gemspec && gem push *.gem && rm *.gem`
13
13
  8. Celebrate!
@@ -197,6 +197,16 @@ command :clean do |clean|
197
197
  end
198
198
  end
199
199
 
200
+ desc "List all stats"
201
+ command :stats do |stats|
202
+ stats.action do
203
+ puts "Total activities: #{@introvert.total_activities}"
204
+ puts "Total friends: #{@introvert.total_friends}"
205
+ days = @introvert.elapsed_days
206
+ puts "Total time elapsed: #{days} day#{'s' if days != 1}"
207
+ end
208
+ end
209
+
200
210
  # Before each command, clean up all arguments and create the global Introvert.
201
211
  pre do |global_options, _, options|
202
212
  final_options = global_options.merge!(options).select do |key, _|
@@ -299,6 +299,24 @@ module Friends
299
299
  end
300
300
  end
301
301
 
302
+ # @return [Integer] the total number of friends
303
+ def total_friends
304
+ @friends.size
305
+ end
306
+
307
+ # @return [Integer] the total number of activities
308
+ def total_activities
309
+ @activities.size
310
+ end
311
+
312
+ # @return [Integer] the number of days elapsed between
313
+ # the first and last activity
314
+ def elapsed_days
315
+ return 0 if @activities.size < 2
316
+ sorted_activities = @activities.sort
317
+ (sorted_activities.first.date - sorted_activities.last.date).to_i
318
+ end
319
+
302
320
  private
303
321
 
304
322
  # Process the friends.md file and store its contents in internal data
@@ -1,3 +1,3 @@
1
1
  module Friends
2
- VERSION = "0.8"
2
+ VERSION = "0.9"
3
3
  end
@@ -75,13 +75,17 @@ describe Friends::Activity do
75
75
  describe "#highlight_friends" do
76
76
  # Add helpers to set internal states for friends and activities.
77
77
  def stub_friends(val)
78
+ old_val = introvert.instance_variable_get(:@friends)
78
79
  introvert.instance_variable_set(:@friends, val)
79
80
  yield
81
+ introvert.instance_variable_set(:@friends, old_val)
80
82
  end
81
83
 
82
84
  def stub_activities(val)
85
+ old_val = introvert.instance_variable_get(:@activities)
83
86
  introvert.instance_variable_set(:@activities, val)
84
87
  yield
88
+ introvert.instance_variable_set(:@activities, old_val)
85
89
  end
86
90
 
87
91
  let(:friends) { [friend1, friend2] }
@@ -8,13 +8,17 @@ describe Friends::Introvert do
8
8
 
9
9
  # Add helpers to set internal states for friends and activities.
10
10
  def stub_friends(val)
11
+ old_val = introvert.instance_variable_get(:@friends)
11
12
  introvert.instance_variable_set(:@friends, val)
12
13
  yield
14
+ introvert.instance_variable_set(:@friends, old_val)
13
15
  end
14
16
 
15
17
  def stub_activities(val)
18
+ old_val = introvert.instance_variable_get(:@activities)
16
19
  introvert.instance_variable_set(:@activities, val)
17
20
  yield
21
+ introvert.instance_variable_set(:@activities, old_val)
18
22
  end
19
23
 
20
24
  let(:filename) { "test/tmp/friends.md" }
@@ -417,4 +421,40 @@ describe Friends::Introvert do
417
421
  end
418
422
  end
419
423
  end
424
+
425
+ describe "#total_friends" do
426
+ it "returns 0 when there are no friends" do
427
+ introvert.total_friends.must_equal 0
428
+ end
429
+
430
+ it "returns the total number of friends" do
431
+ stub_friends(friends) do
432
+ introvert.total_friends.must_equal friends.size
433
+ end
434
+ end
435
+ end
436
+
437
+ describe "#total_activities" do
438
+ it "returns 0 when there are no activities" do
439
+ introvert.total_activities.must_equal 0
440
+ end
441
+
442
+ it "returns the total number of activities" do
443
+ stub_activities(activities) do
444
+ introvert.total_activities.must_equal activities.size
445
+ end
446
+ end
447
+ end
448
+
449
+ describe "#elapsed_days" do
450
+ it "return 0 elapsed days when there are no activities" do
451
+ introvert.elapsed_days.must_equal 0
452
+ end
453
+
454
+ it "returns the number of days between the first and last activity" do
455
+ stub_activities(activities) do
456
+ introvert.elapsed_days.must_equal 1
457
+ end
458
+ end
459
+ end
420
460
  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.8'
4
+ version: '0.9'
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-06 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli