hdfs-viking 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Jarfile +3 -0
- data/Jarfile.lock +124 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +19 -0
- data/lib/viking/dir.rb +137 -0
- data/lib/viking/file.rb +224 -0
- data/lib/viking/fileutilz.rb +101 -0
- data/lib/viking/version.rb +3 -0
- data/lib/viking.rb +32 -0
- data/test/test_dir_class_methods.rb +114 -0
- data/test/test_dir_instance_methods.rb +72 -0
- data/test/test_file_class_methods.rb +115 -0
- data/test/test_file_instance_methods.rb +142 -0
- data/test/test_fileutils_class_methods.rb +191 -0
- data/viking.gemspec +27 -0
- metadata +110 -0
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/pride'
|
3
|
+
require File.expand_path('../../lib/viking.rb', __FILE__)
|
4
|
+
|
5
|
+
class TestFileUtilsClassMethods < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
TMP_DIR = "/tmp/viking"
|
8
|
+
TEST_FILE_1 = "test_file_1.rb"
|
9
|
+
TEST_FILE_2 = "test_file_2.rb"
|
10
|
+
TEST_FILE_PATH_1 = "#{TMP_DIR}/#{TEST_FILE_1}"
|
11
|
+
TEST_FILE_PATH_2 = "#{TMP_DIR}/#{TEST_FILE_2}"
|
12
|
+
|
13
|
+
def setup
|
14
|
+
FileUtils.mkpath(TMP_DIR) unless File.exists?(TMP_DIR)
|
15
|
+
FileUtils.touch(TEST_FILE_PATH_1)
|
16
|
+
FileUtils.touch(TEST_FILE_PATH_2)
|
17
|
+
File.write(TEST_FILE_PATH_2, "test")
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
FileUtils.remove_dir(TMP_DIR) if File.exists?(TMP_DIR)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_cd
|
25
|
+
assert 0 == Viking::FileUtils.cd(TMP_DIR)
|
26
|
+
assert Viking::Dir.pwd == TMP_DIR
|
27
|
+
|
28
|
+
Viking::FileUtils.cd("/tmp") do |path|
|
29
|
+
assert "/tmp" == path
|
30
|
+
assert "/tmp" == Viking::Dir.pwd
|
31
|
+
end
|
32
|
+
|
33
|
+
assert Viking::Dir.pwd == TMP_DIR
|
34
|
+
|
35
|
+
assert 0 == Viking::FileUtils.cd(Dir.pwd)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_chdir
|
39
|
+
assert 0 == Viking::FileUtils.chdir(TMP_DIR)
|
40
|
+
assert Viking::Dir.pwd == TMP_DIR
|
41
|
+
|
42
|
+
Viking::FileUtils.chdir("/tmp") do |path|
|
43
|
+
assert "/tmp" == path
|
44
|
+
assert "/tmp" == Viking::Dir.pwd
|
45
|
+
end
|
46
|
+
|
47
|
+
assert Viking::Dir.pwd == TMP_DIR
|
48
|
+
|
49
|
+
assert 0 == Viking::FileUtils.chdir(Dir.pwd)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_chmod
|
53
|
+
Viking::FileUtils.chmod(777, [TEST_FILE_PATH_1, TEST_FILE_PATH_2])
|
54
|
+
assert 33545 == File.stat(TEST_FILE_PATH_1).mode
|
55
|
+
assert 33545 == File.stat(TEST_FILE_PATH_2).mode
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_chown
|
59
|
+
assert [TEST_FILE_PATH_1] == Viking::FileUtils.chown(ENV["USER"], nil, TEST_FILE_PATH_1)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_getwd
|
63
|
+
assert Dir.pwd == Viking::FileUtils.getwd
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_makedirs
|
67
|
+
dirs = ["#{TMP_DIR}/foo", "#{TMP_DIR}/bar"]
|
68
|
+
|
69
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/foo")
|
70
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/bar")
|
71
|
+
|
72
|
+
Viking::FileUtils.makedirs(dirs)
|
73
|
+
|
74
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/foo")
|
75
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/bar")
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_mkdir
|
79
|
+
dirs = ["#{TMP_DIR}/foo", "#{TMP_DIR}/bar"]
|
80
|
+
|
81
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/foo")
|
82
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/bar")
|
83
|
+
|
84
|
+
Viking::FileUtils.mkdir(dirs)
|
85
|
+
|
86
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/foo")
|
87
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/bar")
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_move
|
91
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/foo")
|
92
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/bar")
|
93
|
+
|
94
|
+
Dir.mkdir("#{TMP_DIR}/foo")
|
95
|
+
|
96
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/foo")
|
97
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/bar")
|
98
|
+
|
99
|
+
Viking::FileUtils.move("#{TMP_DIR}/foo", "#{TMP_DIR}/bar")
|
100
|
+
|
101
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/foo")
|
102
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/bar")
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_mv
|
106
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/foo")
|
107
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/bar")
|
108
|
+
|
109
|
+
Dir.mkdir("#{TMP_DIR}/foo")
|
110
|
+
|
111
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/foo")
|
112
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/bar")
|
113
|
+
|
114
|
+
Viking::FileUtils.mv("#{TMP_DIR}/foo", "#{TMP_DIR}/bar")
|
115
|
+
|
116
|
+
assert !Viking::Dir.exist?("#{TMP_DIR}/foo")
|
117
|
+
assert Viking::Dir.exist?("#{TMP_DIR}/bar")
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_pwd
|
121
|
+
assert Dir.pwd == Viking::FileUtils.pwd
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_remove
|
125
|
+
Viking::FileUtils.remove([TEST_FILE_PATH_1, TEST_FILE_PATH_2])
|
126
|
+
|
127
|
+
assert !File.exist?(TEST_FILE_PATH_1)
|
128
|
+
assert !File.exist?(TEST_FILE_PATH_2)
|
129
|
+
|
130
|
+
assert_raises(IOError) { Viking::FileUtils.remove(TMP_DIR) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_remove_dir
|
134
|
+
assert_raises(Java::JavaIo::IOException) { Viking::FileUtils.remove_dir(TMP_DIR) }
|
135
|
+
|
136
|
+
Dir.mkdir("#{TMP_DIR}/foo")
|
137
|
+
assert Dir.exist?("#{TMP_DIR}/foo")
|
138
|
+
|
139
|
+
Viking::FileUtils.remove_dir("#{TMP_DIR}/foo")
|
140
|
+
|
141
|
+
assert !Dir.exist?("#{TMP_DIR}/foo")
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_remove_entry
|
145
|
+
Viking::FileUtils.remove_entry(TMP_DIR)
|
146
|
+
assert !Dir.exist?(TMP_DIR)
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_remove_file
|
150
|
+
Viking::FileUtils.remove_file(TEST_FILE_PATH_1)
|
151
|
+
assert !File.exist?(TEST_FILE_PATH_1)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_rm
|
155
|
+
Viking::FileUtils.rm([TEST_FILE_PATH_1, TEST_FILE_PATH_2])
|
156
|
+
|
157
|
+
assert !File.exist?(TEST_FILE_PATH_1)
|
158
|
+
assert !File.exist?(TEST_FILE_PATH_2)
|
159
|
+
|
160
|
+
assert_raises(IOError) { Viking::FileUtils.rm(TMP_DIR) }
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_rm_r
|
164
|
+
Viking::FileUtils.rm_r(TMP_DIR)
|
165
|
+
assert !Dir.exist?(TMP_DIR)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_rmdir
|
169
|
+
assert_raises(Java::JavaIo::IOException) { Viking::FileUtils.rmdir(TMP_DIR) }
|
170
|
+
|
171
|
+
Dir.mkdir("#{TMP_DIR}/foo")
|
172
|
+
Dir.mkdir("#{TMP_DIR}/bar")
|
173
|
+
assert Dir.exist?("#{TMP_DIR}/foo")
|
174
|
+
assert Dir.exist?("#{TMP_DIR}/bar")
|
175
|
+
|
176
|
+
Viking::FileUtils.rmdir(["#{TMP_DIR}/foo", "#{TMP_DIR}/bar"])
|
177
|
+
|
178
|
+
assert !Dir.exist?("#{TMP_DIR}/foo")
|
179
|
+
assert !Dir.exist?("#{TMP_DIR}/bar")
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_touch
|
183
|
+
assert !File.exist?("#{TMP_DIR}/foo.test")
|
184
|
+
assert !File.exist?("#{TMP_DIR}/bar.test")
|
185
|
+
|
186
|
+
Viking::FileUtils.touch(["#{TMP_DIR}/foo.test", "#{TMP_DIR}/bar.test"])
|
187
|
+
|
188
|
+
assert File.exist?("#{TMP_DIR}/foo.test")
|
189
|
+
assert File.exist?("#{TMP_DIR}/bar.test")
|
190
|
+
end
|
191
|
+
end
|
data/viking.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'viking/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hdfs-viking"
|
8
|
+
spec.version = Viking::VERSION
|
9
|
+
spec.authors = ["Erik Selin"]
|
10
|
+
spec.email = ["erik.selin@jadedpixel.com"]
|
11
|
+
spec.description = %q{jruby hdfs wrapper attempting to provide an interface that's similar to the common ruby file system api's.}
|
12
|
+
spec.summary = %q{jruby hdfs wrapper}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.extensions = ["Rakefile"]
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
|
26
|
+
spec.add_dependency "lock_jar"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hdfs-viking
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erik Selin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.5
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.3.5
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: lock_jar
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
prerelease: false
|
54
|
+
type: :runtime
|
55
|
+
description: jruby hdfs wrapper attempting to provide an interface that's similar to the common ruby file system api's.
|
56
|
+
email:
|
57
|
+
- erik.selin@jadedpixel.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- Rakefile
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- Jarfile
|
66
|
+
- Jarfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/viking.rb
|
71
|
+
- lib/viking/dir.rb
|
72
|
+
- lib/viking/file.rb
|
73
|
+
- lib/viking/fileutilz.rb
|
74
|
+
- lib/viking/version.rb
|
75
|
+
- test/test_dir_class_methods.rb
|
76
|
+
- test/test_dir_instance_methods.rb
|
77
|
+
- test/test_file_class_methods.rb
|
78
|
+
- test/test_file_instance_methods.rb
|
79
|
+
- test/test_fileutils_class_methods.rb
|
80
|
+
- viking.gemspec
|
81
|
+
homepage: ''
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.1.9
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: jruby hdfs wrapper
|
105
|
+
test_files:
|
106
|
+
- test/test_dir_class_methods.rb
|
107
|
+
- test/test_dir_instance_methods.rb
|
108
|
+
- test/test_file_class_methods.rb
|
109
|
+
- test/test_file_instance_methods.rb
|
110
|
+
- test/test_fileutils_class_methods.rb
|