imw 0.2.5 → 0.2.6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/lib/imw/archives.rb CHANGED
@@ -37,6 +37,13 @@ module IMW
37
37
  true
38
38
  end
39
39
 
40
+ # Archives should not return snippets.
41
+ #
42
+ # @return [nil]
43
+ def snippet
44
+ nil
45
+ end
46
+
40
47
  # Create an archive of the given +input_paths+.
41
48
  #
42
49
  # The input paths must be strings and will be shell-escaped
@@ -71,6 +71,13 @@ module IMW
71
71
  IMW.open(decompressed_path)
72
72
  end
73
73
 
74
+ # Compressed files should not return snippets.
75
+ #
76
+ # @return [nil]
77
+ def snippet
78
+ nil
79
+ end
80
+
74
81
  # Decompress this file in its present directory, overwriting any
75
82
  # existing files while keeping the original compressed file.
76
83
  #
@@ -45,6 +45,21 @@ module IMW
45
45
  io.close unless options[:persist]
46
46
  self
47
47
  end
48
+
49
+ # Return a 10-line sample of this file.
50
+ #
51
+ # @return [Array<Array>]
52
+ def snippet
53
+ require 'fastercsv'
54
+ returning([]) do |rows|
55
+ row_num = 1
56
+ FasterCSV.new(io, delimited_options).each do |row|
57
+ break if row_num > 10
58
+ rows << row
59
+ row_num += 1
60
+ end
61
+ end
62
+ end
48
63
  end
49
64
 
50
65
  module Csv
@@ -27,7 +27,7 @@ module IMW
27
27
  # @param [String, IMW::Resource] new_uri
28
28
  # @return [IMW::Resource] the new resource
29
29
  def cp new_uri
30
- IMW::Transforms::Transferer.new(:cp, self, new_uri).transfer!
30
+ IMW::Tools::Transferer.new(:cp, self, new_uri).transfer!
31
31
  end
32
32
 
33
33
  # Move this resource to the +new_uri+.
@@ -35,7 +35,7 @@ module IMW
35
35
  # @param [String, IMW::Resource] new_uri
36
36
  # @return [IMW::Resource] the new resource
37
37
  def mv new_uri
38
- IMW::Transforms::Transferer.new(:mv, self, new_uri).transfer!
38
+ IMW::Tools::Transferer.new(:mv, self, new_uri).transfer!
39
39
  end
40
40
 
41
41
  # Delete this resource from the HDFS.
@@ -161,7 +161,7 @@ module IMW
161
161
 
162
162
  # Return a 1024-char snippet from this local file.
163
163
  #
164
- # @return [Array<String>]
164
+ # @return [String]
165
165
  def snippet
166
166
  io.read(1024)
167
167
  end
@@ -42,7 +42,13 @@ module IMW
42
42
  #
43
43
  # @return [Array<Hash>]
44
44
  def summary
45
- @summary ||= inputs.map(&:summary)
45
+ @summary ||= inputs.map do |input|
46
+ if input.respond_to?(:summary)
47
+ input.summary
48
+ else
49
+ {}
50
+ end
51
+ end
46
52
  end
47
53
 
48
54
  protected
@@ -58,7 +64,7 @@ module IMW
58
64
  input.should_exist!("Cannot summarize.")
59
65
  end
60
66
  @resources = inputs.map do |input|
61
- input.is_directory? ? input.all_resources : input
67
+ input.is_local? && input.is_directory? ? input.all_resources : input
62
68
  end.compact.flatten
63
69
  end
64
70
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dhruv Bansal
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-06-06 00:00:00 -05:00
13
+ date: 2010-06-15 00:00:00 -05:00
14
14
  default_executable: imw
15
15
  dependencies: []
16
16