orator 0.1.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2JlMGJkOWU0OGIzMWEwM2ZmNmRjMTZkZDFhZTlmMGI5ZDUzZjlhZg==
4
+ OGNmZTliMTc2ZjkxYTM1NzU0YmE2MzY4ODE5MTQ0Y2EyYzBlODU1ZQ==
5
5
  data.tar.gz: !binary |-
6
- MTI4Yzg5NmZlOTJhNTc4ZmM1MzI4ZTlmNzYxMTVjYWUzOWVhMDIyNQ==
6
+ YmJhNDE5ZDI1YmY3OGQ5MjlkMTY5OGE0YTNhZjU5Y2JlMTFmOThhZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWYxOGY0ZDVmNWEzY2JmNTkxZjdkMjlmMTc5OTI4NTgxNDdhMzFlYjQxYWVl
10
- N2IwOTE4YzlkZjU4ZjQzYmEwNzI0NTIwZmFlYTlhOWUxNWQ4MWFhM2VjNGJk
11
- YmU5NDg1ZTYxNWFlMzNhYzhjMjM2ODRhYTNjNjRjZTRjNzQyNDU=
9
+ NTI3YjA0NjdlMjBjOWU4Zjk0NWI1MGMyYmE0YzkzNzVjMzQ4YTE3NzhhNWQ5
10
+ NDc0MGRkODIzZDhlMjg0ZGQ1ZDYyYzA0MDgwM2U5ZWI3YzMzNDc3YWZkNDRj
11
+ NDE4NDc1MmYxMjk4YTY0OTk0NzkzNjg2MmQyMWI2NGIwNWMxMDI=
12
12
  data.tar.gz: !binary |-
13
- OTQ3YzgzOTc5YmY5YmY5OTk1MzcyMWM3YzNjNGU1YzI5ZmEzZmI4OTg2NzU4
14
- ZjNjOTQ4MjkyZTJmNDc3ZGE5MDQ0NjFjN2Q3MmM2OGJiZDUxOGZjZTM4YWJh
15
- YzFkYWU2OTU3YmFiOWU1MmNlZjBlMzM3MDg5NmE1Nzc4YzEyNWQ=
13
+ NGRmM2U1NmVmNWI0YmFiNDM5NjBkMGUwNDYyYzgzYmQ0ZWE4YWEwNmFmMmI5
14
+ NjRkNGZhMmZlZTlkYzRmOWI2ZDE0OTY4Y2NhODQxY2MxODRhZGQ0NDk1N2Jl
15
+ MDYxM2ZiZmU0NDhjMmU0N2FiODk2Mzc3OWYyOWMxYzBjODMyNDI=
data/README.md CHANGED
@@ -98,6 +98,10 @@ send a ping message (whose response will be handled by our TestHandler). When
98
98
  we receive the `user.alias` message, we set the key-pair `:name => json["name"]`
99
99
  on the `#user` hash. Cool, eh?
100
100
 
101
+ To run the server, run `orator --command start` in the root rails directory.
102
+ To daemonize it, run `orator --command start -d`. To stop, run
103
+ `orator --command stop`.
104
+
101
105
  ## JavaScript Client
102
106
  Let's go through an example together.
103
107
 
data/lib/orator/cli.rb CHANGED
@@ -17,7 +17,7 @@ module Orator
17
17
  end
18
18
 
19
19
  def parse_arguments(args)
20
- OptionParser.new do |opts|
20
+ @opt_parser = OptionParser.new do |opts|
21
21
 
22
22
  opts.on('--config FILE', "Loads the configuration settings from FILE.") do |file|
23
23
  @options[:file] = file
@@ -41,11 +41,18 @@ module Orator
41
41
  exit
42
42
  end
43
43
 
44
+ opts.on('-s', '--slient', "Runs orator silently.") do
45
+ $stdout = $stdin = File.open("/dev/null", 'w')
46
+ end
47
+
44
48
  opts.separator ""
45
49
  opts.separator "Valid Commands:"
46
50
  opts.separator "\tstart: start the orator server."
47
51
  opts.separator "\tstop: stop the orator server."
48
- end.parse!(args)
52
+ opts.separator "\tstatus: checks the status of the server. Exits 1 if it's down."
53
+ end
54
+
55
+ @opt_parser.parse!(args)
49
56
  end
50
57
 
51
58
  def handle_command
@@ -79,6 +86,19 @@ module Orator
79
86
  end
80
87
  end
81
88
 
89
+ def status
90
+ check_pid_file if File.exists? yaml_options[:pid_file]
91
+ puts "Not running."
92
+ exit 1
93
+ rescue ProcessExistsError
94
+ puts "Up, running."
95
+ end
96
+
97
+ def help
98
+ puts @opt_parser
99
+ exit
100
+ end
101
+
82
102
  # Add a handler to be used by the server.
83
103
  #
84
104
  # @param klass [Class] the class to use as a handler.
@@ -52,12 +52,8 @@ module Orator
52
52
  puts "Running event #{event}..." if Orator.debug
53
53
  events(event).map do |event|
54
54
  puts "Found responder #{event[:block] || event[:class]}" if Orator.debug
55
- if event[:block]
56
- context.instance_exec *args, context, &event[:block]
57
- elsif event[:class]
58
- event[:class].new(context).__trigger(event[:event], *args)
59
- end
60
-
55
+
56
+ run_event(event, context, args)
61
57
  if event[:count] then event[:count] -= 1 end
62
58
  end
63
59
 
@@ -92,6 +88,20 @@ module Orator
92
88
  end
93
89
  end
94
90
 
91
+ # This runs a given event with the given context and arguments.
92
+ #
93
+ # @param event [Hash] the event to run.
94
+ # @param context [Object] the context to run in.
95
+ # @param arguments [Array<Object>] the arguments to run with.
96
+ # @return [void]
97
+ def run_event(event, context, arguments)
98
+ if event[:block]
99
+ context.instance_exec *arguments, context, &event[:block]
100
+ elsif event[:class]
101
+ event[:class].new(context).__trigger(event[:event], *arguments)
102
+ end
103
+ end
104
+
95
105
  end
96
106
 
97
107
  end
@@ -40,7 +40,7 @@ module Orator
40
40
  def method_missing(method, *args, &block)
41
41
  super unless respond_to_missing?(method)
42
42
 
43
- @struct.__send__(method, *args, &block)
43
+ @struct.public_send(method, *args, &block)
44
44
  end
45
45
 
46
46
  # Lets ruby know we're doing some {#method_missing} magic.
@@ -1,5 +1,5 @@
1
1
  module Orator
2
2
 
3
3
  # Version of Orator.
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rodi