imw 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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['monkeys'].first['monkey']['id'].should == 1
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.load['monkeys'].first['monkey']['id'].should == 1
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
@@ -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 recursively as IMW::Resource objects" do
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
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-05-25 00:00:00 -05:00
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