friends 0.15 → 0.16

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: 1fd5cb3c9a9b913b0772d731f872709820e5fa12
4
- data.tar.gz: 99b28c2a79ae11aea5b49e75f328ed03433f94dd
3
+ metadata.gz: c928a672142f62f482efa128ae2d09e8bb724fd4
4
+ data.tar.gz: 72d50a764d49a98b1d0e227817536a87274c9588
5
5
  SHA512:
6
- metadata.gz: b8aba3f30dfc6de57c2d98a79b8fa3e131458b199c25e3bfff960ec0011069040844a90580848b10e255fb869ab2843e0ab941daa85c390e69e3ba74dbe650ce
7
- data.tar.gz: f9491efb85eed54694805e080c2e00ab5893687d60d78bc643cdccae64cc3081139ea5333e8a9d5d99ba0861e9c3b5586a59156f81b6766d2facbc1ca9eeee65
6
+ metadata.gz: 1cfd5df61aa2f136dc49117a6e7bab7fd4b7c28b776885d564d59c4ffffe0a5c5a92ca04f7557b2a2a214dc6eaefbffc47e23003fd4d658a3d62eff03047c311
7
+ data.tar.gz: dc9e3a6aeac267ca1ab720936d170cf921224a637b8a9ae96da2672acc5bfe74873810825d53138d24082303e1c9ec5057aeea1ae4110ad80be72ed4f9079567
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.16](https://github.com/JacobEvelyn/friends/tree/v0.16) (2016-03-23)
4
+ [Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.15...v0.16)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Allow `graph` without arguments to graph all activities [\#83](https://github.com/JacobEvelyn/friends/issues/83)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - Allow `graph` without arguments to graph all activities \(Closes \#83\) [\#85](https://github.com/JacobEvelyn/friends/pull/85) ([andypearson](https://github.com/andypearson))
13
+
3
14
  ## [v0.15](https://github.com/JacobEvelyn/friends/tree/v0.15) (2016-03-11)
4
15
  [Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.14...v0.15)
5
16
 
@@ -222,4 +233,4 @@
222
233
  ## [v0.0.1](https://github.com/JacobEvelyn/friends/tree/v0.0.1) (2014-12-11)
223
234
 
224
235
 
225
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
236
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -179,11 +179,15 @@ module Friends
179
179
  # and last month in which activities for the given friend have been
180
180
  # recorded.
181
181
  # @raise [FriendsError] if 0 of 2+ friends match the given name
182
- def graph(name:)
183
- friend = friend_with_name_in(name) # Find the friend by name.
182
+ def graph(name: nil)
183
+ if name
184
+ friend = friend_with_name_in(name) # Find the friend by name.
184
185
 
185
- # Filter out activities that don't include the given friend.
186
- acts = @activities.select { |act| act.includes_friend?(friend: friend) }
186
+ # Filter out activities that don't include the given friend.
187
+ acts = @activities.select { |act| act.includes_friend?(friend: friend) }
188
+ else
189
+ acts = @activities
190
+ end
187
191
 
188
192
  # Initialize the table of activities to have all of the months of that
189
193
  # friend's activity range (including months in the middle of the range
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Friends
3
- VERSION = "0.15".freeze
3
+ VERSION = "0.16".freeze
4
4
  end
@@ -387,6 +387,26 @@ describe Friends::Introvert do
387
387
  describe "#graph" do
388
388
  subject { introvert.graph(name: friend_name) }
389
389
 
390
+ let(:activities) do
391
+ [
392
+ Friends::Activity.new(
393
+ str: "2016-04-01: Lunch with **George Washington Carver**."
394
+ ),
395
+
396
+ # Create another activity with a gap of over a month between it and
397
+ # the next activity, so we can test that we correctly return data for
398
+ # months in the range with no activities.
399
+ Friends::Activity.new(
400
+ str: "2016-02-01: Called **George Washington Carver**."
401
+ ),
402
+
403
+ # Create an activity that doesn't involve our friend name.
404
+ Friends::Activity.new(
405
+ str: "2016-01-01: Called **Betsy Ross** on the phone."
406
+ )
407
+ ]
408
+ end
409
+
390
410
  describe "when friend name is invalid" do
391
411
  let(:friend_name) { "Oscar the Grouch" }
392
412
 
@@ -405,49 +425,34 @@ describe Friends::Introvert do
405
425
  end
406
426
  end
407
427
 
428
+ describe "when friend is empty" do
429
+ let(:friend_name) { nil }
430
+
431
+ it "returns a hash of months and frequencies" do
432
+ stub_friends(friends) do
433
+ stub_activities(activities) do
434
+ subject.must_equal({
435
+ "Jan 2016" => 1,
436
+ "Feb 2016" => 1,
437
+ "Mar 2016" => 0,
438
+ "Apr 2016" => 1
439
+ })
440
+ end
441
+ end
442
+ end
443
+ end
444
+
408
445
  describe "when friend name is valid" do
409
446
  let(:friend_name) { "George" }
410
- let(:activities) do
411
- [
412
- Friends::Activity.new(
413
- str: "Lunch with **George Washington Carver**."
414
- ),
415
-
416
- # Create another activity with a gap of over a month between it and
417
- # the next activity, so we can test that we correctly return data for
418
- # months in the range with no activities.
419
- Friends::Activity.new(
420
- str: "70 days ago: Called **George Washington Carver**."
421
- ),
422
-
423
- # Create an activity that doesn't involve our friend name.
424
- Friends::Activity.new(
425
- str: "150 days ago: Called **Betsy Ross** on the phone."
426
- )
427
- ]
428
- end
429
447
 
430
448
  it "returns a hash of months and frequencies" do
431
449
  stub_friends(friends) do
432
450
  stub_activities(activities) do
433
- strftime_format = Friends::Introvert::GRAPH_DATE_FORMAT
434
-
435
- first = activities[0]
436
- second = activities[1]
437
- months = (second.date..first.date).map do |date|
438
- date.strftime(strftime_format)
439
- end.uniq
440
-
441
- # Make sure all of the months are in our output data set (even the
442
- # months with no relevant activity). This also checks that the
443
- # irrelevant activity is not in our data set.
444
- subject.keys.must_equal(months)
445
-
446
- # Check that the activities for George are recorded, and that all
447
- # other months have no activities recorded.
448
- subject[first.date.strftime(strftime_format)].must_equal 1
449
- subject[second.date.strftime(strftime_format)].must_equal 1
450
- subject.values.inject(:+).must_equal 2
451
+ subject.must_equal({
452
+ "Feb 2016" => 1,
453
+ "Mar 2016" => 0,
454
+ "Apr 2016" => 1
455
+ })
451
456
  end
452
457
  end
453
458
  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.15'
4
+ version: '0.16'
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-03-11 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic