procemon 0.5.0 → 0.6.1

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
- ZmQ4YzZlZTQ4NGI2OTNiYTQyMTc3ODU4ODA4YmQ2OTU0MjA1MGE0Zg==
4
+ ZjkyZTRlNGI4YzY5NGMyZWRjYzE1ZTllZmI3MGRjMGVjMjcwNjdkMg==
5
5
  data.tar.gz: !binary |-
6
- MjQ1ZGEzOGUwNjg4MTc5NzllYmU3ZDYyYTQxMjA5YmJkNWU0NGFmMQ==
6
+ ODU2ZjkxZjBmNThiZDBmN2RmODJkMWM4ZGEwNzczMGYwNmZkNzZiZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDYxYWNjZDljN2EwNWExYjUxYjg3MjczNTdiZDkzMzVlZjRmZDhmOWU0YzBi
10
- YTMyNjNkYTM2NWQ3Y2FkYjdkZTdlZDNmMmVlNzI4YzRiMzg2MDRkYTM1MmFk
11
- MWYyYjBjNGQ5ODRjNTk1Y2ExMmEzNmY3N2ViMjhjZDU5MTllYjY=
9
+ N2I4YWM5NGRlNmMxMDhhMzVlNTI1YTA3OWI4Y2RiNzAzNmU3YjdhMzI3NWU0
10
+ MWYxNjkyZmE0Mjg3MWYwNDI5MGNmY2U4OTI4YWFhMDAzMWM4ODQ0OWFjYjRk
11
+ YjQ0M2NlYzYyZjI5NDA1MGZkNWY1OWQ5MGVkYzU4MDQxNzE0YjM=
12
12
  data.tar.gz: !binary |-
13
- NzQ3MWU0ZWMwYzI5Yzc4MGRlNDEyODc1MTQ1MGUyYzJiZDA0YzYyYmYwYTFl
14
- YzNiZTcxZjg1YjhlYjZlYWM3NTk2NmE3OGI0M2Y3M2JhY2ZjOGUyN2U4MWJj
15
- M2FhMjQ0NjNiZDQ1ZGZlZTgwNTM4YjZlZTg5NzQxN2FiMWU0Zjk=
13
+ OGZhYjgyMmE2NGJlMjZjMmM3YTgyNTYwYjQ4ZjMwMDczYzU1NmRhNjUwMWM5
14
+ ZWQzY2RhNWZiZjY5ODVmZWJiYTlhNzkzYjEwMGYxZjBhY2NlMmFjMWVmZjc2
15
+ ZDM5ZDRkMzE5NDYxZTYzMGE4ZGNkNzI0OWM5YThiZjMwNTZhZjA=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.1
@@ -12,7 +12,7 @@ module Application
12
12
  :db_drop,
13
13
  :daemon,
14
14
  :config_file,
15
- :create_documentation,
15
+ :doc,
16
16
  :client
17
17
  end
18
18
 
@@ -20,6 +20,8 @@ module Application
20
20
  self.config ||= Hash.new()
21
21
  self.environment ||= String.new()
22
22
 
23
+ self.doc ||= false
24
+
23
25
  end
24
26
 
25
27
  App= Application unless defined?(App)
@@ -29,7 +29,7 @@ module Procemon
29
29
  Application.environment= ARGV[(ARGV.index(one_param)+1)]
30
30
 
31
31
  when "--documentation","--generate_documentation","-doc"
32
- Application.create_documentation= true
32
+ Application.doc= true
33
33
 
34
34
  when "--db_drop","--drop_database","-dbdrop"
35
35
  Application.db_drop= true
@@ -1,4 +1,7 @@
1
1
  class String
2
+
3
+
4
+
2
5
  def find_doc_part(oth_str)
3
6
  self.each_line do |target_line|
4
7
  puts target_line[0..(oth_str.length-1)]
@@ -7,4 +10,5 @@ class String
7
10
  end
8
11
  end
9
12
  end
13
+
10
14
  end
