dirtravel 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +11 -0
- data/Rakefile +24 -0
- data/test/test_dirtravel.rb +62 -0
- metadata +9 -4
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 tero.isannainen@gmail.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
= DirTravel
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
DirTravel provides filesystem directory content organized as a
|
6
|
+
RubyTree structure. This structure can be conveniently accessed in
|
7
|
+
various ways.
|
8
|
+
|
9
|
+
== Documentation
|
10
|
+
|
11
|
+
Main documentation is generated from DirTravel source.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
Rake::TestTask.new do |t|
|
4
|
+
t.libs << 'test'
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Run tests"
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
task :cleanup_test do
|
11
|
+
sh "rm -rf test/test"
|
12
|
+
end
|
13
|
+
|
14
|
+
task :build do
|
15
|
+
sh "gem build dirtravel.gemspec"
|
16
|
+
end
|
17
|
+
|
18
|
+
task :publish do
|
19
|
+
if Dir.glob('dirtravel-*gem').length == 1
|
20
|
+
sh "gem push dirtravel*.gem"
|
21
|
+
else
|
22
|
+
raise "Multiple gems in the directory..."
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'dirtravel'
|
3
|
+
|
4
|
+
class DirTravelTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
Dir.chdir 'test'
|
9
|
+
|
10
|
+
FileUtils.rm_r( 'test' ) if File.exist?( 'test' )
|
11
|
+
|
12
|
+
# Create test file hierarchy.
|
13
|
+
FileUtils.mkdir_p 'test/test_0/test_0_0'
|
14
|
+
FileUtils.mkdir_p 'test/test_0/test_0_1'
|
15
|
+
FileUtils.mkdir_p 'test/test_1'
|
16
|
+
[ 'test/test_0/test_0_0/test.xtx',
|
17
|
+
'test/test_0/test_0_1/test_0.txt',
|
18
|
+
'test/test_0/test_0_1/test_1.txt',
|
19
|
+
'test/test_1/test.txt' ].each do |tf|
|
20
|
+
File.open( tf, 'w' ) do |fh| fh.puts tf end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_height
|
24
|
+
data = DirTravel::Travel.filetree( 'test' )
|
25
|
+
assert_equal( 3, data.node_height )
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_suffix_selection
|
29
|
+
data = DirTravel::Travel.filetree( 'test', { :suffix => ".txt" } )
|
30
|
+
data.files.each do |i| assert_match( i.name, /.txt$/ ) end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_paths
|
34
|
+
data = DirTravel::Travel.filetree( 'test' )
|
35
|
+
assert_equal( 'test/test_0/test_0_1', data.select_level( 2 )[ 0 ].path )
|
36
|
+
assert_equal( 'test/test_0/test_0_0', data.select_level( 2 )[ 1 ].path )
|
37
|
+
assert_equal( 'test_0/test_0_1', data.select_level( 2 )[ 0 ].subpath )
|
38
|
+
assert_equal( 'test/test_0', data.select_level( 2 )[ 0 ].dir )
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_stat
|
42
|
+
data = DirTravel::Travel.filetree( 'test' )
|
43
|
+
file = ( data.select do |i| i.name == 'test.xtx' end )[0]
|
44
|
+
stat = file.stat
|
45
|
+
assert_equal( 30, stat.size )
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_sort
|
49
|
+
data = DirTravel::Travel.filetree( 'test' )
|
50
|
+
assert_equal( 'test/test_0/test_0_1', data.select_level( 2 )[ 0 ].path )
|
51
|
+
data = DirTravel::Travel.filetree( 'test', { :sort => true } )
|
52
|
+
assert_equal( 'test/test_0/test_0_0', data.select_level( 2 )[ 0 ].path )
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_files
|
56
|
+
data = DirTravel::Travel.filetree( 'test' )
|
57
|
+
assert_equal( 9, data.length )
|
58
|
+
data = DirTravel::Travel.filetree( 'test', { :files => false } )
|
59
|
+
assert_equal( 5, data.length )
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dirtravel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,14 +28,19 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.8.3
|
30
30
|
description: DirTravel provides content of filesystem directories by recursively travelling
|
31
|
-
the directory hierarchy. The content is organized in RubyTree structure
|
32
|
-
directory entry methods.
|
31
|
+
the directory hierarchy. The content is organized in RubyTree structure and RubyTree
|
32
|
+
classes are overloaded with directory entry methods for usability.
|
33
33
|
email: tero.isannainen@gmail.com
|
34
34
|
executables: []
|
35
35
|
extensions: []
|
36
|
-
extra_rdoc_files:
|
36
|
+
extra_rdoc_files:
|
37
|
+
- README.rdoc
|
37
38
|
files:
|
39
|
+
- README.rdoc
|
40
|
+
- LICENSE
|
41
|
+
- Rakefile
|
38
42
|
- lib/dirtravel.rb
|
43
|
+
- test/test_dirtravel.rb
|
39
44
|
homepage:
|
40
45
|
licenses:
|
41
46
|
- Ruby
|