synkronos 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/bin/synkronos +7 -0
- data/lib/synkronos/options.rb +40 -0
- data/lib/synkronos/rsync/rsync.rb +17 -0
- data/lib/synkronos/version.rb +3 -0
- data/lib/synkronos.rb +18 -0
- data/spec/rsync/rsync_spec.rb +46 -0
- data/spec/spec_helper.rb +6 -0
- data/synkronos.gemspec +32 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce5c98c510c2a9f5ffe95712050b386b28148994
|
4
|
+
data.tar.gz: afc4ed30554ad144c611775f687232cdb830f062
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42aea644ff90a15d20c9312e7f64e195c91c025aa38c2b98bab32e7c8e5e43a8a977aeecb3ea0f6a67cab87c6392393f9ce328d8b3a239dbfd2208812c2e9c91
|
7
|
+
data.tar.gz: ee4650a623b8d16fde4383f2e6e2886693584b61f45a2b0800fc819200eefe7c58ff94cb157c29686368c8385b199f265eb823fc4a6011f3724a89f748aa53b0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Synkronos
|
2
|
+
|
3
|
+
Synkronos is a life-time folder synchronization tool.
|
4
|
+
It's based on rsync and works only under MacOSX yet.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'synkronos'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install synkronos
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
TODO: Write usage instructions here
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/akhramov/synkronos/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/synkronos
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Synkronos
|
4
|
+
class OptionsParser
|
5
|
+
def self.parse(args)
|
6
|
+
options = {}
|
7
|
+
opt_parser = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: synkronos [options]"
|
9
|
+
opts.separator ""
|
10
|
+
opts.separator "Required args"
|
11
|
+
|
12
|
+
opts.on("-s", "--src PATH", "PATH of the source directory") { |path| options[:src] = path }
|
13
|
+
opts.on("-d", "--dest PATH", "PATH of the destination directory") { |path| options[:dest] = path }
|
14
|
+
|
15
|
+
opts.separator ""
|
16
|
+
opts.separator "SSH args"
|
17
|
+
opts.on("--[no-]ssh", "Whether we use ssh or not") { |v| options[:ssh] = v }
|
18
|
+
opts.on("-p", "--port NUMBER", "ssh port NUMBER (defaults to 22)") { |v| options[:port] = v }
|
19
|
+
|
20
|
+
|
21
|
+
opts.separator "Common options"
|
22
|
+
opts.separator "SSH args"
|
23
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
24
|
+
puts opts
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on_tail('-v', "--version", "Show version") do
|
29
|
+
puts VERSION
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
opt_parser.parse!(args)
|
35
|
+
abort "You must provide source and destination path" unless options[:src] or options[:dest]
|
36
|
+
options[:src] += '/' unless options[:src].end_with?('/')
|
37
|
+
options
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Synkronos
|
4
|
+
|
5
|
+
#
|
6
|
+
# Generates and executes rsync command. If something is going bad
|
7
|
+
# exits with a message to stderr.
|
8
|
+
#
|
9
|
+
class Rsync
|
10
|
+
def self.sync(src, dest, ssh = false, port = 22)
|
11
|
+
cmd = "rsync -a --delete #{ssh ? "-e 'ssh -p #{port}'" : nil} #{src} #{dest}"
|
12
|
+
Open3.popen3(cmd) do |_, _, stderr, wait_thr|
|
13
|
+
abort(stderr.read) unless wait_thr.value.success?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/synkronos.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "synkronos/version"
|
2
|
+
require 'synkronos/options'
|
3
|
+
require 'synkronos/rsync/rsync'
|
4
|
+
require 'rb-fsevent'
|
5
|
+
|
6
|
+
module Synkronos
|
7
|
+
def self.run(args)
|
8
|
+
opts = OptionsParser.parse(args)
|
9
|
+
rsync_args = [opts[:src], opts[:dest], opts[:ssh], opts[:port]]
|
10
|
+
Rsync.sync(*rsync_args)
|
11
|
+
|
12
|
+
fsevent = FSEvent.new
|
13
|
+
fsevent.watch(opts[:src], {latency: 1}) do
|
14
|
+
Rsync.sync(*rsync_args)
|
15
|
+
end
|
16
|
+
fsevent.run
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'file synchronizator' do |actions|
|
4
|
+
it 'moves a file from src to dest' do
|
5
|
+
expect(File).not_to exist("#{dest}/file")
|
6
|
+
|
7
|
+
actions.call(src, dest)
|
8
|
+
expect(File).to exist("#{dest}/file")
|
9
|
+
expect(File.read("#{dest}/file")).to include('Under the spreading chestnut tree')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'changes a file in dest' do
|
13
|
+
open("#{src}/file", 'a+') { |file| file.write('I sold you and you sold me') }
|
14
|
+
actions.call(src, dest)
|
15
|
+
expect(File.read("#{dest}/file")).to include('I sold you and you sold me')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'removes a file from dest' do
|
19
|
+
FileUtils.remove_entry_secure("#{src}/file")
|
20
|
+
actions.call(src, dest)
|
21
|
+
expect(File).not_to exist("#{dest}/file")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe Synkronos::Rsync do
|
26
|
+
let(:dest) { Dir.mktmpdir }
|
27
|
+
let(:src) do
|
28
|
+
dir = Dir.mktmpdir
|
29
|
+
open("#{dir}/file", 'w') { |file| file.write('Under the spreading chestnut tree') }
|
30
|
+
dir
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'without ssh' do
|
34
|
+
it_behaves_like 'file synchronizator', ->(src, dest) {Synkronos::Rsync.sync(src, dest)}
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with ssh' do
|
38
|
+
context 'to client' do
|
39
|
+
it_behaves_like 'file synchronizator', ->(src, dest) {Synkronos::Rsync.sync(src, 'localhost:' + dest, true)}
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'from server' do
|
43
|
+
it_behaves_like 'file synchronizator', ->(src, dest) {Synkronos::Rsync.sync('localhost:' + src, dest, true)}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/synkronos.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'synkronos/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "synkronos"
|
8
|
+
spec.version = Synkronos::VERSION
|
9
|
+
spec.authors = ["Artyom Khramov"]
|
10
|
+
spec.email = ["futu.fata@gmail.com"]
|
11
|
+
spec.summary = %q{Synchronize your folders with synkronos }
|
12
|
+
spec.description = <<-EOS
|
13
|
+
Synkronos is a life-time folder synchronization tool.
|
14
|
+
It's based on rsync and works only under MacOSX yet.
|
15
|
+
EOS
|
16
|
+
|
17
|
+
spec.homepage = "https://github.com/akhramov/synkronos"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
spec.bindir = 'bin'
|
25
|
+
spec.executables << 'synkronos'
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
30
|
+
|
31
|
+
spec.add_dependency 'rb-fsevent', '~> 0.9.4'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: synkronos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artyom Khramov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rb-fsevent
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.4
|
69
|
+
description: " Synkronos is a life-time folder synchronization tool. \n It's
|
70
|
+
based on rsync and works only under MacOSX yet.\n"
|
71
|
+
email:
|
72
|
+
- futu.fata@gmail.com
|
73
|
+
executables:
|
74
|
+
- synkronos
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/synkronos
|
84
|
+
- lib/synkronos.rb
|
85
|
+
- lib/synkronos/options.rb
|
86
|
+
- lib/synkronos/rsync/rsync.rb
|
87
|
+
- lib/synkronos/version.rb
|
88
|
+
- spec/rsync/rsync_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- synkronos.gemspec
|
91
|
+
homepage: https://github.com/akhramov/synkronos
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.2.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Synchronize your folders with synkronos
|
115
|
+
test_files:
|
116
|
+
- spec/rsync/rsync_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
has_rdoc:
|