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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 692f6cf3fe115aa7894fb65d6549438dede5ec6737290da158a10290c3a5f02a
4
- data.tar.gz: 5a3ca8c23c7f7e35f18fee6789f1e888d94f1cce86bf9adfafc39ab14fa2e6a8
3
+ metadata.gz: 154ba1d7d905a71a75e46a44486b22d65af7541d3f5c57db88be6ac84ff4404b
4
+ data.tar.gz: e913e4bd9cc556ac550bdfeaf7f03840c9f120daf55e17dfa71be03005cd934c
5
5
  SHA512:
6
- metadata.gz: a24223fd0e493e73af666a2f6427f4e8f822383ca3b30c25f54406fc8e265a1db8bfc6c7ccb0469e82599bc111a2b6f1b5fed47fc5f549398c2ad9a1aacbfe6a
7
- data.tar.gz: e4e999f5a136ad3221ea3c4cd096c0adb88fbcbe7bb2fa905cdc634af13abad1c52d0536c5a331921b109cbbee87adaafcb90181905671c77edd375b796d4191
6
+ metadata.gz: 2802c7ea2a3da89c75e84620b98fc508cb0b34f21a229d7cb4e95f09316c182678fd657d834e040b0fca33a8954b4141099311483665df4f892a945126a48208
7
+ data.tar.gz: eb1fa9995450d68dbefd9fcfad83f27269b3f3a03691d5a2cce92b8e70ad4c8bb250fa040bff8485dfffb6ccbc5bf8a47350523a318f347addbd934f417f6ce9
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in bsync.gemspec
3
+ # Specify your gem's dependencies in bdsync.gemspec
4
4
  gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
data/Gemfile.lock CHANGED
@@ -1,14 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bdsync (0.1.1)
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
- # Bsync
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 'bsync'
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 bsync
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/bsync. 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/bsync/blob/master/CODE_OF_CONDUCT.md).
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 Bsync project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/xxjapp/bsync/blob/master/CODE_OF_CONDUCT.md).
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/bsync/version'
1
+ require_relative 'lib/bdsync/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "bdsync"
5
- spec.version = Bsync::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/bsync"
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/bsync"
17
- spec.metadata["changelog_uri"] = "https://github.com/xxjapp/bsync/releases"
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,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "bsync"
4
+ require "bdsync"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -1,8 +1,8 @@
1
- require "bsync/utils"
1
+ require "bdsync/utils"
2
2
  require "colorize"
3
3
  require "yaml"
4
4
 
5
- module Bsync
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}/.bsync/#{sync_type}_#{Utils.md5 params.to_s}.yaml"
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
- exit if !Utils.try_lock
26
+ Utils.try_lock {
27
+ loop {
28
+ @old_data = load_data
29
+ @data = {}
27
30
 
28
- loop {
29
- @old_data = load_data
30
- @data = {}
31
+ start_session {
32
+ remote_ensure_dir @remote_root_path
33
+ local_ensure_dir @local_root_path
31
34
 
32
- start_session {
33
- remote_ensure_dir @remote_root_path
34
- local_ensure_dir @local_root_path
35
+ puts "\n==== traverse_remote_path ===="
36
+ traverse_remote_path @remote_root_path
35
37
 
36
- puts "\n==== traverse_remote_path ===="
37
- traverse_remote_path @remote_root_path
38
+ # merge @data to @old_data, and clear @data
39
+ @old_data.merge! @data
40
+ @data = {}
38
41
 
39
- # merge @data to @old_data, and clear @data
40
- @old_data.merge! @data
41
- @data = {}
42
+ puts "\n==== traverse_local_path ===="
43
+ traverse_local_path @local_root_path
44
+ }
42
45
 
43
- puts "\n==== traverse_local_path ===="
44
- traverse_local_path @local_root_path
45
- }
46
-
47
- save_data @data
46
+ save_data @data
48
47
 
49
- break if !@infinite_loop
48
+ break if !@infinite_loop
50
49
 
51
- sleep 1
50
+ sleep 1
51
+ }
52
52
  }
53
53
  end
54
54
 
@@ -1,7 +1,7 @@
1
- require "bsync/core"
1
+ require "bdsync/core"
2
2
  require "ostruct"
3
3
 
4
- module Bsync
4
+ module Bdsync
5
5
  class Lfs < Core
6
6
  def initialize params
7
7
  super params, "lfs"
@@ -1,6 +1,7 @@
1
- require "bsync/core"
1
+ require "bdsync/core"
2
+ require "net/sftp"
2
3
 
3
- module Bsync
4
+ module Bdsync
4
5
  class Sftp < Core
5
6
  def initialize params
6
7
  @site = params["site"]
@@ -1,6 +1,6 @@
1
1
  require "digest"
2
2
 
3
- module Bsync
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').flock(File::LOCK_EX | File::LOCK_NB)
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
@@ -0,0 +1,3 @@
1
+ module Bdsync
2
+ VERSION = "2.0.0"
3
+ end
data/lib/bdsync.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "bdsync/lfs"
2
+ require "bdsync/sftp"
3
+ require "bdsync/version"
4
+
5
+ module Bdsync
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
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: 1.0.0
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-26 00:00:00.000000000 Z
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
- - bsync.gemspec
46
- - lib/bsync.rb
47
- - lib/bsync/core.rb
48
- - lib/bsync/lfs.rb
49
- - lib/bsync/sftp.rb
50
- - lib/bsync/utils.rb
51
- - lib/bsync/version.rb
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/bsync
57
- source_code_uri: https://github.com/xxjapp/bsync
58
- changelog_uri: https://github.com/xxjapp/bsync/releases
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
@@ -1,3 +0,0 @@
1
- module Bsync
2
- VERSION = "1.0.0"
3
- end
data/lib/bsync.rb DELETED
@@ -1,8 +0,0 @@
1
- require "bsync/lfs"
2
- require "bsync/sftp"
3
- require "bsync/version"
4
-
5
- module Bsync
6
- class Error < StandardError; end
7
- # Your code goes here...
8
- end