synqa 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,18 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'synqa'
16
-
17
- class Test::Unit::TestCase
18
- end
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'synqa'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -1,114 +1,114 @@
1
- require 'helper'
2
-
3
- require 'based'
4
-
5
- module Based
6
-
7
- class BaseDirectoryTestCase < Test::Unit::TestCase
8
- include Based
9
- end
10
-
11
- class TestBaseDirectory < BaseDirectoryTestCase
12
- context "A base directory" do
13
- setup do
14
- @baseDirPath = ::File.expand_path(::File.join(::File.dirname(__FILE__), "data", "dir1"))
15
- #puts "@baseDirPath = #{@baseDirPath}"
16
- @baseDir = BaseDirectory.new(@baseDirPath)
17
- end
18
-
19
- should "not add / if already in base bath" do
20
- @baseDir2 = BaseDirectory.new(@baseDirPath + "/")
21
- assert_equal "#{@baseDirPath}/", @baseDir.fullPath
22
- dir2 = @baseDir.dirs[0]
23
- assert_equal "dir2", dir2.name
24
- end
25
-
26
- should "find files in top-level directory and get their names and relative paths" do
27
- names = @baseDir.files.map {|file| file.name}
28
- assert_equal ["file1.txt", "file2.txt"], names
29
- relativePaths = @baseDir.files.map {|file| file.relativePath}
30
- assert_equal ["file1.txt", "file2.txt"], relativePaths
31
- end
32
-
33
- should "check attributes of basedir" do
34
- assert_equal nil, @baseDir.name
35
- assert_equal nil, @baseDir.parent
36
- assert_equal @baseDir, @baseDir.base
37
- assert_equal "", @baseDir.relativePath
38
- assert_equal [], @baseDir.pathElements
39
- assert_equal "#{@baseDirPath}/", @baseDir.fullPath
40
- end
41
-
42
- should "find one directory and check all its attributes" do
43
- dir2 = @baseDir.dirs[0]
44
- dir4 = dir2.dirs[0]
45
- assert_equal "dir4", dir4.name
46
- assert_equal dir2, dir4.parent
47
- assert_equal @baseDir, dir4.base
48
- assert_equal "dir2/dir4/", dir4.relativePath
49
- assert_equal ["dir2", "dir4"], dir4.pathElements
50
- assert_equal "#{@baseDirPath}/dir2/dir4/", dir4.fullPath
51
- end
52
-
53
- should "find one file and check all its attributes" do
54
- dir2 = @baseDir.dirs[0]
55
- dir4 = dir2.dirs[0]
56
- file5 = dir4.files[0]
57
- assert_equal "file5.text", file5.name
58
- assert_equal dir4, file5.parent
59
- assert_equal @baseDir, file5.base
60
- assert_equal "dir2/dir4/file5.text", file5.relativePath
61
- assert_equal ["dir2", "dir4", "file5.text"], file5.pathElements
62
- assert_equal "#{@baseDirPath}/dir2/dir4/file5.text", file5.fullPath
63
- end
64
-
65
- should "find sub-directories in top-level directory and get their names and relative paths" do
66
- names = @baseDir.dirs.map {|dir| dir.name}
67
- assert_equal ["dir2", "dir3"], names
68
- relativePaths = @baseDir.dirs.map {|dir| dir.relativePath}
69
- assert_equal ["dir2/", "dir3/"], relativePaths
70
- end
71
-
72
- should "find all sub-directories of base directory" do
73
- relativePaths = @baseDir.subDirs.map{|dir| dir.relativePath}
74
- assert_equal ["dir2/", "dir2/dir4/", "dir2/dir4/dir5/", "dir3/"], relativePaths
75
- end
76
-
77
- should "find all files within base directory" do
78
- relativePaths = @baseDir.allFiles.map{|dir| dir.relativePath}
79
- assert_equal ["file1.txt", "file2.txt", "dir2/file3.txt", "dir2/dir4/file5.text",
80
- "dir2/dir4/dir5/file6.text", "dir3/file1.txt"], relativePaths
81
- end
82
-
83
- should "exclude dir2" do
84
- filteredBaseDir = BaseDirectory.new(@baseDirPath,
85
- :dirExclude => lambda{|dir| dir.name == "dir2"})
86
- relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
87
- assert_equal ["file1.txt", "file2.txt", "dir3/file1.txt"], relativePaths
88
- end
89
-
90
- should "include only .txt files" do
91
- filteredBaseDir = BaseDirectory.new(@baseDirPath,
92
- :fileInclude => lambda{|file| file.name.end_with? ".txt"})
93
- relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
94
- assert_equal ["file1.txt", "file2.txt", "dir2/file3.txt",
95
- "dir3/file1.txt"], relativePaths
96
- end
97
-
98
- should "not include .txt files" do
99
- filteredBaseDir = BaseDirectory.new(@baseDirPath,
100
- :fileExclude => lambda{|file| file.name.end_with? ".txt"})
101
- relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
102
- assert_equal ["dir2/dir4/file5.text", "dir2/dir4/dir5/file6.text"], relativePaths
103
- end
104
-
105
- should "include only .txt files not in dir3" do
106
- filteredBaseDir = BaseDirectory.new(@baseDirPath,
107
- :dirExclude => lambda{|dir| dir.name == "dir3"},
108
- :fileInclude => lambda{|file| file.name.end_with? ".txt"})
109
- relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
110
- assert_equal ["file1.txt", "file2.txt", "dir2/file3.txt"], relativePaths
111
- end
112
- end
113
- end
114
- end
1
+ require 'helper'
2
+
3
+ require 'based'
4
+
5
+ module Based
6
+
7
+ class BaseDirectoryTestCase < Test::Unit::TestCase
8
+ include Based
9
+ end
10
+
11
+ class TestBaseDirectory < BaseDirectoryTestCase
12
+ context "A base directory" do
13
+ setup do
14
+ @baseDirPath = ::File.expand_path(::File.join(::File.dirname(__FILE__), "data", "dir1"))
15
+ #puts "@baseDirPath = #{@baseDirPath}"
16
+ @baseDir = BaseDirectory.new(@baseDirPath)
17
+ end
18
+
19
+ should "not add / if already in base bath" do
20
+ @baseDir2 = BaseDirectory.new(@baseDirPath + "/")
21
+ assert_equal "#{@baseDirPath}/", @baseDir.fullPath
22
+ dir2 = @baseDir.dirs[0]
23
+ assert_equal "dir2", dir2.name
24
+ end
25
+
26
+ should "find files in top-level directory and get their names and relative paths" do
27
+ names = @baseDir.files.map {|file| file.name}
28
+ assert_equal ["file1.txt", "file2.txt"], names
29
+ relativePaths = @baseDir.files.map {|file| file.relativePath}
30
+ assert_equal ["file1.txt", "file2.txt"], relativePaths
31
+ end
32
+
33
+ should "check attributes of basedir" do
34
+ assert_equal nil, @baseDir.name
35
+ assert_equal nil, @baseDir.parent
36
+ assert_equal @baseDir, @baseDir.base
37
+ assert_equal "", @baseDir.relativePath
38
+ assert_equal [], @baseDir.pathElements
39
+ assert_equal "#{@baseDirPath}/", @baseDir.fullPath
40
+ end
41
+
42
+ should "find one directory and check all its attributes" do
43
+ dir2 = @baseDir.dirs[0]
44
+ dir4 = dir2.dirs[0]
45
+ assert_equal "dir4", dir4.name
46
+ assert_equal dir2, dir4.parent
47
+ assert_equal @baseDir, dir4.base
48
+ assert_equal "dir2/dir4/", dir4.relativePath
49
+ assert_equal ["dir2", "dir4"], dir4.pathElements
50
+ assert_equal "#{@baseDirPath}/dir2/dir4/", dir4.fullPath
51
+ end
52
+
53
+ should "find one file and check all its attributes" do
54
+ dir2 = @baseDir.dirs[0]
55
+ dir4 = dir2.dirs[0]
56
+ file5 = dir4.files[0]
57
+ assert_equal "file5.text", file5.name
58
+ assert_equal dir4, file5.parent
59
+ assert_equal @baseDir, file5.base
60
+ assert_equal "dir2/dir4/file5.text", file5.relativePath
61
+ assert_equal ["dir2", "dir4", "file5.text"], file5.pathElements
62
+ assert_equal "#{@baseDirPath}/dir2/dir4/file5.text", file5.fullPath
63
+ end
64
+
65
+ should "find sub-directories in top-level directory and get their names and relative paths" do
66
+ names = @baseDir.dirs.map {|dir| dir.name}
67
+ assert_equal ["dir2", "dir3"], names
68
+ relativePaths = @baseDir.dirs.map {|dir| dir.relativePath}
69
+ assert_equal ["dir2/", "dir3/"], relativePaths
70
+ end
71
+
72
+ should "find all sub-directories of base directory" do
73
+ relativePaths = @baseDir.subDirs.map{|dir| dir.relativePath}
74
+ assert_equal ["dir2/", "dir2/dir4/", "dir2/dir4/dir5/", "dir3/"], relativePaths
75
+ end
76
+
77
+ should "find all files within base directory" do
78
+ relativePaths = @baseDir.allFiles.map{|dir| dir.relativePath}
79
+ assert_equal ["file1.txt", "file2.txt", "dir2/file3.txt", "dir2/dir4/file5.text",
80
+ "dir2/dir4/dir5/file6.text", "dir3/file1.txt"], relativePaths
81
+ end
82
+
83
+ should "exclude dir2" do
84
+ filteredBaseDir = BaseDirectory.new(@baseDirPath,
85
+ :dirExclude => lambda{|dir| dir.name == "dir2"})
86
+ relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
87
+ assert_equal ["file1.txt", "file2.txt", "dir3/file1.txt"], relativePaths
88
+ end
89
+
90
+ should "include only .txt files" do
91
+ filteredBaseDir = BaseDirectory.new(@baseDirPath,
92
+ :fileInclude => lambda{|file| file.name.end_with? ".txt"})
93
+ relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
94
+ assert_equal ["file1.txt", "file2.txt", "dir2/file3.txt",
95
+ "dir3/file1.txt"], relativePaths
96
+ end
97
+
98
+ should "not include .txt files" do
99
+ filteredBaseDir = BaseDirectory.new(@baseDirPath,
100
+ :fileExclude => lambda{|file| file.name.end_with? ".txt"})
101
+ relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
102
+ assert_equal ["dir2/dir4/file5.text", "dir2/dir4/dir5/file6.text"], relativePaths
103
+ end
104
+
105
+ should "include only .txt files not in dir3" do
106
+ filteredBaseDir = BaseDirectory.new(@baseDirPath,
107
+ :dirExclude => lambda{|dir| dir.name == "dir3"},
108
+ :fileInclude => lambda{|file| file.name.end_with? ".txt"})
109
+ relativePaths = filteredBaseDir.allFiles.map{|file| file.relativePath}
110
+ assert_equal ["file1.txt", "file2.txt", "dir2/file3.txt"], relativePaths
111
+ end
112
+ end
113
+ end
114
+ end
@@ -1,37 +1,37 @@
1
- require 'helper'
2
-
3
- module Synqa
4
-
5
- class SynqaTestCase < Test::Unit::TestCase
6
- include Synqa
7
- end
8
-
9
- class TestHashCommand < SynqaTestCase
10
- context "A hash command" do
11
- setup do
12
- @hashCommand = HashCommand.new("sha32", 16, 3)
13
- end
14
-
15
- should "extract relative path and hash" do
16
- pathWithHash = @hashCommand.parseFileHashLine("/home/dir/", "abcdeabcde012345 /home/dir/subdir/file.txt")
17
- assert_equal "abcdeabcde012345", pathWithHash.hash
18
- assert_equal "subdir/file.txt", pathWithHash.relativePath
19
- end
20
-
21
- should "complain about mis-matched base dir" do
22
- assert_raise RuntimeError do
23
- @hashCommand.parseFileHashLine("/home/dir/", "abcdeabcde012345 /homes/dir/subdir/file.txt")
24
- end
25
- end
26
- end
27
- end
28
-
29
- class TestNormalisedDir < SynqaTestCase
30
- should "add / if missing" do
31
- assert_equal "home/dir/", normalisedDir("home/dir")
32
- end
33
- should "not add / if already at end" do
34
- assert_equal "home/dir/", normalisedDir("home/dir/")
35
- end
36
- end
37
- end
1
+ require 'helper'
2
+
3
+ module Synqa
4
+
5
+ class SynqaTestCase < Test::Unit::TestCase
6
+ include Synqa
7
+ end
8
+
9
+ class TestHashCommand < SynqaTestCase
10
+ context "A hash command" do
11
+ setup do
12
+ @hashCommand = HashCommand.new("sha32", 16, 3)
13
+ end
14
+
15
+ should "extract relative path and hash" do
16
+ pathWithHash = @hashCommand.parseFileHashLine("/home/dir/", "abcdeabcde012345 /home/dir/subdir/file.txt")
17
+ assert_equal "abcdeabcde012345", pathWithHash.hash
18
+ assert_equal "subdir/file.txt", pathWithHash.relativePath
19
+ end
20
+
21
+ should "complain about mis-matched base dir" do
22
+ assert_raise RuntimeError do
23
+ @hashCommand.parseFileHashLine("/home/dir/", "abcdeabcde012345 /homes/dir/subdir/file.txt")
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ class TestNormalisedDir < SynqaTestCase
30
+ should "add / if missing" do
31
+ assert_equal "home/dir/", normalisedDir("home/dir")
32
+ end
33
+ should "not add / if already at end" do
34
+ assert_equal "home/dir/", normalisedDir("home/dir/")
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synqa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-19 00:00:00.000000000 +12:00
12
+ date: 2011-06-18 00:00:00.000000000 +12:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: net-ssh
17
- requirement: &25189860 !ruby/object:Gem::Requirement
17
+ requirement: &77723210 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '2.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *25189860
25
+ version_requirements: *77723210
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: net-scp
28
- requirement: &25189176 !ruby/object:Gem::Requirement
28
+ requirement: &77679220 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *25189176
36
+ version_requirements: *77679220
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: shoulda
39
- requirement: &25188444 !ruby/object:Gem::Requirement
39
+ requirement: &77678600 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *25188444
47
+ version_requirements: *77678600
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &25187796 !ruby/object:Gem::Requirement
50
+ requirement: &77678180 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,21 +55,21 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *25187796
58
+ version_requirements: *77678180
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &25180356 !ruby/object:Gem::Requirement
61
+ requirement: &77677670 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
65
65
  - !ruby/object:Gem::Version
