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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cbdcc511e30fb27cbc3b0754a9f73201da8ad69
4
- data.tar.gz: 2d141a38c54a73d6e18d6a3f6c5216dae8a103ef
3
+ metadata.gz: b9eb6c53d10161d538abc579482e9d4d295f3a0d
4
+ data.tar.gz: 03567abff968373aa3975e405f63d840fbe7a5cc
5
5
  SHA512:
6
- metadata.gz: 636a15bd9ab11c114b3abd0da1926601f33302e3e06eabe5896405133f198941d63363a515d7c9e57f3e6ea375b83e3bca3c150e3adfd45d14344cf6eaa239a5
7
- data.tar.gz: 8a5f485fef5ae7db93a0908a22739252d259f517d1276125df75f3f37a9c374e664b9db558431cb30836911cd877734bcfb4ad30f2bfe723170bb8481db6ae90
6
+ metadata.gz: 0a386f7c2166541d19edc6f66cdc1afe98679a9823a6c73d31ed0c93108cdd78cbc569e2d876d7c82c8b481e055afdc0429fc22e1a695c2d4e16b89622b2c60f
7
+ data.tar.gz: ae666dbfb6a061c6c8a41b0835e0ea4c7b12c201f6a10b61221aada417ff13f7b80e13085498b4bc92df9a7c6ec5b79291a0eda4575c7ef3889b0aca710d36c4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- todown (0.2.0)
4
+ todown (0.3.0)
5
5
  terminal-table (~> 1.8)
6
6
 
7
7
  GEM
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
- Task.from_file(filepath) do |task|
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
@@ -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
@@ -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]
@@ -1,3 +1,3 @@
1
1
  module Todown
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-05 00:00:00.000000000 Z
12
+ date: 2018-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: terminal-table