@@ -0,0 +1,202 @@
1
+ module Kernel
2
+
3
+ # gives you a basic meta load framework for easy config use (yaml)
4
+ # basic system is
5
+ #
6
+ # root folder:
7
+ # - config
8
+ # -| "YAML files" #> development.yaml
9
+ #
10
+ # - lib
11
+ # -- module_name
12
+ # --- meta
13
+ # ---| "YAML files" #> rack.yaml
14
+ #
15
+ def metaloader_framework(opts={})
16
+
17
+ # defaults
18
+ begin
19
+
20
+ root_folder = opts[:root]
21
+ override = opts[:override]
22
+ target_config_hash = opts[:config]
23
+ lib_folder = opts[:lib_folder]
24
+ config_folder = opts[:config_folder]
25
+
26
+
27
+ override ||= true
28
+ root_folder ||= Dir.pwd
29
+ target_config_hash ||= Application.config
30
+
31
+ lib_folder ||= File.join(root_folder,"{lib,libs}","**","meta")
32
+ config_folder ||= File.join(root_folder,"{config,conf}","**")
33
+
34
+ require "yaml"
35
+ if target_config_hash.class != Hash
36
+ target_config_hash= Hash.new()
37
+ end
38
+
39
+ end
40
+
41
+ # find elements
42
+ begin
43
+
44
+ Dir.glob(File.join(lib_folder,"*.{yaml,yml}")).each do |config_object|
45
+
46
+ # defaults
47
+ begin
48
+ config_name_elements= config_object.split(File::SEPARATOR)
49
+ type= config_name_elements.pop.split('.')[0]
50
+ config_name_elements.pop
51
+
52
+ category = config_name_elements.pop
53
+ tmp_hash = Hash.new()
54
+ yaml_data = YAML.load(File.open(config_object))
55
+ end
56
+
57
+ # processing
58
+ begin
59
+ if target_config_hash[category].nil?
60
+ target_config_hash[category]= { type => yaml_data }
61
+ else
62
+ unless override == false
63
+ target_config_hash[category][type]= yaml_data
64
+ end
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ # update by config
73
+ begin
74
+
75
+ # get config files
76
+ begin
77
+
78
+ config_yaml_paths= Array.new()
79
+ Dir.glob(File.join(config_folder,"*.{yaml,yml}")).uniq.each do |one_path|
80
+
81
+ case true
82
+
83
+ when one_path.downcase.include?('default')
84
+ config_yaml_paths[0]= one_path
85
+
86
+ when one_path.downcase.include?('development')
87
+ config_yaml_paths[1]= one_path
88
+
89
+ when one_path.downcase.include?('test')
90
+ config_yaml_paths[2]= one_path
91
+
92
+ when one_path.downcase.include?('production')
93
+ config_yaml_paths[3]= one_path
94
+
95
+ else
96
+ config_yaml_paths[config_yaml_paths.count]= one_path
97
+
98
+ end
99
+
100
+ end
101
+ config_yaml_paths.select!{|x| x != nil }
102
+ end
103
+
104
+ # params config load
105
+ unless Application.config_file.nil?
106
+ begin
107
+ path= File.expand_path(Application.config_file,"r")
108
+ File.open(path)
109
+ config_yaml_paths.push(path)
110
+ rescue Exception
111
+ config_yaml_paths.push(Application.config_file)
112
+ end
113
+ end
114
+
115
+ # load to last lvl environment
116
+ begin
117
+ config_yaml_paths.each do |one_yaml_file_path|
118
+ begin
119
+ yaml_data= YAML.load(File.open(one_yaml_file_path))
120
+ target_config_hash.deep_merge!(yaml_data)
121
+
122
+ unless Application.environment.nil?
123
+ if one_yaml_file_path.include?(Application.environment.to_s)
124
+ break
125
+ end
126
+ end
127
+ rescue Exception
128
+ end
129
+ end
130
+ end
131
+
132
+ end
133
+
134
+ return target_config_hash
135
+
136
+ end
137
+
138
+ alias :generate_config :metaloader_framework
139
+ alias :metaload_framework :metaloader_framework
140
+
141
+ def generate_documentation(
142
+ target_folder = File.join(Dir.pwd,"docs"),
143
+ keyword= "gen",
144
+ create_doc_bool = Application.doc)
145
+
146
+ if create_doc_bool == true
147
+
148
+ Dir.glob(File.join(Dir.pwd,'{doc,docs,document,documents}','**',"*_#{keyword}.{rb,ru}")).each do |one_doc_generator|
149
+ require one_doc_generator
150
+ end
151
+ puts "done!"
152
+
153
+ Process.exit
154
+
155
+ end
156
+
157
+ end
158
+
159
+ def get_meta_config(target_folder= File.join(Dir.pwd,"lib","**","meta") )
160
+
161
+ # defaults
162
+ begin
163
+ require "yaml"
164
+ target_config_hash= Hash.new()
165
+ end
166
+
167
+ # find elements
168
+ begin
169
+
170
+ Dir.glob(File.join(target_folder,"*.{yaml,yml}")).each do |config_object|
171
+
172
+ # defaults
173
+ begin
174
+ config_name_elements= config_object.split(File::SEPARATOR)
175
+ type= config_name_elements.pop.split('.')[0]
176
+ config_name_elements.pop
177
+ category= config_name_elements.pop
178
+ tmp_hash= Hash.new()
179
+ yaml_data= YAML.load(File.open(config_object))
180
+ end
181
+
182
+ # processing
183
+ begin
184
+ if target_config_hash[category].nil?
185
+ target_config_hash[category]= { type => yaml_data }
186
+ else
187
+ target_config_hash[category][type]= yaml_data
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ end
194
+
195
+ # return data
196
+ begin
197
+ return target_config_hash
198
+ end
199
+
200
+ end
201
+
202
+ end
@@ -1,6 +1,6 @@
1
1
  module Kernel
