imw 0.2.4 → 0.2.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/README.rdoc +174 -86
- data/VERSION +1 -1
- data/lib/imw/formats/delimited.rb +5 -5
- data/lib/imw/formats/json.rb +10 -18
- data/lib/imw/formats/yaml.rb +11 -19
- data/lib/imw/resource.rb +26 -0
- data/lib/imw/schemes/local.rb +59 -10
- data/lib/imw/tools/extension_analyzer.rb +108 -0
- data/lib/imw/tools/summarizer.rb +31 -133
- data/lib/imw/utils/log.rb +2 -2
- data/spec/data/sample.json +782 -1
- data/spec/data/sample.yaml +650 -651
- data/spec/imw/formats/delimited_spec.rb +0 -12
- data/spec/imw/formats/json_spec.rb +1 -15
- data/spec/imw/formats/yaml_spec.rb +1 -23
- data/spec/imw/resource_spec.rb +26 -0
- data/spec/imw/schemes/local_spec.rb +1 -1
- metadata +3 -2
@@ -18,16 +18,4 @@ describe IMW::Formats::Csv do
|
|
18
18
|
IMW.open('test.csv').load[1].last.should == "4"
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should yield each row when load is given a block" do
|
22
|
-
@sample.load do |row|
|
23
|
-
row.class.should == Array
|
24
|
-
break
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it "can map each row with a block" do
|
29
|
-
@sample.map do |row|
|
30
|
-
row.first
|
31
|
-
end.class.should == Array
|
32
|
-
end
|
33
21
|
end
|
@@ -7,7 +7,7 @@ describe IMW::Formats::Json do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should be able to parse the JSON" do
|
10
|
-
@sample.load
|
10
|
+
@sample.load.first['id'].should == 1
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should be able to write JSON" do
|
@@ -15,18 +15,4 @@ describe IMW::Formats::Json do
|
|
15
15
|
IMW.open('test.json').load['foobar'].should == 3
|
16
16
|
end
|
17
17
|
|
18
|
-
it "should yield each key and value when the JSON is a hash and it's given a block" do
|
19
|
-
@sample.load do |key, value|
|
20
|
-
value.size.should == 130
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should yield each element when the JSON is an array and it's given a block" do
|
25
|
-
IMW.open!('test.json').dump([1,2,3])
|
26
|
-
num = 1
|
27
|
-
IMW.open('test.json').load do |parsed_num|
|
28
|
-
parsed_num.should == num
|
29
|
-
num +=1
|
30
|
-
end
|
31
|
-
end
|
32
18
|
end
|
@@ -7,7 +7,7 @@ describe IMW::Formats::Yaml do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should be able to parse the YAML" do
|
10
|
-
@sample.
|
10
|
+
@sample.first['id'].should == 1
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should be able to write YAML" do
|
@@ -16,26 +16,4 @@ describe IMW::Formats::Yaml do
|
|
16
16
|
IMW.open('test.yaml').load['foobar'].should == 3
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should yield each key and value when the YAML is a hash and it's given a block" do
|
20
|
-
@sample.load do |key, value|
|
21
|
-
value.size.should == 130
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should yield each element when the YAML is an array and it's given a block" do
|
26
|
-
IMW.open!('test.yaml').dump([1,2,3])
|
27
|
-
num = 1
|
28
|
-
IMW.open('test.yaml').load do |parsed_num|
|
29
|
-
parsed_num.should == num
|
30
|
-
num +=1
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should yield a string when the YAML is a string and it's given a block" do
|
35
|
-
IMW.open!('test.yaml').dump('foobar')
|
36
|
-
IMW.open('test.yaml').load do |string|
|
37
|
-
string.should == 'foobar'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
19
|
end
|
data/spec/imw/resource_spec.rb
CHANGED
@@ -99,6 +99,32 @@ describe IMW::Resource do
|
|
99
99
|
|
100
100
|
end
|
101
101
|
|
102
|
+
describe "registering a new handler" do
|
103
|
+
after do
|
104
|
+
IMW::USER_DEFINED_HANDLERS.delete_if { true }
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should raise an error if the module given isn't a module or string" do
|
108
|
+
lambda { IMW.register_handler 3, // }.should raise_error(IMW::ArgumentError)
|
109
|
+
lambda { IMW.register_handler "IMW", // }.should_not raise_error(IMW::ArgumentError)
|
110
|
+
lambda { IMW.register_handler IMW, // }.should_not raise_error(IMW::ArgumentError)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should raise an error if the handler given isn't a Regexp, Proc, or true" do
|
114
|
+
lambda { IMW.register_handler IMW, 3 }.should raise_error(IMW::ArgumentError)
|
115
|
+
lambda { IMW.register_handler IMW, /foo/ }.should_not raise_error(IMW::ArgumentError)
|
116
|
+
lambda { IMW.register_handler IMW, Proc.new { |r| true } }.should_not raise_error(IMW::ArgumentError)
|
117
|
+
lambda { IMW.register_handler IMW, true }.should_not raise_error(IMW::ArgumentError)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should use a valid handler when appropriate" do
|
121
|
+
NewModule = Module.new
|
122
|
+
IMW.register_handler NewModule, /\.foo$/
|
123
|
+
IMW.open('/path/to/something.foo').resource_modules.should include(NewModule)
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
102
128
|
end
|
103
129
|
|
104
130
|
|
@@ -96,7 +96,7 @@ describe IMW::Schemes::Local::LocalDirectory do
|
|
96
96
|
@dir.all_contents.size.should == 4
|
97
97
|
end
|
98
98
|
|
99
|
-
it "can list its contents
|
99
|
+
it "can list its contents as IMW::Resource objects" do
|
100
100
|
@dir.resources.map(&:class).uniq.first.should == IMW::Resource
|
101
101
|
end
|
102
102
|
|
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.
|
4
|
+
version: 0.2.5
|
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-
|
13
|
+
date: 2010-06-06 00:00:00 -05:00
|
14
14
|
default_executable: imw
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/imw/schemes/s3.rb
|
73
73
|
- lib/imw/tools.rb
|
74
74
|
- lib/imw/tools/archiver.rb
|
75
|
+
- lib/imw/tools/extension_analyzer.rb
|
75
76
|
- lib/imw/tools/summarizer.rb
|
76
77
|
- lib/imw/tools/transferer.rb
|
77
78
|
- lib/imw/utils.rb
|