taskclient 0.0.2 → 0.0.3

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/Rakefile CHANGED
@@ -11,8 +11,6 @@ begin
11
11
  gem.homepage = "http://github.com/lexrupy/taskclient"
12
12
  gem.authors = ["Alexandre da Silva"]
13
13
  gem.files = FileList["[A-Z]*", "{lib}/**/*"]
14
- #gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
14
  end
17
15
  Jeweler::GemcutterTasks.new
18
16
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ require 'yaml'
3
+
4
+ @config_file = {
5
+ 'customer' => {
6
+ 'user' => 'casa@suportecasa.com.br',
7
+ 'password' => 'casa1908'
8
+ },
9
+ 'database' => {
10
+ 'bkpfile' => 'c:\backup.fbk',
11
+ 'user' => 'sysdba',
12
+ 'password' => 'masterkey',
13
+ 'datafile' => 'c:\database.fdb',
14
+ },
15
+ 'ftp' => {
16
+ 'server' => 'ftp.siverti.com.br',
17
+ 'user' => 'siverti',
18
+ 'password' => 'BoatMeleca'
19
+ }
20
+ }
21
+
22
+ def get_config(query, section, key, &block)
23
+ print "#{query} [#{@config_file[section][key]}]: "
24
+ STDOUT.flush
25
+ value = STDIN.gets.chomp
26
+ if value.to_s.strip != ''
27
+ yield(value) if block_given?
28
+ @config_file[section][key] = value
29
+ end
30
+ end
31
+
32
+ get_config "Id do cliente", 'customer','user'
33
+ get_config "Senha do cliente", 'customer', 'password'
34
+ get_config "Banco de dados", 'database', 'datafile'
35
+ get_config "Usuario banco de dados", 'database', 'user'
36
+ get_config "Senha do banco de dados", 'database', 'password'
37
+ get_config "Local temporario do backup", 'database', 'bkpfile'
38
+ get_config "Servidor ftp", 'ftp', 'server'
39
+ get_config "Usuario ftp", 'ftp', 'user'
40
+ get_config "Senha ftp", 'ftp', 'password'
41
+
42
+ File.open('c:\Ruby\config.yml', 'w') do |f|
43
+ YAML.dump(@config_file, f)
44
+ end
@@ -9,7 +9,7 @@ class TaskClient
9
9
 
10
10
  def initialize
11
11
  log 'Initializing check client...'
12
- @jb_client = Simple.new(TaskClient.config('user'), TaskClient.config('password'))
12
+ @jb_client = Simple.new(TaskClient.config('customer.user'), TaskClient.config('customer.password'))
13
13
  at_exit do
14
14
  @jb_client.status(:away, "Done all jobs for now...")
15
15
  end
@@ -24,10 +24,12 @@ class TaskClient
24
24
  end
25
25
 
26
26
  def self.config(conf)
27
+ get_kv = Proc.new { |k| section,key = k.split('.') }
27
28
  if conf.is_a? Array
28
- conf.map {|c| @@config[c] }
29
+ conf.map {|c| k,v = get_kv.call(c); @@config[k][v] }
29
30
  else
30
- @@config[conf]
31
+ k,v = get_kv.call(conf)
32
+ @@config[k][v]
31
33
  end
32
34
  end
33
35
 
@@ -4,10 +4,10 @@ class BackupWorker
4
4
  include EM::Deferrable
5
5
 
6
6
  def do
7
- db, bkp = TaskClient.config(["database","bkpfile"])
8
- bkp7z = "#{bkp}.7z"
9
- usr, pwd, ftps, ftpu, ftpp = TaskClient.config(['dbuser','dbpassword','ftpserver','ftpuser','ftppassword'])
10
- backup_cmd = "gbak -B #{db} #{bkp} -USER #{usr} -PAS #{pwd}"
7
+ db, bk = TaskClient.config(["database.datafile","database.bkpfile"])
8
+ bkp7z = "#{bk}.7z"
9
+ us, pw, ft, fu, fw = TaskClient.config(['database.user','database.password','ftp.server','ftp.user','ftp.password'])
10
+ backup_cmd = "gbak -B #{db} #{bk} -USER #{us} -PAS #{pw}"
11
11
  compress_cmd = "7z a #{bkp7z} #{bkp}"
12
12
  if File.exists? bkp
13
13
  File.delete bkp
@@ -15,8 +15,8 @@ class BackupWorker
15
15
  system backup_cmd
16
16
  system compress_cmd
17
17
  puts "Starting file transfer...."
18
- Net::FTP.open(ftps) do |ftp|
19
- ftp.login(ftpu,ftpp)
18
+ Net::FTP.open(ft) do |ftp|
19
+ ftp.login(fu,fw)
20
20
  ftp.passive = true
21
21
  ftp.putbinaryfile(bkp7z)
22
22
  ftp.quit
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alexandre da Silva
@@ -15,13 +15,14 @@ bindir: bin
15
15
  cert_chain: []
16
16
 
17
17
  date: 2010-03-21 00:00:00 -03:00
18
- default_executable: taskclient
18
+ default_executable:
19
19
  dependencies: []
20
20
 
21
21
  description: Remotely admin client machines using XMPP
22
22
  email: lexrupy@gmail.com
23
23
  executables:
24
24
  - taskclient
25
+ - taskclient-config
25
26
  extensions: []
26
27
 
27
28
  extra_rdoc_files: