checkcheckit 0.3.1 → 0.4.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.
@@ -20,5 +20,4 @@ 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'
24
23
  end
@@ -1,7 +1,6 @@
1
1
  require 'lucy-goosey'
2
2
  require 'excon'
3
3
  require 'yajl/json_gem'
4
- require 'socketio'
5
4
 
6
5
  require "checkcheckit/version"
7
6
 
@@ -10,7 +10,6 @@ class CheckCheckIt::Console
10
10
  def initialize(opts = {})
11
11
  @out_stream = opts[:out_stream] || $stdout
12
12
  @in_stream = opts[:in_stream] || $stdin
13
- @web_socket = opts[:web_socket] || SocketIO
14
13
  end
15
14
 
16
15
  def dir
@@ -71,14 +70,7 @@ class CheckCheckIt::Console
71
70
 
72
71
  return if @options['no-cli'] || @options['web-only']
73
72
 
74
- begin
75
- @client = web_socket.connect(web_service_url, sync: true) do
76
- after_start { emit('register', {list_id: list_id}) }
77
- end
78
- rescue Errno::ECONNREFUSED, WebSocket::Error, RuntimeError => e
79
- $stderr.puts "Websocket refused connection - using POST"
80
- @use_post = true
81
- end
73
+ @live = true
82
74
  end
83
75
 
84
76
  step_through_list(list)
@@ -142,7 +134,7 @@ class CheckCheckIt::Console
142
134
  return
143
135
  end
144
136
 
145
- if check
137
+ if check && @live
146
138
  update_server_with_step(i)
147
139
  end
148
140
 
@@ -193,15 +185,6 @@ class CheckCheckIt::Console
193
185
  ENV['CHECKCHECKIT_URL'] || DEFAULT_URL
194
186
  end
195
187
 
196
- def post_check(list_id, step_id)
197
- begin
198
- url = URI.join(web_service_url, "/#{list_id}/check/#{step_id}").to_s
199
- Excon.post(url)
200
- rescue Excon::Errors::SocketError, ArgumentError => e
201
- puts "Error POSTing to #{url}"
202
- end
203
- end
204
-
205
188
  # Returns id
206
189
  def notify_server_of_start(emails, list)
207
190
  begin
@@ -219,11 +202,12 @@ class CheckCheckIt::Console
219
202
  end
220
203
  end
221
204
 
222
- def update_server_with_step(i)
223
- if @client
224
- @client.emit 'check', {list_id: @list_id, step_id: i}
225
- elsif @use_post
226
- post_check(@list_id, i)
205
+ def update_server_with_step(step_id)
206
+ begin
207
+ url = URI.join(web_service_url, "/#{@list_id}/check/#{step_id}").to_s
208
+ Excon.post(url)
209
+ rescue Excon::Errors::SocketError, ArgumentError => e
210
+ puts "Error POSTing to #{url}"
227
211
  end
228
212
  end
229
213
  end
@@ -1,3 +1,3 @@
1
1
  module CheckCheckIt
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -6,13 +6,6 @@ class StartTest < CheckCheckIt::TestCase
6
6
  super
7
7
  Examples.create_grocery_list(home)
8
8
  console.in_stream = MiniTest::Mock.new
9
- console.web_socket = MiniTest::Mock.new
10
- end
11
-
12
- def mock_web_socket
13
- client = MiniTest::Mock.new
14
- console.web_socket.expect :connect, client, [String, {sync: true}]
15
- client
16
9
  end
17
10
 
18
11
  def test_list_parses_steps
@@ -33,12 +26,17 @@ class StartTest < CheckCheckIt::TestCase
33
26
  #
34
27
  # we setup the POST with the list data
35
28
  def test_live_flag_triggers_live_mode
36
- client = mock_web_socket
37
- 3.times { client.expect :emit, true, ['check', Hash] }
29
+ #stub setup
38
30
  Excon.stub({:method => :post, :body => {
39
31
  emails: nil,
40
32
  list: List.new(home + '/personal/groceries').to_h
41
- }.to_json}, {:status => 200})
33
+ }.to_json}, {:status => 200,:body => '"DEADBEEF"'})
34
+
35
+ #stub checks
36
+ 3.times do |i|
37
+ Excon.stub({:method => :post, :path => "/DEADBEEF/check/#{i}" },
38
+ {:status => 200})
39
+ end
42
40
  3.times { console.in_stream.expect :gets, "y" }
