rbsync 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. data/README.rdoc +37 -0
  2. data/VERSION +1 -1
  3. data/lib/rbsync.rb +11 -9
  4. data/rbsync.gemspec +1 -1
  5. metadata +3 -3
data/README.rdoc CHANGED
@@ -1,6 +1,43 @@
1
1
  = rbsync
2
2
 
3
3
  rbsync is sync files utility
4
+ == usage
5
+ === mirror files
6
+ �������Ɠ�����𓯂��ɂ���
7
+ require 'rbsync'
8
+ rsync =RbSync.new
9
+ rsync.sync( "src", "dest" )
10
+ === mirror updated only files
11
+ ������ɁA�������Ɠ����̃t�@�C������������A�X�V�����𒲂ׂ�B�V�������m�������R�s�[����D
12
+ require 'rbsync'
13
+ rsync =RbSync.new
14
+ rsync.sync( "src", "dest",{:update=>true} )
15
+ === using exclude pattern
16
+ ������Ɠ������𓯂��ɂ���C�A���A*.rb / *.log �̊g���q�͏��O����D
17
+ require 'rbsync'
18
+ rsync =RbSync.new
19
+ rsync.sync( "src", "dest",{:excludes=>["*.log","*.bak"]} )
20
+ ==special usage , sync by file cotetets
21
+ if directory has a same file with different file name. insted of filename , sync file by file hash
22
+ �f�B���N�g�����̃t�@�C��������������ς��Ă��܂����Ƃ��Ɏg���D�t�@�C�����łȂ��A�t�@�C���̒��g���r���ē�������D
23
+ require 'rbsync'
24
+ rsync =RbSync.new
25
+ rsync.sync( "src", "dest",{:check_hash=>true} )
26
+ === directory has very large file ,such as mpeg video
27
+ checking only head of 1024*1024 bytes to distinguish src / dest files.this is for speed up.
28
+ FileUtils::cmp is reading whole file. large file will take time.With :hash_limit_size Rbsync read only head of files for comparing.
29
+ ����ȃt�@�C�����ƁC�S���ǂݍ��ނ̂Ɏ��Ԃ��|����̂ŁA�擪1024*1024 �o�C�g���r����OK�Ƃ���.�ʐ^�Ƃ��̓R���ŏ\��
30
+ require 'rbsync'
31
+ rsync =RbSync.new
32
+ rsync.sync( "src", "dest",{:check_hash=>true,:hash_limit_size=1024*1024} )
33
+
34
+ === sync both updated files
35
+ �o�����ɓ������������ꍇ�͂Q��N������D
36
+ require 'rbsync'
37
+ rsync =RbSync.new
38
+ rsync.updated_file_only = true
39
+ rsync.sync( "src", "dest" )
40
+ rsync.sync( "dest", "src" )
4
41
 
5
42
  == Contributing to rbsync
6
43
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/rbsync.rb CHANGED
@@ -1,9 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  #rbsyncの改良版。
2
4
  # ファイル名でなくハッシュ値を計算してファイルを同期する。
3
5
  #ファイルの同期
4
6
 
5
7
  require 'fileutils'
6
- $KCODE='u'
7
8
 
8
9
  # Synchronize files src to dest .
9
10
  # this class can sync files and recuresively
@@ -35,9 +36,9 @@ $KCODE='u'
35
36
  # rsync =RbSync.new
36
37
  # rsync.sync( "src", "dest",{:check_hash=>true} )
37
38
  # === directory has very large file ,such as mpeg video
38
- # checking only head of 1024*1024 bytes to distinguish src / dest files for speed up.
39
- # FileUtils::cmp is reading whole file. This will be so slow for large file
40
- # 巨大なファイルだと,全部読み込むのに時間が掛かるので、先頭1024*1024 バイトを比較してOKとする
39
+ # checking only head of 1024*1024 bytes to distinguish src / dest files.this is for speed up.
40
+ # FileUtils::cmp is reading whole file. large file will take time.With :hash_limit_size Rbsync read only head of files for comparing.
41
+ # 巨大なファイルだと,全部読み込むのに時間が掛かるので、先頭1024*1024 バイトを比較してOKとする.写真とかはコレで十分
41
42
  # require 'rbsync'
42
43
  # rsync =RbSync.new
43
44
  # rsync.sync( "src", "dest",{:check_hash=>true,:hash_limit_size=1024*1024} )
@@ -46,7 +47,7 @@ $KCODE='u'
46
47
  # 双方向に同期させたい場合は2回起動する.
47
48
  # require 'rbsync'
48
49
  # rsync =RbSync.new
49
- # rsync.update = true
50
+ # rsync.updated_file_only = true
50
51
  # rsync.sync( "src", "dest" )
51
52
  # rsync.sync( "dest", "src" )
52
53
  class RbSync
@@ -172,7 +173,7 @@ class RbSync
172
173
  # ・ディレクトリ内のファイル一覧を作る
173
174
  # ・ファイル一覧を比較する
174
175
  # ・同期するファイル一覧を作って転送する
175
- def sync_nornally(src,dest,options={})
176
+ def sync_normally(src,dest,options={})
176
177
  files = self.find_files(src,dest,options)
177
178
  puts "同期対象のファイルはありません" if self.debug? && files.size==0
178
179
  return true if files.size == 0
@@ -197,15 +198,16 @@ class RbSync
197
198
  end
198
199
  def sync(src,dest,options={})
199
200
  options[:excludes] = (self.excludes + [options[:excludes]]).flatten.uniq if options[:excludes]
200
- options[:update] = @conf[:update] if options[:update] == nil
201
+ options[:update] = @conf[:update] if options[:update] == nil
201
202
  options[:check_hash] = options[:check_hash] and @conf[:check_hash]
202
- options[:hash_limit_size] = @conf[:hash_limit_size] if options[:hash_limit_size] == nil
203
+ options[:hash_limit_size] = @conf[:hash_limit_size] if options[:hash_limit_size] == nil
203
204
  if options[:check_hash]
204
205
  return self.sync_by_hash(src,dest,options)
205
206
  else
206
- return self.sync_nornally(src,dest,options)
207
+ return self.sync_normally(src,dest,options)
207
208
  end
208
209
  end
210
+
209
211
  #for setting
210
212
 
211
213
  def debug_mode?
data/rbsync.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rbsync}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["takuya"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbsync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - takuya