2
2
 
3
- # load meta-s
3
+ # load meta folders rb files
4
4
  def meta_load(target_folder= File.join(Dir.pwd,"lib","**","meta") )
5
5
 
6
6
  # find elements
@@ -12,61 +12,17 @@ module Kernel
12
12
 
13
13
  end
14
14
 
15
- def get_meta_config(target_folder= File.join(Dir.pwd,"lib","**","meta") )
16
-
17
- # defaults
18
- begin
19
- require "yaml"
20
- target_config_hash= Hash.new()
21
- end
22
-
23
- # find elements
24
- begin
25
-
26
- Dir.glob(File.join(target_folder,"*.{yaml,yml}")).each do |config_object|
27
-
28
- # defaults
29
- begin
30
- config_name_elements= config_object.split(File::SEPARATOR)
31
- type= config_name_elements.pop.split('.')[0]
32
- config_name_elements.pop
33
- category= config_name_elements.pop
34
- tmp_hash= Hash.new()
35
- yaml_data= YAML.load(File.open(config_object))
36
- end
37
-
38
- # processing
39
- begin
40
- if target_config_hash[category].nil?
41
- target_config_hash[category]= { type => yaml_data }
42
- else
43
- target_config_hash[category][type]= yaml_data
44
- end
45
- end
46
-
47
- end
48
-
49
- end
50
-
51
- # return data
52
- begin
53
- return target_config_hash
54
- end
55
-
56
- end
57
-
58
15
  # mount libs
59
- def mount_libs(target_folder= File.join(Dir.pwd, "lib") )
16
+ def mount_libs(lib_folder= File.join(Dir.pwd, "lib") )
60
17
 
61
18
  # load lib files
62
19
  begin
63
- Dir.glob(File.join(target_folder,"*.{rb,ru}")).uniq.each do |one_rb_file|
20
+ Dir.glob(File.join(lib_folder,"*.{rb,ru}")).uniq.each do |one_rb_file|
64
21
  require one_rb_file
65
22
  end
