command_wrap 0.4 → 0.5
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.
- data/lib/command_wrap.rb +8 -0
- data/tests/unit/command_wrap_test.rb +21 -0
- metadata +4 -4
data/lib/command_wrap.rb
CHANGED
|
@@ -16,6 +16,14 @@ module CommandWrap
|
|
|
16
16
|
|
|
17
17
|
# Sources consists of paths followed by the filename that must be used in the zip
|
|
18
18
|
def self.zip (target, *sources)
|
|
19
|
+
if sources.length == 1 && sources[0].is_a?(Array)
|
|
20
|
+
sources = sources[0]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if sources.length % 2 == 1
|
|
24
|
+
raise "sources must contain an even number of string (path to file, filename)"
|
|
25
|
+
end
|
|
26
|
+
|
|
19
27
|
targetdir = "#{CommandWrap::Config.tmp_dir}/zip"
|
|
20
28
|
id = 1
|
|
21
29
|
while File.exists?(targetdir)
|
|
@@ -24,6 +24,27 @@ class CommandWrapTest < Test::Unit::TestCase
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def test_zip_array
|
|
28
|
+
target = File.dirname(__FILE__) + "/../../result.zip"
|
|
29
|
+
source1 = File.dirname(__FILE__) + "/../helpers/2pages.pdf"
|
|
30
|
+
source2 = File.dirname(__FILE__) + "/../helpers/test.odt"
|
|
31
|
+
|
|
32
|
+
File.delete(target) if File.exists?(target)
|
|
33
|
+
|
|
34
|
+
assert_nothing_raised do
|
|
35
|
+
CommandWrap.zip(target, [ source1, 'doc.pdf', source2, 'doc.odt' ])
|
|
36
|
+
assert File.exists?(target)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_zip_exception
|
|
41
|
+
target = File.dirname(__FILE__) + "/../../result.zip"
|
|
42
|
+
|
|
43
|
+
assert_raises RuntimeError, "sources must contain an even number of string (path to file, filename)" do
|
|
44
|
+
CommandWrap.zip(target, "dummy")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
27
48
|
def test_extension
|
|
28
49
|
assert_equal 'exe', CommandWrap.extension('test.exe')
|
|
29
50
|
end
|
metadata
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: command_wrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 1
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: "0.
|
|
8
|
+
- 5
|
|
9
|
+
version: "0.5"
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Stefaan Colman
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2011-03-
|
|
17
|
+
date: 2011-03-19 00:00:00 +01:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|