friends 0.3 → 0.4

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: 014d82e8189c2cf8442af3e9058d56dbfdfb0fd3
4
- data.tar.gz: a4a10982b5139cbe3b800aea6f984e32763beea9
3
+ metadata.gz: a63257ad72fd3c60181fca07b37ebba7833e2d00
4
+ data.tar.gz: 41fd48ad81de9249985c62979b112f03f9e90bdf
5
5
  SHA512:
6
- metadata.gz: ac424ae74a5b3640c9374d4c7a9691d8e5305be1afba2a97f5714dfb662ffa2ea50238c6e30beb54ce48132dc610d8371229d9250a92e349772a5840ea1c9cf1
7
- data.tar.gz: 8df418e8482b5d27eeb6823d870cabe1b818931628283e64c74cdb6d8ade3a78ed0371a2bf16415d08cc3e45492cd92ba88db78e0ec227ea138e69ff42c51cd7
6
+ metadata.gz: bb6b46934923c9973dd04c8eec66b03a455cddbec686e6d6d0b5c353fb624c99cb7dc2f3e95688e742b6e14f5709b11b0bbe30fa0587e219133ea5b156df1516
7
+ data.tar.gz: 15bab42fc57ad1ce636223cf1595ee0d4cee6390d1be162b68bf1b6701fea611781984ecc999e7d475e21e5498b7aa7fa8c3a47c398918c4e2f67bb42cb71429
data/README.md CHANGED
@@ -60,6 +60,18 @@ Or get an **interactive prompt** by just typing `friends add activity`, with or
60
60
  $ friends add activity 2015-11-01
61
61
  2015-11-01: <type description here>
62
62
  ```
63
+ You can escape the names of friends you don't want `friends` to match with a backslash:
64
+ ```
65
+ $ friends add activity "2015-11-01: Grace and I went to \Marie's Diner. \George had to cancel at the last minute."
66
+ Activity added: "2015-11-01: Grace Hopper and I went to Marie's Diner. George had to cancel at the last minute."
67
+ ```
68
+ ##### Suggest a friend to do something with:
69
+ ```
70
+ $ friends suggest
71
+ Distant friend: Marie Curie
72
+ Moderate friend: Grace Hopper
73
+ Close friend: George Washington Carver
74
+ ```
63
75
  ##### List the activities you've recorded:
64
76
  ```
65
77
  $ friends list activities
@@ -104,6 +116,11 @@ George Washington Carver
104
116
  Grace Hopper
105
117
  Marie Curie
106
118
  ```
119
+ ##### Update to the latest version:
120
+ ```
121
+ $ friends update
122
+ Updated to friends 0.3
123
+ ```
107
124
  ### Global options:
108
125
 
109
126
  ##### --quiet
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # Todo:
4
- # - Create file if none exists.
5
4
  # - Split out serialization into separate repository.
6
5
  # - Add auto check for updates.
7
6
  # - Allow friends to have nicknames.
8
7
  # - Allow easy editing of most recent entry.
9
- # - Allow escape char to prevent automatching. ("\Zane wasn't there.")
10
8
 
11
9
  require "gli"
12
10
  require "paint"
@@ -37,6 +35,27 @@ switch [:clean],
37
35
  negatable: false,
38
36
  desc: "Force a clean write of the friends file"
39
37
 
38
+ command :update do |update|
39
+ update.action do
40
+ search = `gem search friends`
41
+ if match = search.match(/^friends\s\(([^\)]+)\)$/)
42
+ remote_version = match[1]
43
+ if remote_version.to_r > Friends::VERSION.to_r
44
+ `gem update friends && gem cleanup friends`
45
+ if $?.success?
46
+ puts Paint["Updated to friends #{remote_version}", :bold, :green]
47
+ else
48
+ puts Paint[
49
+ "Error updating to friends version #{remote_version}", :bold, :red
50
+ ]
51
+ end
52
+ else
53
+ puts Paint["Already up-to-date (#{Friends::VERSION})", :bold, :green]
54
+ end
55
+ end
56
+ end
57
+ end
58
+
40
59
  desc "Lists friends or activities"
41
60
  command :list do |list|
42
61
  list.desc "List all friends"
data/friends.md CHANGED
@@ -1,4 +1,5 @@
1
1
  ### Activities:
2
+ - 2015-11-01: **Grace Hopper** and I went to Marie's Diner. George had to cancel at the last minute.
2
3
  - 2015-01-04: Got lunch with **Grace Hopper** and **George Washington Carver**.
3
4
  - 2014-12-31: Celebrated the new year with **Marie Curie**.
4
5
  - 2014-11-15: Talked to **George Washington Carver** on the phone for an hour.
@@ -122,6 +122,10 @@ module Friends
122
122
  "#{match.post_match}"
123
123
  end
124
124
  end
125
+
126
+ # Lastly, we remove any backslashes, as these are used to escape friends'
127
+ # names that we don't want to match.
128
+ @description.gsub!("\\", "")
125
129
  end
126
130
 
127
131
  # @param friend [Friend] the friend to test
@@ -58,6 +58,10 @@ module Friends
58
58
  # We generously allow any amount of whitespace between parts of a name.
59
59
  splitter = "\\s+"
60
60
 
61
+ # We don't want to match names that are "escaped" with a leading
62
+ # backslash.
63
+ no_leading_backslash = "(?<!\\\\)"
64
+
61
65
  # We don't want to match names that are directly touching double asterisks
62
66
  # as these are treated as sacred by our program.
63
67
  no_leading_asterisks = "(?<!\\*\\*)"
@@ -72,6 +76,7 @@ module Friends
72
76
 
73
77
  [chunks, [chunks.first]].map do |words|
74
78
  Regexp.new(
79
+ no_leading_backslash +
75
80
  no_leading_asterisks +
76
81
  no_leading_alphabeticals +
77
82
  words.join(splitter) +
@@ -1,3 +1,3 @@
1
1
  module Friends
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
@@ -140,6 +140,16 @@ describe Friends::Activity do
140
140
  end
141
141
  end
142
142
 
143
+ describe "when name is escaped with a backslash" do
144
+ # We have to use two backslashes here because that's how Ruby encodes one.
145
+ let(:description) { "Dinner with \\Elizabeth Cady Stanton." }
146
+ it "does not match a friend and removes the backslash" do
147
+ subject
148
+ # No match found.
149
+ activity.description.must_equal "Dinner with Elizabeth Cady Stanton."
150
+ end
151
+ end
152
+
143
153
  describe "when name has leading asterisks" do
144
154
  let(:description) { "Dinner with **Elizabeth Cady Stanton." }
145
155
  it "does not match a friend" do
@@ -71,8 +71,8 @@ describe Friends::Friend do
71
71
 
72
72
  it "generates appropriate regexes" do
73
73
  subject.must_equal [
74
- /(?<!\*\*)(?<![A-z])Jacob\s+Evelyn(?![A-z])(?!\*\*)/i,
75
- /(?<!\*\*)(?<![A-z])Jacob(?![A-z])(?!\*\*)/i
74
+ /(?<!\\)(?<!\*\*)(?<![A-z])Jacob\s+Evelyn(?![A-z])(?!\*\*)/i,
75
+ /(?<!\\)(?<!\*\*)(?<![A-z])Jacob(?![A-z])(?!\*\*)/i
76
76
  ]
77
77
  end
78
78
  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.3'
4
+ version: '0.4'
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-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli