jcangas-datagateway 1.1.0 → 1.2.2
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.
- data/VERSION.yml +4 -4
- data/bin/datagw +8 -8
- data/lib/datagateway/data_gateway.rb +23 -10
- data/lib/datagateway/jobs/nexus_export.rb +6 -14
- data/lib/datagateway/jobs/nexus_import.rb +1 -10
- data/lib/datagateway/jobs/shopin_export.rb +0 -3
- data/lib/datagateway/jobs/shopin_import.rb +0 -2
- data/lib/datagateway/nexus/nexus_ar.rb +4 -2
- data/lib/datagateway/ssh_transfer.rb +2 -3
- data/lib/datagateway.rb +83 -99
- data/lib/version.rb +3 -7
- data/template-prj/README +2 -0
- data/template-prj/config/settings.yml +0 -5
- data/template-prj/dgw-job.rb +25 -0
- data/template-prj/ruby.exe +0 -0
- data/template-prj/run.bat +1 -0
- data/template-prj/sistema.ini +3 -0
- metadata +8 -6
- data/lib/datagateway/version.rb +0 -13
- data/template-prj/datagateway.rb +0 -18
data/VERSION.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
---
|
|
2
|
-
:
|
|
3
|
-
:
|
|
4
|
-
:
|
|
1
|
+
---
|
|
2
|
+
:patch: 2
|
|
3
|
+
:major: 1
|
|
4
|
+
:minor: 2
|
data/bin/datagw
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby -KU
|
|
2
|
-
|
|
3
2
|
|
|
4
3
|
# == Sinopsis
|
|
5
|
-
# DataGateway actua como una '
|
|
4
|
+
# DataGateway actua como una 'pasarela de bases de datos'. Permite trasnferir datos de
|
|
6
5
|
# un origen a un destino, incluso en maquinas diferentes usando el proteocolo
|
|
7
6
|
# sftp.
|
|
8
7
|
#
|
|
@@ -27,9 +26,10 @@
|
|
|
27
26
|
#
|
|
28
27
|
# == Copyright
|
|
29
28
|
# Copyright (c) 2008 Jorge L. Cangas
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
require '
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
|
|
30
|
+
$KCODE = 'UTF8'
|
|
31
|
+
require 'rubygems'
|
|
32
|
+
require 'datagateway'
|
|
33
|
+
|
|
34
|
+
AppConfig.run
|
|
35
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'benchmark'
|
|
5
5
|
require 'fileutils'
|
|
@@ -305,9 +305,7 @@ module DataGateway
|
|
|
305
305
|
|
|
306
306
|
def initialize(name, &block)
|
|
307
307
|
@name = name
|
|
308
|
-
DataGateway.logger.info "DataGateway.use_resources #{DataGateway.use_resources}"
|
|
309
308
|
@use_resources = DataGateway.use_resources
|
|
310
|
-
DataGateway.logger.info "resources will be imported!" if @use_resources
|
|
311
309
|
@encoder = NullEncoder.new
|
|
312
310
|
@transfer = nil
|
|
313
311
|
instance_eval(&block) if block_given?
|
|
@@ -354,7 +352,7 @@ module DataGateway
|
|
|
354
352
|
end
|
|
355
353
|
|
|
356
354
|
def do_run
|
|
357
|
-
transfer.download if transfer
|
|
355
|
+
transfer.download if transfer and transfer.download_from
|
|
358
356
|
|
|
359
357
|
Dir.glob(File.join(DataGateway::inbox, '*.zip')).sort.each do |filename|
|
|
360
358
|
DataGateway.logger.info "Importing #{filename}"
|
|
@@ -368,7 +366,7 @@ module DataGateway
|
|
|
368
366
|
@mappers[table] ||= TableMapper.new(self, table)
|
|
369
367
|
end
|
|
370
368
|
|
|
371
|
-
|
|
369
|
+
public # DSL
|
|
372
370
|
|
|
373
371
|
def download_from(options)
|
|
374
372
|
options.merge! 'local_files' => DataGateway.inbox
|
|
@@ -460,7 +458,6 @@ module DataGateway
|
|
|
460
458
|
end
|
|
461
459
|
|
|
462
460
|
def do_run
|
|
463
|
-
DataGateway.logger.debug 'resource_path ' + DataGateway.resource_path
|
|
464
461
|
begin
|
|
465
462
|
self.each { |cname, records|
|
|
466
463
|
file_name = "#{cname}.#{self.format_id}"
|
|
@@ -476,7 +473,7 @@ module DataGateway
|
|
|
476
473
|
close_export_folder
|
|
477
474
|
end
|
|
478
475
|
|
|
479
|
-
transfer.upload if transfer
|
|
476
|
+
transfer.upload if transfer and transfer.upload_to
|
|
480
477
|
end
|
|
481
478
|
|
|
482
479
|
private # DSL
|
|
@@ -498,7 +495,7 @@ module DataGateway
|
|
|
498
495
|
FileUtils.mkpath(outbox)
|
|
499
496
|
stamp = Time.now.strftime("%Y%m%d%H%M%S")
|
|
500
497
|
folder_name = File.join(outbox, "#{stamp}.#{self.format_id}")
|
|
501
|
-
(APP_ENV == 'development') ? FolderWriter.new(folder_name) :
|
|
498
|
+
#(APP_ENV == 'development') ? FolderWriter.new(folder_name) :
|
|
502
499
|
ZipFolderWriter.new(folder_name)
|
|
503
500
|
end
|
|
504
501
|
|
|
@@ -539,7 +536,7 @@ module DataGateway
|
|
|
539
536
|
end
|
|
540
537
|
end
|
|
541
538
|
end
|
|
542
|
-
|
|
539
|
+
public
|
|
543
540
|
# DataGateway DSL
|
|
544
541
|
def resource_path(path= nil)
|
|
545
542
|
if path
|
|
@@ -549,8 +546,10 @@ module DataGateway
|
|
|
549
546
|
end
|
|
550
547
|
end
|
|
551
548
|
|
|
549
|
+
module_function(:resource_path)
|
|
550
|
+
|
|
552
551
|
def db_connection(conn)
|
|
553
|
-
ActiveRecord::Base.establish_connection conn
|
|
552
|
+
::ActiveRecord::Base.establish_connection conn
|
|
554
553
|
if conn['nax_empresa']
|
|
555
554
|
NAX::ActiveRecord::Base.establish_connection conn if NAX::ActiveRecord::Base.current_connection.nil?
|
|
556
555
|
end
|
|
@@ -579,4 +578,18 @@ module DataGateway
|
|
|
579
578
|
instance_variable_set('@' + name.to_s, new_job)
|
|
580
579
|
return new_job
|
|
581
580
|
end
|
|
581
|
+
|
|
582
|
+
def upload_to(options)
|
|
583
|
+
Export.new('upload') {
|
|
584
|
+
upload_to options
|
|
585
|
+
}.run
|
|
586
|
+
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
def download_from(options)
|
|
590
|
+
Import.new('download') {
|
|
591
|
+
download_from options
|
|
592
|
+
}.run
|
|
593
|
+
|
|
594
|
+
end
|
|
582
595
|
end
|
|
@@ -2,19 +2,12 @@ require 'nexus/nexus_ar'
|
|
|
2
2
|
|
|
3
3
|
db_connection AppConfig.connections[:nexusdb]
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
upload_to AppConfig.sftp
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
export(:nexus_export) do
|
|
5
|
+
export :nexus_export do
|
|
10
6
|
encode( :to => "UTF-8" , :from => "WINDOWS-1252")
|
|
11
7
|
export_to :csv
|
|
12
8
|
exporting :user, :conditions => 'CODCLI IS NOT NULL'
|
|
13
|
-
exporting :category
|
|
14
|
-
exporting :family
|
|
15
|
-
exporting :tarifa_venta,
|
|
16
|
-
:select => 'IDTARIFAV, CODART, FECMAX, PRECIO, TARIFA, UNIDADES',
|
|
17
|
-
:joins => 'as tarf inner join mmproducts p on code = tarf.codart'
|
|
9
|
+
exporting :category
|
|
10
|
+
exporting :family
|
|
18
11
|
|
|
19
12
|
exporting :news,
|
|
20
13
|
:select => 'DESCRIPTION AS TITLE, FROMDATE AS PUBLISHED_AT, TODATE AS EXPIRES_AT, PRIORITY, NEWSTEXT BODY'
|
|
@@ -23,9 +16,8 @@ export(:nexus_export) do
|
|
|
23
16
|
:joins => 'as p left outer join ARTICULO as ar on CODE = ar.CODART left outer join DESCRIPA as da on CODE = da.CODART',
|
|
24
17
|
:conditions => "da.codidioma = 'CAS'"
|
|
25
18
|
|
|
26
|
-
|
|
19
|
+
exporting :tarifa_venta,
|
|
20
|
+
:select => 'IDTARIFAV, CODART, FECMAX, PRECIO, TARIFA, UNIDADES',
|
|
21
|
+
:joins => 'as tarf inner join mmproducts p on code = tarf.codart'
|
|
27
22
|
end
|
|
28
23
|
|
|
29
|
-
nexus_export.run
|
|
30
|
-
#transfer.run
|
|
31
|
-
|
|
@@ -3,10 +3,7 @@ require 'nexus/nexus_ar'
|
|
|
3
3
|
|
|
4
4
|
db_connection AppConfig.connections[:nexusdb]
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
import(:nexus_import) do
|
|
8
|
-
download_from AppConfig.sftp
|
|
9
|
-
|
|
6
|
+
import(:nexus_import) do
|
|
10
7
|
importing :User do
|
|
11
8
|
force_upcase
|
|
12
9
|
identity_by :USERID
|
|
@@ -53,9 +50,3 @@ import(:nexus_import) do
|
|
|
53
50
|
:special_instructions => :OBSERVACIONES
|
|
54
51
|
end
|
|
55
52
|
end
|
|
56
|
-
|
|
57
|
-
begin
|
|
58
|
-
nexus_import.run
|
|
59
|
-
ensure
|
|
60
|
-
NAX::ActiveRecord::Base.close
|
|
61
|
-
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
db_connection AppConfig.connections[:shopindb]
|
|
3
|
-
resource_path AppConfig.path('../public/images/db/')
|
|
4
3
|
|
|
5
4
|
export 'shopin_export' do
|
|
6
5
|
exporting :user,
|
|
@@ -14,6 +13,4 @@ export 'shopin_export' do
|
|
|
14
13
|
exporting :line_items,
|
|
15
14
|
:select => 'line.id as id, number as order_id, price, product_id, quantity',
|
|
16
15
|
:joins => 'as line left outer join orders as ord on line.order_id = ord.id'
|
|
17
|
-
|
|
18
|
-
run
|
|
19
16
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#--
|
|
1
|
+
#--
|
|
2
|
+
require 'activerecord'
|
|
2
3
|
require 'nexus/nax_ar'
|
|
3
4
|
NAX::ActiveRecord::Base.logger = ActiveRecord::Base.logger
|
|
4
5
|
|
|
@@ -142,4 +143,5 @@ class NAX_Pedido
|
|
|
142
143
|
self.AnadirLinea;
|
|
143
144
|
logger.debug "(NAX) fake_line_added"
|
|
144
145
|
end
|
|
145
|
-
end
|
|
146
|
+
end
|
|
147
|
+
#++
|
|
@@ -41,10 +41,9 @@ class SSHTransfer
|
|
|
41
41
|
sftp.download!(download_from, local_files, :progress => self, :recursive => true)
|
|
42
42
|
sftp.dir.foreach(download_from) do |entry|
|
|
43
43
|
sftp.remove!(File.join(download_from, entry.name)) if entry.file?
|
|
44
|
-
end
|
|
45
|
-
|
|
44
|
+
end
|
|
46
45
|
rescue Net::SFTP::StatusException => e
|
|
47
|
-
on_file_error(
|
|
46
|
+
on_file_error(nil, e)
|
|
48
47
|
end
|
|
49
48
|
end
|
|
50
49
|
end
|
data/lib/datagateway.rb
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
$KCODE = 'UTF8'
|
|
3
|
-
|
|
4
1
|
require 'rubygems'
|
|
5
2
|
require 'optparse'
|
|
6
3
|
require 'rdoc/usage'
|
|
@@ -11,14 +8,8 @@ require 'erb'
|
|
|
11
8
|
require 'yaml'
|
|
12
9
|
require 'logger'
|
|
13
10
|
require 'version'
|
|
14
|
-
|
|
15
|
-
$:.unshift File.join(File.dirname(__FILE__), 'datagateway')
|
|
16
|
-
require 'data_gateway'
|
|
17
|
-
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
APP_ROOT = File.join(File.dirname(__FILE__), '')
|
|
21
|
-
end
|
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__), 'datagateway')
|
|
22
13
|
|
|
23
14
|
class LogFormatter < Logger::Formatter
|
|
24
15
|
@@format = "%s #%d [%s] %5s: %s\n"
|
|
@@ -30,11 +21,11 @@ end
|
|
|
30
21
|
class AppConfig
|
|
31
22
|
ROOT = File.join(File.dirname(__FILE__), '')
|
|
32
23
|
class << self
|
|
33
|
-
attr :config
|
|
24
|
+
attr :config
|
|
34
25
|
|
|
35
|
-
def options
|
|
36
|
-
@options
|
|
37
|
-
end
|
|
26
|
+
def options
|
|
27
|
+
@options
|
|
28
|
+
end
|
|
38
29
|
|
|
39
30
|
def run
|
|
40
31
|
if parsed_options? && arguments_valid?
|
|
@@ -50,57 +41,63 @@ class AppConfig
|
|
|
50
41
|
output_usage
|
|
51
42
|
end
|
|
52
43
|
end
|
|
53
|
-
|
|
54
|
-
def parsed_options?
|
|
55
|
-
parse_options unless @parsed_options
|
|
56
|
-
@parsed_options
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def parse_options
|
|
60
|
-
@parsed_options = true
|
|
61
|
-
# Set defaults
|
|
44
|
+
|
|
45
|
+
def parsed_options?
|
|
46
|
+
parse_options unless @parsed_options
|
|
47
|
+
@parsed_options
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def parse_options
|
|
51
|
+
@parsed_options = true
|
|
52
|
+
# Set defaults
|
|
62
53
|
@options = OpenStruct.new
|
|
63
54
|
@options.verbose = false
|
|
64
|
-
@options.quiet = false
|
|
55
|
+
@options.quiet = false
|
|
65
56
|
@options.debug_on = false
|
|
66
|
-
@options.environment = (ENV['APP_ENV'] || 'production').dup
|
|
57
|
+
@options.environment = (ENV['APP_ENV'] || 'production').dup
|
|
67
58
|
@options.generate = false
|
|
68
59
|
|
|
69
|
-
|
|
70
60
|
# Specify options
|
|
71
61
|
opts = OptionParser.new do |opts|
|
|
72
|
-
opts.banner = "\nUso:
|
|
62
|
+
opts.banner = "\nUso: #{File.basename($0)} [opciones]"
|
|
73
63
|
opts.separator "----------------------"
|
|
74
|
-
opts.separator "
|
|
64
|
+
opts.separator "opciones:"
|
|
65
|
+
|
|
66
|
+
opts.on("-h", "--help", "Muestra es mensaje de ayuda.") do
|
|
67
|
+
ouput_version
|
|
68
|
+
puts opts
|
|
69
|
+
exit
|
|
70
|
+
end
|
|
75
71
|
|
|
76
|
-
opts.on('-h', '--help') { output_help }
|
|
77
|
-
|
|
78
72
|
opts.on("-e", "--environment [ENVIRONMENT]", %w[development production test],
|
|
79
73
|
"(development | production | test)") { |env| @options.environment = env }
|
|
80
|
-
|
|
81
|
-
opts.on("-g", '--generate [prj_name]', "Genera un proyecto nuevo") { |project|
|
|
82
|
-
@options.project = project
|
|
83
|
-
@options.generate = true
|
|
74
|
+
|
|
75
|
+
opts.on("-g", '--generate [prj_name]', "Genera un proyecto nuevo") { |project|
|
|
76
|
+
@options.project = project
|
|
77
|
+
@options.generate = true
|
|
84
78
|
}
|
|
85
79
|
|
|
86
|
-
opts.on("-q", '--quiet', 'Modo "silencioso": no muestra nada en pantalla durante la ejecución') { @options.quiet = true }
|
|
80
|
+
opts.on("-q", '--quiet', 'Modo "silencioso": no muestra nada en pantalla durante la ejecución') { @options.quiet = true }
|
|
81
|
+
|
|
82
|
+
opts.on('-v', '--version', 'Muestra la version y termina') { output_version ; exit 0 }
|
|
87
83
|
|
|
88
|
-
opts.on('-v', '--version', 'Print version and exit') { output_version ; exit 0 }
|
|
89
|
-
|
|
90
84
|
opts.on('-d', '--debug', 'Modo depuración') { @options.debug_on = true }
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
|
|
86
|
+
opts.on('-f', '--file [FICHERO]', String, 'procesao el fichero') { |file|
|
|
87
|
+
@options.file = file
|
|
88
|
+
}
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
opts.parse!(ARGV) rescue puts opts; return false
|
|
92
|
+
|
|
95
93
|
process_options
|
|
96
94
|
true
|
|
97
95
|
end
|
|
98
|
-
|
|
96
|
+
|
|
99
97
|
# Performs post-parse processing on options
|
|
100
98
|
def process_options
|
|
101
|
-
|
|
102
99
|
end
|
|
103
|
-
|
|
100
|
+
|
|
104
101
|
# True if required arguments were provided
|
|
105
102
|
def arguments_valid?
|
|
106
103
|
# TO DO - implement your real logic here
|
|
@@ -112,13 +109,15 @@ class AppConfig
|
|
|
112
109
|
end
|
|
113
110
|
|
|
114
111
|
def output_options
|
|
112
|
+
puts @options
|
|
113
|
+
exit
|
|
115
114
|
puts "Options:\\n"
|
|
116
115
|
|
|
117
116
|
@options.marshal_dump.each do |name, val|
|
|
118
117
|
puts " #{name} = #{val}"
|
|
119
118
|
end
|
|
120
119
|
end
|
|
121
|
-
|
|
120
|
+
|
|
122
121
|
def output_help
|
|
123
122
|
output_version
|
|
124
123
|
RDoc::usage #exits app
|
|
@@ -132,16 +131,19 @@ class AppConfig
|
|
|
132
131
|
def output_version
|
|
133
132
|
puts "#{Application::VERSION::PRODUCT} version #{Application::VERSION::STRING}"
|
|
134
133
|
end
|
|
135
|
-
|
|
136
|
-
def process_command
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
FileUtils.
|
|
144
|
-
|
|
134
|
+
|
|
135
|
+
def process_command
|
|
136
|
+
dir = @options.file ? File.dirname(@options.file) : Dir.pwd
|
|
137
|
+
Module.const_set('APP_ROOT', dir) unless Module.const_defined?('APP_ROOT')
|
|
138
|
+
Module.const_set('APP_ENV', AppConfig.options.environment) unless Module.const_defined?('APP_ENV')
|
|
139
|
+
|
|
140
|
+
if @options.generate
|
|
141
|
+
target = File.expand_path(@options.project)
|
|
142
|
+
FileUtils.mkdir target
|
|
143
|
+
puts "generating #{target}"
|
|
144
|
+
FileUtils.cp_r(File.expand_path(File.join(AppConfig::ROOT, '..', 'template-prj'))+'/.', target, :verbose => !@options.quiet)
|
|
145
|
+
elsif @options.file
|
|
146
|
+
run_app(@options.file)
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
#process_standard_input # [Optional]
|
|
@@ -156,7 +158,7 @@ class AppConfig
|
|
|
156
158
|
# # TO DO - process each line
|
|
157
159
|
#end
|
|
158
160
|
end
|
|
159
|
-
|
|
161
|
+
|
|
160
162
|
def logger
|
|
161
163
|
@logger ||= setup_logger
|
|
162
164
|
end
|
|
@@ -164,29 +166,42 @@ class AppConfig
|
|
|
164
166
|
def path(filename='')
|
|
165
167
|
File.expand_path(filename, APP_ROOT)
|
|
166
168
|
end
|
|
167
|
-
|
|
168
|
-
def run_app
|
|
169
|
+
|
|
170
|
+
def run_app(file)
|
|
169
171
|
AppConfig.logger.info echo("Data Gateway started")
|
|
170
|
-
AppConfig.logger.debug echo("Entorno: #{APP_ENV} \n
|
|
171
|
-
AppConfig.logger.info echo("job list: #{AppConfig.jobs.join(',')}")
|
|
172
|
+
#AppConfig.logger.debug echo("Entorno: #{APP_ENV} \n configuración: #{AppConfig.config.inspect}")
|
|
172
173
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
require 'activerecord'
|
|
175
|
+
require 'data_gateway'
|
|
176
|
+
ActiveRecord::Base.logger = AppConfig.logger
|
|
177
|
+
ActiveRecord::Base.colorize_logging = false
|
|
178
|
+
|
|
179
|
+
DataGateway.logger = AppConfig.logger
|
|
180
|
+
DataGateway.inbox = AppConfig.path(AppConfig.data['inbox'])
|
|
181
|
+
DataGateway.outbox = AppConfig.path(AppConfig.data['outbox'])
|
|
182
|
+
DataGateway.donebox = AppConfig.path(AppConfig.data['donebox'])
|
|
183
|
+
DataGateway.use_resources = AppConfig.data['use_resources']
|
|
184
|
+
DataGateway.resource_path(AppConfig.path(AppConfig.data['resource_path']))
|
|
185
|
+
|
|
186
|
+
DataGateway.logger.info "using resources #{DataGateway.use_resources} | #{DataGateway.resource_path}"
|
|
187
|
+
|
|
188
|
+
require file
|
|
189
|
+
## Porque no va:?
|
|
190
|
+
##eval(File.read(File.expand_path(file)))
|
|
191
|
+
|
|
177
192
|
AppConfig.logger.info echo("Data Gateway finished ok")
|
|
178
193
|
|
|
179
194
|
rescue Exception => e
|
|
180
195
|
puts "Error:\n#{e}\n."
|
|
181
196
|
AppConfig.logger.error "#{e}\n" + e.backtrace.join("\n")
|
|
182
|
-
end
|
|
197
|
+
end
|
|
183
198
|
|
|
184
199
|
def log_path
|
|
185
200
|
path('log/application.log')
|
|
186
201
|
end
|
|
187
202
|
|
|
188
203
|
def settings(name)
|
|
189
|
-
env = (APP_ENV == 'production' ? '' : '.' + APP_ENV)
|
|
204
|
+
env = (Module::APP_ENV == 'production' ? '' : '.' + Module::APP_ENV)
|
|
190
205
|
path("config#{env}/#{name}.yml")
|
|
191
206
|
end
|
|
192
207
|
|
|
@@ -244,7 +259,7 @@ class AppConfig
|
|
|
244
259
|
puts msg unless AppConfig.options.quiet
|
|
245
260
|
msg
|
|
246
261
|
end
|
|
247
|
-
|
|
262
|
+
|
|
248
263
|
def method_missing(name, *args)
|
|
249
264
|
load
|
|
250
265
|
if (args.size > 0)
|
|
@@ -260,35 +275,4 @@ class AppConfig
|
|
|
260
275
|
end
|
|
261
276
|
end
|
|
262
277
|
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
__END__
|
|
267
|
-
|
|
268
|
-
AppConfig.parse_options
|
|
269
|
-
|
|
270
|
-
APP_ENV = AppConfig.options.environment unless defined?(APP_ENV)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
['actionmailer','actionpack', 'activerecord', 'activeresource', 'activesupport'].each {|gem|
|
|
274
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'vendor', 'rails',gem, 'lib')
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
#gem 'activerecord', '<2.2.2'
|
|
279
|
-
|
|
280
|
-
require 'active_record'
|
|
281
|
-
|
|
282
|
-
ActiveRecord::Base.logger = AppConfig.logger
|
|
283
|
-
ActiveRecord::Base.colorize_logging = false
|
|
284
|
-
|
|
285
|
-
DataGateway.logger = AppConfig.logger
|
|
286
|
-
DataGateway.inbox = AppConfig.path(AppConfig.data['inbox'])
|
|
287
|
-
DataGateway.outbox = AppConfig.path(AppConfig.data['outbox'])
|
|
288
|
-
DataGateway.donebox = AppConfig.path(AppConfig.data['donebox'])
|
|
289
|
-
DataGateway.use_resources = AppConfig.data['use_resources']
|
|
290
|
-
DataGateway.resource_path(AppConfig.path(AppConfig.data['resource_path']))
|
|
291
|
-
|
|
292
|
-
AppConfig.jobs ||= []
|
|
293
|
-
|
|
294
|
-
|
|
278
|
+
end
|
data/lib/version.rb
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
require 'time'
|
|
1
|
+
require 'time'
|
|
2
2
|
|
|
3
3
|
module Application
|
|
4
|
-
module VERSION #:nodoc:
|
|
4
|
+
module VERSION #:nodoc:
|
|
5
5
|
@res = File.join(File.dirname(__FILE__), '..', 'VERSION.yml')
|
|
6
6
|
PRODUCT = 'DataGateway'
|
|
7
7
|
COMPANY = 'Memory Comm S. L.'
|
|
8
8
|
AUTHOR = 'jorge.cangas@gmail.com'
|
|
9
9
|
NUMBER = YAML::load(ERB.new(IO.read(@res)).result)
|
|
10
|
-
#MAJOR = 1
|
|
11
|
-
#MINOR = 1
|
|
12
|
-
#TINY = 0
|
|
13
10
|
STRING = [NUMBER[:major], NUMBER[:minor], NUMBER[:patch]].join('.')
|
|
14
|
-
RELEASED_AT = Time.parse('2008/03/22 03:04:54')
|
|
15
11
|
end
|
|
16
|
-
end
|
|
12
|
+
end
|
data/template-prj/README
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
## Sample job file for datagateway
|
|
3
|
+
include DataGateway
|
|
4
|
+
|
|
5
|
+
# we can use built-in jobs
|
|
6
|
+
require 'datagateway/jobs/nexus_export'
|
|
7
|
+
require 'datagateway/jobs/nexus_import'
|
|
8
|
+
require 'datagateway/jobs/shopin_export'
|
|
9
|
+
require 'datagateway/jobs/shopin_export'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
nexus_export.run
|
|
13
|
+
upload_to AppConfig.sftp
|
|
14
|
+
|
|
15
|
+
download_from AppConfig.sftp
|
|
16
|
+
begin
|
|
17
|
+
nexus_import.run
|
|
18
|
+
ensure
|
|
19
|
+
NAX::ActiveRecord::Base.close
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
resource_path AppConfig.path('../public/images/db/')
|
|
24
|
+
|
|
25
|
+
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
datagw -f dgw-job
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jcangas-datagateway
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jorge L. Cangas
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-02-02 00:00:00 -08:00
|
|
13
13
|
default_executable: datagw
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -17,9 +17,9 @@ dependencies:
|
|
|
17
17
|
version_requirement:
|
|
18
18
|
version_requirements: !ruby/object:Gem::Requirement
|
|
19
19
|
requirements:
|
|
20
|
-
- -
|
|
20
|
+
- - <
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
22
|
+
version: 2.2.2
|
|
23
23
|
version:
|
|
24
24
|
description: TODO
|
|
25
25
|
email: jorge.cangas@gmail.com
|
|
@@ -34,7 +34,6 @@ files:
|
|
|
34
34
|
- bin/datagw
|
|
35
35
|
- lib/version.rb
|
|
36
36
|
- lib/datagateway
|
|
37
|
-
- lib/datagateway/version.rb
|
|
38
37
|
- lib/datagateway/dbchange_point.rb
|
|
39
38
|
- lib/datagateway/ssh_transfer.rb
|
|
40
39
|
- lib/datagateway/jobs
|
|
@@ -56,6 +55,7 @@ files:
|
|
|
56
55
|
- test/datagateway_test.rb
|
|
57
56
|
- template-prj/log
|
|
58
57
|
- template-prj/log/README
|
|
58
|
+
- template-prj/dgw-job.rb
|
|
59
59
|
- template-prj/data
|
|
60
60
|
- template-prj/data/outbox
|
|
61
61
|
- template-prj/data/outbox/README
|
|
@@ -67,8 +67,10 @@ files:
|
|
|
67
67
|
- template-prj/config/settings.yml
|
|
68
68
|
- template-prj/config/README
|
|
69
69
|
- template-prj/config/database.yml
|
|
70
|
+
- template-prj/ruby.exe
|
|
70
71
|
- template-prj/README
|
|
71
|
-
- template-prj/
|
|
72
|
+
- template-prj/sistema.ini
|
|
73
|
+
- template-prj/run.bat
|
|
72
74
|
has_rdoc: true
|
|
73
75
|
homepage: http://github.com/jcangas/datagateway
|
|
74
76
|
post_install_message:
|
data/lib/datagateway/version.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require 'time'
|
|
2
|
-
module Application
|
|
3
|
-
module VERSION #:nodoc:
|
|
4
|
-
PRODUCT = 'DataGateway'
|
|
5
|
-
COMPANY = 'Memory Comm S. L.'
|
|
6
|
-
AUTHOR = 'jorge.cangas@gmail.com'
|
|
7
|
-
MAJOR = 1
|
|
8
|
-
MINOR = 1
|
|
9
|
-
TINY = 0
|
|
10
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
|
11
|
-
RELEASED_AT = Time.parse('2008/03/22 03:04:54')
|
|
12
|
-
end
|
|
13
|
-
end
|
data/template-prj/datagateway.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'datagateway'
|
|
2
|
-
|
|
3
|
-
begin
|
|
4
|
-
AppConfig.logger.info echo("Data Gateway started")
|
|
5
|
-
AppConfig.logger.debug echo("Entorno: #{APP_ENV} \n Opciones: #{AppConfig.config.inspect}")
|
|
6
|
-
AppConfig.logger.info echo("job list: #{AppConfig.jobs.join(',')}")
|
|
7
|
-
|
|
8
|
-
include DataGateway
|
|
9
|
-
AppConfig.jobs.each do |job|
|
|
10
|
-
#require File.join('jobs', job)
|
|
11
|
-
end
|
|
12
|
-
AppConfig.logger.info echo("Data Gateway finished ok")
|
|
13
|
-
|
|
14
|
-
rescue Exception => e
|
|
15
|
-
puts "Error:\n#{e}\n."
|
|
16
|
-
AppConfig.logger.error "#{e}\n" + e.backtrace.join("\n")
|
|
17
|
-
end
|
|
18
|
-
|