topicz 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/topicz/commands/_index.rb +1 -0
- data/lib/topicz/commands/list_command.rb +31 -0
- data/lib/topicz/commands/repository_command.rb +5 -1
- data/lib/topicz/repository.rb +3 -1
- data/lib/topicz/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4caae007666aa94548df6d36d511bfeac735caa3
|
4
|
+
data.tar.gz: ae3b2c30457618799327904ffb2ddd40a52261ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1be6990fe23b2f6258d5d1198ba2c7c3e02564d947321a882973ef5dd5bdd3d8516054db89e71a787c01d77ca6f11bfc800cde06f0aff46697b132eb6bf2e9
|
7
|
+
data.tar.gz: 0c163f2d68371b7d28f4816bfceb744b1e5cee105ffd891b48a809f434fb1732928c32ea1cd9931031b061a8c333584bbfc56b80c0dee856e59f943e4b35a186
|
data/README.md
CHANGED
@@ -78,6 +78,8 @@ Topicz will do two things. First it will create an empty directory at the locati
|
|
78
78
|
|
79
79
|
Some commands call an external text editor, for example to edit journals and notes. By default Topicz will use the `EDITOR` environment variable. You can override it on a per-repository basis by defining an `editor` property in the configuration file.
|
80
80
|
|
81
|
+
Maybe you put some directories in the repositories that you want Topicz to ignore. No problem: define a property `excludes`, with either a single value or an array of values. Each value must be a regular expression. For example, I use `^_` to skip all directories that start with an underscore.
|
82
|
+
|
81
83
|
## Topic configuration
|
82
84
|
|
83
85
|
Each topic directory can have a `topic.yaml` file in it, which holds a YAML file describing that topic. It looks as follows:
|
@@ -3,6 +3,7 @@ module Topicz
|
|
3
3
|
COMMANDS = {
|
4
4
|
'init' => 'Initializes a new topic repository',
|
5
5
|
'create' => 'Creates a new topic',
|
6
|
+
'list' => 'Lists topics',
|
6
7
|
'path' => 'Prints the full path to a topic',
|
7
8
|
'journal' => 'Opens a (new) weekly journal entry for a topic',
|
8
9
|
'note' => 'Opens a new note for a topic',
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'repository_command'
|
2
|
+
|
3
|
+
module Topicz::Commands
|
4
|
+
|
5
|
+
class ListCommand < RepositoryCommand
|
6
|
+
|
7
|
+
def initialize(config_file = nil, arguments = [])
|
8
|
+
super(config_file)
|
9
|
+
@filter = arguments.join ' '
|
10
|
+
end
|
11
|
+
|
12
|
+
def option_parser
|
13
|
+
OptionParser.new do |options|
|
14
|
+
options.banner = 'Usage: list [<filter>]'
|
15
|
+
options.separator ''
|
16
|
+
options.separator 'Lists topics'
|
17
|
+
options.separator ''
|
18
|
+
options.separator 'The filter specifies the text to search on. The text is matched against the topic\'s: '
|
19
|
+
options.separator '- path on the filesystem'
|
20
|
+
options.separator '- id, if specified in the topic\'s topic.yaml file'
|
21
|
+
options.separator '- title, if specified in the topic\'s topic.yaml file'
|
22
|
+
options.separator '- aliases, if specified in the topic\'s topic.yaml file'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def execute
|
27
|
+
@repository.find_all(@filter).each { |topic| puts topic.title }
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -35,7 +35,11 @@ module Topicz::Commands
|
|
35
35
|
unless Dir.exist? directory
|
36
36
|
raise "Repository directory doesn't exist: #{directory}."
|
37
37
|
end
|
38
|
-
Topicz::Repository.new(directory)
|
38
|
+
Topicz::Repository.new(directory, process_excludes(@config['excludes']))
|
39
|
+
end
|
40
|
+
|
41
|
+
def process_excludes(excludes_config)
|
42
|
+
[excludes_config].compact.flatten
|
39
43
|
end
|
40
44
|
|
41
45
|
def find_exactly_one_topic(filter, strict)
|
data/lib/topicz/repository.rb
CHANGED
@@ -6,12 +6,14 @@ module Topicz
|
|
6
6
|
|
7
7
|
attr_reader :root
|
8
8
|
|
9
|
-
def initialize(root)
|
9
|
+
def initialize(root, exclude_filters = [])
|
10
10
|
@root = root
|
11
11
|
@topics = {}
|
12
12
|
errors = []
|
13
|
+
excludes = exclude_filters.map { | filter | Regexp.new(filter) }
|
13
14
|
Dir.foreach(root) do |path|
|
14
15
|
next if path.start_with?('.')
|
16
|
+
next if excludes.any? { | regexp | path =~ regexp }
|
15
17
|
next unless File.directory?(File.join(root, path))
|
16
18
|
topic = Topic.new(root, path)
|
17
19
|
if @topics.has_key?(topic.id)
|
data/lib/topicz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topicz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Oostindië
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zaru
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/topicz/commands/help_command.rb
|
124
124
|
- lib/topicz/commands/init_command.rb
|
125
125
|
- lib/topicz/commands/journal_command.rb
|
126
|
+
- lib/topicz/commands/list_command.rb
|
126
127
|
- lib/topicz/commands/note_command.rb
|
127
128
|
- lib/topicz/commands/path_command.rb
|
128
129
|
- lib/topicz/commands/report_command.rb
|