43
41
  check "start groceries --live"
44
42
  end
@@ -50,12 +48,17 @@ class StartTest < CheckCheckIt::TestCase
50
48
  # The webservice sends you an email with a link to the list so
51
49
  # you can run it on the web.
52
50
  def test_email_flag_triggers_live_mode
53
- client = mock_web_socket
54
- 3.times { client.expect :emit, true, ['check', Hash] }
51
+ # stub setup
55
52
  Excon.stub({:method => :post, :body => {
56
53
  emails: "csquared@heroku.com,thea.lamkin@gmail.com",
57
54
  list: List.new(home + '/personal/groceries').to_h
58
- }.to_json}, {:status => 200})
55
+ }.to_json}, {:status => 200, :body => '"DEADBEEF"'})
56
+
57
+ # stub checks
58
+ 3.times do |i|
59
+ Excon.stub({:method => :post, :path => "/DEADBEEF/check/#{i}" },
60
+ {:status => 200})
61
+ end
59
62
  3.times { console.in_stream.expect :gets, "y" }
60
63
  check "start groceries --email csquared@heroku.com,thea.lamkin@gmail.com"
61
64
  end
@@ -63,38 +66,43 @@ class StartTest < CheckCheckIt::TestCase
63
66
  # Same as above but with env set
64
67
  def test_reads_email_from_env
65
68
  set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
66
- client = mock_web_socket
67
- 3.times { client.expect :emit, true, ['check', Hash] }
69
+
70
+ #stub setup
68
71
  Excon.stub({:method => :post, :body => {
69
72
  emails: "csquared@heroku.com,thea.lamkin@gmail.com",
70
73
  list: List.new(home + '/personal/groceries').to_h
71
- }.to_json}, {:status => 200})
74
+ }.to_json}, {:status => 200, :body => '"FOO"'})
75
+
76
+ # stub checks
77
+ 3.times do |i|
78
+ Excon.stub({:method => :post, :path => "/FOO/check/#{i}" },
79
+ {:status => 200})
80
+ end
81
+
72
82
  3.times { console.in_stream.expect :gets, "y" }
73
83
  check "start groceries"
74
84
  end
75
85
 
76
86
  def test_live_only_sends_on_success
77
- client = mock_web_socket
78
- 1.times { client.expect :emit, true, ['check', Hash] }
79
- Excon.stub({:method => :post}, {:status => 200})
87
+ #stub setup
88
+ Excon.stub({:method => :post, :body => {
89
+ emails: nil,
90
+ list: List.new(home + '/personal/groceries').to_h
91
+ }.to_json}, {:status => 200, :body => '"FOO"'})
92
+
93
+ # stub checks
94
+ Excon.stub({:method => :post, :path => "/FOO/check/2" },
95
+ {:status => 200})
96
+
80
97
  2.times { console.in_stream.expect :gets, "n" }
81
98
  1.times { console.in_stream.expect :gets, "y" }
82
99
  check "start groceries --live"
83
100
  end
84
101
 
85
- def test_live_falls_back_to_post
86
- # stub it the old way
87
- ws = console.web_socket
88
- def ws.connect(*args); raise WebSocket::Error; end
89
- 4.times { Excon.stub({:method => :post}, {:status => 200}) }
90
- 3.times { console.in_stream.expect :gets, "y" }
91
- assert_output(//,/POST/) do
92
- check "start groceries --live"
93
- end
94
- end
95
-
102
+ =begin
96
103
  def test_reads_url_from_env
97
104
  #skip "too lazy to implement"
98
105
  end
106
+ =end
99
107
  end
100
108
 
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.3.1
4
+ version: 0.4.0
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: 2013-07-23 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lucy-goosey
@@ -59,22 +59,6 @@ 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'
78
62
  description: Checklists like a boss
79
63
  email:
80
64
  - christopher.continanza@gmail.com
@@ -117,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
101
  version: '0'
118
102
  segments:
119
103
  - 0
120
- hash: 3147570249937767500
104
+ hash: 3500965305452217251
121
105
  required_rubygems_version: !ruby/object:Gem::Requirement
122
106
  none: false
123
107
  requirements:
@@ -126,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
110
  version: '0'
127
111
  segments:
128
112
  - 0
129
- hash: 3147570249937767500
113
+ hash: 3500965305452217251
130
114
  requirements: []
131
115
  rubyforge_project:
132
116
  rubygems_version: 1.8.23