topicz 0.2.0 → 0.3.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: 4caae007666aa94548df6d36d511bfeac735caa3
4
- data.tar.gz: ae3b2c30457618799327904ffb2ddd40a52261ba
3
+ metadata.gz: 844f63d69cda9f2348e86b1065278ee4c8e52c8c
4
+ data.tar.gz: a298c668f262047f91195c815902c17ad8427fa3
5
5
  SHA512:
6
- metadata.gz: db1be6990fe23b2f6258d5d1198ba2c7c3e02564d947321a882973ef5dd5bdd3d8516054db89e71a787c01d77ca6f11bfc800cde06f0aff46697b132eb6bf2e9
7
- data.tar.gz: 0c163f2d68371b7d28f4816bfceb744b1e5cee105ffd891b48a809f434fb1732928c32ea1cd9931031b061a8c333584bbfc56b80c0dee856e59f943e4b35a186
6
+ metadata.gz: ebcb89858126e21bbae8db0694d958c94031824196bfb6c0e883a92ed6e5cd23127d0f66279f985e1c93b502c399b10977946f56c9c726ffaa0b8f56c828fdf8
7
+ data.tar.gz: 9983d8ce2d7340f2fa93c0bc89b49bbd8d27ed5a1249dcd0c06b7dafdfd04dd6d036c0a7eae962b224637a64b8ba6ceef72fb12e8fcb35349aacf23a8872d6c2
data/README.md CHANGED
@@ -20,11 +20,13 @@ See below (*Development*) in case you’re working with a Git clone directly.
20
20
 
21
21
  init : Initializes a new topic repository
22
22
  create : Creates a new topic
23
+ list : List topics
23
24
  path : Prints the full path to a topic
24
25
  journal: Opens a (new) weekly journal entry for a topic
25
26
  note : Opens a new note for a topic
26
- alfred : Searches in Alfred Script Filter format
27
+ stats : Generates weekly statistics across all topics
27
28
  report : Generates a weekly report of all topics
29
+ alfred : Searches in Alfred Script Filter format
28
30
  help : Shows help about a command
29
31
 
30
32
  ## Background
@@ -56,7 +58,7 @@ A topic can certainly have other subdirectories than the ones shown above. These
56
58
 
57
59
  ### Documents and Reference Material
58
60
 
59
- The `Documents` and `Reference Material` directories speak for themselves. The first is for stuff I create, the second for stuff that others create. There are no rules as to the files and subdirectories in these directories, although I tend to prefix each filename with the date I created or received the file in `YYYY-mm-DD` format. But that’s just my way of keeping things organized.
61
+ The `Documents` and `Reference Material` directories speak for themselves. The first is for stuff I create, the second for stuff that others create. Files and subdirectories in these directories must have filenames that are prefixed with the date in `YYYY-mm-DD`. That keeps the files in the right order, and it makes the files show up in the `stats` command.
60
62
 
61
63
  ### Journal
62
64
 
@@ -101,7 +103,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
101
103
 
102
104
  ## Plans
103
105
 
104
- * Allow topics to be archived when no longer relevant.
106
+ * Allow topics to be archived and unarchived when no longer relevant.
105
107
  * Allow relationships between topics to be defined in the YAML files, and use these to generate graphs for Graphviz: `depends-on`, `part-of`, `relates-to`. The CLI will help to guarantee correctness, for example when archiving a topic, or when renaming one’s title and/or ID.
106
108
  * Allow metadata to be defined for each topic, like main stakeholders, categories and topic goals.
107
109
 
@@ -7,8 +7,9 @@ module Topicz
7
7
  'path' => 'Prints the full path to a topic',
8
8
  'journal' => 'Opens a (new) weekly journal entry for a topic',
9
9
  'note' => 'Opens a new note for a topic',
10
- 'alfred' => 'Searches in Alfred Script Filter format',
10
+ 'stats' => 'Generates weekly statistics across all topics',
11
11
  'report' => 'Generates a weekly report of all topics',
