recollect 0.0.6 → 0.1.0

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: 8c177e96f7e3949dbcef4f928ee87732e5d63236
4
- data.tar.gz: 44d7d65b15fd1094cca08a241f803bb94b4d08eb
3
+ metadata.gz: 0600b7dae82a9c3853a28f73ce154cdd77a105ea
4
+ data.tar.gz: b2df4c99b9c99c2aee08e051cf07f0042b6f63e1
5
5
  SHA512:
6
- metadata.gz: 7ab03355d64eaa96130f471ba609c9bb25edefd3fd686869a13701318850357b91f2867b35267c3261d44aefbbce710a903c38ce2c81dd34ea37c9268209c954
7
- data.tar.gz: c74cd30221dc64d570de0aa62d97e6d2e2f72bf9ec8f18feb9f185b861a62bf7ecdb7923b4c3a2f84ca89fe92059a890c94aa3f524ddef00cb44fe4e73583173
6
+ metadata.gz: ae745ccda2932e8fb783321a627f0875cfdbbcf5e7385ea9c6729efca42ee77f872ac1e7ddb64d414a3e764524d383e5b1a7e697e9a6c79da6c5dbab53e0c94d
7
+ data.tar.gz: 32eba3f3a177b06d1e3beb8bc6593be4a8d4a989f24d41b8258d9f4dcceeae253073c5fecdd92804e11a447d6e747b42789ac06da749ae0543fca07fed098fc1
data/README.md CHANGED
@@ -16,13 +16,18 @@ If you haven't already, you should set your EDITOR. On OSX you can set it to Tex
16
16
  USAGE: recollect ACTION [arg]
17
17
  Recollect manages a series of things worth remembering "recollections" as a series of
18
18
  text files.
19
-
19
+
20
20
  Actions: list, new, edit, or <name> where <name> is the recollection to be displayed.
21
- list - provides a listing of all available recollections
21
+ list [category] - provides a listing of all available recollections.
22
+ use [category] to specify a subdirectory
22
23
  name - displays the recollection matching 'name'
23
- new [name] - creates a new recollection
24
- edit [name] - modifies an existing recollection
25
- remove [name] - removes a recollection
26
-
27
- Note: ["new", "edit", "remove", "help", "search"] are reserved and cannot be the name
24
+ new <name> - creates a new recollection
25
+ edit <name> - modifies an existing recollection
26
+ remove <name> - removes a recollection
27
+ search <searchstr> - searches all recollections for "searchstr"
28
+ append <name> <str> - appends <str> to the existing recollection <name>
29
+
30
+ Note: ["new", "edit", "remove", "help", "search", "append"] are reserved and cannot be the name
28
31
  of a recollection.
32
+
33
+ Version: 0.1.0
data/TODO CHANGED
@@ -1,3 +1,3 @@
1
1
  Feature Requests:
2
2
 
3
- - Add a search functionality that lists the snippet(s) containing the item searched for along with any matching content lines
3
+ - Let me know what you'd like to see next.
@@ -1,12 +1,15 @@
1
1
  require 'fileutils'
2
2
  require 'pathname'
3
+ require 'version'
3
4
 
4
5
  module Recollect
5
6
  class Recollection
6
7
  def initialize(args)
7
- @reserved = %w[new edit remove help search]
8
- usage unless args.length >= 1 && args.length <= 2
9
- @action, @name = args
8
+ @reserved = %w[new edit remove help search append]
9
+ @action, @name, @append_string = args
10
+ usage unless args.length >= 1 && args.length <= 3
11
+ usage if @action == 'append' && args.length != 3
12
+ usage if @action != 'append' && args.length > 2
10
13
  usage if @reserved.include?(@action) && args.length < 2
11
14
  usage if args.length == 2 && @reserved.include?(@name)
12
15
  @separator = '-------------------------'
@@ -27,8 +30,11 @@ module Recollect
27
30
  puts ' new <name> - creates a new recollection'
28
31
  puts ' edit <name> - modifies an existing recollection'
29
32
  puts ' remove <name> - removes a recollection'
33
+ puts ' search <searchstr> - searches all recollections for "searchstr"'
34
+ puts ' append <name> <str> - appends <str> to the existing recollection <name>'
30
35
  puts "\nNote: #{@reserved} are reserved and cannot be the name"