66
23
  end
67
24
 
68
25
  end
69
-
70
26
  alias :require_folder :mount_libs
71
27
 
72
28
  # Offline repo activate
@@ -149,134 +105,4 @@ module Kernel
149
105
 
150
106
  end
151
107
 
152
- # generate config from yaml
153
- def generate_config(
154
- target_folder= File.join(Dir.pwd,"lib", "**","meta"),
155
- override= true,
156
- target_config_hash= Application.config
157
- )
158
-
159
- # defaults
160
- begin
161
- require "yaml"
162
- if target_config_hash.class != Hash
163
- target_config_hash= Hash.new()
164
- end
165
- end
166
-
167
- # find elements
168
- begin
169
- Dir.glob(File.join(target_folder,"*.{yaml,yml}")).each do |config_object|
170
-
171
- # defaults
172
- begin
173
- config_name_elements= config_object.split(File::SEPARATOR)
174
- type= config_name_elements.pop.split('.')[0]
175
- config_name_elements.pop
176
- category= config_name_elements.pop
177
- tmp_hash= Hash.new()
178
- yaml_data= YAML.load(File.open(config_object))
179
- end
180
-
181
- # processing
182
- begin
183
- if target_config_hash[category].nil?
184
- target_config_hash[category]= { type => yaml_data }
185
- else
186
- unless override == false
187
- target_config_hash[category][type]= yaml_data
188
- end
189
- end
190
- end
191
-
192
- end
193
- end
194
-
195
-
196
- # update by config
197
- begin
198
-
199
- # get config files
200
- begin
201
- target_folder= target_folder.split(File::Separator).pinch(3).join(File::Separator)
202
- config_yaml_paths= Array.new()
203
- Dir.glob(File.join(target_folder, "{config,conf}","*.{yaml,yml}")).uniq.each do |one_path|
204
-
205
- case true
206
-
207
- when one_path.downcase.include?('default')
208
- config_yaml_paths[0]= one_path
209
-
210
- when one_path.downcase.include?('development')
211
- config_yaml_paths[1]= one_path
212
-
213
- when one_path.downcase.include?('test')
214
- config_yaml_paths[2]= one_path
215
-
216
- when one_path.downcase.include?('production')
217
- config_yaml_paths[3]= one_path
218
-
219
- else
220
- config_yaml_paths[config_yaml_paths.count]= one_path
221
-
222
- end
223
-
224
- end
225
- config_yaml_paths.select!{|x| x != nil }
226
- end
227
-
228
- # params config load
229
- unless Application.config_file.nil?
230
- begin
231
- path= File.expand_path(Application.config_file,"r")
232
- File.open(path)
233
- config_yaml_paths.push(path)
234
- rescue Exception
235
- config_yaml_paths.push(Application.config_file)
236
- end
237
- end
238
-
239
- # load to last lvl environment
240
- begin
241
- config_yaml_paths.each do |one_yaml_file_path|
242
- begin
243
- yaml_data= YAML.load(File.open(one_yaml_file_path))
244
- Application.config.deep_merge!(yaml_data)
245
-
246
- unless Application.environment.nil?
247
- if one_yaml_file_path.include?(Application.environment.to_s)
248
- break
249
- end
250
- end
251
- rescue Exception
252
- end
253
- end
254
- end
255
-
256
- end if target_folder == File.join(Dir.pwd,"lib", "**","meta")
257
-
258
- return target_config_hash
259
-
260
- end
261
-
262
- def generate_documentation(target_folder= File.join(Dir.pwd,"docs"), boolean= false,keyword= "generate")
263
- boolean= false if boolean.nil?
264
- if boolean == true
265
-
266
- document_generators= Array.new
267
- tmp_path_container= Dir.glob(File.join(target_folder, "**", "*.{rb,ru}"))
268
- tmp_path_container.each do |one_path|
269
- if one_path.include? keyword
270
- document_generators.push one_path
271
- end
272
- end
273
-
274
- document_generators.each do |docs_file_path|
275
- require docs_file_path
276
- end
277
-
278
- Process.exit!
279
- end
280
- end
281
-
282
108
  end
