task-list 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +33 -0
- data/.rvmrc +55 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +25 -0
- data/Guardfile +6 -0
- data/LICENSE.md +7 -0
- data/README.md +54 -0
- data/Rakefile +10 -0
- data/bin/tl +8 -0
- data/config/excluded_extensions.yml +11 -0
- data/config/excluded_folders.yml +6 -0
- data/config/valid_tasks.yml +9 -0
- data/lib/task-list.rb +9 -0
- data/lib/task-list/parser.rb +159 -0
- data/lib/task-list/version.rb +3 -0
- data/spec/parser_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -0
- data/task-list.gemspec +23 -0
- metadata +111 -0
data/.gitignore
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
*.gem
|
2
|
+
.bundle
|
3
|
+
pkg/*
|
4
|
+
|
5
|
+
*.rbc
|
6
|
+
.config
|
7
|
+
coverage
|
8
|
+
InstalledFiles
|
9
|
+
lib/bundler/man
|
10
|
+
rdoc
|
11
|
+
spec/reports
|
12
|
+
test/tmp
|
13
|
+
test/version_tmp
|
14
|
+
tmp
|
15
|
+
|
16
|
+
# YARD artifacts
|
17
|
+
.yardoc
|
18
|
+
_yardoc
|
19
|
+
doc/
|
20
|
+
|
21
|
+
.DS_Store
|
22
|
+
|
23
|
+
# Thumbnails
|
24
|
+
._*
|
25
|
+
|
26
|
+
# Files that might appear on external disk
|
27
|
+
.Spotlight-V100
|
28
|
+
.Trashes
|
29
|
+
|
30
|
+
.*.sw[a-z]
|
31
|
+
*.un~
|
32
|
+
Session.vim
|
33
|
+
NERD_tree*
|
data/.rvmrc
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ruby-1.9.3-p0@task-list"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment following line if you want options to be set only for given project.
|
11
|
+
#
|
12
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
13
|
+
|
14
|
+
#
|
15
|
+
# First we attempt to load the desired environment directly from the environment
|
16
|
+
# file. This is very fast and efficient compared to running through the entire
|
17
|
+
# CLI and selector. If you want feedback on which environment was used then
|
18
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
+
#
|
20
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
21
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
22
|
+
then
|
23
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
24
|
+
|
25
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
26
|
+
then
|
27
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
28
|
+
fi
|
29
|
+
else
|
30
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
31
|
+
if ! rvm --create "$environment_id"
|
32
|
+
then
|
33
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
34
|
+
exit 1
|
35
|
+
fi
|
36
|
+
fi
|
37
|
+
|
38
|
+
#
|
39
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
40
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
41
|
+
# necessary.
|
42
|
+
#
|
43
|
+
# filename=".gems"
|
44
|
+
# if [[ -s "$filename" ]]
|
45
|
+
# then
|
46
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
47
|
+
# fi
|
48
|
+
|
49
|
+
# If you use bundler, this might be useful to you:
|
50
|
+
# if command -v bundle && [[ -s Gemfile ]]
|
51
|
+
# then
|
52
|
+
# bundle install
|
53
|
+
# fi
|
54
|
+
|
55
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
task-list (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
guard (0.8.8)
|
10
|
+
thor (~> 0.14.6)
|
11
|
+
guard-minitest (0.4.0)
|
12
|
+
guard (~> 0.4)
|
13
|
+
rb-fsevent (0.4.3.1)
|
14
|
+
ruby_gntp (0.3.4)
|
15
|
+
thor (0.14.6)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
guard
|
22
|
+
guard-minitest
|
23
|
+
rb-fsevent
|
24
|
+
ruby_gntp
|
25
|
+
task-list!
|
data/Guardfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 Aziz Light
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
TaskList
|
2
|
+
========
|
3
|
+
|
4
|
+
Code tasks are constructive comments in the code that are prefixed with a tag. Here are some examples of code tasks in ruby:
|
5
|
+
|
6
|
+
# TODO: This is a todo item that needs to be done urgently!
|
7
|
+
# BUG Something wrong is happening...
|
8
|
+
# NOTE - This method is used for a specific reason.
|
9
|
+
|
10
|
+
Obviously real code tasks are a lot more constructive than the examples I gave above.
|
11
|
+
|
12
|
+
TaskList parses code files and lists code tasks.
|
13
|
+
|
14
|
+
Installation
|
15
|
+
------------
|
16
|
+
|
17
|
+
TaskList is provided as a gem, so the installation process is as simple as this:
|
18
|
+
|
19
|
+
% [sudo] gem install task-list
|
20
|
+
|
21
|
+
> **Note**: `%` is the prompt and `sudo` (without the square brackets) is not needed if you use RVM.
|
22
|
+
|
23
|
+
Features:
|
24
|
+
---------
|
25
|
+
|
26
|
+
As stated above, TaskList lists code tags that it finds in code passed to it. Here are the supported tags:
|
27
|
+
|
28
|
+
- `TODO`
|
29
|
+
- `FIXME`
|
30
|
+
- `NOTE`
|
31
|
+
- `BUG`
|
32
|
+
- `CHANGED`
|
33
|
+
- `OPTIMIZE`
|
34
|
+
- `XXX`
|
35
|
+
- `!!!`
|
36
|
+
|
37
|
+
Also, TaskList will ignore the files that are under certain folders like `log` or `coverage`. Finally, TaskList will ignore files with certain extensions like images and SQLite databases.
|
38
|
+
|
39
|
+
Usage:
|
40
|
+
------
|
41
|
+
|
42
|
+
The TaskList comes with a command-line script called `tl` which takes one argument and only one argument. This argument can be one of two things:
|
43
|
+
|
44
|
+
- a file
|
45
|
+
- a folder
|
46
|
+
|
47
|
+
If a file is passed, TaskList will parse this file to find code tags. On the other hand, if a folder is passed, TaskList will recursively parse all the files under that folder to find code tags. Here are some examples:
|
48
|
+
|
49
|
+
% tl task-list.rb
|
50
|
+
% tl task-list/
|
51
|
+
% tl task-list/task-list.rb
|
52
|
+
% tl .
|
53
|
+
|
54
|
+
All the calls to `tl` shown above are valid.
|
data/Rakefile
ADDED
data/bin/tl
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
---
|
2
|
+
- :TODO: 'TODO[\s,:-]+(\S.*)$'
|
3
|
+
- :FIXME: 'FIX ?ME[\s,:-]+(\S.*)$'
|
4
|
+
- :NOTE: 'NOTE[\s,:-]+(\S.*)$'
|
5
|
+
- :BUG: 'BUG[\s,:-]+(\S.*)$'
|
6
|
+
- :CHANGED: 'CHANGED[\s,:-]+(\S.*)$'
|
7
|
+
- :OPTIMIZE: 'OPTIMIZE[\s,:-]+(\S.*)$'
|
8
|
+
- :XXX: 'XXX[\s,:-]+(\S.*)$'
|
9
|
+
- :!!!: '!!![\s,:-]+(\S.*)$'
|
data/lib/task-list.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
module TaskList
|
2
|
+
class Parser
|
3
|
+
attr_reader :files, :tasks
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
validate args
|
7
|
+
|
8
|
+
# Get the list of files
|
9
|
+
@files = collect args
|
10
|
+
|
11
|
+
# Setup the absolute path to the config folder
|
12
|
+
@config_folder = File.realpath(File.dirname(__FILE__) + "/../../config")
|
13
|
+
|
14
|
+
# Get the list of valid tasks
|
15
|
+
@valid_tasks = get_valid_tasks
|
16
|
+
|
17
|
+
# Get excluded folders
|
18
|
+
@excluded_folders = get_excluded_folders
|
19
|
+
|
20
|
+
# Initialize the tasks hash
|
21
|
+
@tasks = initialize_tasks_hash
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parse all the collected files to find tasks
|
25
|
+
# and populate the @tasks hash
|
26
|
+
def parse(type = nil)
|
27
|
+
unless type.nil? || (type.is_a?(Symbol) && @valid_tasks.has_key?(type))
|
28
|
+
raise ArgumentError
|
29
|
+
end
|
30
|
+
|
31
|
+
@files.each do |file|
|
32
|
+
parsef file, type
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def print
|
37
|
+
@tasks.each do |type, tasks|
|
38
|
+
unless tasks.empty?
|
39
|
+
puts "\n#{type}:\n#{'-' * (type.length + 1)}\n"
|
40
|
+
|
41
|
+
tasks.each do |task|
|
42
|
+
puts task[:task]
|
43
|
+
# CHANGED: Colors are now always enabled.
|
44
|
+
# Without colors the output is unreadable.
|
45
|
+
puts " \e[30m\e[1mline #{task[:line_number]} in #{task[:file]}\e[0m"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Validate the argument passed to the parser's controller.
|
54
|
+
# The argument must be a String and a valid file/folder path (relative or absolute).
|
55
|
+
def validate(args)
|
56
|
+
raise ArgumentError unless args.is_a?(Array) && args.any?
|
57
|
+
|
58
|
+
args.each do |arg|
|
59
|
+
unless arg.is_a? String
|
60
|
+
raise ArgumentError, "The argument passed to the parser's constructor must be a String"
|
61
|
+
end
|
62
|
+
|
63
|
+
unless File.file?(arg) || File.directory?(arg)
|
64
|
+
raise ArgumentError, "The argument passed to the parse's constructor must be either a file or a folder"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Take the args, which are files/folders list,
|
70
|
+
# and create a list of all the files to parse
|
71
|
+
def collect(args)
|
72
|
+
files = []
|
73
|
+
args.each do |arg|
|
74
|
+
%w[**/* **/*.* **/.*].each do |glob|
|
75
|
+
files << Dir.glob("#{arg}/#{glob}")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
files.flatten.uniq.delete_if { |file| File.directory?(file) }
|
80
|
+
end
|
81
|
+
|
82
|
+
# Get the valid tasks and their regex
|
83
|
+
# from the config/valid_tasks.yml YAML file
|
84
|
+
def get_valid_tasks
|
85
|
+
tasks = {}
|
86
|
+
|
87
|
+
shit = YAML::load(File.open(@config_folder + "/valid_tasks.yml"))
|
88
|
+
shit.each do |crap|
|
89
|
+
crap.each do |task, regex|
|
90
|
+
tasks[task] = regex
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
tasks
|
95
|
+
end
|
96
|
+
|
97
|
+
# Get the list of excluded folders and their regex
|
98
|
+
# from the config/excluded_folders.yml YAML file
|
99
|
+
def get_excluded_folders
|
100
|
+
YAML::load(File.open(@config_folder + "/excluded_folders.yml"))
|
101
|
+
end
|
102
|
+
|
103
|
+
# Initialize the tasks hash
|
104
|
+
def initialize_tasks_hash
|
105
|
+
tasks = {}
|
106
|
+
@valid_tasks.each do |task, regex|
|
107
|
+
tasks[task] = []
|
108
|
+
end
|
109
|
+
|
110
|
+
tasks
|
111
|
+
end
|
112
|
+
|
113
|
+
# Parse a file to find tasks
|
114
|
+
def parsef(file, type = nil)
|
115
|
+
# Don't parse files that are in excluded folders!
|
116
|
+
@excluded_folders.each do |regex|
|
117
|
+
return if file =~ /#{regex}/
|
118
|
+
end
|
119
|
+
|
120
|
+
valid_tasks = (type.nil?) ? @valid_tasks : @valid_tasks.select { |k,v| k == type }
|
121
|
+
|
122
|
+
unless ignore?(file)
|
123
|
+
File.open(file, "r") do |f|
|
124
|
+
line_number = 1
|
125
|
+
while line = f.gets
|
126
|
+
valid_tasks.each do |type, regex|
|
127
|
+
begin
|
128
|
+
result = line.match regex
|
129
|
+
rescue ArgumentError
|
130
|
+
# NOTE: Some files like .DS_Store are not filtered by the ignore? method...
|
131
|
+
return
|
132
|
+
end
|
133
|
+
|
134
|
+
unless result.nil?
|
135
|
+
task = {
|
136
|
+
file: file,
|
137
|
+
line_number: line_number,
|
138
|
+
task: result.to_a.last
|
139
|
+
}
|
140
|
+
|
141
|
+
@tasks[type] << task
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
line_number += 1
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Should a file be ignored?
|
152
|
+
# Some files, like images or SQLite databases, are not meant to be parsed
|
153
|
+
def ignore?(file)
|
154
|
+
# Get the list of file extensions to ignore
|
155
|
+
extensions = YAML::load(File.open(@config_folder + "/excluded_extensions.yml"))
|
156
|
+
extensions.include?(File.extname(file))
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe "Parser" do
|
4
|
+
it "must work" do
|
5
|
+
lambda do
|
6
|
+
TaskList::Parser
|
7
|
+
end.must_be_silent
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "arguments" do
|
11
|
+
it "must require at least one argument" do
|
12
|
+
lambda do
|
13
|
+
TaskList::Parser.new
|
14
|
+
end.must_raise ArgumentError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/task-list.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "task-list/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "task-list"
|
7
|
+
s.version = TaskList::VERSION
|
8
|
+
s.authors = ["Aziz Light"]
|
9
|
+
s.email = ["aziz@azizlight.me"]
|
10
|
+
s.homepage = "https://github.com/AzizLight/TaskList"
|
11
|
+
s.summary = %q{Code tasks parser and lister}
|
12
|
+
s.description = %q{TaskList parses source code to find code tags and list them in a terminal. See README.md for more info.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_development_dependency "guard"
|
20
|
+
s.add_development_dependency "guard-minitest"
|
21
|
+
s.add_development_dependency "rb-fsevent"
|
22
|
+
s.add_development_dependency "ruby_gntp"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: task-list
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Aziz Light
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: guard
|
16
|
+
requirement: &70291384857900 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70291384857900
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: guard-minitest
|
27
|
+
requirement: &70291384857400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70291384857400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rb-fsevent
|
38
|
+
requirement: &70291384856820 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70291384856820
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: ruby_gntp
|
49
|
+
requirement: &70291384856260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70291384856260
|
58
|
+
description: TaskList parses source code to find code tags and list them in a terminal.
|
59
|
+
See README.md for more info.
|
60
|
+
email:
|
61
|
+
- aziz@azizlight.me
|
62
|
+
executables:
|
63
|
+
- tl
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- .rvmrc
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- Guardfile
|
72
|
+
- LICENSE.md
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/tl
|
76
|
+
- config/excluded_extensions.yml
|
77
|
+
- config/excluded_folders.yml
|
78
|
+
- config/valid_tasks.yml
|
79
|
+
- lib/task-list.rb
|
80
|
+
- lib/task-list/parser.rb
|
81
|
+
- lib/task-list/version.rb
|
82
|
+
- spec/parser_spec.rb
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
- task-list.gemspec
|
85
|
+
homepage: https://github.com/AzizLight/TaskList
|
86
|
+
licenses: []
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.8.10
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: Code tasks parser and lister
|
109
|
+
test_files:
|
110
|
+
- spec/parser_spec.rb
|
111
|
+
- spec/spec_helper.rb
|