31
36
  puts 'of a recollection.'
37
+ puts "\nVersion: #{Recollect::VERSION}"
32
38
  exit 1
33
39
  end
34
40
 
@@ -39,15 +45,19 @@ module Recollect
39
45
  def recollection_names(search_path = @recollect_path)
40
46
  rec = []
41
47
  recollections(search_path).each do |r|
42
- abs = Pathname.new(File.expand_path(r))
43
- rel = abs.relative_path_from(Pathname.new(File.expand_path(search_path)))
44
- *p, f = rel.to_s.split('/')
45
- file = File.basename(f, File.extname(f))
46
- out = p.empty? ? file : File.join(p, file)
48
+ out = nice_name(r, search_path)
47
49
  rec << out
48
50
  end
49
51
  rec
50
52
  end
53
+
54
+ def nice_name(r, search_path = @recollect_path)
55
+ abs = Pathname.new(File.expand_path(r))
56
+ rel = abs.relative_path_from(Pathname.new(File.expand_path(search_path)))
57
+ *p, f = rel.to_s.split('/')
58
+ file = File.basename(f, File.extname(f))
59
+ p.empty? ? file : File.join(p, file)
60
+ end
51
61
 
52
62
  def recollections(search_path = @recollect_path)
53
63
  Dir.glob(File.join(search_path, '**/*')).select { |f| f unless File.directory?(f) }
@@ -76,6 +86,11 @@ module Recollect
76
86
  FileUtils.mkdir_p(subdir) unless subdir == '.'
77
87
  `#{ENV['EDITOR']} #{fullPath}`
78
88
  end
89
+
90
+ def append_file
91
+ fullPath = File.join(@recollect_path, @name) + '.txt'
92
+ File.open(fullPath, 'a') {|file| file.puts "#{@append_string}" }
93
+ end
79
94
 
80
95
  def list_recollections(local_name = @name)
81
96
  location = @recollect_path
@@ -94,6 +109,11 @@ module Recollect
94
109
  verify_name
95
110
  write_file
96
111
  end
112
+
113
+ def append_recollection
114
+ verify_name
115
+ append_file
116
+ end
97
117
 
98
118
  def remove_recollection
99
119
  verify_name
@@ -120,6 +140,23 @@ module Recollect
120
140
  end
121
141
  end
122
142
  end
143
+
144
+ def search_recollection
145
+ puts "Searching for '#{@name}'..."
146
+ puts @separator
147
+ count=0
148
+ recollections.map do |r|
149
+ File.open r do |file|
150
+ file.each_line do |line|
151
+ if line =~ /#{@name}/
152
+ puts "#{nice_name(r)} - #{line}"
153
+ count+=1
154
+ end
155
+ end
156
+ end
157
+ end
158
+ puts 'No results found!' if count == 0
159
+ end
123
160
 
124
161
  def confirm?
125
162
  puts "Are you sure you want to remove #{@name} [Y/n]?"
@@ -137,6 +174,10 @@ module Recollect
137
174
  edit_recollection
138
175
  when 'remove'
139
176
  remove_recollection
177
+ when 'search'
178
+ search_recollection
179
+ when 'append'
180
+ append_recollection
140
181
  else
141
182
  print_recollection
142
183
  end
@@ -1,3 +1,3 @@
1
1
  module Recollect
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,17 @@
1
+ Bash:
2
+ # change to previous directory
3
+ cd - # alternative to pushd/popd
4
+
5
+ # Repeat last command
6
+ !!
7
+
8
+ # Replace last command with a different command and re-run with same options
9
+ recollert list
10
+ ^recollert^recollect
11
+
12
+ # run command with previous command's arguments
13
+ mkdir /tmp/new
14
+ cd !!:*
15
+
16
+ # list only sub-directories
17
+ ls -d */
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recollect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Poland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-29 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Storage, Management and Retrieval of things you'd like to remember (recollect).
14
14
  email: recollect@tylerpoland.com
@@ -29,6 +29,7 @@ files:
29
29
  - lib/recollect/recollect.rb
30
30
  - lib/recollect/version.rb
31
31
  - recollect.gemspec
32
+ - samples/bash.txt
32
33
  homepage: http://github.com/tpoland/recollect
33
34
  licenses: []
34
35
  metadata: {}