12
+ 'alfred' => 'Searches in Alfred Script Filter format',
12
13
  'help' => 'Shows help about a command',
13
14
  }
14
15
 
@@ -1,5 +1,4 @@
1
1
  require_relative 'repository_command'
2
- require 'json'
3
2
 
4
3
  module Topicz::Commands
5
4
 
@@ -10,7 +9,6 @@ module Topicz::Commands
10
9
  @week = Date.today.cweek
11
10
  @year = Date.today.cwyear
12
11
  option_parser.order! arguments
13
- @filter = arguments.join ' '
14
12
  end
15
13
 
16
14
  def option_parser
@@ -23,7 +21,7 @@ module Topicz::Commands
23
21
  @year = year.to_i
24
22
  end
25
23
  options.separator ''
26
- options.separator 'Generates a weekly report from all journals across all topics.'
24
+ options.separator 'Generates a weekly report from all journals across all topics in a single Markdown file.'
27
25
  end
28
26
  end
29
27
 
@@ -0,0 +1,61 @@
1
+ require_relative 'repository_command'
2
+
3
+ module Topicz::Commands
4
+
5
+ class StatsCommand < RepositoryCommand
6
+
7
+ def initialize(config_file = nil, arguments = [])
8
+ super(config_file)
9
+ @week = Date.today.cweek
10
+ @year = Date.today.cwyear
11
+ option_parser.order! arguments
12
+ end
13
+
14
+ def option_parser
15
+ OptionParser.new do |options|
16
+ options.banner = 'Usage: stats'
17
+ options.on('-w', '--week WEEK', 'Use week WEEK instead of the current week') do |week|
18
+ @week = week.to_i
19
+ end
20
+ options.on('-y', '--year YEAR', 'Use year YEAR instead of the current year') do |year|
21
+ @year = year.to_i
22
+ end
23
+ options.separator ''
24
+ options.separator 'Generates weekly statistics across all topics.'
25
+ options.separator ''
26
+ options.separator 'This command reports on all Documents, Notes and Reference Material across all topics.'
27
+ options.separator 'Contrary to what you might think, this command does NOT look at file timestamps!'
28
+ options.separator 'Instead it expects each filename to start with a date in yyyy-mm-dd format.'
29
+ end
30
+ end
31
+
32
+ def execute
33
+ date = Date.commercial(@year, @week)
34
+ first = date.strftime('%Y-%m-%d')
35
+ last = (date + 7).strftime('%Y-%m-%d')
36
+
37
+ output = []
38
+ @repository.topics.each do |topic|
39
+ stats = find_files(topic, first, last)
40
+ next if stats.empty?
41
+ item = "#{topic.title}\n"
42
+ stats.each {|path| item += "* #{path}\n"}
43
+ output << item
44
+ end
45
+
46
+ puts output.join("\n") unless output.empty?
47
+ end
48
+
49
+ GLOB_PATTERN = File.join("{#{Topicz::DIR_NOTES},#{Topicz::DIR_DOCUMENTS},#{Topicz::DIR_REFERENCE}}", '*')
50
+
51
+ def find_files(topic, first, last)
52
+ Dir.chdir(topic.fullpath) do
53
+ Dir.glob(GLOB_PATTERN).select do |path|
54
+ file = File.basename(path)
55
+ file >= first && file < last
56
+ end.sort
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module Topicz
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.0
4
+ version: 0.3.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-01 00:00:00.000000000 Z
11
+ date: 2016-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zaru
@@ -128,6 +128,7 @@ files:
128
128
  - lib/topicz/commands/path_command.rb
129
129
  - lib/topicz/commands/report_command.rb
130
130
  - lib/topicz/commands/repository_command.rb
131
+ - lib/topicz/commands/stats_command.rb
131
132
  - lib/topicz/defaults.rb
132
133
  - lib/topicz/repository.rb
133
134
  - lib/topicz/version.rb