imw 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/README.rdoc +34 -14
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/lib/imw.rb +9 -6
  5. data/lib/imw/{resources/archive.rb → archives.rb} +20 -10
  6. data/lib/imw/archives/rar.rb +19 -0
  7. data/lib/imw/archives/tar.rb +19 -0
  8. data/lib/imw/archives/tarbz2.rb +73 -0
  9. data/lib/imw/archives/targz.rb +73 -0
  10. data/lib/imw/archives/zip.rb +51 -0
  11. data/lib/imw/{resources/compressed_file.rb → compressed_files.rb} +16 -11
  12. data/lib/imw/compressed_files/bz2.rb +16 -0
  13. data/lib/imw/{resources → compressed_files}/compressible.rb +2 -4
  14. data/lib/imw/compressed_files/gz.rb +16 -0
  15. data/lib/imw/formats.rb +31 -0
  16. data/lib/imw/formats/delimited.rb +90 -0
  17. data/lib/imw/formats/excel.rb +125 -0
  18. data/lib/imw/formats/json.rb +51 -0
  19. data/lib/imw/formats/sgml.rb +69 -0
  20. data/lib/imw/formats/yaml.rb +51 -0
  21. data/lib/imw/resource.rb +108 -10
  22. data/lib/imw/schemes.rb +21 -0
  23. data/lib/imw/schemes/hdfs.rb +240 -0
  24. data/lib/imw/schemes/http.rb +166 -0
  25. data/lib/imw/schemes/local.rb +219 -0
  26. data/lib/imw/schemes/remote.rb +114 -0
  27. data/lib/imw/schemes/s3.rb +135 -0
  28. data/lib/imw/tools.rb +8 -0
  29. data/lib/imw/{transforms → tools}/archiver.rb +1 -1
  30. data/lib/imw/{transforms → tools}/transferer.rb +10 -10
  31. data/spec/imw/{resources/archive_spec.rb → archive_spec.rb} +3 -3
  32. data/spec/imw/{resources/archives_and_compressed → archives}/rar_spec.rb +2 -2
  33. data/spec/imw/{resources/archives_and_compressed → archives}/tar_spec.rb +2 -2
  34. data/spec/imw/{resources/archives_and_compressed → archives}/tarbz2_spec.rb +4 -4
  35. data/spec/imw/{resources/archives_and_compressed → archives}/targz_spec.rb +4 -4
  36. data/spec/imw/{resources/archives_and_compressed → archives}/zip_spec.rb +2 -2
  37. data/spec/imw/compressed_files/bz2_spec.rb +15 -0
  38. data/spec/imw/{resources → compressed_files}/compressible_spec.rb +1 -1
  39. data/spec/imw/compressed_files/gz_spec.rb +15 -0
  40. data/spec/imw/{resources/compressed_file_spec.rb → compressed_files_spec.rb} +3 -3
  41. data/spec/imw/{resources/formats → formats}/delimited_spec.rb +2 -2
  42. data/spec/imw/{resources/formats → formats}/json_spec.rb +2 -2
  43. data/spec/imw/{resources/formats → formats}/sgml_spec.rb +2 -2
  44. data/spec/imw/{resources/formats → formats}/yaml_spec.rb +2 -2
  45. data/spec/imw/resource_spec.rb +4 -4
  46. data/spec/imw/{resources/schemes → schemes}/hdfs_spec.rb +7 -7
  47. data/spec/imw/{resources/schemes → schemes}/http_spec.rb +2 -2
  48. data/spec/imw/{resources → schemes}/local_spec.rb +5 -5
  49. data/spec/imw/{resources → schemes}/remote_spec.rb +7 -3
  50. data/spec/imw/{resources/schemes → schemes}/s3_spec.rb +2 -2
  51. data/spec/imw/{transforms → tools}/archiver_spec.rb +2 -2
  52. data/spec/imw/tools/transferer_spec.rb +113 -0
  53. metadata +69 -71
  54. data/lib/imw/resources.rb +0 -118
  55. data/lib/imw/resources/archives_and_compressed.rb +0 -32
  56. data/lib/imw/resources/archives_and_compressed/bz2.rb +0 -18
  57. data/lib/imw/resources/archives_and_compressed/gz.rb +0 -18
  58. data/lib/imw/resources/archives_and_compressed/rar.rb +0 -23
  59. data/lib/imw/resources/archives_and_compressed/tar.rb +0 -23
  60. data/lib/imw/resources/archives_and_compressed/tarbz2.rb +0 -78
  61. data/lib/imw/resources/archives_and_compressed/targz.rb +0 -78
  62. data/lib/imw/resources/archives_and_compressed/zip.rb +0 -57
  63. data/lib/imw/resources/formats.rb +0 -32
  64. data/lib/imw/resources/formats/delimited.rb +0 -92
  65. data/lib/imw/resources/formats/excel.rb +0 -125
  66. data/lib/imw/resources/formats/json.rb +0 -53
  67. data/lib/imw/resources/formats/sgml.rb +0 -72
  68. data/lib/imw/resources/formats/yaml.rb +0 -53
  69. data/lib/imw/resources/local.rb +0 -198
  70. data/lib/imw/resources/remote.rb +0 -110
  71. data/lib/imw/resources/schemes.rb +0 -19
  72. data/lib/imw/resources/schemes/hdfs.rb +0 -242
  73. data/lib/imw/resources/schemes/http.rb +0 -161
  74. data/lib/imw/resources/schemes/s3.rb +0 -137
  75. data/lib/imw/transforms.rb +0 -8
  76. data/spec/imw/resources/archives_and_compressed/bz2_spec.rb +0 -15
  77. data/spec/imw/resources/archives_and_compressed/gz_spec.rb +0 -15
  78. data/spec/imw/transforms/transferer_spec.rb +0 -113
