nori 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nori might be problematic. Click here for more details.

@@ -0,0 +1,7 @@
1
+ module Nori
2
+ class StringIOFile < StringIO
3
+
4
+ attr_accessor :original_filename, :content_type
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Nori
2
+ class StringWithAttributes < String
3
+
4
+ attr_accessor :attributes
5
+
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module Nori
2
2
 
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
 
5
5
  end
@@ -4,6 +4,9 @@ require "time"
4
4
  require "yaml"
5
5
  require "bigdecimal"
6
6
 
7
+ require "nori/string_with_attributes"
8
+ require "nori/string_io_file"
9
+
7
10
  module Nori
8
11
 
9
12
  # This is a slighly modified version of the XMLUtilityNode from
@@ -85,21 +88,16 @@ module Nori
85
88
 
86
89
  def to_hash
87
90
  if @type == "file"
88
- f = StringIO.new((@children.first || '').unpack('m').first)
89
- class << f
90
- attr_accessor :original_filename, :content_type
91
- end
91
+ f = StringIOFile.new((@children.first || '').unpack('m').first)
92
92
  f.original_filename = attributes['name'] || 'untitled'
93
93
  f.content_type = attributes['content_type'] || 'application/octet-stream'
94
- return {name => f}
94
+ return { name => f }
95
95
  end
96
96
 
97
97
  if @text
98
- t = typecast_value( unnormalize_xml_entities( inner_html ) )
98
+ t = typecast_value unnormalize_xml_entities(inner_html)
99
99
  if t.is_a?(String)
100
- class << t
101
- attr_accessor :attributes
102
- end
100
+ t = StringWithAttributes.new(t)
103
101
  t.attributes = attributes
104
102
  end
105
103
  return { name => t }
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.rubyforge_project = "nori"
15
15
 
16
16
  s.add_development_dependency "nokogiri", ">= 1.4.0"
17
- s.add_development_dependency "rspec", "~> 2.6.0"
17
+ s.add_development_dependency "rspec", "~> 2.5.0"
18
18
  s.add_development_dependency "autotest"
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
@@ -3,12 +3,16 @@ require "spec_helper"
3
3
  describe Object do
4
4
 
5
5
  describe "#blank?" do
6
- it "should return true for blank objects" do
7
- [nil, false, [], {}].each { |object| object.should be_blank }
6
+ [nil, false, [], {}].each do |object|
7
+ it "should return true for: #{object.inspect}" do
8
+ object.blank?.should be_true
9
+ end
8
10
  end
9
11
 
10
- it "should return false for non-blank objects" do
11
- [true, [nil], 1, "string", { :key => "value" }].each { |object| object.should_not be_blank }
12
+ [true, [nil], 1, "string", { :key => "value" }].each do |object|
13
+ it "should return false for: #{object.inspect}" do
14
+ object.blank?.should be_false
15
+ end
12
16
  end
13
17
  end
14
18
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nori
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-05-16 00:00:00 +02:00
20
+ date: 2011-05-27 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -44,12 +44,12 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- hash: 23
47
+ hash: 27
48
48
  segments:
49
49
  - 2
50
- - 6
50
+ - 5
51
51
  - 0
52
- version: 2.6.0
52
+ version: 2.5.0
53
53
  type: :development
54
54
  version_requirements: *id002
55
55
  - !ruby/object:Gem::Dependency
@@ -93,6 +93,8 @@ files:
93
93
  - lib/nori/parser.rb
94
94
  - lib/nori/parser/nokogiri.rb
95
95
  - lib/nori/parser/rexml.rb
96
+ - lib/nori/string_io_file.rb
97
+ - lib/nori/string_with_attributes.rb
96
98
  - lib/nori/version.rb
97
99
  - lib/nori/xml_utility_node.rb
98
100
  - nori.gemspec