@@ -99,7 +99,7 @@ class Array
99
99
  alias :has_element_of_class? :contain_element_of_class?
100
100
 
101
101
  # generate params structure from array
102
- # *args => {:args,:opts}
102
+ # *args => [:opts,:args]
103
103
  def params_separation
104
104
 
105
105
  options= self.map { |element|
@@ -111,12 +111,7 @@ class Array
111
111
  arguments= self.dup - options
112
112
  options= Hash[*options]
113
113
 
114
- return {
115
- arguments: arguments,
116
- args: arguments,
117
- options: options,
118
- opts: options
119
- }
114
+ return [options,arguments]
120
115
 
121
116
  end
122
117
 
@@ -124,17 +119,31 @@ class Array
124
119
  alias :process_params :params_separation
125
120
 
126
121
  # generate params structure from array
127
- # *args - options {}
128
- def extract_options!
129
- options= self.map { |element|
130
- if element.class == Hash
122
+ # return_array
123
+ def extract_class! class_name
124
+
125
+ if class_name.class != Class
126
+ raise ArgumentError, "parameter must be a class name"
127
+ end
128
+
129
+ return_value= self.map { |element|
130
+ if element.class == class_name
131
131
  element
132
132
  end
133
133
  }.uniq - [ nil ]
134
- options.each{|e| self.delete(e) }
135
- return Hash[*options]
134
+ return_value.each{|e| self.delete(e) }
135
+
136
+ return return_value
137
+
136
138
  end
139
+ alias :cut_class! :extract_class!
137
140
 
138
- alias :get_options! :extract_options!
141
+ # generate params structure from array
142
+ # *args - options {}
143
+ def extract_options!
144
+ options= self.extract_class! Hash
145
+ return Hash[*options]
146
+ end
147
+ alias :extract_hash! :extract_options!
139
148
 
140
149
  end
data/lib/procemon.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  #encoding: UTF-8
2
2
  module Procemon
3
3
 
4
+ require 'asynchronous'
4
5
  require File.join(File.dirname(__FILE__),"procemon","function","require")
5
6
  require_relative_directory File.join("procemon","mpatch")
6
7
  require_relative_directory File.join("procemon","function")
7
- require 'asynchronous'
8
-
9
8
 
10
9
  def self.init_all
11
10
 
@@ -19,7 +18,7 @@ module Procemon
19
18
  tmpdir_init
20
19
 
21
20
  # create config singleton
22
- generate_config
21
+ metaloader_framework
23
22
 
24
23
  # load meta-s
25
24
  meta_load
@@ -34,23 +33,12 @@ module Procemon
34
33
  ObjectSpace.garbage_collect
35
34
 
36
35
  # documentation generate
37
- generate_documentation(Application.create_documentation)
36
+ generate_documentation
38
37
 
39
38
  # Daemonize
40
39
  Daemon.init
41
40
 
42
41
  end
43
42
 
44
- def self.doc_gen
45
- Dir.glob(File.join(Dir.pwd,'{doc,docs,document,documents}','**','generate_*')).each do |one_doc_generator|
46
- require one_doc_generator
47
- end
48
- puts "done!"
49
- Process.exit!
50
- end
51
-
52
- ### Load the requirements in to the general Module
53
- #load File.expand_path(File.join(File.dirname(__FILE__),'procemon'
54
-
55
43
 
56
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-17 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asynchronous
@@ -57,6 +57,7 @@ files:
57
57
  - lib/procemon/function/binding/bindless.rb
58
58
  - lib/procemon/function/daemon.rb
59
59
  - lib/procemon/function/documentation.rb
60
+ - lib/procemon/function/generate.rb
60
61
  - lib/procemon/function/macaddr.rb
61
62
  - lib/procemon/function/meta/eval.rb
62
63
  - lib/procemon/function/meta/inject_methods.rb