dti_nitf 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
data/dti_nitf.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dti_nitf}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Turner"]
12
- s.date = %q{2010-02-23}
12
+ s.date = %q{2010-02-25}
13
13
  s.description = %q{Helps you processes the 'XML' (Quotes intentional) from DTI's XML export into valid NITF documents or Story & Media objects}
14
14
  s.email = %q{mark@amerine.net}
15
15
  s.extra_rdoc_files = [
data/lib/dti_nitf.rb CHANGED
@@ -3,7 +3,7 @@ dir = File.dirname(__FILE__)
3
3
  require File.join(dir, 'dti_nitf/nitf')
4
4
  require File.join(dir, 'dti_nitf/story')
5
5
 
6
- # require 'pp'
6
+ require 'pp'
7
7
  #
8
8
  # file_contents = File.read('/tmp/02/a1furn 020810.xml')
9
9
  # story = DTI::Story.new(file_contents)
@@ -10,7 +10,6 @@ module DTI
10
10
  self.correction = false
11
11
 
12
12
  cracked = Crack::XML.parse(self.raw_xml)
13
- #pp cracked
14
13
 
15
14
  if cracked["nitf"]['head']['original_storyid']
16
15
  self.correction = true
@@ -31,8 +30,8 @@ module DTI
31
30
  self.pub_date = pub_data["date.publication"].rstrip
32
31
  self.page = pub_data["position.sequence"].rstrip.to_i
33
32
 
34
- self.body = join_hash(doc_body["body.content"]["p"])
35
- self.body = fix_quotes(self.body)
33
+ self.body = doc_body["body.content"]["p"].collect{|d| "<p>#{d}</p>"}.join
34
+ self.body = fix_escaped_elements(self.body)
36
35
 
37
36
  if !self.correction?
38
37
  self.byline = doc_body["body.head"]["byline"]["person"].gsub!(/^By\s/, '').rstrip if doc_body["body.head"]["byline"]
@@ -49,20 +48,10 @@ module DTI
49
48
  self.correction
50
49
  end
51
50
 
52
- def join_hash(hash)
53
- hash_string =""
54
- hash.each { |h|
55
- hash_string << "<p>#{h}</p>"
56
- }
57
- return hash_string
58
- end
59
-
60
- def fix_quotes(string)
61
- string.gsub! "\342\200\230", "'"
62
- string.gsub! "\342\200\231", "'"
63
- string.gsub! "\342\200\234", '"'
64
- string.gsub! "\342\200\235", '"'
65
- string
51
+ def fix_escaped_elements(string)
52
+ return_string = string
53
+ return_string.gsub! /\342\200[\230\231]/, "'"
54
+ return_string.gsub! /\342\200[\234\235]/, '"'
66
55
  end
67
56
  end
68
57
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Turner
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-23 00:00:00 -08:00
17
+ date: 2010-02-25 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency