checkcheckit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/README.md +4 -6
- data/checkcheckit.gemspec +2 -0
- data/lib/checkcheckit/console.rb +15 -5
- data/lib/checkcheckit/list.rb +9 -0
- data/lib/checkcheckit/version.rb +1 -1
- data/lib/checkcheckit.rb +3 -0
- data/test/console_test.rb +32 -9
- data/test/helper.rb +14 -16
- data/test/list_test.rb +11 -2
- data/test/start_test.rb +33 -2
- metadata +36 -3
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,17 +8,15 @@ use checklists, like a boss
|
|
8
8
|
|
9
9
|
## TODO
|
10
10
|
|
11
|
+
- run on phone
|
12
|
+
- kick off from cmd line
|
13
|
+
- send email to self
|
14
|
+
- click on url in email in phone
|
11
15
|
- save a run
|
12
16
|
- to file
|
13
17
|
- to service
|
14
18
|
- resume a run
|
15
19
|
- run to campfire
|
16
|
-
- commands with confirmation
|
17
|
-
- saves results
|
18
|
-
- run on phone
|
19
|
-
- kick off from cmd line
|
20
|
-
- send email to self
|
21
|
-
- click on url in email in phone
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
data/checkcheckit.gemspec
CHANGED
data/lib/checkcheckit/console.rb
CHANGED
@@ -15,6 +15,7 @@ class CheckCheckIt::Console
|
|
15
15
|
|
16
16
|
def run!(args = [])
|
17
17
|
@options = Lucy::Goosey.parse_options(args)
|
18
|
+
@options['email'] ||= ENV['CHECKCHECKIT_EMAIL']
|
18
19
|
@list_dir = File.expand_path(@options.fetch('home', '~/checkcheckit'))
|
19
20
|
|
20
21
|
if args.length == 0
|
@@ -36,9 +37,19 @@ class CheckCheckIt::Console
|
|
36
37
|
list(args)
|
37
38
|
return
|
38
39
|
end
|
39
|
-
|
40
|
-
if
|
41
|
-
|
40
|
+
list_name = Dir[dir + '/*/*'].find{ |fname| fname.include? target }
|
41
|
+
if list_name
|
42
|
+
list = List.new(list_name)
|
43
|
+
if emails = @options['email']
|
44
|
+
web_service_url = ENV['CHECKCHECKIT_URL']
|
45
|
+
response = Excon.post(web_service_url, :body => {
|
46
|
+
emails: emails,
|
47
|
+
list: list.to_h
|
48
|
+
}.to_json,
|
49
|
+
:headers => { 'Content-Type' => 'application/json' })
|
50
|
+
end
|
51
|
+
|
52
|
+
step_through_list(list)
|
42
53
|
else
|
43
54
|
puts "Could not find checklist via: #{target}"
|
44
55
|
end
|
@@ -97,8 +108,7 @@ class CheckCheckIt::Console
|
|
97
108
|
puts
|
98
109
|
end
|
99
110
|
|
100
|
-
|
101
|
-
puts "#{fmt_results(results)} #{msg}"
|
111
|
+
puts "#{fmt_results(results)} Done"
|
102
112
|
save_results(list, results)
|
103
113
|
end
|
104
114
|
|
data/lib/checkcheckit/list.rb
CHANGED
@@ -6,6 +6,11 @@ class List
|
|
6
6
|
@name = fname.sub(File.extname(fname), '')
|
7
7
|
@body = File.read(file)
|
8
8
|
@steps = parse_steps(@body)
|
9
|
+
@current_step = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{name: @name, steps: @steps.map(&:to_h)}
|
9
14
|
end
|
10
15
|
|
11
16
|
private
|
@@ -33,5 +38,9 @@ class List
|
|
33
38
|
@name = name
|
34
39
|
@body = body
|
35
40
|
end
|
41
|
+
|
42
|
+
def to_h
|
43
|
+
{name: @name, body: @body}
|
44
|
+
end
|
36
45
|
end
|
37
46
|
end
|
data/lib/checkcheckit/version.rb
CHANGED
data/lib/checkcheckit.rb
CHANGED
data/test/console_test.rb
CHANGED
@@ -23,6 +23,7 @@ class ConsoleTest < CheckCheckIt::TestCase
|
|
23
23
|
|
24
24
|
|
25
25
|
def test_default_no_notes
|
26
|
+
Examples.create_grocery_list(home)
|
26
27
|
console.in_stream = MiniTest::Mock.new
|
27
28
|
console.out_stream = MiniTest::Mock.new
|
28
29
|
|
@@ -39,22 +40,44 @@ class ConsoleTest < CheckCheckIt::TestCase
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_includes_notes
|
43
|
+
Examples.create_grocery_list(home)
|
42
44
|
console.in_stream = MiniTest::Mock.new
|
43
45
|
console.out_stream = MiniTest::Mock.new
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
3.times do
|
49
|
-
console.out_stream.expect :print, true, ["Check: "]
|
50
|
-
console.out_stream.expect :print, true, ["Notes: "]
|
51
|
-
end
|
47
|
+
#check 1
|
48
|
+
console.out_stream.expect :puts, true, ["|...| Step 1: pineapple"]
|
49
|
+
console.out_stream.expect :print, true, ["Check: "]
|
52
50
|
console.in_stream.expect :gets, "n"
|
51
|
+
|
52
|
+
# notes 1
|
53
|
+
console.out_stream.expect :print, true, ["Notes: "]
|
53
54
|
console.in_stream.expect :gets, "Shit's fucked"
|
55
|
+
console.out_stream.expect :puts, true, ['']
|
56
|
+
|
57
|
+
#check 2
|
58
|
+
console.out_stream.expect :puts, true, ["|-..| Step 2: mangoes"]
|
59
|
+
console.out_stream.expect :puts, true, [String]
|
60
|
+
console.out_stream.expect :print, true, ["Check: "]
|
54
61
|
console.in_stream.expect :gets, "y"
|
55
|
-
|
62
|
+
|
63
|
+
# notes 2
|
64
|
+
console.out_stream.expect :print, true, ["Notes: "]
|
65
|
+
console.in_stream.expect :gets, "Tasty"
|
66
|
+
console.out_stream.expect :puts, true, ['']
|
67
|
+
|
68
|
+
# NO FUDGE FOR YOU
|
69
|
+
console.out_stream.expect :puts, true, ["|-+.| Step 3: fudge"]
|
70
|
+
console.out_stream.expect :puts, true, [String]
|
71
|
+
console.out_stream.expect :print, true, ["Check: "]
|
56
72
|
console.in_stream.expect :gets, "n"
|
57
|
-
|
73
|
+
|
74
|
+
# notes 3
|
75
|
+
console.out_stream.expect :print, true, ["Notes: "]
|
76
|
+
console.in_stream.expect :gets, "Tasty"
|
77
|
+
console.out_stream.expect :puts, true, ['']
|
78
|
+
|
79
|
+
console.out_stream.expect :puts, true, ['|-+-| Done']
|
80
|
+
|
58
81
|
check "start groceries --notes"
|
59
82
|
console.in_stream.verify
|
60
83
|
console.out_stream.verify
|
data/test/helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib')))
|
2
2
|
ENV['RACK_ENV'] = 'test'
|
3
|
+
ENV['CHECKCHECKIT_URL'] = 'http://example.com'
|
3
4
|
|
4
|
-
require '
|
5
|
-
require 'minitest/spec'
|
5
|
+
require 'vault-test-tools'
|
6
6
|
require 'minitest/mock'
|
7
7
|
require 'fakefs'
|
8
8
|
require 'checkcheckit'
|
@@ -12,9 +12,9 @@ module Examples
|
|
12
12
|
dir = File.join(home, 'personal')
|
13
13
|
FileUtils.mkdir_p(dir)
|
14
14
|
File.open(File.join(dir, 'groceries'), 'w') do |file|
|
15
|
-
file << "- pineapple "
|
16
|
-
file << "
|
17
|
-
file << "
|
15
|
+
file << "- pineapple \n"
|
16
|
+
file << "- mangoes \n enhance the flavor with \n spice\n"
|
17
|
+
file << "- fudge \n best from a place in sutter creek"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -50,23 +50,21 @@ module ConsoleTestHelpers
|
|
50
50
|
console.list_dir || '~/checkcheckit'
|
51
51
|
end
|
52
52
|
|
53
|
-
end
|
54
|
-
|
55
|
-
class CheckCheckIt::TestCase < MiniTest::Unit::TestCase
|
56
|
-
include ConsoleTestHelpers
|
57
|
-
|
58
53
|
def setup
|
59
54
|
super
|
60
55
|
reset_console
|
56
|
+
FakeFS.activate!
|
57
|
+
Excon.defaults[:mock] = true
|
61
58
|
end
|
62
|
-
end
|
63
59
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
reset_console
|
60
|
+
def teardown
|
61
|
+
super
|
62
|
+
FakeFS.deactivate!
|
63
|
+
Excon.stubs.clear
|
69
64
|
end
|
70
65
|
end
|
71
66
|
|
67
|
+
CheckCheckIt::TestCase = Class.new(Vault::TestCase)
|
68
|
+
CheckCheckIt::Spec = Class.new(Vault::Spec)
|
72
69
|
MiniTest::Spec.register_spec_type //, CheckCheckIt::Spec
|
70
|
+
Vault::Test.include_in_all Vault::Test::EnvironmentHelpers, ConsoleTestHelpers
|
data/test/list_test.rb
CHANGED
@@ -3,6 +3,7 @@ require 'helper'
|
|
3
3
|
class ListTest < CheckCheckIt::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
+
super
|
6
7
|
Examples.create_grocery_list(home)
|
7
8
|
@list = List.new('~/checkcheckit/personal/groceries')
|
8
9
|
end
|
@@ -11,7 +12,15 @@ class ListTest < CheckCheckIt::TestCase
|
|
11
12
|
@list.steps.size.must_equal 3
|
12
13
|
end
|
13
14
|
|
14
|
-
def test_list_parses_commands
|
15
|
-
end
|
16
15
|
|
16
|
+
def test_to_json
|
17
|
+
@list.to_h.must_equal({
|
18
|
+
name: 'groceries',
|
19
|
+
steps: [
|
20
|
+
{ name: 'pineapple', body: '' },
|
21
|
+
{ name: 'mangoes', body: " enhance the flavor with \n spice\n" },
|
22
|
+
{ name: 'fudge', body: ' best from a place in sutter creek'}
|
23
|
+
]
|
24
|
+
})
|
25
|
+
end
|
17
26
|
end
|
data/test/start_test.rb
CHANGED
@@ -3,12 +3,13 @@ require 'helper'
|
|
3
3
|
class StartTest < CheckCheckIt::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
+
super
|
6
7
|
Examples.create_grocery_list(home)
|
8
|
+
console.in_stream = MiniTest::Mock.new
|
7
9
|
end
|
8
10
|
|
9
11
|
def test_list_parses_steps
|
10
|
-
console.in_stream
|
11
|
-
6.times { console.in_stream.expect :gets, "y" }
|
12
|
+
3.times { console.in_stream.expect :gets, "y" }
|
12
13
|
result = check "start groceries"
|
13
14
|
console.in_stream.verify
|
14
15
|
end
|
@@ -19,5 +20,35 @@ class StartTest < CheckCheckIt::TestCase
|
|
19
20
|
output.must_include "groceries"
|
20
21
|
end
|
21
22
|
|
23
|
+
# When you do
|
24
|
+
#
|
25
|
+
# check start deploy --email csquared@heroku.com
|
26
|
+
#
|
27
|
+
# It PUT/POSTS? to the checkcheckit webservice
|
28
|
+
#
|
29
|
+
# The webservice sends you an email with a link to the list so
|
30
|
+
# you can run it on the web.
|
31
|
+
def test_email_flag_triggers_live_mode
|
32
|
+
Excon.stub({:method => :post, :body => {
|
33
|
+
emails: "csquared@heroku.com,thea.lamkin@gmail.com",
|
34
|
+
list: List.new(home + '/personal/groceries').to_h
|
35
|
+
}.to_json}, {:status => 200})
|
36
|
+
3.times { console.in_stream.expect :gets, "y" }
|
37
|
+
check "start groceries --email csquared@heroku.com,thea.lamkin@gmail.com"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Same as above but with env set
|
41
|
+
def test_reads_email_from_env
|
42
|
+
set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
|
43
|
+
Excon.stub({:method => :post, :body => {
|
44
|
+
emails: "csquared@heroku.com,thea.lamkin@gmail.com",
|
45
|
+
list: List.new(home + '/personal/groceries').to_h
|
46
|
+
}.to_json}, {:status => 200})
|
47
|
+
3.times { console.in_stream.expect :gets, "y" }
|
48
|
+
check "start groceries"
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_reads_url_from_env
|
52
|
+
end
|
22
53
|
end
|
23
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkcheckit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: excon
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yajl-ruby
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
30
62
|
description: Checklists like a boss
|
31
63
|
email:
|
32
64
|
- christopher.continanza@gmail.com
|
@@ -66,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
98
|
version: '0'
|
67
99
|
segments:
|
68
100
|
- 0
|
69
|
-
hash:
|
101
|
+
hash: 2187395605340468974
|
70
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
103
|
none: false
|
72
104
|
requirements:
|
@@ -75,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
107
|
version: '0'
|
76
108
|
segments:
|
77
109
|
- 0
|
78
|
-
hash:
|
110
|
+
hash: 2187395605340468974
|
79
111
|
requirements: []
|
80
112
|
rubyforge_project:
|
81
113
|
rubygems_version: 1.8.23
|
@@ -88,3 +120,4 @@ test_files:
|
|
88
120
|
- test/list_test.rb
|
89
121
|
- test/resume_test.rb
|
90
122
|
- test/start_test.rb
|
123
|
+
has_rdoc:
|