bdsync 1.0.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +5 -1
- data/README.md +5 -5
- data/Rakefile +0 -0
- data/{bsync.gemspec → bdsync.gemspec} +6 -5
- data/bin/console +1 -1
- data/lib/{bsync → bdsync}/core.rb +22 -22
- data/lib/{bsync → bdsync}/lfs.rb +2 -2
- data/lib/{bsync → bdsync}/sftp.rb +3 -2
- data/lib/{bsync → bdsync}/utils.rb +6 -3
- data/lib/bdsync/version.rb +3 -0
- data/lib/bdsync.rb +8 -0
- metadata +27 -13
- data/lib/bsync/version.rb +0 -3
- data/lib/bsync.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154ba1d7d905a71a75e46a44486b22d65af7541d3f5c57db88be6ac84ff4404b
|
4
|
+
data.tar.gz: e913e4bd9cc556ac550bdfeaf7f03840c9f120daf55e17dfa71be03005cd934c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2802c7ea2a3da89c75e84620b98fc508cb0b34f21a229d7cb4e95f09316c182678fd657d834e040b0fca33a8954b4141099311483665df4f892a945126a48208
|
7
|
+
data.tar.gz: eb1fa9995450d68dbefd9fcfad83f27269b3f3a03691d5a2cce92b8e70ad4c8bb250fa040bff8485dfffb6ccbc5bf8a47350523a318f347addbd934f417f6ce9
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bdsync (0.
|
4
|
+
bdsync (2.0.0)
|
5
5
|
colorize (~> 0.8)
|
6
|
+
net-sftp (~> 2.1)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
11
|
colorize (0.8.1)
|
11
12
|
diff-lcs (1.3)
|
13
|
+
net-sftp (2.1.2)
|
14
|
+
net-ssh (>= 2.6.5)
|
15
|
+
net-ssh (5.2.0)
|
12
16
|
rake (12.3.3)
|
13
17
|
rspec (3.9.0)
|
14
18
|
rspec-core (~> 3.9.0)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Bdsync
|
2
2
|
|
3
3
|
Bidirectional Synchronization tool for sftp or local file system
|
4
4
|
|
@@ -7,7 +7,7 @@ Bidirectional Synchronization tool for sftp or local file system
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem '
|
10
|
+
gem 'bdsync'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -16,7 +16,7 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install
|
19
|
+
$ gem install bdsync
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
@@ -30,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
30
|
|
31
31
|
## Contributing
|
32
32
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/xxjapp/
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xxjapp/bdsync. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/xxjapp/bdsync/blob/master/CODE_OF_CONDUCT.md).
|
34
34
|
|
35
35
|
|
36
36
|
## License
|
@@ -39,4 +39,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
39
39
|
|
40
40
|
## Code of Conduct
|
41
41
|
|
42
|
-
Everyone interacting in the
|
42
|
+
Everyone interacting in the Bdsync project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/xxjapp/bdsync/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
File without changes
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require_relative 'lib/
|
1
|
+
require_relative 'lib/bdsync/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "bdsync"
|
5
|
-
spec.version =
|
5
|
+
spec.version = Bdsync::VERSION
|
6
6
|
spec.authors = ["Xia Xiongjun"]
|
7
7
|
spec.email = ["xxjapp@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = %q{Bidirectional Synchronization tool for sftp or local file system}
|
10
10
|
spec.description = %q{Bidirectional Synchronization tool for sftp or local file system}
|
11
|
-
spec.homepage = "https://github.com/xxjapp/
|
11
|
+
spec.homepage = "https://github.com/xxjapp/bdsync"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
spec.metadata["source_code_uri"] = "https://github.com/xxjapp/
|
17
|
-
spec.metadata["changelog_uri"] = "https://github.com/xxjapp/
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/xxjapp/bdsync"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/xxjapp/bdsync/releases"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
28
|
spec.add_runtime_dependency "colorize", "~> 0.8"
|
29
|
+
spec.add_runtime_dependency "net-sftp", "~> 2.1"
|
29
30
|
end
|
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require "
|
1
|
+
require "bdsync/utils"
|
2
2
|
require "colorize"
|
3
3
|
require "yaml"
|
4
4
|
|
5
|
-
module
|
5
|
+
module Bdsync
|
6
6
|
class Core
|
7
7
|
attr_reader :data_path
|
8
8
|
|
@@ -13,7 +13,7 @@ module Bsync
|
|
13
13
|
@local_root_path = params["local_root_path"]
|
14
14
|
@remote_root_path = params["remote_root_path"]
|
15
15
|
@infinite_loop = params["infinite_loop"]
|
16
|
-
@data_path = "#{Dir.home}/.
|
16
|
+
@data_path = "#{Dir.home}/.bdsync/#{sync_type}_#{Utils.md5 params.to_s}.yaml"
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.options
|
@@ -23,32 +23,32 @@ module Bsync
|
|
23
23
|
def synchronize
|
24
24
|
# Run only one instance of a Ruby program at the same time - self locking
|
25
25
|
# SEE: https://code-maven.com/run-only-one-instance-of-a-script
|
26
|
-
|
26
|
+
Utils.try_lock {
|
27
|
+
loop {
|
28
|
+
@old_data = load_data
|
29
|
+
@data = {}
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
start_session {
|
32
|
+
remote_ensure_dir @remote_root_path
|
33
|
+
local_ensure_dir @local_root_path
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
local_ensure_dir @local_root_path
|
35
|
+
puts "\n==== traverse_remote_path ===="
|
36
|
+
traverse_remote_path @remote_root_path
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
# merge @data to @old_data, and clear @data
|
39
|
+
@old_data.merge! @data
|
40
|
+
@data = {}
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
puts "\n==== traverse_local_path ===="
|
43
|
+
traverse_local_path @local_root_path
|
44
|
+
}
|
42
45
|
|
43
|
-
|
44
|
-
traverse_local_path @local_root_path
|
45
|
-
}
|
46
|
-
|
47
|
-
save_data @data
|
46
|
+
save_data @data
|
48
47
|
|
49
|
-
|
48
|
+
break if !@infinite_loop
|
50
49
|
|
51
|
-
|
50
|
+
sleep 1
|
51
|
+
}
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
data/lib/{bsync → bdsync}/lfs.rb
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "digest"
|
2
2
|
|
3
|
-
module
|
3
|
+
module Bdsync
|
4
4
|
module Utils
|
5
5
|
# Examples:
|
6
6
|
#
|
@@ -27,8 +27,11 @@ module Bsync
|
|
27
27
|
"#{info.captures[0]}:#{info.captures[1]} - #{info.captures[2]}"
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.try_lock
|
31
|
-
File.open(__FILE__, 'r')
|
30
|
+
def self.try_lock &block
|
31
|
+
File.open(__FILE__, 'r') { |f|
|
32
|
+
return if !f.flock(File::LOCK_EX | File::LOCK_NB)
|
33
|
+
yield
|
34
|
+
}
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
data/lib/bdsync.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bdsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xia Xiongjun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-sftp
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
27
41
|
description: Bidirectional Synchronization tool for sftp or local file system
|
28
42
|
email:
|
29
43
|
- xxjapp@gmail.com
|
@@ -40,22 +54,22 @@ files:
|
|
40
54
|
- LICENSE.txt
|
41
55
|
- README.md
|
42
56
|
- Rakefile
|
57
|
+
- bdsync.gemspec
|
43
58
|
- bin/console
|
44
59
|
- bin/setup
|
45
|
-
-
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
50
|
-
- lib/
|
51
|
-
|
52
|
-
homepage: https://github.com/xxjapp/bsync
|
60
|
+
- lib/bdsync.rb
|
61
|
+
- lib/bdsync/core.rb
|
62
|
+
- lib/bdsync/lfs.rb
|
63
|
+
- lib/bdsync/sftp.rb
|
64
|
+
- lib/bdsync/utils.rb
|
65
|
+
- lib/bdsync/version.rb
|
66
|
+
homepage: https://github.com/xxjapp/bdsync
|
53
67
|
licenses:
|
54
68
|
- MIT
|
55
69
|
metadata:
|
56
|
-
homepage_uri: https://github.com/xxjapp/
|
57
|
-
source_code_uri: https://github.com/xxjapp/
|
58
|
-
changelog_uri: https://github.com/xxjapp/
|
70
|
+
homepage_uri: https://github.com/xxjapp/bdsync
|
71
|
+
source_code_uri: https://github.com/xxjapp/bdsync
|
72
|
+
changelog_uri: https://github.com/xxjapp/bdsync/releases
|
59
73
|
post_install_message:
|
60
74
|
rdoc_options: []
|
61
75
|
require_paths:
|
data/lib/bsync/version.rb
DELETED