ng 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,10 @@
1
1
  require_relative 'client/chunk'
2
2
  require_relative 'client/chunk_header'
3
3
  require 'socket'
4
- require 'io/wait'
5
- require 'logger'
6
4
  require 'timeout'
7
5
 
8
6
  module Nailgun
9
7
  class Client
10
- LOGGER = Logger.new('log')
11
-
12
8
  attr_reader :opts, :socket
13
9
 
14
10
  # Public: Convinience method to instantiate and run the command
@@ -28,7 +24,6 @@ module Nailgun
28
24
  def initialize(opts = {})
29
25
  @opts = Nailgun::DEFAULTS.merge(opts)
30
26
  @socket = TCPSocket.new(*@opts.values_at(:hostname, :port))
31
- debug "Opened new #{@socket.inspect}"
32
27
  end
33
28
 
34
29
  # Public: Run a command on the Client instance
@@ -113,7 +108,6 @@ module Nailgun
113
108
  # content = nil - the actual content
114
109
  def send_chunk(type, content = nil)
115
110
  chunk = Chunk.new(type, content).to_s
116
- debug "Sending #{type} chunk: #{content.inspect}"
117
111
  socket.write chunk
118
112
  end
119
113
 
@@ -121,14 +115,8 @@ module Nailgun
121
115
  def receive_chunk
122
116
  Timeout.timeout(Nailgun::TIMEOUT, Nailgun::TimeoutError) do
123
117
  length, type = receive_header
124
- if length == 0
125
- debug "Received #{type} chunk with no content"
126
- else
127
- debug "About to read #{type} chunk (#{length} B). Content follows (until <<<< END CHUNK >>>>) "
128
-
118
+ if length > 0
129
119
  content = socket.read(length)
130
-
131
- LOGGER << (content + "<<<< END CHUNK >>>>\n")
132
120
  end
133
121
 
134
122
  handle_chunk(type, content)
@@ -168,27 +156,5 @@ module Nailgun
168
156
  end
169
157
  end
170
158
 
171
- # Private: Debug log message
172
- def debug(message)
173
- LOGGER.debug(message)
174
- end
175
-
176
- # Extend the return value with a success? method akin to Process::Status, which I can't figure
177
- # out how to instantiate manually
178
- class ExitStatus
179
- def initialize(value)
180
- @val = value
181
- end
182
- def success?
183
- @val == 0
184
- end
185
- def method_missing(*args)
186
- @val.send(*args)
187
- end
188
- def inspect
189
- @val.inspect
190
- end
191
- end
192
-
193
159
  end
194
160
  end
@@ -1,3 +1,3 @@
1
1
  module Nailgun
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: