checkcheckit 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +84 -0
- data/Rakefile +1 -0
- data/bin/check +7 -0
- data/bin/t +1 -0
- data/checkcheckit.gemspec +19 -0
- data/lib/checkcheckit/console.rb +106 -0
- data/lib/checkcheckit/list.rb +37 -0
- data/lib/checkcheckit/version.rb +3 -0
- data/lib/checkcheckit.rb +7 -0
- data/test/console_test.rb +26 -0
- data/test/helper.rb +72 -0
- data/test/list_test.rb +17 -0
- data/test/results_test.rb +46 -0
- data/test/start_test.rb +20 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Chris Continanza
|
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,84 @@
|
|
1
|
+
# Check, Check, It
|
2
|
+
|
3
|
+
use checklists, like a boss
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install checkcheckit
|
8
|
+
|
9
|
+
## TODO
|
10
|
+
|
11
|
+
- option parsing
|
12
|
+
- save a run
|
13
|
+
- to file
|
14
|
+
- to service
|
15
|
+
- resume a run
|
16
|
+
- run commands with confirmation
|
17
|
+
- saves results
|
18
|
+
- `pull` list(s) (via git)
|
19
|
+
- `push` list(s) (via git)
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### `list` the checklists
|
24
|
+
|
25
|
+
`checkcheckit` assumes a home directory of ~/checkcheckit
|
26
|
+
|
27
|
+
In that directory are folders for your organizations, groups, etc.
|
28
|
+
|
29
|
+
In those folders are your checklists.
|
30
|
+
|
31
|
+
A "checklist" is just a text file.
|
32
|
+
Every line that starts with a dash '-' is a step.
|
33
|
+
Everything beneath a step is that step's body or description.
|
34
|
+
|
35
|
+
$ check list
|
36
|
+
# Checklists
|
37
|
+
heroku
|
38
|
+
todo
|
39
|
+
personal
|
40
|
+
todo
|
41
|
+
vault
|
42
|
+
deploy
|
43
|
+
|
44
|
+
### `start` a checklist
|
45
|
+
|
46
|
+
You can go through a checklist by running `check start ` and then the checklist name.
|
47
|
+
|
48
|
+
(NIY - Not Implemented Yet)
|
49
|
+
If there are multiple checklists with the same name use the format `folder/checklist`.
|
50
|
+
|
51
|
+
When you iterate through a checklist you can just type "enter", "y", or "+" to confirm a step.
|
52
|
+
|
53
|
+
A "no", "-", or body of text (body of text NIY) is considered a failed step.
|
54
|
+
The body of text is for describing what went wrong.
|
55
|
+
|
56
|
+
For example:
|
57
|
+
|
58
|
+
$ check start deploy
|
59
|
+
|-------| Step 1: Pull everything from git
|
60
|
+
> git pull origin
|
61
|
+
Check: <enter>
|
62
|
+
|
63
|
+
|+------| Step 2: Make sure there are no uncommitted changes
|
64
|
+
> `git status`
|
65
|
+
Check: <n>
|
66
|
+
|
67
|
+
|+------| Step 3: Diff master with heroku/master
|
68
|
+
Make sure the change you want to push are what you're pushing
|
69
|
+
> git fetch heroku
|
70
|
+
> git diff heroku/master | $EDITOR
|
71
|
+
Check: <y>
|
72
|
+
|
73
|
+
|+-+----| Step 4: Run the test suite
|
74
|
+
Check: failures!
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
1. Fork it
|
81
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
82
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
83
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
84
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/check
ADDED
data/bin/t
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bundle exec turn -Itest test/*_test.rb
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'checkcheckit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "checkcheckit"
|
8
|
+
gem.version = CheckCheckIt::VERSION
|
9
|
+
gem.authors = ["Chris Continanza"]
|
10
|
+
gem.email = ["christopher.continanza@gmail.com"]
|
11
|
+
gem.description = %q{Checklists like a boss}
|
12
|
+
gem.summary = %q{Command line tool for using checklists}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = 'check'
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class CheckCheckIt::Console
|
4
|
+
attr_accessor :list_dir
|
5
|
+
attr_accessor :stream, :in_stream
|
6
|
+
|
7
|
+
def initialize(opts = {})
|
8
|
+
ARGV.clear
|
9
|
+
default_dir = opts.fetch(:dir, '~/checkcheckit')
|
10
|
+
@list_dir = File.expand_path(default_dir)
|
11
|
+
@stream = opts[:out_stream] || STDOUT
|
12
|
+
@in_stream = opts[:in_stream] || STDIN
|
13
|
+
end
|
14
|
+
|
15
|
+
def puts(text = '')
|
16
|
+
@stream.puts text
|
17
|
+
end
|
18
|
+
|
19
|
+
def print(text = '')
|
20
|
+
@stream.print text
|
21
|
+
end
|
22
|
+
|
23
|
+
def run!(args)
|
24
|
+
if args.length == 0
|
25
|
+
puts "No command given"
|
26
|
+
else
|
27
|
+
method = args.shift
|
28
|
+
if respond_to? method
|
29
|
+
send method, args
|
30
|
+
else
|
31
|
+
puts "did not understand: #{method}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def dir
|
37
|
+
File.expand_path(@list_dir)
|
38
|
+
end
|
39
|
+
|
40
|
+
def step_through_list(list)
|
41
|
+
results = Array.new(list.steps.length, false)
|
42
|
+
|
43
|
+
list.steps.each_with_index do |step, i|
|
44
|
+
puts "#{fmt_results(results)} Step #{i+1}: #{step.name}"
|
45
|
+
puts step.body unless step.body.empty?
|
46
|
+
print "Check: "
|
47
|
+
|
48
|
+
case input = in_stream.gets
|
49
|
+
when /^[y|+]$/ || ''
|
50
|
+
results[i] = true
|
51
|
+
when /^[n|-]$/
|
52
|
+
results[i] = false
|
53
|
+
else
|
54
|
+
results[i] = false
|
55
|
+
end
|
56
|
+
puts
|
57
|
+
end
|
58
|
+
|
59
|
+
msg = results.all? { |r| r } ? "Done" : "Issues"
|
60
|
+
puts "#{fmt_results(results)} #{msg}"
|
61
|
+
save_results(list, results)
|
62
|
+
end
|
63
|
+
|
64
|
+
def save_results(list,results)
|
65
|
+
report = {
|
66
|
+
'list-name' => list.name,
|
67
|
+
'results' => []
|
68
|
+
}
|
69
|
+
list.steps.each_with_index do |step, i|
|
70
|
+
report['results'] << {
|
71
|
+
index: i,
|
72
|
+
name: step.name,
|
73
|
+
body: step.body,
|
74
|
+
result: results[i] ? 'CHECK' : 'FAIL',
|
75
|
+
status: results[i] ? 1 : 0,
|
76
|
+
}
|
77
|
+
end
|
78
|
+
report
|
79
|
+
end
|
80
|
+
|
81
|
+
def start(args)
|
82
|
+
target = args.join(' ')
|
83
|
+
hit = Dir[dir + '/*/*'].find{ |fname| fname.include? target }
|
84
|
+
if hit
|
85
|
+
step_through_list(List.new(hit))
|
86
|
+
else
|
87
|
+
puts "Could not find checklist via: #{target}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def list(args)
|
92
|
+
puts "# Checklists\n"
|
93
|
+
Dir[dir + '/*'].each do |dir|
|
94
|
+
team = File.basename dir
|
95
|
+
puts team
|
96
|
+
Dir[dir + '/*'].each do |file|
|
97
|
+
puts " " + List.new(file).name
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
def fmt_results(results)
|
104
|
+
"|#{results.map { |r| r ? '+' : '-' }.join}|"
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class List
|
2
|
+
attr_accessor :name, :body, :steps
|
3
|
+
|
4
|
+
def initialize(file)
|
5
|
+
fname = File.basename(file)
|
6
|
+
@name = fname.sub(File.extname(fname), '')
|
7
|
+
@body = File.read(file)
|
8
|
+
@steps = parse_steps(@body)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def parse_steps(body)
|
14
|
+
steps = []
|
15
|
+
current_step = nil
|
16
|
+
body.lines.each do |line|
|
17
|
+
next if line.strip.empty?
|
18
|
+
if line =~ /^-/
|
19
|
+
current_name = line.sub(/^-/,'').strip
|
20
|
+
current_step = Step.new(current_name)
|
21
|
+
steps << current_step
|
22
|
+
elsif current_step
|
23
|
+
current_step.body << line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
steps
|
27
|
+
end
|
28
|
+
|
29
|
+
class Step
|
30
|
+
attr_accessor :name, :body
|
31
|
+
|
32
|
+
def initialize(name, body = '')
|
33
|
+
@name = name
|
34
|
+
@body = body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/checkcheckit.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ConsoleTest < CheckCheckIt::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_lists_orgs_and_lists
|
9
|
+
Examples.create_grocery_list(home)
|
10
|
+
check "list"
|
11
|
+
assert_match(/^# Checklists\n/, output)
|
12
|
+
assert_match(/^personal\n/, output)
|
13
|
+
assert_match(/^ groceries\n/, output)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_configurable_list_dir
|
17
|
+
dir = File.join('/foo', 'personal')
|
18
|
+
FileUtils.mkdir_p(dir)
|
19
|
+
|
20
|
+
@console = CheckCheckIt::Console.new(:dir => '/foo', out_stream: StringIO.new)
|
21
|
+
|
22
|
+
check "list"
|
23
|
+
assert_match(/^personal\n/, output)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib')))
|
2
|
+
ENV['RACK_ENV'] = 'test'
|
3
|
+
|
4
|
+
require 'minitest/unit'
|
5
|
+
require 'minitest/spec'
|
6
|
+
require 'minitest/mock'
|
7
|
+
require 'fakefs'
|
8
|
+
require 'checkcheckit'
|
9
|
+
|
10
|
+
module Examples
|
11
|
+
def self.create_grocery_list(home)
|
12
|
+
dir = File.join(home, 'personal')
|
13
|
+
FileUtils.mkdir_p(dir)
|
14
|
+
File.open(File.join(dir, 'groceries'), 'w') do |file|
|
15
|
+
file << "- pineapple "
|
16
|
+
file << "\n- mangoes \n enhance the flavor with \n spice "
|
17
|
+
file << "\n- fudge \n best from a place in sutter creek"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module ConsoleTestHelpers
|
23
|
+
# Internal: Runs command lines in tests like their command line invocation.
|
24
|
+
#
|
25
|
+
# Examples:
|
26
|
+
#
|
27
|
+
# # check 'list'
|
28
|
+
#
|
29
|
+
# # check 'list deploy'
|
30
|
+
#
|
31
|
+
# # check 'start deploy'
|
32
|
+
def check(cmd_string)
|
33
|
+
console.run! cmd_string.split
|
34
|
+
end
|
35
|
+
|
36
|
+
def reset_console
|
37
|
+
## Clear out the output
|
38
|
+
@console = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def console
|
42
|
+
@console ||= CheckCheckIt::Console.new(out_stream: StringIO.new)
|
43
|
+
end
|
44
|
+
|
45
|
+
def output
|
46
|
+
console.stream.string
|
47
|
+
end
|
48
|
+
|
49
|
+
def home
|
50
|
+
console.list_dir
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
class CheckCheckIt::TestCase < MiniTest::Unit::TestCase
|
56
|
+
include ConsoleTestHelpers
|
57
|
+
|
58
|
+
def setup
|
59
|
+
super
|
60
|
+
reset_console
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class CheckCheckIt::Spec < MiniTest::Spec
|
65
|
+
include ConsoleTestHelpers
|
66
|
+
|
67
|
+
before do
|
68
|
+
reset_console
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
MiniTest::Spec.register_spec_type //, CheckCheckIt::Spec
|
data/test/list_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ListTest < CheckCheckIt::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Examples.create_grocery_list(home)
|
7
|
+
@list = List.new('~/checkcheckit/personal/groceries')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_list_parses_steps
|
11
|
+
@list.steps.size.must_equal 3
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_list_parses_commands
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe 'Storing Results after a run' do
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
Examples.create_grocery_list(home)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should record the pass/fail of each step" do
|
10
|
+
console.in_stream = MiniTest::Mock.new
|
11
|
+
console.in_stream.expect :gets, "n"
|
12
|
+
console.in_stream.expect :gets, "y"
|
13
|
+
console.in_stream.expect :gets, "n"
|
14
|
+
result = check "start groceries"
|
15
|
+
console.in_stream.verify
|
16
|
+
result["results"][0][:result].must_equal "FAIL"
|
17
|
+
result["results"][0][:status].must_equal 0
|
18
|
+
result["results"][1][:result].must_equal "CHECK"
|
19
|
+
result["results"][1][:status].must_equal 1
|
20
|
+
result["results"][2][:result].must_equal "FAIL"
|
21
|
+
result["results"][2][:status].must_equal 0
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should record the name of each step" do
|
25
|
+
console.in_stream = MiniTest::Mock.new
|
26
|
+
3.times { console.in_stream.expect :gets, "y" }
|
27
|
+
result = check "start groceries"
|
28
|
+
console.in_stream.verify
|
29
|
+
result["results"][0][:name].must_equal "pineapple"
|
30
|
+
result["results"][1][:name].must_equal "mangoes"
|
31
|
+
result["results"][2][:name].must_equal "fudge"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should record the body of each step" do
|
35
|
+
console.in_stream = MiniTest::Mock.new
|
36
|
+
3.times { console.in_stream.expect :gets, "y" }
|
37
|
+
result = check "start groceries"
|
38
|
+
console.in_stream.verify
|
39
|
+
=begin
|
40
|
+
result["results"][0][:body].must_equal ""
|
41
|
+
result["results"][1][:name].must_equal "enhance the flavor with \n spice"
|
42
|
+
result["results"][2][:name].must_equal "best from a place in sutter creek"
|
43
|
+
=end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/test/start_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class StartTest < CheckCheckIt::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Examples.create_grocery_list(home)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_list_parses_steps
|
10
|
+
console.in_stream = MiniTest::Mock.new
|
11
|
+
3.times { console.in_stream.expect :gets, "y" }
|
12
|
+
result = check "start groceries"
|
13
|
+
console.in_stream.verify
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list_parses_commands
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: checkcheckit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Continanza
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Checklists like a boss
|
15
|
+
email:
|
16
|
+
- christopher.continanza@gmail.com
|
17
|
+
executables:
|
18
|
+
- check
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- bin/check
|
28
|
+
- bin/t
|
29
|
+
- checkcheckit.gemspec
|
30
|
+
- lib/checkcheckit.rb
|
31
|
+
- lib/checkcheckit/console.rb
|
32
|
+
- lib/checkcheckit/list.rb
|
33
|
+
- lib/checkcheckit/version.rb
|
34
|
+
- test/console_test.rb
|
35
|
+
- test/helper.rb
|
36
|
+
- test/list_test.rb
|
37
|
+
- test/results_test.rb
|
38
|
+
- test/start_test.rb
|
39
|
+
homepage: ''
|
40
|
+
licenses: []
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
hash: 3522511683697989869
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
hash: 3522511683697989869
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.23
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Command line tool for using checklists
|
69
|
+
test_files:
|
70
|
+
- test/console_test.rb
|
71
|
+
- test/helper.rb
|
72
|
+
- test/list_test.rb
|
73
|
+
- test/results_test.rb
|
74
|
+
- test/start_test.rb
|