todown 0.2.0 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/todown +2 -2
- data/lib/todown.rb +33 -0
- data/lib/todown/task.rb +0 -17
- data/lib/todown/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: b9eb6c53d10161d538abc579482e9d4d295f3a0d
|
4
|
+
data.tar.gz: 03567abff968373aa3975e405f63d840fbe7a5cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a386f7c2166541d19edc6f66cdc1afe98679a9823a6c73d31ed0c93108cdd78cbc569e2d876d7c82c8b481e055afdc0429fc22e1a695c2d4e16b89622b2c60f
|
7
|
+
data.tar.gz: ae666dbfb6a061c6c8a41b0835e0ea4c7b12c201f6a10b61221aada417ff13f7b80e13085498b4bc92df9a7c6ec5b79291a0eda4575c7ef3889b0aca710d36c4
|
data/Gemfile.lock
CHANGED
data/bin/todown
CHANGED
@@ -9,7 +9,7 @@ options = {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
OptionParser.new do |opts|
|
12
|
-
opts.banner = "Usage: todown FILEPATH [options]"
|
12
|
+
opts.banner = "Usage: todown FILEPATH [options] with FILEPATH as file or a folder containig files"
|
13
13
|
|
14
14
|
opts.on '-i', '--only_unfinished', 'Display only infinished tasks' do |o|
|
15
15
|
options[:only_unfinished] = true
|
@@ -46,7 +46,7 @@ filepath = ARGV[0]
|
|
46
46
|
tasks = []
|
47
47
|
total_count = 0
|
48
48
|
|
49
|
-
|
49
|
+
Todown.tasks_from_path(filepath) do |task|
|
50
50
|
total_count += 1
|
51
51
|
# filter
|
52
52
|
next if options[:only_finished] and task.finished == false
|
data/lib/todown.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "todown/version"
|
2
2
|
require "todown/task"
|
3
3
|
require 'terminal-table'
|
4
|
+
require 'find'
|
4
5
|
|
5
6
|
module Todown
|
6
7
|
|
@@ -49,4 +50,36 @@ module Todown
|
|
49
50
|
return {rows: rows, headings: headings }
|
50
51
|
end
|
51
52
|
|
53
|
+
|
54
|
+
# Create many task from given filepath
|
55
|
+
#
|
56
|
+
# @param filepath [String] filepath of readable markdown file
|
57
|
+
# @yield [Task]
|
58
|
+
# @return [Array<Task>]
|
59
|
+
def self.tasks_from_file filepath
|
60
|
+
tasks = []
|
61
|
+
|
62
|
+
File.read(filepath).scan(/- \[( |X|x)\] (.+)/).each do |data|
|
63
|
+
task = Task.new data[1], (data[0] != ' ')
|
64
|
+
tasks << task
|
65
|
+
yield task if block_given?
|
66
|
+
end
|
67
|
+
|
68
|
+
return tasks
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def self.tasks_from_path path
|
73
|
+
tasks = []
|
74
|
+
|
75
|
+
Find.find(path).select{|f| File.file?(f) and File.readable?(f)}.each do |file|
|
76
|
+
self.tasks_from_file(file) do |task|
|
77
|
+
tasks << task
|
78
|
+
yield task
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
return tasks
|
83
|
+
end
|
84
|
+
|
52
85
|
end
|
data/lib/todown/task.rb
CHANGED
@@ -7,23 +7,6 @@ class Task
|
|
7
7
|
# @return [Hash] an hash containing various attributes
|
8
8
|
attr_reader :attributes
|
9
9
|
|
10
|
-
# Create many task from given filepath
|
11
|
-
#
|
12
|
-
# @param filepath [String] filepath of readable markdown file
|
13
|
-
# @yield [Task]
|
14
|
-
# @return [Array<Task>]
|
15
|
-
def self.from_file filepath
|
16
|
-
tasks = []
|
17
|
-
|
18
|
-
File.read(filepath).scan(/- \[( |X|x)\] (.+)/).each do |data|
|
19
|
-
task = Task.new data[1], (data[0] != ' ')
|
20
|
-
tasks << task
|
21
|
-
yield task if block_given?
|
22
|
-
end
|
23
|
-
|
24
|
-
return tasks
|
25
|
-
end
|
26
|
-
|
27
10
|
# Returns a new instance of Task
|
28
11
|
#
|
29
12
|
# @param name [String]
|
data/lib/todown/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Rousseau
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-07-
|
12
|
+
date: 2018-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: terminal-table
|