checkcheckit 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ tmp
18
18
  bin/minitar
19
19
  bin/rdebug
20
20
  bin/turn
21
+ test/.test.profile*
data/README.md CHANGED
@@ -8,15 +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
+ - interactive run
12
+ - socket.io between page and cmd line
15
13
  - save a run
16
14
  - to file
17
15
  - to service
18
16
  - resume a run
19
- - run to campfire
17
+ - locally
18
+
19
+ - post to campfire
20
20
 
21
21
  ## Usage
22
22
 
@@ -76,7 +76,20 @@ For example:
76
76
  Check: failures!
77
77
  Notes: <enter>
78
78
 
79
+ ### Live mode
80
+
81
+ This is fun. Specify an email (or a comma-separated list) on the command line and
82
+ that address will receive a message with a link to a web version of the checklist.
83
+
84
+ Right now the cmd line client and web don't interact. For now.
85
+
86
+ $ check start deploy --email me@me.com,another.guy@gmail.com
87
+ |-------| Step 1: Pull everything from git
88
+ > git pull origin
89
+
90
+ You'll get an email with a link:
79
91
 
92
+ http://checkcheckit.herokuapp.com/1
80
93
 
81
94
  ## Contributing
82
95
 
data/checkcheckit.gemspec CHANGED
@@ -20,4 +20,5 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'lucy-goosey', '~> 0.2.0'
21
21
  gem.add_dependency 'excon'
22
22
  gem.add_dependency 'yajl-ruby'
23
+ gem.add_dependency 'socketio-client'
23
24
  end
@@ -2,11 +2,12 @@ require 'ostruct'
2
2
 
3
3
  class CheckCheckIt::Console
4
4
  attr_accessor :list_dir
5
- attr_accessor :out_stream, :in_stream
5
+ attr_accessor :out_stream, :in_stream, :web_socket
6
6
 
7
7
  def initialize(opts = {})
8
8
  @out_stream = opts[:out_stream] || $stdout
9
9
  @in_stream = opts[:in_stream] || $stdin
10
+ @web_socket = opts[:web_socket] || SocketIO
10
11
  end
11
12
 
12
13
  def dir
@@ -40,13 +41,21 @@ class CheckCheckIt::Console
40
41
  list_name = Dir[dir + '/*/*'].find{ |fname| fname.include? target }
41
42
  if list_name
42
43
  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' })
44
+ web_service_url = ENV['CHECKCHECKIT_URL']
45
+ client = nil
46
+ if (emails = @options['email']) || @options['live']
47
+
48
+ @list_id = list_id = notify_server_of_start(emails, list)
49
+
50
+ puts "Live at URL: #{web_service_url}/#{list_id}"
51
+
52
+ if @options['ws']
53
+ @client = web_socket.connect(web_service_url, sync: true) do
54
+ after_start do
55
+ emit('register', {list_id: list_id})
56
+ end
57
+ end
58
+ end
50
59
  end
51
60
 
52
61
  step_through_list(list)
@@ -95,6 +104,13 @@ class CheckCheckIt::Console
95
104
  return
96
105
  end
97
106
 
107
+ if @client
108
+ @client.emit 'check', {
109
+ list_id: @list_id,
110
+ step_id: i
111
+ }
112
+ end
113
+
98
114
  results[i] = {
99
115
  step: i + 1,
100
116
  name: step.name,
@@ -138,4 +154,18 @@ class CheckCheckIt::Console
138
154
  @out_stream.print text
139
155
  end
140
156
 
157
+ def web_service_url
158
+ ENV['CHECKCHECKIT_URL']
159
+ end
160
+
161
+ # Returns id
162
+ def notify_server_of_start(emails, list)
163
+ Excon.post(web_service_url, :body => {
164
+ emails: emails,
165
+ list: list.to_h
166
+ }.to_json,
167
+ :headers => {
168
+ 'Content-Type' => 'application/json'
169
+ }).body.to_i
170
+ end
141
171
  end
@@ -1,3 +1,3 @@
1
1
  module CheckCheckIt
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/checkcheckit.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'lucy-goosey'
2
2
  require 'excon'
3
3
  require 'yajl/json_gem'
4
+ require 'socketio'
4
5
 
5
6
  require "checkcheckit/version"
6
7
 
data/test/start_test.rb CHANGED
@@ -5,7 +5,8 @@ class StartTest < CheckCheckIt::TestCase
5
5
  def setup
6
6
  super
7
7
  Examples.create_grocery_list(home)
8
- console.in_stream = MiniTest::Mock.new
8
+ console.in_stream = MiniTest::Mock.new
9
+ console.web_socket = MiniTest::Mock.new
9
10
  end
10
11
 
11
12
  def test_list_parses_steps
@@ -29,6 +30,7 @@ class StartTest < CheckCheckIt::TestCase
29
30
  # The webservice sends you an email with a link to the list so
30
31
  # you can run it on the web.
31
32
  def test_email_flag_triggers_live_mode
33
+ client = MiniTest::Mock.new
32
34
  Excon.stub({:method => :post, :body => {
33
35
  emails: "csquared@heroku.com,thea.lamkin@gmail.com",
34
36
  list: List.new(home + '/personal/groceries').to_h
@@ -37,6 +39,16 @@ class StartTest < CheckCheckIt::TestCase
37
39
  check "start groceries --email csquared@heroku.com,thea.lamkin@gmail.com"
38
40
  end
39
41
 
42
+ def test_websocket_mode
43
+ set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
44
+ client = MiniTest::Mock.new
45
+ console.web_socket.expect :connect, client, [String, {sync: true}]
46
+ Excon.stub({:method => :post}, {:status => 200})
47
+ 3.times { console.in_stream.expect :gets, "y" }
48
+ 3.times { client.expect :emit, true, ['check', Hash] }
49
+ check "start groceries --ws"
50
+ end
51
+
40
52
  # Same as above but with env set
41
53
  def test_reads_email_from_env
42
54
  set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
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
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-15 00:00:00.000000000 Z
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lucy-goosey
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: socketio-client
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: Checklists like a boss
63
79
  email:
64
80
  - christopher.continanza@gmail.com
@@ -98,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
114
  version: '0'
99
115
  segments:
100
116
  - 0
101
- hash: 2187395605340468974
117
+ hash: 861194127315958268
102
118
  required_rubygems_version: !ruby/object:Gem::Requirement
103
119
  none: false
104
120
  requirements:
@@ -107,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
123
  version: '0'
108
124
  segments:
109
125
  - 0
110
- hash: 2187395605340468974
126
+ hash: 861194127315958268
111
127
  requirements: []
112
128
  rubyforge_project:
113
129
  rubygems_version: 1.8.23