recollect 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/TODO +0 -6
- data/lib/recollect/recollect.rb +53 -16
- data/lib/recollect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c177e96f7e3949dbcef4f928ee87732e5d63236
|
4
|
+
data.tar.gz: 44d7d65b15fd1094cca08a241f803bb94b4d08eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ab03355d64eaa96130f471ba609c9bb25edefd3fd686869a13701318850357b91f2867b35267c3261d44aefbbce710a903c38ce2c81dd34ea37c9268209c954
|
7
|
+
data.tar.gz: c74cd30221dc64d570de0aa62d97e6d2e2f72bf9ec8f18feb9f185b861a62bf7ecdb7923b4c3a2f84ca89fe92059a890c94aa3f524ddef00cb44fe4e73583173
|
data/CHANGELOG
CHANGED
data/TODO
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
Known Issues:
|
2
|
-
|
3
|
-
- Add an open license
|
4
|
-
|
5
1
|
Feature Requests:
|
6
2
|
|
7
|
-
- Allow for the creation of nested snippets (sub-directories)
|
8
|
-
- when listing, count topics in subdirectories but don't list the individual snippets
|
9
3
|
- Add a search functionality that lists the snippet(s) containing the item searched for along with any matching content lines
|
data/lib/recollect/recollect.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module Recollect
|
4
5
|
class Recollection
|
@@ -11,6 +12,7 @@ module Recollect
|
|
11
12
|
@separator = '-------------------------'
|
12
13
|
@recollect_path = File.join(ENV['HOME'], '.recollections')
|
13
14
|
FileUtils.mkdir_p(@recollect_path)
|
15
|
+
@debug = ENV['DEBUG']
|
14
16
|
end
|
15
17
|
|
16
18
|
def usage(msg = nil)
|
@@ -19,42 +21,67 @@ module Recollect
|
|
19
21
|
puts 'Recollect manages a series of things worth remembering "recollections" as a series of'
|
20
22
|
puts "text files.\n\n"
|
21
23
|
puts ' Actions: list, new, edit, or <name> where <name> is the recollection to be displayed.'
|
22
|
-
puts ' list
|
24
|
+
puts ' list [category] - provides a listing of all available recollections.'
|
25
|
+
puts ' use [category] to specify a subdirectory'
|
23
26
|
puts " name - displays the recollection matching 'name'"
|
24
|
-
puts ' new
|
25
|
-
puts ' edit
|
26
|
-
puts ' remove
|
27
|
+
puts ' new <name> - creates a new recollection'
|
28
|
+
puts ' edit <name> - modifies an existing recollection'
|
29
|
+
puts ' remove <name> - removes a recollection'
|
27
30
|
puts "\nNote: #{@reserved} are reserved and cannot be the name"
|
28
31
|
puts 'of a recollection.'
|
29
32
|
exit 1
|
30
33
|
end
|
34
|
+
|
35
|
+
def debug(msg)
|
36
|
+
puts msg if @debug == '1' or @debug == 'true'
|
37
|
+
end
|
31
38
|
|
32
|
-
def recollection_names
|
33
|
-
|
39
|
+
def recollection_names(search_path = @recollect_path)
|
40
|
+
rec = []
|
41
|
+
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)
|
47
|
+
rec << out
|
48
|
+
end
|
49
|
+
rec
|
34
50
|
end
|
35
51
|
|
36
|
-
def recollections
|
37
|
-
|
52
|
+
def recollections(search_path = @recollect_path)
|
53
|
+
Dir.glob(File.join(search_path, '**/*')).select { |f| f unless File.directory?(f) }
|
38
54
|
end
|
39
55
|
|
40
56
|
def verify_name(item = @name)
|
41
57
|
unless item_exists?(item)
|
42
|
-
puts "Unable to find a
|
43
|
-
|
58
|
+
puts "**** Unable to find a recollection matching '#{item}'"
|
59
|
+
if File.directory?(File.join(@recollect_path, item))
|
60
|
+
puts "Here are the contents of that category:"
|
61
|
+
list_recollections(item)
|
62
|
+
exit
|
63
|
+
else
|
64
|
+
usage
|
65
|
+
end
|
44
66
|
end
|
45
67
|
end
|
46
68
|
|
47
69
|
def item_exists?(item)
|
48
70
|
recollections.find { |e| /#{item}\./ =~ e }
|
49
71
|
end
|
50
|
-
|
72
|
+
|
51
73
|
def write_file
|
52
|
-
|
74
|
+
fullPath = File.join(@recollect_path, @name) + '.txt'
|
75
|
+
subdir = File.dirname(fullPath)
|
76
|
+
FileUtils.mkdir_p(subdir) unless subdir == '.'
|
77
|
+
`#{ENV['EDITOR']} #{fullPath}`
|
53
78
|
end
|
54
79
|
|
55
|
-
def list_recollections
|
80
|
+
def list_recollections(local_name = @name)
|
81
|
+
location = @recollect_path
|
82
|
+
location = File.join(@recollect_path, local_name) unless local_name.nil?
|
56
83
|
puts "Available recollections:\n#{@separator}"
|
57
|
-
puts recollection_names.map { |r| ' ' + r }
|
84
|
+
puts recollection_names(location).map { |r| ' ' + r }
|
58
85
|
end
|
59
86
|
|
60
87
|
def new_recollection
|
@@ -70,13 +97,23 @@ module Recollect
|
|
70
97
|
|
71
98
|
def remove_recollection
|
72
99
|
verify_name
|
73
|
-
|
100
|
+
if confirm?
|
101
|
+
File.delete(File.join(@recollect_path, @name) + '.txt')
|
102
|
+
cleanup_path(File.dirname(File.join(@recollect_path, @name)))
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def cleanup_path(path)
|
107
|
+
if path != @recollect_path && Dir["#{path}/*"].empty?
|
108
|
+
debug "removing #{path}..."
|
109
|
+
FileUtils.rmdir(path)
|
110
|
+
cleanup_path(File.dirname(path))
|
111
|
+
end
|
74
112
|
end
|
75
113
|
|
76
114
|
def print_recollection
|
77
115
|
verify_name(@action)
|
78
116
|
puts @separator
|
79
|
-
#puts `cat #{File.join(@recollect_path, @action) + '.*'}`
|
80
117
|
File.open(File.join(@recollect_path, @action) + '.txt', 'r') do |f|
|
81
118
|
f.each_line do |line|
|
82
119
|
puts line
|
data/lib/recollect/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2017-04-29 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
|