forcast 0.0.110

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 (149) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/COPYRIGHTS +11 -0
  4. data/Gemfile +22 -0
  5. data/Gemfile.lock +166 -0
  6. data/PENDIENTES +39 -0
  7. data/README.md +35 -0
  8. data/Rakefile +7 -0
  9. data/VERSION +1 -0
  10. data/bin/console +14 -0
  11. data/bin/rake +28 -0
  12. data/bin/setup +8 -0
  13. data/forcast.gemspec +73 -0
  14. data/lib/forcast.rb +5 -0
  15. data/lib/forcast/controllers/all.rb +2 -0
  16. data/lib/forcast/controllers/application/all.rb +12 -0
  17. data/lib/forcast/controllers/application/crud.rb +91 -0
  18. data/lib/forcast/controllers/application/database.rb +34 -0
  19. data/lib/forcast/controllers/application/error.rb +18 -0
  20. data/lib/forcast/controllers/application/exception_handler.rb +25 -0
  21. data/lib/forcast/controllers/application/json.rb +83 -0
  22. data/lib/forcast/controllers/application/locale.rb +30 -0
  23. data/lib/forcast/controllers/application/log.rb +22 -0
  24. data/lib/forcast/controllers/application/login.rb +41 -0
  25. data/lib/forcast/controllers/application/meta.rb +61 -0
  26. data/lib/forcast/controllers/application/model.rb +17 -0
  27. data/lib/forcast/controllers/application/permitirtodo.rb +27 -0
  28. data/lib/forcast/controllers/application/utils.rb +28 -0
  29. data/lib/forcast/controllers/controller/all.rb +8 -0
  30. data/lib/forcast/controllers/controller/asociar.rb +121 -0
  31. data/lib/forcast/controllers/controller/busqueda.rb +151 -0
  32. data/lib/forcast/controllers/controller/definitor/definitor.rb +322 -0
  33. data/lib/forcast/controllers/controller/definitor/definitor_page.rb +40 -0
  34. data/lib/forcast/controllers/controller/definitor_all.rb +2 -0
  35. data/lib/forcast/controllers/controller/filtro.rb +48 -0
  36. data/lib/forcast/controllers/controller/login/controllers/base_controller.rb +135 -0
  37. data/lib/forcast/controllers/controller/login/controllers/login_controller.rb +38 -0
  38. data/lib/forcast/controllers/controller/login/login.rb +71 -0
  39. data/lib/forcast/controllers/controller/login_all.rb +1 -0
  40. data/lib/forcast/controllers/controller/paper_trail/paper_trail.rb +21 -0
  41. data/lib/forcast/controllers/controller/paper_trail_all.rb +1 -0
  42. data/lib/forcast/controllers/controller/relacion.rb +157 -0
  43. data/lib/forcast/controllers/controller/rule_engine/action_engine.rb +92 -0
  44. data/lib/forcast/controllers/controller/rule_engine/controllers/action_logs_controller.rb +12 -0
  45. data/lib/forcast/controllers/controller/rule_engine/controllers/actions_controller.rb +10 -0
  46. data/lib/forcast/controllers/controller/rule_engine/controllers/pollings_controller.rb +13 -0
  47. data/lib/forcast/controllers/controller/rule_engine/controllers/rule_logs_controller.rb +12 -0
  48. data/lib/forcast/controllers/controller/rule_engine/controllers/rules_controller.rb +19 -0
  49. data/lib/forcast/controllers/controller/rule_engine/controllers/webhooks_controller.rb +27 -0
  50. data/lib/forcast/controllers/controller/rule_engine/polling_engine.rb +76 -0
  51. data/lib/forcast/controllers/controller/rule_engine/rule_controller.rb +27 -0
  52. data/lib/forcast/controllers/controller/rule_engine/rule_engine.rb +88 -0
  53. data/lib/forcast/controllers/controller/rule_engine/webhook_engine.rb +38 -0
  54. data/lib/forcast/controllers/controller/rule_engine_all.rb +5 -0
  55. data/lib/forcast/jobs/all.rb +2 -0
  56. data/lib/forcast/jobs/jobs_assets.rb +25 -0
  57. data/lib/forcast/jobs/jobs_wrapper.rb +25 -0
  58. data/lib/forcast/jobs/rule_engine/jobs_actions.rb +73 -0
  59. data/lib/forcast/jobs/rule_engine/jobs_pollings.rb +77 -0
  60. data/lib/forcast/jobs/rule_engine/jobs_webhooks.rb +54 -0
  61. data/lib/forcast/migrations/0_migracion_general.rb +44 -0
  62. data/lib/forcast/migrations/paper_trail/versions.rb +61 -0
  63. data/lib/forcast/migrations/rule_engine/action_logs.rb +15 -0
  64. data/lib/forcast/migrations/rule_engine/actions.rb +15 -0
  65. data/lib/forcast/migrations/rule_engine/pollings.rb +26 -0
  66. data/lib/forcast/migrations/rule_engine/rule_logs.rb +22 -0
  67. data/lib/forcast/migrations/rule_engine/rules.rb +27 -0
  68. data/lib/forcast/migrations/rule_engine/webhooks.rb +25 -0
  69. data/lib/forcast/models/all.rb +8 -0
  70. data/lib/forcast/models/asociar.rb +74 -0
  71. data/lib/forcast/models/busqueda.rb +17 -0
  72. data/lib/forcast/models/login/authorization.rb +37 -0
  73. data/lib/forcast/models/login/json_web_token.rb +15 -0
  74. data/lib/forcast/models/login/login.rb +26 -0
  75. data/lib/forcast/models/login_all.rb +2 -0
  76. data/lib/forcast/models/meta.rb +19 -0
  77. data/lib/forcast/models/modelo.rb +125 -0
  78. data/lib/forcast/models/models/meta.rb +6 -0
  79. data/lib/forcast/models/paper_trail/paper_trail.rb +13 -0
  80. data/lib/forcast/models/paper_trail_all.rb +1 -0
  81. data/lib/forcast/models/permitirtodo.rb +57 -0
  82. data/lib/forcast/models/rule_engine/action_engine.rb +19 -0
  83. data/lib/forcast/models/rule_engine/models/action.rb +41 -0
  84. data/lib/forcast/models/rule_engine/models/action_log.rb +40 -0
  85. data/lib/forcast/models/rule_engine/models/polling.rb +43 -0
  86. data/lib/forcast/models/rule_engine/models/rule.rb +44 -0
  87. data/lib/forcast/models/rule_engine/models/rule_log.rb +39 -0
  88. data/lib/forcast/models/rule_engine/models/webhook.rb +43 -0
  89. data/lib/forcast/models/rule_engine/polling_engine.rb +113 -0
  90. data/lib/forcast/models/rule_engine/rule.rb +62 -0
  91. data/lib/forcast/models/rule_engine/rule_engine.rb +137 -0
  92. data/lib/forcast/models/rule_engine/rule_scope.rb +35 -0
  93. data/lib/forcast/models/rule_engine/webhook_engine.rb +55 -0
  94. data/lib/forcast/models/rule_engine_all.rb +6 -0
  95. data/lib/forcast/routes/concerns/asociar.rb +15 -0
  96. data/lib/forcast/routes/concerns/buscar.rb +6 -0
  97. data/lib/forcast/routes/concerns/definitor.rb +3 -0
  98. data/lib/forcast/routes/concerns/modelo.rb +6 -0
  99. data/lib/forcast/routes/database.rb +4 -0
  100. data/lib/forcast/routes/login.rb +4 -0
  101. data/lib/forcast/routes/paper_trail/paper_trail.rb +3 -0
  102. data/lib/forcast/routes/rule_engine/rule.rb +5 -0
  103. data/lib/forcast/tasks/.giosaveZr0hbs +21 -0
  104. data/lib/forcast/tasks/.keep +0 -0
  105. data/lib/forcast/tasks/all.rb +16 -0
  106. data/lib/forcast/tasks/diagramas.rake +32 -0
  107. data/lib/forcast/tasks/documentation/documentation.rb +100 -0
  108. data/lib/forcast/tasks/env.rake +10 -0
  109. data/lib/forcast/tasks/git.rake +22 -0
  110. data/lib/forcast/tasks/indy/indy.rb +28 -0
  111. data/lib/forcast/tasks/logs.rake +13 -0
  112. data/lib/forcast/tasks/process.rake +18 -0
  113. data/lib/forcast/tasks/schema.rake +17 -0
  114. data/lib/forcast/tasks/schema/recips/action.rb +18 -0
  115. data/lib/forcast/tasks/schema/recips/controller.rb +29 -0
  116. data/lib/forcast/tasks/schema/recips/definitor.rb +38 -0
  117. data/lib/forcast/tasks/schema/recips/model.rb +43 -0
  118. data/lib/forcast/tasks/schema/recips/project.rb +19 -0
  119. data/lib/forcast/tasks/schema/recips/route.rb +9 -0
  120. data/lib/forcast/tasks/schema/recips/tmp/controller.rb +0 -0
  121. data/lib/forcast/tasks/schema/recips/tmp/model.rb +0 -0
  122. data/lib/forcast/tasks/schema/recips/tmp/model/.keep +0 -0
  123. data/lib/forcast/tasks/schema/rule_engine/rule_engine.rb +98 -0
  124. data/lib/forcast/tasks/schema/schema.rb +346 -0
  125. data/lib/forcast/tasks/test.rake +129 -0
  126. data/lib/forcast/tasks/utils.rake +68 -0
  127. data/lib/forcast/tasks/yard.rake +18 -0
  128. data/lib/forcast/utils/all.rb +4 -0
  129. data/lib/forcast/utils/email.rb +49 -0
  130. data/lib/forcast/utils/email/forcast/utils/email/layout/default.html.erb +3 -0
  131. data/lib/forcast/utils/email/forcast/utils/email/layout/default.text.erb +5 -0
  132. data/lib/forcast/utils/firebase.rb +60 -0
  133. data/lib/forcast/utils/firebase_database.rb +117 -0
  134. data/lib/forcast/utils/measure.rb +44 -0
  135. data/lib/forcast/utils/qvo.rb +141 -0
  136. data/lib/forcast/utils/server.rb +296 -0
  137. data/lib/forcast/utils/telegram.rb +82 -0
  138. data/lib/forcast/utils/thing.rb +180 -0
  139. data/lib/forcast/version.rb +15 -0
  140. data/lib/lib/backup.rb +42 -0
  141. data/lib/lib/deploy.sh +40 -0
  142. data/lib/lib/forcast_servidor_rails.sh +11 -0
  143. data/lib/lib/pg_generator.sh +10 -0
  144. data/lib/lib/production.rb +66 -0
  145. data/lib/lib/production/production.rb +30 -0
  146. data/lib/lib/systemctl_maker.rb +88 -0
  147. data/lib/lib/update.rb +100 -0
  148. data/production.rb +31 -0
  149. metadata +301 -0
