grsync 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24eaeaafd867331a50e60e3fbdf750b603454b17
4
- data.tar.gz: 0ee53dd899aae8732643d278e38a0277418a8a8f
3
+ metadata.gz: de99ffe827d1c73cbf2cecb80105944f169372f8
4
+ data.tar.gz: d9b4eabba343b0cf73b1153a1f8b3c001ffeb373
5
5
  SHA512:
6
- metadata.gz: 2dfbd96e80746a42b98c80c066701844d0b4faccc7e1266850f1a13c48e113086488bf7382b52ce903be6522de245630551d440fa87810f6de97005afbee62fc
7
- data.tar.gz: 58908813abe97fb53f959d5cd7ca082ff8bcedc0b021197b2e4d70e1815c57e6c23cdeecbe58bff060e9a3b4f6fee08a9bbd96869b98878abc3aab6860030239
6
+ metadata.gz: da04bdd002f65a2ddd4814b76c36a08bcb40d7d793dd9a1d14501de0c2f1f2d295db36a051e93789389e8198e91f43a03178673e1db45c5d3c8416eb84aa977c
7
+ data.tar.gz: 8e5d2ff12d81960f4711f5bd3d179d0d88987703fd1179d7968910396db005f504a5b9dd97d933243ea51fe9ead68d82ffe1d84a25163feac47cfac3a5fc909d
data/bin/grsync CHANGED
@@ -14,66 +14,60 @@ require 'grsync/logger'
14
14
  # --passwd barabara
15
15
  # --port 2222
16
16
 
17
- module GRSync
18
- # execution entrance
19
- if __FILE__ == $0
20
- # parse arguments
21
- opts = Trollop::options do
22
- opt :local, 'local source git repository(e.g. /path/to/repo)', :type => :string
23
- opt :remote, 'remote destination git repository(e.g. username@host:/path/to/repo)', :type => :string
24
- opt :passwd, 'password for ssh login', :type => :string
25
- opt :port, 'port for ssh login', :default => 22
26
- opt :save, 'save this synchronization link'
27
- end
17
+ # parse arguments
18
+ opts = Trollop::options do
19
+ opt :local, 'local source git repository(e.g. /path/to/repo)', :type => :string
20
+ opt :remote, 'remote destination git repository(e.g. username@host:/path/to/repo)', :type => :string
21
+ opt :passwd, 'password for ssh login', :type => :string
22
+ opt :port, 'port for ssh login', :default => 22
23
+ opt :save, 'save this synchronization link'
24
+ end
28
25
 
29
- local = opts[:local]
30
- remote_full = opts[:remote] # location with username, host and path
26
+ local = opts[:local]
27
+ remote_full = opts[:remote] # location with username, host and path
31
28
 
32
- # since save feature is unimplemented
33
- # both local and remote option have to be specified for an explicit synchronization
34
- Trollop::die :local, 'must be specified' if local.nil?
35
- Trollop::die :remote, 'must be specified' if remote_full.nil?
29
+ # since save feature is unimplemented
30
+ # both local and remote option have to be specified for an explicit synchronization
31
+ Trollop::die :local, 'must be specified' if local.nil?
32
+ Trollop::die :remote, 'must be specified' if remote_full.nil?
36
33
 
37
- # local dir must exist
38
- # always check existence asap
39
- unless Dir.exist?(File.expand_path(local))
40
- $Log.error "Local directory #{local} doesn't exist"
41
- abort
42
- end
34
+ # local dir must exist
35
+ # always check existence asap
36
+ unless Dir.exist?(File.expand_path(local))
37
+ $Log.error "Local directory #{local} doesn't exist"
38
+ abort
39
+ end
43
40
 
44
- # extract remote, user_name and host from dest_full
45
- login_str, remote = remote_full.split ':'
46
- if login_str.split('@').size == 2
47
- user_name, host = login_str.split('@')
48
- else
49
- host = login_str
50
- user_name = nil
51
- end
41
+ # extract remote, user_name and host from dest_full
42
+ login_str, remote = remote_full.split ':'
43
+ if login_str.split('@').size == 2
44
+ user_name, host = login_str.split('@')
45
+ else
46
+ host = login_str
47
+ user_name = nil
48
+ end
52
49
 
53
- # optional options for login
54
- passwd = opts[:passwd] || ''
55
- port = opts[:port]
50
+ # optional options for login
51
+ passwd = opts[:passwd] || ''
52
+ port = opts[:port]
56
53
 
57
- # ssh login
58
- begin
59
- Net::SSH.start(host, user_name, :password => passwd, :port => port) do |ssh|
60
- syncer = GRSync::Syncer.new ssh, local, remote
61
- syncer.sync
62
- end
63
- rescue Net::SSH::AuthenticationFailed
64
- login_info = {
65
- host: host,
66
- user_name: user_name,
67
- port: port,
68
- passwd: passwd
69
- }
70
- $Log.error "Authentication failed. Please check whether the following login information is correct: #{login_info}"
71
- abort
72
- rescue Exception => ex
73
- $Log.error "#{ex.class.name} -- #{ex}"
74
- abort
75
- end
54
+ # ssh login
55
+ begin
56
+ Net::SSH.start(host, user_name, :password => passwd, :port => port) do |ssh|
57
+ syncer = GRSync::Syncer.new ssh, local, remote
58
+ syncer.sync
76
59
  end
60
+ rescue Net::SSH::AuthenticationFailed
61
+ login_info = {
62
+ host: host,
63
+ user_name: user_name,
64
+ port: port,
65
+ passwd: passwd
66
+ }
67
+ $Log.error "Authentication failed. Please check whether the following login information is correct: #{login_info}"
68
+ abort
69
+ rescue Exception => ex
70
+ $Log.error "#{ex.class.name} -- #{ex}"
71
+ abort
77
72
  end
78
73
 
79
-
@@ -20,6 +20,5 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency 'trollop', '~> 2.1'
21
21
  spec.add_dependency 'net-ssh', '~> 3.1'
22
22
  spec.add_dependency 'log4r', '~> 1.1'
23
-
24
- spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_dependency 'bundler', '~> 1.10'
25
24
  end
@@ -1,3 +1,3 @@
1
1
  module GRSync
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - luminocean
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.10'
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements: