todo_agent 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +49 -0
- data/.story_branch.yml +5 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +57 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +8 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/exe/todo_agent +18 -0
- data/lib/todo_agent.rb +10 -0
- data/lib/todo_agent/cli.rb +35 -0
- data/lib/todo_agent/command.rb +121 -0
- data/lib/todo_agent/commands/.gitkeep +1 -0
- data/lib/todo_agent/commands/analyze.rb +57 -0
- data/lib/todo_agent/comment.rb +21 -0
- data/lib/todo_agent/file_identifier.rb +14 -0
- data/lib/todo_agent/parsers/default_tags.rb +16 -0
- data/lib/todo_agent/parsers/regex_builder.rb +41 -0
- data/lib/todo_agent/parsers/ruby.rb +26 -0
- data/lib/todo_agent/templates/.gitkeep +1 -0
- data/lib/todo_agent/templates/analyze/.gitkeep +1 -0
- data/lib/todo_agent/version.rb +5 -0
- data/todo_agent.gemspec +31 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 72f7bd4257ca7cc18ae0f92b4f1b1c650b358e590d24a830f602a73288e87a12
|
4
|
+
data.tar.gz: 369f1fa42f4dfa7dcff6a0cf1179d4cdc8ef9deb751af3f56132bd2a1ca68eb8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 680317b406eda4e555e80200fa46693d5829a56718e5a8542311a7db74ab93febcf3c7a6af8d02132db356af58e78bf1490d16ab9c906d5a3857335ce8fda734
|
7
|
+
data.tar.gz: ee93b41d24e470176fe86cb2338e5d3bf86868a7186474c69c36cad4a33153aaeff144d1cbd8a98bcf3cf3ff89e8a0efff77af89080a005c998b4e9d461926cf
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
Style/StringLiterals:
|
2
|
+
EnforcedStyle: double_quotes
|
3
|
+
|
4
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
5
|
+
Enabled: true
|
6
|
+
Layout/SpaceAroundMethodCallOperator:
|
7
|
+
Enabled: true
|
8
|
+
Lint/DeprecatedOpenSSLConstant:
|
9
|
+
Enabled: true
|
10
|
+
Lint/DuplicateElsifCondition:
|
11
|
+
Enabled: true
|
12
|
+
Lint/MixedRegexpCaptureTypes:
|
13
|
+
Enabled: true
|
14
|
+
Lint/RaiseException:
|
15
|
+
Enabled: true
|
16
|
+
Lint/StructNewOverride:
|
17
|
+
Enabled: true
|
18
|
+
Style/AccessorGrouping:
|
19
|
+
Enabled: true
|
20
|
+
Style/ArrayCoercion:
|
21
|
+
Enabled: true
|
22
|
+
Style/BisectedAttrAccessor:
|
23
|
+
Enabled: true
|
24
|
+
Style/CaseLikeIf:
|
25
|
+
Enabled: true
|
26
|
+
Style/ExponentialNotation:
|
27
|
+
Enabled: true
|
28
|
+
Style/HashAsLastArrayItem:
|
29
|
+
Enabled: true
|
30
|
+
Style/HashEachMethods:
|
31
|
+
Enabled: true
|
32
|
+
Style/HashLikeCase:
|
33
|
+
Enabled: true
|
34
|
+
Style/HashTransformKeys:
|
35
|
+
Enabled: true
|
36
|
+
Style/HashTransformValues:
|
37
|
+
Enabled: true
|
38
|
+
Style/RedundantAssignment:
|
39
|
+
Enabled: true
|
40
|
+
Style/RedundantFetchBlock:
|
41
|
+
Enabled: true
|
42
|
+
Style/RedundantFileExtensionInRequire:
|
43
|
+
Enabled: true
|
44
|
+
Style/RedundantRegexpCharacterClass:
|
45
|
+
Enabled: true
|
46
|
+
Style/RedundantRegexpEscape:
|
47
|
+
Enabled: true
|
48
|
+
Style/SlicingWithRange:
|
49
|
+
Enabled: true
|
data/.story_branch.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at rui.p.baltazar@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
todo_agent (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.1)
|
10
|
+
byebug (11.1.3)
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
parallel (1.19.2)
|
13
|
+
parser (2.7.1.4)
|
14
|
+
ast (~> 2.4.1)
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (12.3.3)
|
17
|
+
regexp_parser (1.7.1)
|
18
|
+
rexml (3.2.4)
|
19
|
+
rspec (3.9.0)
|
20
|
+
rspec-core (~> 3.9.0)
|
21
|
+
rspec-expectations (~> 3.9.0)
|
22
|
+
rspec-mocks (~> 3.9.0)
|
23
|
+
rspec-core (3.9.2)
|
24
|
+
rspec-support (~> 3.9.3)
|
25
|
+
rspec-expectations (3.9.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.9.0)
|
28
|
+
rspec-mocks (3.9.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-support (3.9.3)
|
32
|
+
rubocop (0.88.0)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 2.7.1.1)
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
36
|
+
regexp_parser (>= 1.7)
|
37
|
+
rexml
|
38
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
39
|
+
ruby-progressbar (~> 1.7)
|
40
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
41
|
+
rubocop-ast (0.1.0)
|
42
|
+
parser (>= 2.7.0.1)
|
43
|
+
ruby-progressbar (1.10.1)
|
44
|
+
unicode-display_width (1.7.0)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
byebug
|
51
|
+
rake (~> 12.0)
|
52
|
+
rspec (~> 3.0)
|
53
|
+
rubocop
|
54
|
+
todo_agent!
|
55
|
+
|
56
|
+
BUNDLED WITH
|
57
|
+
2.1.4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Story Branch
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Rui Baltazar
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# TodoAgent
|
2
|
+
|
3
|
+
Searches the code for TODOs and creates issues in the configured tracker
|
4
|
+
|
5
|
+
This is the initial description of the concept and it will probably evolve with the requirements.
|
6
|
+
|
7
|
+
Initial concept is to look for a list of regex (preferably configurable) and create issues in a configured tracker or if no tracker is configured, output the result into a log file.
|
8
|
+
|
9
|
+
Might be interesting to extract some of the features from story_branch gem to a separate gem that will handle the wrapping of the API and so on, so we can easily use those functionalities here as well. Probably will start with a copy paste of the needed code and when the patterns are clearer then extract them to separate gems.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'todo_agent'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install todo_agent
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
TODO: Write usage instructions here
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rpbaltazar/todo_agent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/rpbaltazar/todo_agent/blob/master/CODE_OF_CONDUCT.md).
|
40
|
+
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
45
|
+
|
46
|
+
## Code of Conduct
|
47
|
+
|
48
|
+
Everyone interacting in the TodoAgent project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rpbaltazar/todo_agent/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "todo_agent"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
# require "pry"
|
13
|
+
# Pry.start
|
14
|
+
|
15
|
+
require "irb"
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/todo_agent
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib_path = File.expand_path('../lib', __dir__)
|
5
|
+
$:.unshift(lib_path) if !$:.include?(lib_path)
|
6
|
+
require 'todo_agent/cli'
|
7
|
+
|
8
|
+
Signal.trap('INT') do
|
9
|
+
warn("\n#{caller.join("\n")}: interrupted")
|
10
|
+
exit(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
TodoAgent::CLI.start
|
15
|
+
rescue TodoAgent::CLI::Error => err
|
16
|
+
puts "ERROR: #{err.message}"
|
17
|
+
exit 1
|
18
|
+
end
|
data/lib/todo_agent.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module TodoAgent
|
6
|
+
# Handle the application command line parsing
|
7
|
+
# and the dispatch to various command objects
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
class CLI < Thor
|
11
|
+
# Error raised by this runner
|
12
|
+
Error = Class.new(StandardError)
|
13
|
+
|
14
|
+
desc "version", "todo_agent version"
|
15
|
+
def version
|
16
|
+
require_relative "version"
|
17
|
+
puts "v#{TodoAgent::VERSION}"
|
18
|
+
end
|
19
|
+
map %w[--version -v] => :version
|
20
|
+
|
21
|
+
desc "analyze PATH", "Runs through the tree from the passed path, searching for configured keywords and builds a log"
|
22
|
+
method_option :help, aliases: "-h", type: :boolean, desc: "Display usage information"
|
23
|
+
method_option :ignore_paths, aliases: "-I", type: :array, desc: "Paths to ignore while searching for keywords"
|
24
|
+
method_option :output_file, aliases: "-o", type: :string, desc: "File to log the output"
|
25
|
+
|
26
|
+
def analyze(path = ".")
|
27
|
+
if options[:help]
|
28
|
+
invoke :help, ["analyze"]
|
29
|
+
else
|
30
|
+
require_relative "commands/analyze"
|
31
|
+
TodoAgent::Commands::Analyze.new(path, options).execute
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module TodoAgent
|
6
|
+
class Command
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def_delegators :command, :run
|
10
|
+
|
11
|
+
# Execute this command
|
12
|
+
#
|
13
|
+
# @api public
|
14
|
+
def execute(*)
|
15
|
+
raise(
|
16
|
+
NotImplementedError,
|
17
|
+
"#{self.class}##{__method__} must be implemented"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
# The external commands runner
|
22
|
+
#
|
23
|
+
# @see http://www.rubydoc.info/gems/tty-command
|
24
|
+
#
|
25
|
+
# @api public
|
26
|
+
def command(**options)
|
27
|
+
require 'tty-command'
|
28
|
+
TTY::Command.new(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# The cursor movement
|
32
|
+
#
|
33
|
+
# @see http://www.rubydoc.info/gems/tty-cursor
|
34
|
+
#
|
35
|
+
# @api public
|
36
|
+
def cursor
|
37
|
+
require 'tty-cursor'
|
38
|
+
TTY::Cursor
|
39
|
+
end
|
40
|
+
|
41
|
+
# Open a file or text in the user's preferred editor
|
42
|
+
#
|
43
|
+
# @see http://www.rubydoc.info/gems/tty-editor
|
44
|
+
#
|
45
|
+
# @api public
|
46
|
+
def editor
|
47
|
+
require 'tty-editor'
|
48
|
+
TTY::Editor
|
49
|
+
end
|
50
|
+
|
51
|
+
# File manipulation utility methods
|
52
|
+
#
|
53
|
+
# @see http://www.rubydoc.info/gems/tty-file
|
54
|
+
#
|
55
|
+
# @api public
|
56
|
+
def generator
|
57
|
+
require 'tty-file'
|
58
|
+
TTY::File
|
59
|
+
end
|
60
|
+
|
61
|
+
# Terminal output paging
|
62
|
+
#
|
63
|
+
# @see http://www.rubydoc.info/gems/tty-pager
|
64
|
+
#
|
65
|
+
# @api public
|
66
|
+
def pager(**options)
|
67
|
+
require 'tty-pager'
|
68
|
+
TTY::Pager.new(options)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Terminal platform and OS properties
|
72
|
+
#
|
73
|
+
# @see http://www.rubydoc.info/gems/tty-pager
|
74
|
+
#
|
75
|
+
# @api public
|
76
|
+
def platform
|
77
|
+
require 'tty-platform'
|
78
|
+
TTY::Platform.new
|
79
|
+
end
|
80
|
+
|
81
|
+
# The interactive prompt
|
82
|
+
#
|
83
|
+
# @see http://www.rubydoc.info/gems/tty-prompt
|
84
|
+
#
|
85
|
+
# @api public
|
86
|
+
def prompt(**options)
|
87
|
+
require 'tty-prompt'
|
88
|
+
TTY::Prompt.new(options)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Get terminal screen properties
|
92
|
+
#
|
93
|
+
# @see http://www.rubydoc.info/gems/tty-screen
|
94
|
+
#
|
95
|
+
# @api public
|
96
|
+
def screen
|
97
|
+
require 'tty-screen'
|
98
|
+
TTY::Screen
|
99
|
+
end
|
100
|
+
|
101
|
+
# The unix which utility
|
102
|
+
#
|
103
|
+
# @see http://www.rubydoc.info/gems/tty-which
|
104
|
+
#
|
105
|
+
# @api public
|
106
|
+
def which(*args)
|
107
|
+
require 'tty-which'
|
108
|
+
TTY::Which.which(*args)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Check if executable exists
|
112
|
+
#
|
113
|
+
# @see http://www.rubydoc.info/gems/tty-which
|
114
|
+
#
|
115
|
+
# @api public
|
116
|
+
def exec_exist?(*args)
|
117
|
+
require 'tty-which'
|
118
|
+
TTY::Which.exist?(*args)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake"
|
4
|
+
require_relative "../command"
|
5
|
+
require_relative "../file_identifier"
|
6
|
+
# TODO: load remaining parsers
|
7
|
+
require_relative "../parsers/ruby"
|
8
|
+
|
9
|
+
module TodoAgent
|
10
|
+
module Commands
|
11
|
+
class Analyze < TodoAgent::Command
|
12
|
+
def initialize(path, options)
|
13
|
+
@path = path
|
14
|
+
@options = options
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute(_input: $stdin, _output: $stdout)
|
18
|
+
comments = []
|
19
|
+
Rake::FileList["#{@path}/**/*"].exclude(paths_to_ignore).each do |filepath|
|
20
|
+
parser = TodoAgent::FileIdentifier.based_on_file_extension(filepath)
|
21
|
+
next unless parser
|
22
|
+
|
23
|
+
parser_class = Object.const_get("TodoAgent::Parsers::#{parser}")
|
24
|
+
result = parser_class.parse(filepath)
|
25
|
+
comments += result
|
26
|
+
end
|
27
|
+
|
28
|
+
output(comments)
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def paths_to_ignore
|
35
|
+
return [] if @options["ignore_paths"].nil?
|
36
|
+
|
37
|
+
@options["ignore_paths"].map do |ignore_path|
|
38
|
+
next ignore_path if ignore_path.start_with?(@path)
|
39
|
+
|
40
|
+
"#{@path}/ignore_path"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def output(comments)
|
45
|
+
File.open(output_file, "w") do |f|
|
46
|
+
comments.each do |comment|
|
47
|
+
f.write "#{comment}\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def output_file
|
53
|
+
@options["output_file"] || "todo_agent.log"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TodoAgent
|
4
|
+
class Comment
|
5
|
+
attr_reader :line, :filename
|
6
|
+
|
7
|
+
def initialize(match, filename, line)
|
8
|
+
@filename = filename
|
9
|
+
@match = match
|
10
|
+
@line = line
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag
|
14
|
+
@match[1]
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"Matched: #{tag} in #{filename} at line #{line}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "default_tags"
|
4
|
+
|
5
|
+
module TodoAgent
|
6
|
+
module Parsers
|
7
|
+
class RegexBuilder
|
8
|
+
DEFAULT_TAGS = [DefaultTags.todo, DefaultTags.fixme].freeze
|
9
|
+
|
10
|
+
def self.regex(custom_tags = [])
|
11
|
+
tags = (DEFAULT_TAGS + custom_tags).uniq
|
12
|
+
|
13
|
+
# Regex building taken from https://github.com/pgilad/leasot/blob/ffc68de48d91f6b0d4ba35d6a21b4fb3580b54f9/src/lib/utils/comments.ts
|
14
|
+
# Optional space.
|
15
|
+
'\\s*' +
|
16
|
+
# Optional `@`.
|
17
|
+
"@?" +
|
18
|
+
# One of the keywords such as `TODO` and `FIXME`.
|
19
|
+
"(" +
|
20
|
+
tags.join("|") +
|
21
|
+
")" +
|
22
|
+
# tag cannot be followed by an alpha-numeric character (strict tag match)
|
23
|
+
'(?!\\w)' +
|
24
|
+
# Optional space.
|
25
|
+
'\\s*' +
|
26
|
+
# Optional leading reference in parenthesis.
|
27
|
+
'(?:\\(([^)]*)\\))?' +
|
28
|
+
# Optional space.
|
29
|
+
'\\s*' +
|
30
|
+
# Optional colon `:`.
|
31
|
+
":?" +
|
32
|
+
# Optional space.
|
33
|
+
'\\s*' +
|
34
|
+
# Comment text.
|
35
|
+
"(.*?)" +
|
36
|
+
# Optional trailing reference after a space and a slash, followed by an optional space.
|
37
|
+
'(?:\\s+/([^\\s]+)\\s*)?'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
require_relative "regex_builder"
|
5
|
+
require_relative "../comment"
|
6
|
+
|
7
|
+
module TodoAgent
|
8
|
+
module Parsers
|
9
|
+
class Ruby
|
10
|
+
def self.parse(file)
|
11
|
+
regex_str = TodoAgent::Parsers::RegexBuilder.regex
|
12
|
+
regexp = Regexp.new("^\\s*##{regex_str}$", "mig")
|
13
|
+
comments = []
|
14
|
+
|
15
|
+
# TODO: This logic belongs out of the specific ruby parser
|
16
|
+
# This only matches single line.
|
17
|
+
IO.foreach(file) do |line|
|
18
|
+
match = regexp.match(line)
|
19
|
+
comments << TodoAgent::Comment.new(match, file, $INPUT_LINE_NUMBER) if match
|
20
|
+
end
|
21
|
+
|
22
|
+
comments
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
data/todo_agent.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/todo_agent/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "todo_agent"
|
7
|
+
spec.version = TodoAgent::VERSION
|
8
|
+
spec.authors = ["Rui Baltazar"]
|
9
|
+
spec.email = ["rui.p.baltazar@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Transform tags into tickets"
|
12
|
+
spec.description = "Search for specific keywords in the codebase and create tickets in the tracker"
|
13
|
+
spec.homepage = "https://github.com/story-branch/todo-tracker"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/story-branch/todo-tracker"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/story-branch/todo-tracker"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: todo_agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rui Baltazar
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Search for specific keywords in the codebase and create tickets in the
|
14
|
+
tracker
|
15
|
+
email:
|
16
|
+
- rui.p.baltazar@gmail.com
|
17
|
+
executables:
|
18
|
+
- todo_agent
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- ".gitignore"
|
23
|
+
- ".rspec"
|
24
|
+
- ".rubocop.yml"
|
25
|
+
- ".story_branch.yml"
|
26
|
+
- ".travis.yml"
|
27
|
+
- CODE_OF_CONDUCT.md
|
28
|
+
- Gemfile
|
29
|
+
- Gemfile.lock
|
30
|
+
- LICENSE
|
31
|
+
- LICENSE.txt
|
32
|
+
- README.md
|
33
|
+
- Rakefile
|
34
|
+
- bin/console
|
35
|
+
- bin/setup
|
36
|
+
- exe/todo_agent
|
37
|
+
- lib/todo_agent.rb
|
38
|
+
- lib/todo_agent/cli.rb
|
39
|
+
- lib/todo_agent/command.rb
|
40
|
+
- lib/todo_agent/commands/.gitkeep
|
41
|
+
- lib/todo_agent/commands/analyze.rb
|
42
|
+
- lib/todo_agent/comment.rb
|
43
|
+
- lib/todo_agent/file_identifier.rb
|
44
|
+
- lib/todo_agent/parsers/default_tags.rb
|
45
|
+
- lib/todo_agent/parsers/regex_builder.rb
|
46
|
+
- lib/todo_agent/parsers/ruby.rb
|
47
|
+
- lib/todo_agent/templates/.gitkeep
|
48
|
+
- lib/todo_agent/templates/analyze/.gitkeep
|
49
|
+
- lib/todo_agent/version.rb
|
50
|
+
- todo_agent.gemspec
|
51
|
+
homepage: https://github.com/story-branch/todo-tracker
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata:
|
55
|
+
homepage_uri: https://github.com/story-branch/todo-tracker
|
56
|
+
source_code_uri: https://github.com/story-branch/todo-tracker
|
57
|
+
changelog_uri: https://github.com/story-branch/todo-tracker
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.3.0
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubygems_version: 3.1.4
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Transform tags into tickets
|
77
|
+
test_files: []
|