@@ -1,8 +0,0 @@
1
- module IMW
2
- module Transforms
3
- autoload :Archiver, 'imw/transforms/archiver'
4
- autoload :Transferer, 'imw/transforms/transferer'
5
- end
6
- end
7
-
8
-
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../../spec_helper"
2
- require File.dirname(__FILE__) + "/../compressed_file_spec"
3
-
4
- describe IMW::Resources::CompressedFiles::Bz2 do
5
-
6
- before do
7
- @extension = 'bz2'
8
- end
9
-
10
- it_should_behave_like 'a compressed file'
11
- end
12
-
13
-
14
-
15
-
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../../spec_helper"
2
- require File.dirname(__FILE__) + "/../compressed_file_spec"
3
-
4
- describe IMW::Resources::CompressedFiles::Gz do
5
-
6
- before do
7
- @extension = 'gz'
8
- end
9
-
10
- it_should_behave_like 'a compressed file'
11
- end
12
-
13
-
14
-
15
-
@@ -1,113 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../spec_helper"
2
-
3
- describe IMW::Transforms::Transferer do
4
- before do
5
- @local = IMW.open("foobar.txt")
6
- @http = IMW.open("http://www.google.com")
7
- @hdfs = IMW.open("hdfs:///path/to/foobar.txt")
8
- @s3 = IMW.open("s3://mybucket/foo/bar")
9
- end
10
-
11
- it "should raise an error unless the action is one of :cp, :copy, :mv :move, or :mv!" do
12
- IMW::Transforms::Transferer.new(:cp, @local, @http).should be
13
- IMW::Transforms::Transferer.new(:copy, @local, @http).should be
14
- IMW::Transforms::Transferer.new(:mv, @local, @http).should be
15
- IMW::Transforms::Transferer.new(:move, @local, @http).should be
16
- IMW::Transforms::Transferer.new(:mv!, @local, @http).should be
17
- lambda { IMW::Transforms::Transferer.new(:foobar, @local, @http) }.should raise_error(IMW::ArgumentError)
18
- end
19
-
20
- it "should raise an error if the source and the destination have the same URI" do
21
- lambda { IMW::Transforms::Transferer.new(:cp, @local, @local) }.should raise_error(IMW::PathError)
22
- end
23
-
24
- describe "transfering local files" do
25
- it "should raise an error if the source doesn't exist" do
26
- lambda { IMW::Transforms::Transferer.new(:cp, @local, 'barbaz.txt').transfer! }.should raise_error(IMW::PathError)
27
- end
28
-
29
- it "can copy a local file" do
30
- IMWTest::Random.file @local.path
31
- IMW::Transforms::Transferer.new(:cp, @local, 'barbaz.txt').transfer!
32
- @local.exist?.should be_true
33
- IMW.open('barbaz.txt').exist?.should be_true
34
- end
35
-
36
- it "can move a local file" do
37
- IMWTest::Random.file @local.path
38
- IMW::Transforms::Transferer.new(:mv, @local, 'barbaz.txt').transfer!
39
- @local.exist?.should be_false
40
- IMW.open('barbaz.txt').exist?.should be_true
41
- end
42
-
43
- end
44
-
45
- describe "transferring HTTP files" do
46
- it "can copy a remote file to a local path" do
47
- IMW::Transforms::Transferer.new(:cp, @http, @local).transfer!
48
- @local.exist?.should be_true
49
- end
50
- end
51
-
52
- describe "transferring S3 files" do
53
-
54
- it "can copy an S3 file to a local path" do
55
- IMW::Resources::Schemes::S3.should_receive(:get).with(@s3, @local)
56
- IMW::Transforms::Transferer.new(:cp, @s3, @local).transfer!
57
- end
58
-
59
- it "can copy a local path to an S3 file" do
60
- IMWTest::Random.file @local.path
61
- IMW::Resources::Schemes::S3.should_receive(:put).with(@local, @s3)
62
- IMW::Transforms::Transferer.new(:cp, @local, @s3).transfer!
63
- end
64
-
65
- it "can copy between S3 files" do
66
- @new_s3 = IMW.open('s3://mybucket/new/path')
67
- IMW::Resources::Schemes::S3.should_receive(:copy).with(@s3, @new_s3)
68
- IMW::Transforms::Transferer.new(:cp, @s3, @new_s3).transfer!
69
- end
70
- end
71
-
72
- describe "transferring HDFS files" do
73
- before do
74
- IMW::Resources::Schemes::HDFS.stub!(:fs)
75
- end
76
-
77
- it "can copy a local file to an HDFS path" do
78
- IMWTest::Random.file @local.path
79
-
80
- IMW::Resources::Schemes::HDFS.should_receive(:fs).with(:put, @local.path, @hdfs.path)
81
- IMW::Transforms::Transferer.new(:cp, @local, @hdfs).transfer!
82
- end
83
-
84
- it "can copy an HDFS file to a local path" do
85
- IMW::Resources::Schemes::HDFS.should_receive(:fs).with(:get, @hdfs.path, @local.path)
86
- IMW::Transforms::Transferer.new(:cp, @hdfs, @local).transfer!
87
- end
88
-
89
- it "can copy between HDFS paths" do
90
- @new_hdfs = IMW.open('hdfs:///a/new/path')
91
- IMW::Resources::Schemes::HDFS.should_receive(:fs).with(:cp, @hdfs.path, @new_hdfs.path)
92
- IMW::Transforms::Transferer.new(:cp, @hdfs, @new_hdfs).transfer!
93
- end
94
-
95
- it "can move between HDFS paths" do
96
- @new_hdfs = IMW.open('hdfs:///a/new/path')
97
- IMW::Resources::Schemes::HDFS.should_receive(:fs).with(:mv, @hdfs.path, @new_hdfs.path)
98
- IMW::Transforms::Transferer.new(:mv, @hdfs, @new_hdfs).transfer!
99
- end
100
-
101
- it "can copy from S3 to HDFS" do
102
- IMW::Resources::Schemes::HDFS.should_receive(:fs).with(:cp, @s3.s3n_url, @hdfs.path)
103
- IMW::Transforms::Transferer.new(:cp, @s3, @hdfs).transfer!
104
- end
105
-
106
- it "can copy from HDFS to S3" do
107
- IMW::Resources::Schemes::HDFS.should_receive(:fs).with(:cp, @hdfs.path, @s3.s3n_url)
108
- IMW::Transforms::Transferer.new(:cp, @hdfs, @s3).transfer!
109
- end
110
- end
111
- end
112
-
113
-