daemon-ogre 1.4.4 → 1.4.5

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/daemon-ogre.rb +46 -13
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.4
1
+ 1.4.5
data/lib/daemon-ogre.rb CHANGED
@@ -8,7 +8,9 @@ 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
+ #directory = File.expand_path(directory)
13
+ delayed_loads = Array.new
12
14
 
13
15
  if !arg[:delayed].nil?
14
16
  raise ArgumentError, "Delayed items must be in an "+\
@@ -22,28 +24,46 @@ begin
22
24
 
23
25
  arg[:type]= "rb" if arg[:type].nil?
24
26
 
25
- #=================================================================================================================
27
+ #=============================================================================================================
26
28
 
27
- puts "LOADING_FILES_FROM_"+directory.to_s.split('/').last.split('.').first.capitalize if $DEBUG
29
+ ### GET Pre path + validation
30
+ begin
31
+ #get method callers path
32
+ pre_path = caller[1].split('.rb:').first+('.rb')
33
+ separator_symbol= String.new
34
+ pre_path.include?('/') ? separator_symbol = '/' : separator_symbol = '\\'
35
+ pre_path= ((pre_path.split(separator_symbol))-([pre_path.split(separator_symbol).pop])).join(separator_symbol)
36
+ end
28
37
 
29
- delayed_loads = Array.new
30
- Dir["#{directory}/**/*.#{arg[:type]}"].each do |file|
38
+ puts "LOADING_FILES_FROM_"+directory.to_s.split(separator_symbol).last.split('.').first.capitalize if $DEBUG
31
39
 
32
- arg[:delayed]= [nil] if arg[:delayed].nil?
40
+ puts "Elements found in #{directory}" if $DEBUG
41
+ puts File.join("#{pre_path}","#{directory}","**","*.#{arg[:type]}") if $DEBUG
42
+ puts Dir[File.join("#{pre_path}","#{directory}","**","*.#{arg[:type]}")].sort.inspect if $DEBUG
43
+
44
+ Dir[File.join("#{pre_path}","#{directory}","**","*.#{arg[:type]}")].sort.each do |file|
45
+
46
+ arg[:delayed]= [nil] if arg[:delayed].nil?
33
47
  arg[:excluded]= [nil] if arg[:excluded].nil?
34
48
 
35
49
  arg[:excluded].each do |except|
36
- if file.split('/').last.split('.').first == except.to_s.split('.').first
50
+ if file.split(separator_symbol).last.split('.').first == except.to_s.split('.').first
51
+
37
52
  puts file.to_s + " cant be loaded because it's an exception" if $DEBUG
53
+
38
54
  else
55
+
39
56
  arg[:delayed].each do |delay|
40
- if file.split('/').last.split('.').first == delay.to_s.split('.').first
57
+
58
+ if file.split(separator_symbol).last.split('.').first == delay.to_s.split('.').first
41
59
  delayed_loads.push(file)
42
60
  else
43
61
  load(file)
44
62
  puts file.to_s if $DEBUG
45
63
  end
64
+
46
65
  end
66
+
47
67
  end
48
68
  end
49
69
  end
@@ -51,7 +71,7 @@ begin
51
71
  load(delayed_load_element)
52
72
  puts delayed_load_element.to_s if $DEBUG
53
73
  end
54
- puts "DONE_LOAD_FILES_FROM_"+directory.to_s.split('/').last.split('.').first.capitalize if $DEBUG
74
+ puts "DONE_LOAD_FILES_FROM_"+directory.to_s.split(separator_symbol).last.split('.').first.capitalize if $DEBUG
55
75
 
56
76
  end
57
77
 
@@ -73,7 +93,7 @@ begin
73
93
 
74
94
  def error_logger(error_msg,prefix="",log_file=App.log_path)
75
95
 
76
- ###convert error msg to more humanfriendly one
96
+ ###convert error msg to more human friendly one
77
97
  begin
78
98
  error_msg= error_msg.to_s.gsub('", "','",'+"\n\"")
79
99
  rescue Exception
@@ -98,13 +118,26 @@ begin
98
118
  require 'yaml'
99
119
  #require "hashie"
100
120
 
101
- yaml_files = Dir["#{directory}/**/*.yml"].each { |f| puts f.to_s if $DEBUG }
102
- puts "\nyaml file found: "+yaml_files.inspect.to_s if $DEBUG
121
+ begin
122
+ pre_path = caller[1].split('.rb:').first+('.rb')
123
+ separator_symbol= String.new
124
+ pre_path.include?('/') ? separator_symbol = '/' : separator_symbol = '\\'
125
+ pre_path= ((pre_path.split(separator_symbol))-([pre_path.split(separator_symbol).pop])).join(separator_symbol)
126
+ end
127
+
128
+ puts "Elements found in #{directory}" if $DEBUG
129
+ puts File.join("#{pre_path}","#{directory}","**","*.yml") if $DEBUG
130
+ puts Dir[File.join("#{pre_path}","#{directory}","**","*.yml")].sort.inspect if $DEBUG
131
+
132
+ yaml_files = Dir[File.join("#{pre_path}","#{directory}","**","*.yml")].sort
133
+
134
+ puts "\nyaml file found: "+yaml_files.inspect if $DEBUG
135
+
103
136
  @result_hash = {}
104
137
  yaml_files.each_with_index do |full_path_file_name|
105
138
 
106
139
 
107
- file_name = full_path_file_name.split('/').last.split('.').first
140
+ file_name = full_path_file_name.split(separator_symbol).last.split(separator_symbol).first
108
141
 
109
142
  hash_key = file_name
110
143
  @result_hash[hash_key] = YAML.load(File.read("#{full_path_file_name}"))
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.4.4
4
+ version: 1.4.5
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-03 00:00:00.000000000 Z
12
+ date: 2013-07-06 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: 3913919040804686018
115
+ hash: 878850171271647068
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements: