daemon-ogre 1.3.1 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/daemon-ogre.rb +26 -28
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.4
data/lib/daemon-ogre.rb CHANGED
@@ -8,22 +8,23 @@ begin
8
8
  #Based on the rb location
9
9
  def load_directory(directory,*args)
10
10
  arg = Hash[*args]
11
+ directory = File.expand_path(directory)
11
12
 
12
13
  if !arg[:delayed].nil?
13
14
  raise ArgumentError, "Delayed items must be in an "+\
14
- "Array! Example:\n:delayed => ['abc']" if arg[:delayed].class == Array
15
+ "Array! Example:\n:delayed => ['abc']" if arg[:delayed].class != Array
15
16
  end
16
17
 
17
18
  if !arg[:exclude].nil?
18
19
  raise ArgumentError, "Exclude items must be in an "+\
19
- "Array! Example:\n:exclude => ['abc']" if arg[:exclude].class == Array
20
+ "Array! Example:\n:exclude => ['abc']" if arg[:exclude].class != Array
20
21
  end
21
22
 
22
- arg[:type]= "rb" if !arg[:type].nil?
23
+ arg[:type]= "rb" if arg[:type].nil?
23
24
 
24
25
  #=================================================================================================================
25
26
 
26
- puts "LOADING_FILES_FROM_"+directory.to_s.split('/').last.split('.').first.capitalize if App.debug
27
+ puts "LOADING_FILES_FROM_"+directory.to_s.split('/').last.split('.').first.capitalize if $DEBUG
27
28
 
28
29
  delayed_loads = Array.new
29
30
  Dir["#{directory}/**/*.#{arg[:type]}"].each do |file|
@@ -33,14 +34,14 @@ begin
33
34
 
34
35
  arg[:exclude].each do |except|
35
36
  if file.split('/').last.split('.').first == except.to_s.split('.').first
36
- puts file.to_s + " cant be loaded because it's an exception"
37
+ puts file.to_s + " cant be loaded because it's an exception" if $DEBUG
37
38
  else
38
39
  arg[:delayed].each do |delay|
39
40
  if file.split('/').last.split('.').first == delay.to_s.split('.').first
40
41
  delayed_loads.push(file)
41
42
  else
42
43
  load(file)
43
- puts file.to_s
44
+ puts file.to_s if $DEBUG
44
45
  end
45
46
  end
46
47
  end
@@ -48,9 +49,9 @@ begin
48
49
  end
49
50
  delayed_loads.each do |delayed_load_element|
50
51
  load(delayed_load_element)
51
- puts delayed_load_element.to_s if App.debug
52
+ puts delayed_load_element.to_s if $DEBUG
52
53
  end
53
- puts "DONE_LOAD_FILES_FROM_"+directory.to_s.split('/').last.split('.').first.capitalize if App.debug
54
+ puts "DONE_LOAD_FILES_FROM_"+directory.to_s.split('/').last.split('.').first.capitalize if $DEBUG
54
55
 
55
56
  end
56
57
 
@@ -90,8 +91,8 @@ begin
90
91
  require 'yaml'
91
92
  #require "hashie"
92
93
 
93
- yaml_files = Dir["#{directory}/**/*.yml"].each { |f| puts f.to_s if App.debug }
94
- puts "\nyaml file found: "+yaml_files.inspect.to_s if App.debug
94
+ yaml_files = Dir["#{directory}/**/*.yml"].each { |f| puts f.to_s if $DEBUG }
95
+ puts "\nyaml file found: "+yaml_files.inspect.to_s if $DEBUG
95
96
  @result_hash = {}
96
97
  yaml_files.each_with_index do |full_path_file_name|
97
98
 
@@ -104,16 +105,16 @@ begin
104
105
  #@result_hash = @result_hash.merge!(tmp_hash)
105
106
 
106
107
 