66
- version: 1.5.2
66
+ version: 1.6.2
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *25180356
69
+ version_requirements: *77677670
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rcov
72
- requirement: &25179864 !ruby/object:Gem::Requirement
72
+ requirement: &77677010 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,8 +77,11 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *25179864
81
- description: Sync files from a local directory to a remote directory via SSH/SCP
80
+ version_requirements: *77677010
81
+ description: Synqa syncs files from a local directory to a remote directory using
82
+ an SSH connection. It is designed for uploading a static website. It determines
83
+ if existing files need to be updated by calculating cryptographic hashes on the
84
+ remote server.
82
85
  email: http://www.1729.com/email.html
83
86
  executables: []
84
87
  extensions: []
@@ -123,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
126
  version: '0'
124
127
  segments:
125
128
  - 0
126
- hash: 874582639
129
+ hash: -1047501743
127
130
  required_rubygems_version: !ruby/object:Gem::Requirement
128
131
  none: false
129
132
  requirements:
@@ -132,12 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
135
  version: '0'
133
136
  requirements: []
134
137
  rubyforge_project:
135
- rubygems_version: 1.5.2
138
+ rubygems_version: 1.6.2
136
139
  signing_key:
137
140
  specification_version: 3
138
141
  summary: Sync files from a local directory to a remote directory via SSH/SCP
139
- test_files:
140
- - examples/synqa-useage.rb
141
- - test/helper.rb
142
- - test/test_based.rb
143
- - test/test_synqa.rb
142
+ test_files: []