@@ -0,0 +1,82 @@
1
+ module FORCAST
2
+ module Telegram
3
+ class Send
4
+ attr_accessor :headers
5
+ attr_accessor :url
6
+ attr_accessor :json_send
7
+ attr_accessor :metodo
8
+ attr_accessor :chat_id
9
+
10
+ def initialize(chat_id)
11
+ self.chat_id = chat_id.to_s
12
+ end
13
+
14
+ def getUpdates
15
+ json_recived = constructor do
16
+ self.metodo = :get
17
+ self.url = "/getUpdates"
18
+ self.json_send = {}
19
+ end
20
+
21
+ end
22
+ #Mostrar usuarios
23
+ def sendMessage(message)
24
+ json_recived = constructor do
25
+ self.metodo = :post
26
+ self.url = "/sendMessage?"
27
+ self.url += "chat_id="+self.chat_id.to_s
28
+ self.url += "&text="+message
29
+ self.url += "&parse_mode=HTML"
30
+ self.json_send = {}
31
+ end
32
+
33
+ end
34
+
35
+ def sendPhoto(url_imagen,message)
36
+ json_recived = constructor do
37
+ self.metodo = :post
38
+ self.url = "/sendPhoto?"
39
+ self.url += "chat_id="+self.chat_id.to_s
40
+ self.url += "&photo="+url_imagen
41
+ self.url += "&caption="+message
42
+ self.url += "&parse_mode=HTML"
43
+ self.json_send = {}
44
+ end
45
+
46
+ end
47
+
48
+ def constructor
49
+ yield
50
+ self.headers = {}
51
+ resp = SERVIDORTELEGRAM.conexion(self.metodo, self.headers, self.url, self.json_send)
52
+ puts resp
53
+ return true if resp[1].blank?
54
+ json_recived = {}
55
+ logger.info "[TELEGRAM] "+resp[1].to_s
56
+ if resp[0] && self.valid_json?(resp[1])
57
+ json_recived = JSON.parse(resp[1])
58
+ unless json_recived.is_a?(Array)
59
+ unless json_recived["error"].nil?
60
+ logger.info "[TELEGRAM] "+json_recived["error"].to_s
61
+ return false
62
+ end
63
+ end
64
+ return json_recived
65
+ else
66
+ return false
67
+ end
68
+ end
69
+
70
+ def valid_json?(json)
71
+ begin
72
+ JSON.parse(json)
73
+ return true
74
+ rescue JSON::ParserError => e
75
+ puts e
76
+ return false
77
+ end
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,180 @@
1
+ require "forcast/utils/server"
2
+
3
+ module Forcast
4
+ module Utils
5
+ module Server
6
+ class Thing
7
+ attr_accessor :headers
8
+ attr_accessor :url
9
+ attr_accessor :json_send
10
+ attr_accessor :metodo
11
+ def initialize
12
+ self.headers = eval(File.read(Rails.root.join("tmp/cache/loginthings.txt")))
13
+ end
14
+ def auth_login_things
15
+ app = Rails.application.class.parent.to_s
16
+ url = "/auth/login"
17
+ json_send = { :username => ENV[app+'_serverthings_user'], :password => ENV[app+'_serverthings_pass'] }
18
+ headers_send = {}
19
+ response = SERVIDORTHINGS.conexion(:post,{},url,json_send)[1]
20
+ #p response
21
+ json_recived = JSON.parse(response) if valid_json?(response)
22
+ if json_recived.include?("token")
23
+ @headers_send = {"X-Authorization" => "Bearer "+ json_recived["token"]}
24
+ else
25
+ return false
26
+ end
27
+ end
28
+ def dorpc_device_things(id,metodo,parametros)
29
+ constructor do
30
+ self.metodo = :post
31
+ self.url = "/plugins/rpc/twoway/"
32
+ self.url += id.to_s
33
+ self.json_send = {"method" => metodo, "params" => parametros}
34
+ end
35
+ end
36
+ def keys_telemetry_device_things(id)
37
+ constructor do
38
+ self.metodo = :get
39
+ self.url = "/plugins/telemetry/DEVICE/"
40
+ self.url += id
41
+ self.url += "/keys/timeseries"
42
+ self.json_send = {}
43
+ end
44
+ end
45
+ def attributes_telemetry_device_things(id)
46
+ constructor do
47
+ self.metodo = :get
48
+ self.url = "/plugins/telemetry/DEVICE/"
49
+ self.url += id
50
+ self.url += "/keys/attributes"
51
+ self.json_send = {}
52
+ end
53
+ end
54
+ def attributes_device_things(id,devices)
55
+ constructor do
56
+ self.metodo = :get
57
+ self.url = "/plugins/telemetry/DEVICE/"
58
+ self.url += id.to_s
59
+ self.url += "/values/attributes?keys="
60
+ devices.each do |device|
61
+ self.url += device + ','
62
+ end
63
+ self.url = url[0...-1]
64
+ self.json_send = {}
65
+ end
66
+ end
67
+ def last_telemetry_device_things(id,parametros)
68
+ constructor do
69
+ self.metodo = :get
70
+ self.url = "/plugins/telemetry/DEVICE/"
71
+ self.url += id
72
+ self.url += "/values/timeseries?keys="
73
+ parametros.each do |obis|
74
+ self.url += obis + ','
75
+ end
76
+ self.url = url[0...-1]
77
+ self.json_send = {}
78
+ end
79
+ end
80
+
81
+ def create_device_things(name, device_type: 'default')
82
+ json_received = constructor do
83
+ self.metodo = :post
84
+ self.url = '/device'
85
+ self.json_send = { name: name, type: device_type }
86
+ end
87
+ p json_received
88
+ if json_received.include?('id')
89
+ data = {}
90
+ data['token'] = get_token_device_things(json_received['id']['id'])
91
+ return false unless data['token']
92
+
93
+ data['id'] = json_received['id']['id']
94
+ return data
95
+ else
96
+ return false
97
+ end
98
+ end
99
+
100
+ def get_token_device_things(id)
101
+ json_recived = constructor do
102
+ self.metodo = :get
103
+ self.url = "/device/"+id.to_s+"/credentials"
104
+ self.json_send = {}
105
+ end
106
+ if json_recived.include?("credentialsId")
107
+ return json_recived["credentialsId"]
108
+ else
109
+ return false
110
+ end
111
+ end
112
+
113
+ def delete_device_things(id_things)
114
+ json_recived = constructor do
115
+ self.metodo = :delete
116
+ self.url = "/device/"+id_things.to_s
117
+ self.json_send = {}
118
+ end
119
+ p json_recived
120
+ if json_recived.include?("errorCode")
121
+ return false
122
+ else
123
+ return true
124
+ end
125
+ end
126
+ def constructor
127
+ yield
128
+ if SERVIDORTHINGS
129
+ response = SERVIDORTHINGS.conexion(self.metodo, self.headers, self.url, self.json_send)[1]
130
+ json_recived = {}
131
+ json_recived = JSON.parse(response) if self.valid_json?(response)
132
+ return json_recived
133
+ else
134
+ puts "Servidor SERVIDORTHINGS no definido"
135
+ return
136
+ end
137
+ end
138
+ def valid_json?(json)
139
+ begin
140
+ JSON.parse(json)
141
+ return true
142
+ rescue JSON::ParserError => e
143
+ puts e
144
+ return false
145
+ end
146
+ end
147
+ def self.sync_login
148
+ p "LOGIN THINGS"
149
+ app = Rails.application.class.parent.to_s
150
+ servidorthings = Forcast::Utils::Server::Server.new do |config|
151
+ config.headers.merge!(eval(ENV[app+'_serverthings_headers']))
152
+ config.dns = ENV[app+'_serverthings_dns']
153
+ config.connect = ENV[app+'_serverthings_connect']
154
+ config.read = ENV[app+'_serverthings_read']
155
+ config.write = ENV[app+'_serverthings_write']
156
+ config.data = ENV[app+'_serverthings_data']
157
+ end
158
+ usuario = ENV[app+'_serverthings_user']
159
+ password = ENV[app+'_serverthings_pass']
160
+ url = "/auth/login"
161
+ json_send = {:username => usuario, :password => password}
162
+ headers_send = {}
163
+ response = servidorthings.conexion(:post,{},url,json_send)[1]
164
+ begin
165
+ json_recived = JSON.parse(response)
166
+ rescue JSON::ParserError => e
167
+ json_recived = {}
168
+ end
169
+ if json_recived.include?("token")
170
+ headers = {"X-Authorization" => "Bearer "+ json_recived["token"]}.to_s
171
+ else
172
+ headers = "PRUEBA HEADERS"
173
+ end
174
+ File.write(Rails.root.join("tmp/cache/loginthings.txt"),headers)
175
+ p "DONE LOGIN"
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,15 @@
1
+ module Forcast
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 0
6
+ # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
7
+ PRE = nil
8
+
9
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
10
+
11
+ def self.to_s
12
+ STRING
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ require 'optparse'
4
+ require 'date'
5
+
6
+ arg1, *FILES = ARGV
7
+ @base_path = Dir.pwd
8
+
9
+ repos = [Hash.new]
10
+
11
+ repos.push({folder_development: 'adminbodega'
12
+ })
13
+ repos.push({folder_development: 'operario'
14
+ })
15
+ repos.push({folder_development: 'clientebodega'
16
+ })
17
+ repos.push({folder_development: 'server'
18
+ })
19
+
20
+ def backup (folder)
21
+ folder_development = folder[:folder_development]
22
+ Dir.chdir("#{@base_path}")
23
+ date = Date.today.strftime('%d-%m-%Y')
24
+ system("mkdir -p backup/#{date}")
25
+ system("cp -TR #{folder_development} backup/#{date}/#{folder_development}")
26
+ end
27
+
28
+ def restore (folder)
29
+
30
+
31
+ end
32
+
33
+
34
+ case arg1
35
+
36
+ when "backup"
37
+ FILES.each do |arg|
38
+ backup(repos[arg.to_i])
39
+ end
40
+ else
41
+ puts "Nada"
42
+ end
@@ -0,0 +1,40 @@
1
+ #!/bin/sh
2
+
3
+ #RVM
4
+ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
5
+ \curl -sSL https://get.rvm.io | bash -s stable --ruby=jruby --gems=rails,puma
6
+ #Ruby
7
+ source /usr/local/rvm/scripts/rvm
8
+ rvm install 2.3.0
9
+ rvm use 2.3.0
10
+ rvm --default use 2.3.0
11
+ #Foreman
12
+ sudo apt install ruby-foreman
13
+ gem install foreman
14
+ gem install bundler
15
+ #Add Universe
16
+ sudo add-apt-repository universe
17
+
18
+ #node
19
+ sudo apt install nodejs npm
20
+ sudo apt install npm
21
+
22
+ #NVM
23
+ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
24
+ nvm install v10.0.0
25
+ #graphviz erd model
26
+ sudo apt-get install graphviz
27
+
28
+ #Postgresql
29
+ sudo apt-get install postgresql postgresql-contrib
30
+ sudo apt-get install libpq-dev
31
+ gem install pg -v '1.1.4'
32
+
33
+ #Redis-Server
34
+ sudo apt-get install build-essential tcl
35
+ cd /tmp
36
+ curl -O http://download.redis.io/redis-stable.tar.gz
37
+ tar xzvf redis-stable.tar.gz
38
+ cd redis-stable
39
+ make
40
+ sudo make install
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ sleep 5
3
+ cd /home/seguridad/Rails/root
4
+ source /usr/local/rvm/scripts/rvm
5
+ sleep 2
6
+ rvm use 2.3.0
7
+ sleep 5
8
+ fuser -k 6379/tcp
9
+ fuser -k 4321/tcp
10
+ sleep 1
11
+ foreman start -f Procfile.dev
@@ -0,0 +1,10 @@
1
+ user=$1
2
+ password=$2
3
+ echo "Create DB" &&
4
+ sudo -i -u postgres -H sh -c "createuser $user;
5
+ createdb $user;
6
+ psql -c 'ALTER USER $user WITH ENCRYPTED PASSWORD '\'$password''\'' ';
7
+ psql -c 'ALTER DATABASE $user OWNER TO $user';
8
+ psql -c 'GRANT ALL PRIVILEGES ON DATABASE $user to $user';
9
+ psql -c '\l';" &&
10
+ echo "Base de datos creada correctamente"
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ require 'optparse'
4
+ arg1, *FILES = ARGV
5
+ @base_path = Dir.pwd
6
+
7
+ @base_remote_path = '/home/LBG/'
8
+ @remote_ip = '186.64.120.100'
9
+ @remote_port = 22222
10
+ @remote_user = 'root'
11
+ @remote_password = 'NpdlP1oT4976KIL8ea'
12
+
13
+ repos = [Hash.new]
14
+ repos.push({folder_development: 'adminbodega',
15
+ folder_production: 'adminbodega'
16
+ })
17
+
18
+ repos.push({folder_development: 'operario',
19
+ folder_production: 'operario'
20
+ })
21
+
22
+ repos.push({folder_development: 'clientebodega',
23
+ folder_production: 'clientebodega'
24
+ })
25
+
26
+ repos.push({folder_development: 'server',
27
+ folder_production: 'server'
28
+ })
29
+
30
+ def deploy (folder)
31
+ folder_development = folder[:folder_development]
32
+ folder_production = folder[:folder_production]
33
+ Dir.chdir("#{@base_path}/production")
34
+ system("rm -R #{folder_production}")
35
+ system("mkdir #{folder_production}")
36
+ Dir.chdir("#{@base_path}/#{folder_development}")
37
+ system("ruby production.rb")
38
+ system("cp -R production/ #{@base_path}/production/#{folder_production}")
39
+ #system("cp server.sh #{@base_path}/production/#{folder_production}/production")
40
+ scp(folder_production)
41
+ end
42
+
43
+ def scp (folder)
44
+
45
+ Dir.chdir("#{@base_path}/production")
46
+ commrm = "sshpass -p #{@remote_password} ssh -p #{@remote_port} #{@remote_user}@#{@remote_ip} 'rm -r #{@base_remote_path}#{folder}' "
47
+ puts commrm
48
+ system(commrm)
49
+ comm = "sshpass -p #{@remote_password} scp -P #{@remote_port} -r #{folder} #{@remote_user}@#{@remote_ip}:#{@base_remote_path}"
50
+ puts comm
51
+ system(comm)
52
+ commsystem = "sshpass -p #{@remote_password} ssh -p #{@remote_port} #{@remote_user}@#{@remote_ip} '#{@base_remote_path}restart.sh' "
53
+ puts commsystem
54
+ system(commsystem)
55
+
56
+ end
57
+
58
+ case arg1
59
+
60
+ when "deploy"
61
+ FILES.each do |arg|
62
+ deploy(repos[arg.to_i])
63
+ end
64
+ else
65
+ puts "Nada"
66
+ end