Top Level Namespace
- Includes:
- Sidekiq::Worker
Defined Under Namespace
Modules: ActiveRecord, Api, DefinitorModule, FORCAST, Forcast, JobsActions, JobsPollings, JobsWebhooks, ProjectModule
Classes: Action, ActionLog, Authorization, CreateVersions, JsonWebToken, Meta, MigracionGeneral, Polling, Pretender, Rule, RuleLog, VARIABLE, Webhook
Instance Method Summary
collapse
-
#add_comment_to_top(file_path_documentation, comments) ⇒ Object
-
#add_documentation_to_line(file_path_documentation, line, new_lines_lines) ⇒ Object
-
#backup(folder) ⇒ Object
-
#complete_object(object, array) ⇒ Object
-
#constructor_systemctl(file) ⇒ Object
-
#copy_to_documentation(file_path, relative_path_document) ⇒ Object
-
#cp_controllers_rule_engine ⇒ Object
-
#cp_jobs_rule_engine ⇒ Object
-
#cp_migrations_rule_engine ⇒ Object
-
#cp_models(files) ⇒ Object
-
#cp_models_rule_engine ⇒ Object
-
#cp_routes_rule_engine ⇒ Object
-
#create_draw_structure(array) ⇒ Object
-
#deep_draw_structure(array, rel) ⇒ Object
-
#deploy(folder) ⇒ Object
-
#draw_complex_structure(line = "", space = "", object) ⇒ Object
-
#draw_deep_complex_structure(line, array, space_int) ⇒ Object
-
#draw_draw_deep_complex_structure(relation = '', line, array, space_int) ⇒ Object
-
#draw_draw_draw_deep_complex_structure(relation = '', line, array, space_int) ⇒ Object
-
#draw_method_action(action, space) ⇒ Object
-
#draw_method_end(space) ⇒ Object
-
#draw_simple_structure(space = "", object) ⇒ Object
-
#enable_systemctl(file) ⇒ Object
-
#generate_actions(object) ⇒ Object
-
#generate_controllers(object) ⇒ Object
-
#generate_definitor(object) ⇒ Object
-
#generate_folders ⇒ Object
-
#generate_models(object) ⇒ Object
-
#generate_projects(object) ⇒ Object
-
#generate_routes(object) ⇒ Object
-
#init_documentation(root) ⇒ Object
-
#init_rule_engine ⇒ Object
-
#init_schema ⇒ Object
-
#list_all_service_name(project) ⇒ Object
-
#make_restart(files) ⇒ Object
-
#method_clone(repo) ⇒ Object
-
#method_pull(repo) ⇒ Object
-
#obscure ⇒ Object
-
#open_file_and_find_lines_to(file_path, lines_to_scan) ⇒ Object
-
#restore(folder) ⇒ Object
-
#routes_generate_action(routes) ⇒ Object
-
#routes_schema_parse(object) ⇒ Object
-
#scp(folder) ⇒ Object
-
#search_files(name) ⇒ Object
-
#verify_sh(file) ⇒ Object
-
#write_at(fname, at_line, sdat) ⇒ Object
-
#write_belongs_to(tmp_path, origin, relation, index) ⇒ Object
-
#write_draw_routes ⇒ Object
-
#write_file(file, input) ⇒ Object
-
#write_has_many ⇒ Object
Instance Method Details
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/forcast/tasks/documentation/documentation.rb', line 27
def (file_path_documentation,)
open(file_path_documentation, 'r+') do |f|
line = 0
while (line-=1) > 0
f.readline
end
pos = f.pos
rest = f.read
f.seek(pos)
= .split("&")
.each do |line|
f.write(line+"\n")
end
f.write(rest)
end
end
|
#add_documentation_to_line(file_path_documentation, line, new_lines_lines) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/forcast/tasks/documentation/documentation.rb', line 45
def add_documentation_to_line(file_path_documentation,line,new_lines_lines)
new_lines = 0
open(file_path_documentation, 'r+') do |f|
line_num = line[:line_num]-1
while (line_num-=1) > 0
f.readline
end
pos = f.pos
rest = f.read
f.seek(pos)
documentation = line[:documentation].split("//")
documentation.each do |line|
new_lines += 1
f.write(line+"\n")
end
f.write(rest)
end
return new_lines + new_lines_lines
end
|
#backup(folder) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/lib/backup.rb', line 20
def backup (folder)
folder_development = folder[:folder_development]
Dir.chdir("#{@base_path}")
date = Date.today.strftime('%d-%m-%Y')
system("mkdir -p backup/#{date}")
system("cp -TR #{folder_development} backup/#{date}/#{folder_development}")
end
|
#complete_object(object, array) ⇒ Object
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
# File 'lib/forcast/tasks/schema/schema.rb', line 221
def complete_object(object,array)
new_array = []
object.keys.each do |obj|
array.push({:relation => obj.singularize, :origin => ''})
end
array.map { |e| e[:origin] = {:relation => e[:origin], :has_many => []} }
keys = object.keys
keys.each do |key|
key = key.singularize
merge = array.select {|e| e[:relation] == key}
ar = {:relation => key, :has_many => []}
merge.each do |me|
ar[:has_many].push(me[:origin])
end
new_array.push(ar)
end
return new_array
end
|
#constructor_systemctl(file) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/lib/systemctl_maker.rb', line 17
def constructor_systemctl(file)
parse = file.split("_")
client_name = parse[0].capitalize
project_name = parse[1].capitalize
framework_name = parse[2].capitalize
str = "[Unit]"+ "\n"
str += "Description=#{client_name} #{project_name} #{framework_name} Service" + "\n"
str += "After=network.target" + "\n"
str += "[Service]" + "\n"
str += "Type=simple" + "\n"
str += "User=root" + "\n"
str += "WorkingDirectory=#{@base_path}" + "\n"
str += "ExecStart=#{@base_path}/#{file}.sh" + "\n"
str += "Restart=always" + "\n"
str += "RestartSec=2" + "\n"
str += "[Install]" + "\n"
str += "WantedBy=multi-user.target"
return str
end
|
#copy_to_documentation(file_path, relative_path_document) ⇒ Object
4
5
6
7
|
# File 'lib/forcast/tasks/documentation/documentation.rb', line 4
def copy_to_documentation(file_path,relative_path_document)
FileUtils.mkpath("#{relative_path_document}")
system("cp #{file_path} #{relative_path_document}")
end
|
#cp_controllers_rule_engine ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 19
def cp_controllers_rule_engine
@routes.each do |route|
path = File.expand_path("../../../../controllers/controller/rule_engine/controllers/#{route.pluralize}_controller.rb", __FILE__)
system("mkdir -p #{@root}/app/controllers/api/rule_engine")
system("cp #{path} #{@root}/app/controllers/api/rule_engine")
end
puts "DONE CONTROLLERS RULE ENGINE...."
end
|
#cp_jobs_rule_engine ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 47
def cp_jobs_rule_engine
routes = ["pollings","webhooks","actions"]
routes.each do |route|
path = File.expand_path("../../../../jobs/rule_engine/jobs_#{route}.rb", __FILE__)
system("mkdir -p #{@root}/app/jobs/concerns/rule_engine")
system("cp #{path} #{@root}/app/jobs/concerns/rule_engine")
end
puts "DONE JOBS RULE ENGINE...."
end
|
#cp_migrations_rule_engine ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 38
def cp_migrations_rule_engine
@routes.each do |route|
path = File.expand_path("../../../../migrations/rule_engine/#{route.pluralize}.rb", __FILE__)
system("mkdir -p #{@root}/db/migrate/tables/rule_engine")
system("cp #{path} #{@root}/db/migrate/tables/rule_engine")
end
puts "DONE MIGRATIONS RULE ENGINE...."
end
|
#cp_models(files) ⇒ Object
199
200
201
202
203
204
205
206
|
# File 'lib/forcast/tasks/schema/schema.rb', line 199
def cp_models(files)
files.each do |file|
file = file.singularize
tmp_path = File.dirname(__FILE__)+"/recips/tmp/model/#{file}.rb"
system("cp #{tmp_path} #{@root}/app/models/test/#{file}.rb")
system("rm #{tmp_path}")
end
end
|
#cp_models_rule_engine ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 10
def cp_models_rule_engine
@routes.each do |route|
path = File.expand_path("../../../../models/rule_engine/models/#{route}.rb", __FILE__)
system("mkdir -p #{@root}/app/models/rule_engine")
system("cp #{path} #{@root}/app/models/rule_engine")
end
puts "DONE MODELS RULE ENGINE...."
end
|
#cp_routes_rule_engine ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 28
def cp_routes_rule_engine
@routes.each do |route|
path = File.expand_path("../../recips/route.rb", __FILE__)
system("mkdir -p #{@root}/config/routes/rule_engine")
system("cp #{path} #{@root}/config/routes/rule_engine/#{route.pluralize}.rb")
end
write_draw_routes
puts "DONE ROUTES RULE ENGINE...."
end
|
#create_draw_structure(array) ⇒ Object
247
248
249
250
251
252
253
254
|
# File 'lib/forcast/tasks/schema/schema.rb', line 247
def create_draw_structure(array)
array_init = array
new_array = array_init.each do |rel|
deep_draw_structure(array_init,rel)
end
return new_array
end
|
#deep_draw_structure(array, rel) ⇒ Object
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
# File 'lib/forcast/tasks/schema/schema.rb', line 256
def deep_draw_structure(array,rel)
return if array.empty?
array.each do |arr|
next if arr[:relation] == rel[:relation]
arr[:has_many].each do |e|
if e[:relation] == ""
arr[:has_many].delete(e)
end
if e[:relation] == [rel[:relation]] || e[:relation] == rel[:relation]
e[:has_many] = rel[:has_many]
end
end
array = arr[:has_many].select {|e| e[:relation] != ""}
deep_draw_structure(array,rel)
end
end
|
#deploy(folder) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/lib/production.rb', line 30
def deploy (folder)
folder_development = folder[:folder_development]
folder_production = folder[:folder_production]
Dir.chdir("#{@base_path}/production")
system("rm -R #{folder_production}")
system("mkdir #{folder_production}")
Dir.chdir("#{@base_path}/#{folder_development}")
system("ruby production.rb")
system("cp -R production/ #{@base_path}/production/#{folder_production}")
scp(folder_production)
end
|
#draw_complex_structure(line = "", space = "", object) ⇒ Object
296
297
298
299
300
301
|
# File 'lib/forcast/tasks/schema/schema.rb', line 296
def draw_complex_structure(line = "",space = "",object)
object.each_with_index do |key|
line = draw_deep_complex_structure(line,[key],space)
end
return line
end
|
#draw_deep_complex_structure(line, array, space_int) ⇒ Object
303
304
305
306
307
308
309
310
311
312
313
314
|
# File 'lib/forcast/tasks/schema/schema.rb', line 303
def draw_deep_complex_structure(line,array,space_int)
return if array.empty?
array.each do |key|
line += draw_method_action(key[:relation],space_int)
space_int = space_int+" "
line = draw_draw_deep_complex_structure(line,key[:has_many],space_int)
space_end = space_int[0...-2]
line += draw_method_end(space_end) unless key[:has_many].empty?
end
return line
end
|
#draw_draw_deep_complex_structure(relation = '', line, array, space_int) ⇒ Object
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
# File 'lib/forcast/tasks/schema/schema.rb', line 316
def draw_draw_deep_complex_structure(relation = '',line,array,space_int)
if array.empty?
space_int = space_int[0...-2]
line += draw_method_end(space_int)
return line
end
array.each do |has_many|
line += draw_method_action(has_many[:relation],space_int)
space = space_int+" "
line = draw_draw_draw_deep_complex_structure(line,has_many[:has_many],space)
end
return line
end
|
#draw_draw_draw_deep_complex_structure(relation = '', line, array, space_int) ⇒ Object
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
# File 'lib/forcast/tasks/schema/schema.rb', line 331
def draw_draw_draw_deep_complex_structure(relation = '',line,array,space_int)
if array.empty?
space_int = space_int[0...-2]
line += draw_method_end(space_int)
return line
end
array.each do |has_many|
line += draw_method_action(has_many[:relation],space_int)
space = space_int+" "
line = draw_draw_draw_deep_complex_structure(line,has_many[:has_many],space)
space_end = space_int[0...-2]
line += draw_method_end(space_end)
end
return line
end
|
#draw_method_action(action, space) ⇒ Object
273
274
275
276
277
|
# File 'lib/forcast/tasks/schema/schema.rb', line 273
def draw_method_action(action,space)
line = space+"draw :#{action.pluralize} do\n"
return line
end
|
#draw_method_end(space) ⇒ Object
278
279
280
281
|
# File 'lib/forcast/tasks/schema/schema.rb', line 278
def draw_method_end(space)
line = space+"end\n"
return line
end
|
#draw_simple_structure(space = "", object) ⇒ Object
283
284
285
286
287
288
289
290
291
292
293
294
|
# File 'lib/forcast/tasks/schema/schema.rb', line 283
def draw_simple_structure(space = "",object)
line = ""
object.keys.each_with_index do |key|
line += draw_method_action(key,space)
space = space+" "
end
object.keys.each_with_index do |key|
space = space[0...-2]
line += draw_method_end(space)
end
return line
end
|
#enable_systemctl(file) ⇒ Object
54
55
56
|
# File 'lib/lib/systemctl_maker.rb', line 54
def enable_systemctl(file)
system("systemctl enable #{file}")
end
|
#generate_actions(object) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/forcast/tasks/schema/schema.rb', line 95
def generate_actions(object)
routes = object.keys
path = File.dirname(__FILE__)+"/recips/action.rb"
tmp_path = File.dirname(__FILE__)+"/recips/tmp/action.rb"
routes.each do |route|
text = File.read(path)
new_contents = text.gsub("VARIABLE", "#{route.classify.pluralize}")
new_contents = new_contents.gsub("METODO", "#{route}")
File.open(tmp_path, "w") {|file| file.puts new_contents }
system("cp #{tmp_path} #{@root}/app/controllers/action/test/#{route}_controller.rb")
end
puts "DONE MAKING ACTION CONTROLLERS...."
routes_generate_action(routes)
end
|
#generate_controllers(object) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/forcast/tasks/schema/schema.rb', line 82
def generate_controllers(object)
routes = object.keys
path = File.dirname(__FILE__)+"/recips/controller.rb"
tmp_path = File.dirname(__FILE__)+"/recips/tmp/controller.rb"
routes.each do |route|
text = File.read(path)
new_contents = text.gsub("VARIABLE", "#{route.classify.pluralize}")
File.open(tmp_path, "w") {|file| file.puts new_contents }
system("cp #{tmp_path} #{@root}/app/controllers/api/test/#{route}_controller.rb")
end
puts "DONE MAKING API CONTROLLERS...."
end
|
#generate_definitor(object) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/forcast/tasks/schema/schema.rb', line 120
def generate_definitor(object)
routes = object.keys
path = File.dirname(__FILE__)+"/recips/definitor.rb"
tmp_path = File.dirname(__FILE__)+"/recips/tmp/definitor.rb"
routes.each do |route|
text = File.read(path)
new_contents = text.gsub("VARIABLE", "#{route.classify.pluralize}")
File.open(tmp_path, "w") {|file| file.puts new_contents }
system("cp #{tmp_path} #{@root}/app/controllers/concerns/definitor_module/test/definitor_#{route}.rb")
end
puts "DONE MAKING DEFINITORS...."
end
|
#generate_folders ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/forcast/tasks/schema/schema.rb', line 62
def generate_folders
system("mkdir -p #{@root}/config/routes/test")
system("mkdir -p #{@root}/app/models/test")
system("mkdir -p #{@root}/app/controllers/api/test")
system("mkdir -p #{@root}/app/controllers/action/test")
system("mkdir -p #{@root}/app/controllers/concerns/project_module/test")
system("mkdir -p #{@root}/app/controllers/concerns/definitor_module/test")
system("mkdir -p #{@root}/app/controllers/concerns/serializer_module/test")
puts "DONE MAKING FOLDERS...."
end
|
#generate_models(object) ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/forcast/tasks/schema/schema.rb', line 146
def generate_models(object)
routes = object.keys
path = File.dirname(__FILE__)+"/recips/model.rb"
@array_has_many = []
routes.each do |route|
attributes = object[route]
route = route.singularize
tmp_path = File.dirname(__FILE__)+"/recips/tmp/model/#{route}.rb"
text = File.read(path)
new_contents = text.gsub("VARIABLE", "#{route.capitalize.classify}")
system("touch #{tmp_path}")
File.open(tmp_path, "w") {|file| file.puts new_contents }
size = attributes.size.to_i - 1
relations = size - attributes.index("updated_at").to_i
relations = attributes.pop(relations)
relations.each_with_index do |relation,index|
write_belongs_to(tmp_path,route,relation.to_s,index)
end
end
write_has_many
cp_models(routes)
routes_schema_parse(object)
puts "DONE MAKING MODELS...."
end
|
#generate_projects(object) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/forcast/tasks/schema/schema.rb', line 133
def generate_projects(object)
routes = object.keys
path = File.dirname(__FILE__)+"/recips/project.rb"
tmp_path = File.dirname(__FILE__)+"/recips/tmp/project.rb"
routes.each do |route|
text = File.read(path)
new_contents = text.gsub("VARIABLE", "#{route.classify.pluralize}")
File.open(tmp_path, "w") {|file| file.puts new_contents }
system("cp #{tmp_path} #{@root}/app/controllers/concerns/project_module/test/project_#{route}.rb")
end
puts "DONE MAKING PROJECTS...."
end
|
#generate_routes(object) ⇒ Object
73
74
75
76
77
78
79
80
|
# File 'lib/forcast/tasks/schema/schema.rb', line 73
def generate_routes(object)
routes = object.keys
path = File.dirname(__FILE__)+"/recips/route.rb"
routes.each do |route|
system("cp #{path} #{@root}/config/routes/test/#{route}.rb")
end
puts "DONE MAKING ROUTES...."
end
|
#init_documentation(root) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/forcast/tasks/documentation/documentation.rb', line 66
def init_documentation(root)
system("rm -R #{root}/documentation/")
documents = YAML.load_file("#{root}/config/documentation_files.yml")
documents.each do |document|
begin
document = YAML.load_file("#{root}/"+document["file"]+".yml")
relative_path_document = document["relative_path"]
files = document["files"]
@absolute_path = "#{root}/"+relative_path_document.to_s
files.each do |documentation_file|
documentation_file = documentation_file["file"]
file_path = @absolute_path + documentation_file["path"]+".rb"
copy_to_documentation(file_path,"#{root}/"+"documentation"+relative_path_document)
file_path_documentation = "#{root}/"+"documentation"+relative_path_document+documentation_file["path"]+".rb"
= documentation_file["comments"]
body = documentation_file["body"]
lines_to_scan = body.keys
positions_lines = open_file_and_find_lines_to(file_path,lines_to_scan)
new_lines = 0
positions_lines.each_with_index do |line,index|
line[:documentation] = body[line[:line_match]]["documentation"]
line[:line_num] += new_lines
new_lines = add_documentation_to_line(file_path_documentation,line,new_lines)
end
(file_path_documentation,)
puts "Terminado archivo: "+file_path_documentation.to_s
end
rescue Exception => e
puts e
next
end
end
end
|
#init_rule_engine ⇒ Object
1
2
3
4
5
6
7
8
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 1
def init_rule_engine
@routes = ["webhook","action","action_log","polling","rule","rule_log"]
cp_models_rule_engine
cp_controllers_rule_engine
cp_routes_rule_engine
cp_migrations_rule_engine
cp_jobs_rule_engine
end
|
#init_schema ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/forcast/tasks/schema/schema.rb', line 50
def init_schema
path = "#{@root}/db/schema.rb"
object = Pretender.parse("#{path}")
generate_folders
generate_routes(object)
generate_controllers(object)
generate_actions(object)
generate_models(object)
generate_definitor(object)
generate_projects(object)
end
|
#list_all_service_name(project) ⇒ Object
41
42
43
44
|
# File 'lib/lib/systemctl_maker.rb', line 41
def list_all_service_name(project)
puts "Archivos listados en: #{@base_path_systemctl}"
system("ls /etc/systemd/system | grep #{project}")
end
|
#make_restart(files) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/lib/systemctl_maker.rb', line 46
def make_restart(files)
str = "#!/bin/bash"+ "\n"
files.each do |file|
str += "systemctl restart #{file.gsub(".sh", '')}" + "\n"
end
File.open("#{@base_path}/restart.sh", 'w') { |file| file.write(str) }
end
|
#method_clone(repo) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/lib/update.rb', line 59
def method_clone(repo)
url = repo[:url]
file = repo[:file]
branch = repo[:branch]
systemctl = repo[:systemctl]
start_time = Time.now
puts (start_time)
Dir.chdir("#{@base_path}")
system("rm -r #{file}")
system("git clone -b #{branch} #{url}")
Dir.chdir("#{file}")
system("npm i")
Dir.chdir("client")
system("npm i")
Dir.chdir("src/environments")
system('cp environment.server.ts environment.prod.ts')
Dir.chdir("../")
system("ng build --prod")
system("sudo systemctl restart #{systemctl}")
end_time = Time.now
Dir.chdir("#{@base_path}")
system("chown -R jenkins:jenkins #{file}")
puts (end_time)
end
|
#method_pull(repo) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/lib/update.rb', line 30
def method_pull(repo)
url = repo[:url]
file = repo[:file]
branch = repo[:branch]
systemctl = repo[:systemctl]
start_time = Time.now
puts (start_time)
Dir.chdir("#{@base_path}")
Dir.chdir("#{file}")
system("git stash")
system("git pull origin #{branch}")
system("git checkout #{branch}")
system("npm i")
Dir.chdir("client")
system("npm i")
system('ls')
Dir.chdir("src/environments")
system('cp environment.server.ts environment.prod.ts')
Dir.chdir("../")
system("ng build --prod")
system("sudo systemctl restart #{systemctl}")
end_time = Time.now
puts (end_time)
end
|
#obscure ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/lib/production/production.rb', line 12
def obscure
Dir.chdir("#{@base_path}")
system('rm -R production')
system('mkdir production')
system('cp -R node_modules production/')
system('cp -R logs production/')
system('cp -R audios production/')
Dir.chdir("production")
@files.each do |file|
puts file
system("javascript-obfuscator ../#{file} --output #{file}")
end
@folders.each do |folder|
puts folder
system("javascript-obfuscator ../#{folder} --output #{folder}")
end
end
|
#open_file_and_find_lines_to(file_path, lines_to_scan) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/forcast/tasks/documentation/documentation.rb', line 9
def open_file_and_find_lines_to(file_path,lines_to_scan)
text = File.open(file_path).read
positions_lines = []
line_num = 0
i = 0
text.gsub!(/\r\n?/, "\n")
text.each_line do |line|
line_num += 1
line_match = lines_to_scan[i]
next unless line_match
if line.match(line_match)
positions_lines[i] = {:line_num => line_num, :line_match => line_match}
i += 1
end
end
return positions_lines
end
|
#restore(folder) ⇒ Object
28
29
30
31
|
# File 'lib/lib/backup.rb', line 28
def restore (folder)
end
|
#routes_generate_action(routes) ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/forcast/tasks/schema/schema.rb', line 110
def routes_generate_action(routes)
line = ""
routes.each do |route|
line += "post '/#{route}' => '#{route}##{route}'\n"
end
path = "#{@root}/config/routes_action_parse.txt"
File.write(path,line)
puts "DONE MAKING ACTION ROUTES...."
end
|
#routes_schema_parse(object) ⇒ Object
208
209
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/forcast/tasks/schema/schema.rb', line 208
def routes_schema_parse(object)
object = complete_object(object,@array_has_many)
structure = create_draw_structure(object)
line = "GENERAL ROUTES SCHEMA\n"
line += draw_complex_structure(structure)
path = "#{@root}/config/routes_schema_parse.txt"
File.write(path,line)
puts "DONE MAKING DRAW ROUTES...."
end
|
#scp(folder) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/lib/production.rb', line 43
def scp (folder)
Dir.chdir("#{@base_path}/production")
commrm = "sshpass -p #{@remote_password} ssh -p #{@remote_port} #{@remote_user}@#{@remote_ip} 'rm -r #{@base_remote_path}#{folder}' "
puts commrm
system(commrm)
comm = "sshpass -p #{@remote_password} scp -P #{@remote_port} -r #{folder} #{@remote_user}@#{@remote_ip}:#{@base_remote_path}"
puts comm
system(comm)
commsystem = "sshpass -p #{@remote_password} ssh -p #{@remote_port} #{@remote_user}@#{@remote_ip} '#{@base_remote_path}restart.sh' "
puts commsystem
system(commsystem)
end
|
#search_files(name) ⇒ Object
58
59
60
61
62
63
|
# File 'lib/lib/systemctl_maker.rb', line 58
def search_files(name)
files = Dir.entries(".").select do |entry|
entry.include?(name) && entry.include?(".sh")
end
return files
end
|
#verify_sh(file) ⇒ Object
13
14
15
|
# File 'lib/lib/systemctl_maker.rb', line 13
def verify_sh(file)
raise "Archivo no contiene es un .sh" unless file.include?(".sh")
end
|
#write_at(fname, at_line, sdat) ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/forcast/tasks/schema/schema.rb', line 171
def write_at(fname, at_line, sdat)
open(fname, 'r+') do |f|
while (at_line-=1) > 0
f.readline
end
pos = f.pos
rest = f.read
f.seek pos
f.write sdat
f.write rest
end
end
|
#write_belongs_to(tmp_path, origin, relation, index) ⇒ Object
184
185
186
187
188
|
# File 'lib/forcast/tasks/schema/schema.rb', line 184
def write_belongs_to(tmp_path,origin,relation,index)
relation = relation.gsub("_id","").gsub("[","").gsub("]","").gsub('"',"")
write_at(tmp_path,index.to_i+3," belongs_to :#{relation}\n")
@array_has_many.push({:relation => relation, :origin => origin})
end
|
#write_draw_routes ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/forcast/tasks/schema/rule_engine/rule_engine.rb', line 70
def write_draw_routes
path = "#{@root}/config/routes_rule_engine.txt"
line = "ENGINE ROUTES SCHEMA\n"
line += "draw :action_logs do\n"
line += "end\n"
line += "draw :rule_logs do\n"
line += "end\n"
line += "draw :actions do\n"
line += " draw :action_logs do\n"
line += " end\n"
line += "end\n"
line += "draw :pollings do\n"
line += "end\n"
line += "draw :webhooks do\n"
line += "end\n"
line += "draw :rules do\n"
line += " draw :actions do\n"
line += " draw :action_logs do\n"
line += " end\n"
line += " end\n"
line += " draw :pollings do\n"
line += " end\n"
line += " draw :webhooks do\n"
line += " end\n"
line += " draw :rule_logs do\n"
line += " end\n"
line += "end\n"
File.write(path,line)
end
|
#write_file(file, input) ⇒ Object
37
38
39
|
# File 'lib/lib/systemctl_maker.rb', line 37
def write_file(file,input)
File.open("#{@base_path_systemctl}/#{file}.service", 'w') { |file| file.write(input) }
end
|
#write_has_many ⇒ Object
190
191
192
193
194
195
196
197
|
# File 'lib/forcast/tasks/schema/schema.rb', line 190
def write_has_many
@array_has_many.each do |has|
relation = has[:relation]
origin = has[:origin]
tmp_path = File.dirname(__FILE__)+"/recips/tmp/model/#{relation}.rb"
write_at(tmp_path,2," has_many :#{origin}\n")
end
end
|