recollect 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0600b7dae82a9c3853a28f73ce154cdd77a105ea
4
- data.tar.gz: b2df4c99b9c99c2aee08e051cf07f0042b6f63e1
3
+ metadata.gz: e3d00282c17fba86e18ad631460ffcc5cc226e76
4
+ data.tar.gz: a59f90c81d71381aa96892d9d8ee3505faf85538
5
5
  SHA512:
6
- metadata.gz: ae745ccda2932e8fb783321a627f0875cfdbbcf5e7385ea9c6729efca42ee77f872ac1e7ddb64d414a3e764524d383e5b1a7e697e9a6c79da6c5dbab53e0c94d
7
- data.tar.gz: 32eba3f3a177b06d1e3beb8bc6593be4a8d4a989f24d41b8258d9f4dcceeae253073c5fecdd92804e11a447d6e747b42789ac06da749ae0543fca07fed098fc1
6
+ metadata.gz: '084a527836009242fc5658f36dccc22131dede1092d1bcfc68e171c928f006e648b74cc364d1c35f0fb6d28f0c213600075fbe64826016ee8ae08d9a95158871'
7
+ data.tar.gz: 7395a729ae2753b11a1da054191f8e9bf0d1ff745b78985b00688e6277f5bf8ec9f9374522eb677bcea257576f82a4ec45a8ded1544f9074e6c233f90bb390cb
data/README.md CHANGED
@@ -7,9 +7,13 @@ A simple tool for creating, managing, and viewing snippets, notes, or pretty muc
7
7
 
8
8
  gem install recollect
9
9
 
10
- If you haven't already, you should set your EDITOR. On OSX you can set it to Textmate with a command like:
11
10
 
12
- echo 'export EDITOR="mate -w" >> ~/.bash_profile
11
+ ### Search Functions
12
+ Recollect includes both a `search` directive and a recollection matching capability.
13
+
14
+ The search capability looks inside of files for a specific search string using a line match (`=~ /string/`).
15
+
16
+ The recollection match will try to find similar recollection names when showing a recollection or when using edit, remove, or append. When only one match is found the user is prompted to confirm this is the recollection intended; on confirmation the requested action will be executed. When multiple matches are found they will be displayed as suggestions.
13
17
 
14
18
  ### Usage
15
19
 
@@ -30,4 +34,38 @@ If you haven't already, you should set your EDITOR. On OSX you can set it to Tex
30
34
  Note: ["new", "edit", "remove", "help", "search", "append"] are reserved and cannot be the name
31
35
  of a recollection.
32
36
 
33
- Version: 0.1.0
37
+ Version: 0.2.0
38
+
39
+ ### Examples
40
+
41
+ If you haven't already, you should set your EDITOR. On OSX you can set it to Textmate with a command like:
42
+
43
+ echo 'export EDITOR="mate -w" >> ~/.bash_profile
44
+
45
+ ##### Create a new recollection named git
46
+ recollect new git # edit, save, and close the editor
47
+
48
+ ##### List the available recollections
49
+ recollect list
50
+
51
+ ##### List the available recollections under mysql/
52
+ recollect list mysql
53
+
54
+ ##### Edit the git recollection
55
+ recollect edit git # edit, save, and close the editor
56
+
57
+ ##### Display the git recollection
58
+ recollect git
59
+
60
+ ##### Search for recollections containing 'postgres'
61
+ recollect search 'postgres'
62
+
63
+ ##### Find with a partial recollection name
64
+ recollect ra
65
+
66
+ > **** Unable to find a recollection matching 'ra'
67
+ > You might have meant:
68
+ > raid
69
+ > rails
70
+ > unicorn/rack
71
+
@@ -5,12 +5,12 @@ require 'version'
5
5
  module Recollect
6
6
  class Recollection
7
7
  def initialize(args)
8
- @reserved = %w[new edit remove help search append]
8
+ @reserved = %w[new edit remove help list search append]
9
9
  @action, @name, @append_string = args
10
10
  usage unless args.length >= 1 && args.length <= 3
11
11
  usage if @action == 'append' && args.length != 3
12
12
  usage if @action != 'append' && args.length > 2
13
- usage if @reserved.include?(@action) && args.length < 2
13
+ usage if @reserved.include?(@action) && args.length < 2 && @action != 'list'
14
14
  usage if args.length == 2 && @reserved.include?(@name)
15
15
  @separator = '-------------------------'
16
16
  @recollect_path = File.join(ENV['HOME'], '.recollections')
@@ -66,10 +66,22 @@ module Recollect
66
66
  def verify_name(item = @name)
67
67
  unless item_exists?(item)
68
68
  puts "**** Unable to find a recollection matching '#{item}'"
69
+ similar = find_similar(item)
69
70
  if File.directory?(File.join(@recollect_path, item))
70
71
  puts "Here are the contents of that category:"
71
72
  list_recollections(item)
72
73
  exit
74
+ elsif similar.length == 1
75
+ puts "Did you mean: '#{nice_name(similar.first)}' [Y/n]?"
76
+ if confirm?
77
+ @name = nice_name(similar.first)
78
+ else
79
+ exit
80
+ end
81
+ elsif similar.length > 1
82
+ puts "You might have meant:"
83
+ similar.each { |s| puts " #{nice_name(s)}" }
84
+ exit
73
85
  else
74
86
  usage
75
87
  end
@@ -80,6 +92,10 @@ module Recollect
80
92
  recollections.find { |e| /#{item}\./ =~ e }
81
93
  end
82
94
 
95
+ def find_similar(item)
96
+ recollections.reject { |e| e unless /\b#{item}/ =~ nice_name(e) }
97
+ end
98
+
83
99
  def write_file
84
100
  fullPath = File.join(@recollect_path, @name) + '.txt'
85
101
  subdir = File.dirname(fullPath)
@@ -117,6 +133,7 @@ module Recollect
117
133
 
118
134
  def remove_recollection
119
135
  verify_name
136
+ puts "Are you sure you want to remove #{@name} [Y/n]?"
120
137
  if confirm?
121
138
  File.delete(File.join(@recollect_path, @name) + '.txt')
122
139
  cleanup_path(File.dirname(File.join(@recollect_path, @name)))
@@ -132,9 +149,9 @@ module Recollect
132
149
  end
133
150
 
134
151
  def print_recollection
135
- verify_name(@action)
152
+ verify_name
136
153
  puts @separator
137
- File.open(File.join(@recollect_path, @action) + '.txt', 'r') do |f|
154
+ File.open(File.join(@recollect_path, @name) + '.txt', 'r') do |f|
138
155
  f.each_line do |line|
139
156
  puts line
140
157
  end
@@ -159,7 +176,6 @@ module Recollect
159
176
  end
160
177
 
161
178
  def confirm?
162
- puts "Are you sure you want to remove #{@name} [Y/n]?"
163
179
  a = $stdin.gets.chomp.downcase
164
180
  a == 'y' ? true : false
165
181
  end
@@ -179,6 +195,7 @@ module Recollect
179
195
  when 'append'
180
196
  append_recollection
181
197
  else
198
+ @name = @action
182
199
  print_recollection
183
200
  end
184
201
  end
@@ -1,3 +1,3 @@
1
1
  module Recollect
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recollect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Poland