107
- puts "==========================================================" if App.debug
108
- puts "Loading "+file_name.to_s.capitalize+"\n" if App.debug
109
- puts YAML.load(File.read("#{full_path_file_name}")) if App.debug
110
- puts "__________________________________________________________" if App.debug
108
+ puts "==========================================================" if $DEBUG
109
+ puts "Loading "+file_name.to_s.capitalize+"\n" if $DEBUG
110
+ puts YAML.load(File.read("#{full_path_file_name}")) if $DEBUG
111
+ puts "__________________________________________________________" if $DEBUG
111
112
 
112
113
  end
113
114
 
114
- puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" if App.debug
115
- puts "The Main Hash: \n"+@result_hash.inspect.to_s if App.debug
116
- puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" if App.debug
115
+ puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" if $DEBUG
116
+ puts "The Main Hash: \n"+@result_hash.inspect.to_s if $DEBUG
117
+ puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" if $DEBUG
117
118
 
118
119
  return @result_hash
119
120
  end
@@ -190,8 +191,7 @@ begin
190
191
  :exceptions,
191
192
  :app_name,
192
193
  :port,
193
- :terminate,
194
- :debug
194
+ :terminate
195
195
  end
196
196
  end
197
197
  end
@@ -203,7 +203,6 @@ begin
203
203
  App.terminate = false
204
204
  App.port = 80
205
205
  App.app_name = $0
206
- App.debug = false
207
206
 
208
207
  begin
209
208
  ['daemon_stderr','exceptions'].each do |one_log|
@@ -248,16 +247,16 @@ begin
248
247
  Process.kill 'HUP', opid.to_i
249
248
  true
250
249
  rescue Errno::ENOENT
251
- $stdout.puts "#{pidfile} did not exist: Errno::ENOENT" if App.debug
250
+ $stdout.puts "#{pidfile} did not exist: Errno::ENOENT" if $DEBUG
252
251
  true
253
252
  rescue Errno::ESRCH
254
- $stdout.puts "The process #{opid} did not exist: Errno::ESRCH" if App.debug
253
+ $stdout.puts "The process #{opid} did not exist: Errno::ESRCH" if $DEBUG
255
254
  true
256
255
  rescue Errno::EPERM
257
- $stderr.puts "Lack of privileges to manage the process #{opid}: Errno::EPERM" if App.debug
256
+ $stderr.puts "Lack of privileges to manage the process #{opid}: Errno::EPERM" if $DEBUG
258
257
  false
259
258
  rescue ::Exception => e
260
- $stderr.puts "While signaling the PID, unexpected #{e.class}: #{e}" if App.debug
259
+ $stderr.puts "While signaling the PID, unexpected #{e.class}: #{e}" if $DEBUG
261
260
  false
262
261
  end
263
262
 
@@ -296,7 +295,6 @@ begin
296
295
  end
297
296
 
298
297
  def debug
299
- App.debug=true
300
298
  $DEBUG = true
301
299
  end
302
300
 
@@ -358,13 +356,13 @@ begin
358
356
  def kill_with_pid
359
357
  begin
360
358
  if File.exists?(DaemonOgre::App.pid_path)
361
- puts "PidFile found, processing..." if App.debug
359
+ puts "PidFile found, processing..." if $DEBUG
362
360
  File.open(DaemonOgre::App.pid_path).each_line do |row|
363
361
  begin
364
362
  Process.kill 'TERM', row.to_i
365
- puts "terminated process at: #{row}" if App.debug
363
+ puts "terminated process at: #{row}" if $DEBUG
366
364
  rescue Exception => ex
367
- puts "At process: #{row}, #{ex}" if App.debug
365
+ puts "At process: #{row}, #{ex}" if $DEBUG
368
366
  end
369
367
  end
370
368
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemon-ogre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.4
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-06-04 00:00:00.000000000 Z
12
+ date: 2013-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: -1913629350989088546
115
+ hash: -1463888442419117198
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements: