do_by 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/bin/do_by +5 -0
- data/do_by.gemspec +24 -0
- data/lib/do_by.rb +35 -0
- data/lib/do_by/version.rb +3 -0
- data/spec/do_by_spec.rb +52 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0ac827c16c5a8a9f3b26d4666d59363c139818ed
|
4
|
+
data.tar.gz: 36147bfacc93db4b9a7de5945d9a6173ed973ad2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 00f3a53e6918fbcf2ea4f8749bbd253049ac00bcd4dc01704c5f3b6c5cb98ca1b1268c3f857703ea04d555b022b7f9d7db91c997d81c041817ae81b0d2886bb1
|
7
|
+
data.tar.gz: fde4245de69422df8d4d2bddd924394a8608984924e007b2e326fdae3b588b97d89749ffc1d8675297d093edf54558d819349f8f546c9c846525cef47b1dd03d
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Andy Waite
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# DoBy
|
2
|
+
|
3
|
+
This is a proof-of-concept of automatically-expiring TODO notes.
|
4
|
+
|
5
|
+
TODO comments can be a plague on a software codebase. They begin as a good
|
6
|
+
intention to go back and do something, but are easily forgotten or ignored.
|
7
|
+
They can hang around in code for years. And unlike stale code, they're not excecuted,
|
8
|
+
so they never cause anything to break.
|
9
|
+
|
10
|
+
DoBy makes your TODO comments complain when they become stale. You add a note
|
11
|
+
using a special `TODO` method, providing a date which you to defer until.
|
12
|
+
When your code runs, the expiry date on the TODO will be checked, and it will
|
13
|
+
raise an error if it's overdue.
|
14
|
+
|
15
|
+
This forces you to look at the TODO task again. If it's no longer relevant, you
|
16
|
+
can delete it. If you can fix it, you fix it. If you cannot fix it right now,
|
17
|
+
change the date to something in the future to re-visit it again.
|
18
|
+
|
19
|
+
# Example
|
20
|
+
|
21
|
+
DoBy requires that all TODO commments are suffixed with a due date, for example:
|
22
|
+
|
23
|
+
`# TODO 20140601 fix this, '2014-06-01'`
|
24
|
+
|
25
|
+
In your CI system, configure your test suite to be dependent on DoBy exiting
|
26
|
+
succesfully, for example in your build script:
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Add this line to your application's Gemfile:
|
31
|
+
|
32
|
+
gem 'do_by', group: 'test'
|
33
|
+
|
34
|
+
And then execute:
|
35
|
+
|
36
|
+
$ bundle
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/andyw8/do_by/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/do_by
ADDED
data/do_by.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'do_by/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "do_by"
|
8
|
+
spec.version = DoBy::VERSION
|
9
|
+
spec.authors = ["Andy Waite"]
|
10
|
+
spec.email = ["github.aw@andywaite.com"]
|
11
|
+
spec.summary = %q{Expiring 'to do' reminders}
|
12
|
+
spec.description = %q{Expiring 'to do' reminders}
|
13
|
+
spec.homepage = "https://github.com/andyw8/do_by"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
data/lib/do_by.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "do_by/version"
|
2
|
+
|
3
|
+
module DoBy
|
4
|
+
class Checker
|
5
|
+
def self.invoke
|
6
|
+
new.invoke
|
7
|
+
end
|
8
|
+
|
9
|
+
def invoke
|
10
|
+
Dir.glob("**/*").each do |path|
|
11
|
+
next if File.directory?(path)
|
12
|
+
File.open(path).each_line.with_index do |line, line_no|
|
13
|
+
# TODO 20140531 make this more efficient
|
14
|
+
parse(path, line, line_no + 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def parse(path, line, line_no)
|
20
|
+
return if ENV['DO_BY_TESTING']
|
21
|
+
return unless line.match('TODO')
|
22
|
+
matches = line.match('TODO (\d{8}) (.*)')
|
23
|
+
unless matches
|
24
|
+
Kernel.abort("#{path}:#{line_no} No due by date detected in TODO comment")
|
25
|
+
end
|
26
|
+
date_portion = matches[1]
|
27
|
+
comment = matches[2]
|
28
|
+
parsed_date = DateTime.parse date_portion
|
29
|
+
if parsed_date < Time.now
|
30
|
+
message = "Expired TODO: #{comment} (#{date_portion})"
|
31
|
+
Kernel.abort(message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/do_by_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'do_by'
|
2
|
+
|
3
|
+
describe DoBy::Note do
|
4
|
+
before do
|
5
|
+
allow(Time).to receive(:now) { DateTime.parse('20140601') }
|
6
|
+
end
|
7
|
+
|
8
|
+
it "is happy with a note with a date in the future" do
|
9
|
+
scan '# TODO 20140701 with date'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is not happy with a note with a date in the past" do
|
13
|
+
expect do
|
14
|
+
scan '# TODO 20140501 with date'
|
15
|
+
end.to exit_with_code(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "is not happy with a note without a date" do
|
19
|
+
expect do
|
20
|
+
scan '# TODO without date'
|
21
|
+
end.to exit_with_code(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def scan(line)
|
27
|
+
DoBy::Note.parse line
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# http://stackoverflow.com/questions/1480537/how-can-i-validate-exits-and-aborts-in-rspec
|
32
|
+
RSpec::Matchers.define :exit_with_code do |exp_code|
|
33
|
+
actual = nil
|
34
|
+
match do |block|
|
35
|
+
begin
|
36
|
+
block.call
|
37
|
+
rescue SystemExit => e
|
38
|
+
actual = e.status
|
39
|
+
end
|
40
|
+
actual and actual == exp_code
|
41
|
+
end
|
42
|
+
failure_message do |block|
|
43
|
+
"expected block to call exit(#{exp_code}) but exit" +
|
44
|
+
(actual.nil? ? " not called" : "(#{actual}) was called")
|
45
|
+
end
|
46
|
+
failure_message_when_negated do |block|
|
47
|
+
"expected block not to call exit(#{exp_code})"
|
48
|
+
end
|
49
|
+
description do
|
50
|
+
"expect block to call exit(#{exp_code})"
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: do_by
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Waite
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Expiring 'to do' reminders
|
56
|
+
email:
|
57
|
+
- github.aw@andywaite.com
|
58
|
+
executables:
|
59
|
+
- do_by
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/do_by
|
69
|
+
- do_by.gemspec
|
70
|
+
- lib/do_by.rb
|
71
|
+
- lib/do_by/version.rb
|
72
|
+
- spec/do_by_spec.rb
|
73
|
+
homepage: https://github.com/andyw8/do_by
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Expiring 'to do' reminders
|
97
|
+
test_files:
|
98
|
+
- spec/do_by_spec.rb
|