checkcheckit 0.0.6 → 0.1.0
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/lib/checkcheckit/console.rb +23 -13
- data/lib/checkcheckit/version.rb +1 -1
- data/test/start_test.rb +4 -9
- metadata +3 -3
data/lib/checkcheckit/console.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ostruct'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
class CheckCheckIt::Console
|
4
5
|
attr_accessor :list_dir
|
@@ -41,26 +42,21 @@ class CheckCheckIt::Console
|
|
41
42
|
list_name = Dir[dir + '/*/*'].find{ |fname| fname.include? target }
|
42
43
|
if list_name
|
43
44
|
list = List.new(list_name)
|
44
|
-
web_service_url = ENV['CHECKCHECKIT_URL']
|
45
|
-
client = nil
|
46
45
|
if (emails = @options['email']) || @options['live']
|
47
|
-
|
48
46
|
@list_id = list_id = notify_server_of_start(emails, list)
|
47
|
+
puts "Live at URL: #{URI.join(web_service_url, list_id)}"
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
begin
|
54
|
-
@client = web_socket.connect(web_service_url, sync: true) do
|
55
|
-
after_start { emit('register', {list_id: list_id}) }
|
56
|
-
end
|
57
|
-
rescue Errno::ECONNREFUSED => e
|
58
|
-
STDERR.puts "Websocket refused connection"
|
49
|
+
begin
|
50
|
+
@client = web_socket.connect(web_service_url, sync: true) do
|
51
|
+
after_start { emit('register', {list_id: list_id}) }
|
59
52
|
end
|
53
|
+
rescue Errno::ECONNREFUSED, WebSocket::Error => e
|
54
|
+
STDERR.puts "Websocket refused connection - using POST"
|
55
|
+
@use_post = true
|
60
56
|
end
|
61
57
|
end
|
62
58
|
|
63
|
-
return if @options['no-cli'] || @options['
|
59
|
+
return if @options['no-cli'] || @options['web']
|
64
60
|
step_through_list(list)
|
65
61
|
else
|
66
62
|
puts "Could not find checklist via: #{target}"
|
@@ -114,6 +110,10 @@ class CheckCheckIt::Console
|
|
114
110
|
}
|
115
111
|
end
|
116
112
|
|
113
|
+
if @use_post
|
114
|
+
post_check(@list_id, i)
|
115
|
+
end
|
116
|
+
|
117
117
|
results[i] = {
|
118
118
|
step: i + 1,
|
119
119
|
name: step.name,
|
@@ -161,6 +161,16 @@ class CheckCheckIt::Console
|
|
161
161
|
ENV['CHECKCHECKIT_URL']
|
162
162
|
end
|
163
163
|
|
164
|
+
def post_check(list_id, step_id)
|
165
|
+
begin
|
166
|
+
url = URI.join(web_service_url, "/#{list_id}/check/#{step_id}").to_s
|
167
|
+
STDERR.puts url
|
168
|
+
Excon.post(url)
|
169
|
+
rescue Excon::Errors::SocketError, ArgumentError => e
|
170
|
+
puts "Error POSTing to #{url}"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
164
174
|
# Returns id
|
165
175
|
def notify_server_of_start(emails, list)
|
166
176
|
begin
|
data/lib/checkcheckit/version.rb
CHANGED
data/test/start_test.rb
CHANGED
@@ -31,6 +31,8 @@ class StartTest < CheckCheckIt::TestCase
|
|
31
31
|
# you can run it on the web.
|
32
32
|
def test_email_flag_triggers_live_mode
|
33
33
|
client = MiniTest::Mock.new
|
34
|
+
console.web_socket.expect :connect, client, [String, {sync: true}]
|
35
|
+
3.times { client.expect :emit, true, ['check', Hash] }
|
34
36
|
Excon.stub({:method => :post, :body => {
|
35
37
|
emails: "csquared@heroku.com,thea.lamkin@gmail.com",
|
36
38
|
list: List.new(home + '/personal/groceries').to_h
|
@@ -39,19 +41,12 @@ class StartTest < CheckCheckIt::TestCase
|
|
39
41
|
check "start groceries --email csquared@heroku.com,thea.lamkin@gmail.com"
|
40
42
|
end
|
41
43
|
|
42
|
-
|
44
|
+
# Same as above but with env set
|
45
|
+
def test_reads_email_from_env
|
43
46
|
set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
|
44
47
|
client = MiniTest::Mock.new
|
45
48
|
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
49
|
3.times { client.expect :emit, true, ['check', Hash] }
|
49
|
-
check "start groceries --ws"
|
50
|
-
end
|
51
|
-
|
52
|
-
# Same as above but with env set
|
53
|
-
def test_reads_email_from_env
|
54
|
-
set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
|
55
50
|
Excon.stub({:method => :post, :body => {
|
56
51
|
emails: "csquared@heroku.com,thea.lamkin@gmail.com",
|
57
52
|
list: List.new(home + '/personal/groceries').to_h
|
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.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash:
|
117
|
+
hash: 2251498122202537334
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash:
|
126
|
+
hash: 2251498122202537334
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
129
|
rubygems_version: 1.8.23
|