synchrotron 0.0.8 → 0.1.0.beta.1

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: 3776cbf91ffb47b2f1233116f229c6ea8c461141
4
- data.tar.gz: 2b3ad33955f1379d9dcb43cee98a3dcf614e870e
3
+ metadata.gz: 583a705e35b97685cd08344c090445d0b6b68186
4
+ data.tar.gz: 91a73f7b6ad82ef18c17e16c7b35ed11f4982569
5
5
  SHA512:
6
- metadata.gz: f160afc8f0ae0a0d5f0fe58ecf73f77686d48d1f322fd28dfb5b6d887b25ced192579990a08abe0e4c19b2b45cd4ba79395a2e227302a116abe9501dd0e01042
7
- data.tar.gz: eee5d63b959b1a9224488bf59ea40c6431c907d274ae3338da6f26bc0e391a9485fb7239838ec10556c91eae2bb7afa920a41747a74b852d5062ca67d174dc75
6
+ metadata.gz: f6bebcd99f0fc151e20c99877df1be2a01d4b49b83fd5c116138ce8b98d19fea88d2bff4a894fb4ed0491336791fd354b74053e9b3a76c587344b56d851fb566
7
+ data.tar.gz: 8e9a157e3b289b57f88a576bc0c43e6c5996a8828c4c68e6dddfb5b816796872d4b7261b146ca9769d9408dc911826c770c787bd203741effa8ae54d114d0b44
data/bin/synchrotron CHANGED
@@ -3,7 +3,9 @@
3
3
  require 'rubygems'
4
4
  require 'trollop'
5
5
 
6
- require 'synchrotron'
6
+ require_relative '../lib/synchrotron'
7
+
8
+ Thread.abort_on_exception = true
7
9
 
8
10
  module Synchrotron
9
11
  config = {}
@@ -1,6 +1,6 @@
1
1
  module Synchrotron
2
2
  APP_NAME = 'Synchrotron'
3
- APP_VERSION = '0.0.8'
3
+ APP_VERSION = '0.1.0.beta.1'
4
4
  APP_AUTHOR = 'Ryan Grove'
5
5
  APP_EMAIL = 'ryan@wonko.com'
6
6
  APP_URL = 'http://github.com/rgrove/synchrotron/'
data/lib/synchrotron.rb CHANGED
@@ -1,15 +1,20 @@
1
1
  require 'find'
2
2
  require 'pathname'
3
- require 'thread'
4
-
5
3
  require 'rb-fsevent'
4
+ require 'thread'
6
5
 
7
- require 'synchrotron/ignore'
8
- require 'synchrotron/logger'
9
- require 'synchrotron/stream'
10
- require 'synchrotron/version'
6
+ require_relative 'synchrotron/ignore'
7
+ require_relative 'synchrotron/logger'
8
+ require_relative 'synchrotron/stream'
9
+ require_relative 'synchrotron/version'
11
10
 
12
11
  module Synchrotron; class << self
12
+ # If more than this many paths change at once, we'll just do a full resync.
13
+ MAX_CHANGED_PATHS = 1
14
+
15
+ # If the change queue exceeds this size, we'll clear it and do a full resync.
16
+ MAX_QUEUE_SIZE = 1
17
+
13
18
  attr_reader :config, :ignore, :log, :scanner
14
19
 
15
20
  def init(config = {})
@@ -72,15 +77,28 @@ module Synchrotron; class << self
72
77
 
73
78
  @sync_thread = Thread.new do
74
79
  while changed = @queue.pop do
75
- @log.verbose "Change detected"
80
+ @log.verbose "#{changed.size} changed path(s) detected (change sets in queue: #{@queue.size})"
76
81
 
77
82
  changed.each {|path| @log.verbose "--> #{path}" }
78
- changed.each {|path| sync(path) if File.exist?(path) }
83
+
84
+ if @queue.size > MAX_QUEUE_SIZE
85
+ @log.verbose "Syncing the root path since the queue is too large (#{@queue.size})"
86
+ @queue.clear
87
+ sync
88
+ elsif changed.size > MAX_CHANGED_PATHS
89
+ @log.verbose "Syncing the root path since more than #{MAX_CHANGED_PATHS} path(s) changed"
90
+ sync
91
+ else
92
+ changed.each {|path| sync(path) if File.exist?(path) }
93
+ end
79
94
  end
80
95
  end
81
96
 
82
97
  fsevent = FSEvent.new
83
- fsevent.watch(@config[:local_path], {:latency => 1}) do |paths|
98
+ fsevent.watch(@config[:local_path], {
99
+ :latency => 1,
100
+ :no_defer => false
101
+ }) do |paths|
84
102
  changed = coalesce_changes(paths.reject {|path| @ignore.match(path) })
85
103
  @queue << changed unless changed.empty?
86
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synchrotron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-30 00:00:00.000000000 Z
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb-fsevent
@@ -85,10 +85,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: 1.2.0
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.2.2
88
+ rubygems_version: 2.5.2.3
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Synchrotron monitors a local directory tree and performs nearly instantaneous
92
92
  one-way synchronization of changes to a remote directory using rsync.
93
93
  test_files: []
94
- has_rdoc: