minep-request 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/mine-request CHANGED
@@ -52,6 +52,7 @@ ARGV.each do |arg|
52
52
  args = arg.split '='
53
53
  options[args[0].to_sym] = args[1]
54
54
  end
55
+ options[:closeLoop] = true
55
56
  begin
56
57
  MINEP.send request, options
57
58
  rescue MINEP::ArgumentsError => e
@@ -4,9 +4,10 @@ module MINEP
4
4
  # Initialize the object
5
5
  #
6
6
  # @param [Hash] request is the request, The text request is built from this
7
- def initialize request
7
+ def initialize request, closeLoop=false
8
8
  super
9
9
  @request = ["#{request[:header][:head]}\n"]
10
+ @closeLoop = closeLoop
10
11
  request[:header].each do |key, value|
11
12
  if key == :head
12
13
  next
@@ -37,7 +38,7 @@ module MINEP
37
38
  end
38
39
 
39
40
  def unbind
40
- EventMachine::stop_event_loop
41
+ EventMachine::stop_event_loop if @closeLoop
41
42
  end
42
43
  end
43
44
  end
data/lib/minep/minep.rb CHANGED
@@ -4,12 +4,14 @@ module MINEP
4
4
  #
5
5
  # @param [Symbol] type the request type, see main page for the requests list
6
6
  # @param [Hash] opts stores the parameters of the request and host and port, see main page for the requests parameters
7
+ # @param [Bool] closeLoop define if the event loop has to be closed when unbinding
7
8
  def self.send type, opts={}
8
9
  request = {}
9
10
  return false unless Utils.makeRequest request, type, opts
10
11
  EM.run do
11
12
  EM.connect(opts[:host] || "localhost",
12
- opts[:port] || 8080, Connection, request)
13
+ opts[:port] || 8080, Connection, request,
14
+ opts[:closeLoop])
13
15
  end
14
16
  end
15
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minep-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-11-13 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Allows to communicate with a MINE server.
15
15