friends 0.45 → 0.46

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: eb0258b3dca86e0aba3b852b4d58462e2e3570f6
4
- data.tar.gz: cbb2091ca9b77764999b5667b4a00c309ce1263d
3
+ metadata.gz: 6e2e73301c76c3d799abebb73a9e1f53a1233783
4
+ data.tar.gz: 929e11c8180395acf1338c316d3b0fd6f657ffd4
5
5
  SHA512:
6
- metadata.gz: '052706180f25b59c73618c545e659becf4a1b9295ba3bb4e8478b7279a0c7460c5e974eafc8627c3f5745c5236ba37ff31648b4129b9a70780bc4d55f83cac96'
7
- data.tar.gz: 4e0819d8bcab2152a883853e5b2b6899660faa8eca350dfa73085658ad1e5b4a2fe95be97d4006f8fd5d23d11865a25a7cae66b8c8a78184ddc6b0c9406bef50
6
+ metadata.gz: 3ad10cbe59e1932947ce389c9fdaa16cd08b326d4129486328746801207c8e51b45c4db7319a7ee59742e0555360b2789d9e6a19a3bdaeebc04da0f88ad3a868
7
+ data.tar.gz: 1ba1ab37eec7c942cb44db4285b822a5fa0083e1a564375b6eec6caa0c0ff921e7cfc355d9200a7f120f1a76f77a5d452492a78478e2b152e84dbcbafdbe36bc
@@ -14,6 +14,17 @@ making a small donation (🙏) to show you appreciate its continued development.
14
14
 
15
15
  👆 Donate with these buttons! 👆
16
16
 
17
+ ## [v0.46](https://github.com/JacobEvelyn/friends/tree/v0.46) (2019-01-27)
18
+ [Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.45...v0.46)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - Data overwritten when --filename is not specified [\#231](https://github.com/JacobEvelyn/friends/issues/231)
23
+
24
+ **Merged pull requests:**
25
+
26
+ - Fix file-reading issues with default file [\#232](https://github.com/JacobEvelyn/friends/pull/232) ([JacobEvelyn](https://github.com/JacobEvelyn))
27
+
17
28
  ## [v0.45](https://github.com/JacobEvelyn/friends/tree/v0.45) (2019-01-15)
18
29
  [Full Changelog](https://github.com/JacobEvelyn/friends/compare/v0.44...v0.45)
19
30
 
@@ -23,7 +23,8 @@ module Friends
23
23
 
24
24
  # @param filename [String] the name of the friends Markdown file
25
25
  def initialize(filename:)
26
- @filename = filename
26
+ @user_facing_filename = filename
27
+ @expanded_filename = File.expand_path(filename)
27
28
  @output = []
28
29
 
29
30
  # Read in the input file. It's easier to do this now and optimize later
@@ -59,7 +60,7 @@ module Friends
59
60
  end
60
61
  end
61
62
 
62
- File.open(File.expand_path(@filename), "w") do |file|
63
+ File.open(@expanded_filename, "w") do |file|
63
64
  file.puts(ACTIVITIES_HEADER)
64
65
  stable_sort(@activities).each { |act| file.puts(act.serialize) }
65
66
  file.puts # Blank line separating activities from notes.
@@ -75,7 +76,7 @@ module Friends
75
76
 
76
77
  # This is a special-case piece of code that lets us print a message that
77
78
  # includes the filename when `friends clean` is called.
78
- @output << "File cleaned: \"#{@filename}\"" if clean_command
79
+ @output << "File cleaned: \"#{@user_facing_filename}\"" if clean_command
79
80
  end
80
81
 
81
82
  # Add a friend.
@@ -665,12 +666,12 @@ module Friends
665
666
  @notes = []
666
667
  @locations = []
667
668
 
668
- return unless File.exist?(@filename)
669
+ return unless File.exist?(@expanded_filename)
669
670
 
670
671
  state = :unknown
671
672
 
672
673
  # Loop through all lines in the file and process them.
673
- File.foreach(@filename).with_index(1) do |line, line_num|
674
+ File.foreach(@expanded_filename).with_index(1) do |line, line_num|
674
675
  line.chomp! # Remove trailing newline from each line.
675
676
 
676
677
  # Parse the line and update the parsing state.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Friends
4
- VERSION = "0.45".freeze
4
+ VERSION = "0.46".freeze
5
5
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "./test/helper"
4
+
5
+ # Since this touches the ~/friends.md file instead of a temp
6
+ # one, we only want to run it on our CI servers.
7
+ if ENV["TRAVIS"] == "true"
8
+ describe "default filename behavior" do
9
+ let(:filename) { File.expand_path("~/friends.md") }
10
+
11
+ after { File.delete(filename) }
12
+
13
+ # Since the filename is the system-wide one, we can't have
14
+ # more than one test that touches it, because multiple
15
+ # tests can run in parallel and might stomp on one another.
16
+ # Instead, we just run one test that exercises a lot.
17
+ # This test specifically checks for regressions akin to
18
+ # https://github.com/JacobEvelyn/friends/issues/231
19
+ it "creates a new file and adds to it multiple times" do
20
+ # File does not exist at first.
21
+ File.exist?(filename).must_equal false
22
+
23
+ `bundle exec bin/friends add friend Mohandas Karamchand Gandhi`
24
+ `bundle exec bin/friends add friend Sojourner Truth`
25
+ `bundle exec bin/friends add activity 1859-11-30: Lunch with **Harriet Tubman** in _Auburn_.`
26
+ `bundle exec bin/friends add note "1851-05-29: Sojourner Truth's speech"`
27
+
28
+ File.read(filename).must_equal <<-FILE
29
+ ### Activities:
30
+ - 1859-11-30: Lunch with **Harriet Tubman** in _Auburn_.
31
+
32
+ ### Notes:
33
+ - 1851-05-29: **Sojourner Truth**'s speech
34
+
35
+ ### Friends:
36
+ - Harriet Tubman
37
+ - Mohandas Karamchand Gandhi
38
+ - Sojourner Truth
39
+
40
+ ### Locations:
41
+ - Auburn
42
+ FILE
43
+ end
44
+ end
45
+ end
@@ -139,8 +139,8 @@ def line_added(expected)
139
139
  lines.size.must_equal(n_initial_lines + 1) # Line was added, not changed.
140
140
  end
141
141
 
142
- def clean_describe(desc, *additional_desc, &block)
143
- describe desc, *additional_desc do
142
+ def clean_describe(desc, &block)
143
+ describe desc do
144
144
  let(:filename) { "test/tmp/friends#{SecureRandom.uuid}.md" }
145
145
 
146
146
  before { File.write(filename, content) unless content.nil? }
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.45'
4
+ version: '0.46'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Evelyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-15 00:00:00.000000000 Z
11
+ date: 2019-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -246,6 +246,7 @@ files:
246
246
  - test/commands/stats_spec.rb
247
247
  - test/commands/suggest_spec.rb
248
248
  - test/commands/update_spec.rb
249
+ - test/default_file_spec.rb
249
250
  - test/editor
250
251
  - test/helper.rb
251
252
  - test/paging_spec.rb
@@ -302,6 +303,7 @@ test_files:
302
303
  - test/commands/stats_spec.rb
303
304
  - test/commands/suggest_spec.rb
304
305
  - test/commands/update_spec.rb
306
+ - test/default_file_spec.rb
305
307
  - test/editor
306
308
  - test/helper.rb
307
309
  - test/paging_spec.rb