dti_nitf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/dti_nitf.gemspec +60 -0
- data/lib/dti_nitf.rb +9 -0
- data/lib/dti_nitf/lookup_table.yml +31 -0
- data/lib/dti_nitf/nitf.rb +51 -0
- data/lib/dti_nitf/story.rb +54 -0
- data/test/helper.rb +10 -0
- data/test/test_dti_nitf.rb +148 -0
- metadata +88 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mark Turner
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= dti_nitf
|
2
|
+
|
3
|
+
This library helps you processes the "XML" (quotes are intentional) from DTI's export software into valid NITF documents or Story & Media objects.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Mark Turner. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "dti_nitf"
|
8
|
+
gem.summary = "Process DTI's XML export into valid NITF documents or Story & Media objects"
|
9
|
+
gem.description = "Helps you processes the 'XML' (Quotes intentional) from DTI's XML export into valid NITF documents or Story & Media objects"
|
10
|
+
gem.email = "mark@amerine.net"
|
11
|
+
gem.homepage = "http://github.com/amerine/dti_nitf"
|
12
|
+
gem.authors = ["Mark Turner"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.add_dependency "crack", ">= 0.1.6"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "dti_nitf #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/dti_nitf.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{dti_nitf}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Mark Turner"]
|
12
|
+
s.date = %q{2010-02-19}
|
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
|
+
s.email = %q{mark@amerine.net}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"dti_nitf.gemspec",
|
27
|
+
"lib/dti_nitf.rb",
|
28
|
+
"lib/dti_nitf/lookup_table.yml",
|
29
|
+
"lib/dti_nitf/nitf.rb",
|
30
|
+
"lib/dti_nitf/story.rb",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/test_dti_nitf.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/amerine/dti_nitf}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.5}
|
38
|
+
s.summary = %q{Process DTI's XML export into valid NITF documents or Story & Media objects}
|
39
|
+
s.test_files = [
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/test_dti_nitf.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<crack>, [">= 0.1.6"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
53
|
+
s.add_dependency(%q<crack>, [">= 0.1.6"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
57
|
+
s.add_dependency(%q<crack>, [">= 0.1.6"])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/dti_nitf.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
%w[rubygems pp crack].each { |x| require x}
|
3
|
+
require File.join(dir, 'dti_nitf/nitf')
|
4
|
+
require File.join(dir, 'dti_nitf/story')
|
5
|
+
|
6
|
+
#file_contents = File.read('/tmp/02/AIRPORT 021010.xml')
|
7
|
+
#story = DTI::Story.new(file_contents)
|
8
|
+
|
9
|
+
#pp story
|
@@ -0,0 +1,31 @@
|
|
1
|
+
26: "&"
|
2
|
+
200a: ""
|
3
|
+
c3a9: "é"
|
4
|
+
c2bd: "½"
|
5
|
+
2026: "…"
|
6
|
+
e2809c: "“"
|
7
|
+
c3bc: "ü"
|
8
|
+
e2809d: "”"
|
9
|
+
2018: "‘"
|
10
|
+
2014: "—"
|
11
|
+
e28099: "’"
|
12
|
+
c391: "Ñ"
|
13
|
+
e28094: "—"
|
14
|
+
201c: "“"
|
15
|
+
2013: "–"
|
16
|
+
2011: "‑"
|
17
|
+
c3b1: "ñ"
|
18
|
+
c2ae: "®"
|
19
|
+
2009: ""
|
20
|
+
2022: "•"
|
21
|
+
e28098: "‘"
|
22
|
+
2019: "’"
|
23
|
+
c2bc: "¼"
|
24
|
+
c3a1: "á"
|
25
|
+
c3a8: "è"
|
26
|
+
c2be: "¾"
|
27
|
+
c3b6: "ö"
|
28
|
+
201d: "”"
|
29
|
+
c3a2: "â"
|
30
|
+
c3a9: "é"
|
31
|
+
2044: "⁄"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module DTI
|
2
|
+
class NITF
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
@@utf_table = YAML::load_file(File.join(dir, 'lookup_table.yml'))
|
5
|
+
|
6
|
+
def self.parse(file_string)
|
7
|
+
@@story_string = cleanup_text(file_string)
|
8
|
+
@@story_string
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def self.cleanup_text(file_string)
|
13
|
+
file_string.gsub! /\xef\xbb\xbf/, '' #BOMS
|
14
|
+
file_string.gsub! /\t/, ' '
|
15
|
+
file_string.gsub! /([\x00-\x09])/, ''
|
16
|
+
file_string.gsub! /([\x0B\x0C\x0E-\x1F])/, ''
|
17
|
+
|
18
|
+
file_string.gsub! /\r\n/, "\n"
|
19
|
+
file_string.gsub! /\n\r/, "\n"
|
20
|
+
file_string.gsub! /\r/, "\n"
|
21
|
+
file_string.gsub! /\n/, "\007"
|
22
|
+
|
23
|
+
file_string.gsub! /<EM STYLE="BOLD">/, '<em style="bold">'
|
24
|
+
file_string.gsub! /<\/EM>/, "</em>"
|
25
|
+
file_string.gsub! /&/, "&"
|
26
|
+
file_string.gsub! /<P>/, "<p>"
|
27
|
+
file_string.gsub! /<\/P>/, "</p>"
|
28
|
+
|
29
|
+
file_string.gsub! /<hl2_chapterhead>/, '<p><em style="bold" class="hl2_chapterhead">'
|
30
|
+
file_string.gsub! /<\/hl2_chapterhead>/, '</em></p><p> </p>'
|
31
|
+
|
32
|
+
file_string.gsub!(/<!-- (.*?)\(unknown\) -->/) {replace_unknown($1)}
|
33
|
+
|
34
|
+
file_string.gsub!(/<hl1>(.*?)<\/hl1>/) { "<hl1>#{clear_tags($1)}</hl1>" }
|
35
|
+
file_string.gsub!(/<hl2>(.*?)<\/hl2>/) { "<hl2>#{clear_tags($1)}</hl2>" }
|
36
|
+
|
37
|
+
file_string.gsub! /\007/, "\n"
|
38
|
+
|
39
|
+
file_string
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.replace_unknown(unicode_character)
|
43
|
+
@@utf_table[unicode_character] || "&#x#{unicode_character}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.clear_tags(text)
|
47
|
+
text.gsub! /<.*?>/, ''
|
48
|
+
text.lstrip
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module DTI
|
2
|
+
class Story
|
3
|
+
attr_accessor :raw_xml, :doc_id, :copyright_holder, :doc_name
|
4
|
+
attr_accessor :publication, :section, :pub_date, :page
|
5
|
+
attr_accessor :body, :byline, :paper, :hl1, :hl2, :tagline
|
6
|
+
|
7
|
+
def initialize(xml)
|
8
|
+
self.raw_xml = DTI::NITF.parse(xml)
|
9
|
+
|
10
|
+
cracked = Crack::XML.parse(self.raw_xml)
|
11
|
+
#pp cracked
|
12
|
+
|
13
|
+
doc_data = cracked["nitf"]["head"]["docdata"]
|
14
|
+
pub_data = cracked["nitf"]["head"]["pubdata"]
|
15
|
+
doc_body = cracked["nitf"]["body"]
|
16
|
+
|
17
|
+
self.doc_id = doc_data["doc_id"]["id_string"].to_i
|
18
|
+
self.copyright_holder = doc_data["doc.copyright"]["holder"]
|
19
|
+
self.doc_name = doc_data["doc_name"]["name_string"]
|
20
|
+
|
21
|
+
self.publication = pub_data["name"].rstrip
|
22
|
+
self.section = pub_data["position.section"].rstrip
|
23
|
+
self.pub_date = pub_data["date.publication"].rstrip
|
24
|
+
self.page = pub_data["position.sequence"].rstrip.to_i
|
25
|
+
|
26
|
+
self.body = join_hash(doc_body["body.content"]["p"])
|
27
|
+
self.body = fix_quotes(self.body)
|
28
|
+
|
29
|
+
self.byline = doc_body["body.head"]["byline"]["person"].gsub!(/^By\s/, '').rstrip!
|
30
|
+
self.paper = doc_body["body.head"]["byline"]["byttl"].rstrip!
|
31
|
+
self.hl1 = doc_body["body.head"]["hedline"]["hl1"].to_s.rstrip
|
32
|
+
self.hl2 = doc_body["body.head"]["hedline"]["hl2"].to_s.lstrip.rstrip
|
33
|
+
self.tagline = doc_body["body.end"]["tagline"].to_s.lstrip.rstrip
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def join_hash(hash)
|
39
|
+
hash_string =""
|
40
|
+
hash.each { |h|
|
41
|
+
hash_string << "<p>#{h}</p>"
|
42
|
+
}
|
43
|
+
return hash_string
|
44
|
+
end
|
45
|
+
|
46
|
+
def fix_quotes(string)
|
47
|
+
string.gsub! "\342\200\230", "'"
|
48
|
+
string.gsub! "\342\200\231", "'"
|
49
|
+
string.gsub! "\342\200\234", '"'
|
50
|
+
string.gsub! "\342\200\235", '"'
|
51
|
+
string
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestDtiNitf < Test::Unit::TestCase
|
4
|
+
@@xml = <<-EOT
|
5
|
+
<?xml-stylesheet type="text/css" href="bulletin.css"?>
|
6
|
+
<!DOCTYPE nitf SYSTEM "nitf-3-2.dtd">
|
7
|
+
<nitf>
|
8
|
+
<head>
|
9
|
+
<meta name="project_group" content="AIRPORT 021010"/>
|
10
|
+
<tobject tobject.type="news">
|
11
|
+
<Keyword name = '19000'/><Keyword name = '334630'/><Keyword name = '4004'/><Keyword name = '4015001'/><Keyword name = '41220'/>
|
12
|
+
</tobject>
|
13
|
+
<docdata>
|
14
|
+
<doc.copyright holder="Western Communications, Inc."/>
|
15
|
+
<doc-id id-string="13973764"/>
|
16
|
+
<doc-name name-string="AIRPORT 021010"/>
|
17
|
+
</docdata>
|
18
|
+
<pubdata name="The Bulletin " position.sequence="1 " position.section="LOCAL " date.publication="2010-02-10 "/>
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<body.head>
|
22
|
+
<hedline>
|
23
|
+
<hl1><p> Master plan to focus<b> on</b> attracting <x>new </x>tenants</p></hl1><hl2><p> Optimistic <x></x>about funding, officials hope to start work on plan in April</p></hl2>
|
24
|
+
</hedline>
|
25
|
+
<byline>
|
26
|
+
<person>By Hillary Borrud </person>
|
27
|
+
<byttl>The Bulletin </byttl>
|
28
|
+
</byline>
|
29
|
+
</body.head>
|
30
|
+
<body.content>
|
31
|
+
<p> Local officials hope a new plan for the Bend Municipal Airport will encourage economic development and help resolve neighbors<!-- 2019(unknown) --> concerns, including noise from low-flying aircraft. </p><p> Bend officials hope to start work in April on a new airport master plan, which lays out where and how the city<!-- 2019(unknown) -->s airport will develop in the future. </p><p> Airport Manager Gary Judd said officials wanted to begin work on the airport master plan a year ago, but the city has struggled to find the money to pay for the project. </p><p> A consultant will likely provide a cost estimate to the city before next Wednesday<!-- 2019(unknown) -->s City Council meeting, and Judd said the cost will probably exceed the $150,000 in Federal Aviation Administration money the city will receive this year. </p><p> Officials were optimistic that the city can make up the shortfall. Bend Finance Director Sonia Andrews said the city could get money to cover the remaining cost from grants, airport revenue or the city<!-- 2019(unknown) -->s general fund. </p><p> The city also is trying to find another agency that receives FAA money and cannot use all of the money it will receive this year. Bend Municipal Airport could borrow that money this year and pay it back with Bend<!-- 2019(unknown) -->s 2011 FAA money, Andrews said. </p><p> An up-to-date plan could make it easier for the city to do development projects at the airport. The airport sits on 415 acres northeast of Bend, on unincorporated land under Deschutes County<!-- 2019(unknown) -->s jurisdiction. </p><p> In September 2009, Deschutes County Commissioners Dennis Luke and Tammy Baney said they could not support the city<!-- 2019(unknown) -->s proposal to form a 526-acre urban renewal district, which would have redirected a portion of property taxes to fund the district. </p><p> The district would have raised money for runway extensions, a new traffic control tower, highway improvements and other development. </p><p> The plan died before making it to an official vote, and Baney said at the time she would not be ready to vote on the issue until the city updated its airport master plan. </p><p> Baney said Tuesday that it would not have been appropriate to allow development at the airport based on an old plan, and the process of drafting a new plan will provide an opportunity for neighbors and others to give input on the airport<!-- 2019(unknown) -->s future. </p><p> Luke said Tuesday that without a more up-to-date airport master plan, he could not determine whether the city needed the renewal district. </p><p> The current airport master plan was completed in 1999, updated in 2002 and covers about 20 years. The process of drafting a new 20-year plan will take about a year and will include public meetings. </p><p> The FAA will give the city input throughout the process, and the city needs the federal agency to sign off on the city<!-- 2019(unknown) -->s final vision of how the airport will develop in the future, Judd said. </p><p> Councilor Jim Clinton said the new airport master plan could help resolve questions about what type of businesses belong at the airport and how closely they should be tied to aviation. </p><p> <!-- 201c(unknown) -->I personally like having a place where small businesses are doing some stuff that<!-- 2019(unknown) -->s not 100 percent aviation-related,<!-- 201d(unknown) --> Clinton said. The new plan also could set rules for how low aircraft can fly in areas around the airport, and other activities that impact neighbors. </p><p> Councilor Mark Capell said the document is important because the city needs an updated plan to receive federal grants for the airport and because it helps the city prepare for the airport<!-- 2019(unknown) -->s future. </p><p> <!-- 201c(unknown) -->The airport is one of the economic engines for our community,<!-- 201d(unknown) --> Capell said. </p><p> </p>
|
32
|
+
|
33
|
+
|
34
|
+
<media media-type="image">
|
35
|
+
<media-id>1932102</media-id>
|
36
|
+
<media-name>airport-g1 021010</media-name>
|
37
|
+
<media-reference height="100" width="205" mime-type="application/postscript" source="1932102.eps"/>
|
38
|
+
<media-printcaption></media-printcaption>
|
39
|
+
<media-printproducer> </media-printproducer>
|
40
|
+
<media-originalcaption>Locator map of Bend Airport. Ramberg </media-originalcaption>
|
41
|
+
<media-source> </media-source>
|
42
|
+
<media-byline> </media-byline>
|
43
|
+
<media-job>airport 021010</media-job>
|
44
|
+
<media-notes> </media-notes>
|
45
|
+
<media-status>Worked</media-status>
|
46
|
+
</media>
|
47
|
+
</body.content>
|
48
|
+
<body.end>
|
49
|
+
<tagline>Hillary Borrud can be reached at 541-617-7829 or at hborrud@bendbulletin.com. </tagline>
|
50
|
+
</body.end>
|
51
|
+
</body>
|
52
|
+
</nitf>
|
53
|
+
EOT
|
54
|
+
context "An NITF Parser instance" do
|
55
|
+
setup do
|
56
|
+
@story = DTI::Story.new(@@xml)
|
57
|
+
end
|
58
|
+
|
59
|
+
should "should remove java BOMS" do
|
60
|
+
assert_nil @story.raw_xml =~ /\xef\xbb\xbf/
|
61
|
+
end
|
62
|
+
|
63
|
+
should "remove tabs" do
|
64
|
+
assert_nil @story.raw_xml =~ /\t/
|
65
|
+
end
|
66
|
+
|
67
|
+
should "remove bad character output from DTI export" do
|
68
|
+
assert_nil @story.raw_xml =~ /([\x00-\x09])/
|
69
|
+
assert_nil @story.raw_xml =~ /([\x0B\x0C\x0E-\x1F])/
|
70
|
+
end
|
71
|
+
|
72
|
+
should "remove the un-wanted new line/carriage returns" do
|
73
|
+
assert_nil @story.raw_xml =~ /\r\n/
|
74
|
+
assert_nil @story.raw_xml =~ /\n\r/
|
75
|
+
assert_nil @story.raw_xml =~ /\r/
|
76
|
+
end
|
77
|
+
|
78
|
+
should "remove the 007 character we add to parse" do
|
79
|
+
assert_nil @story.raw_xml =~ /\007/
|
80
|
+
end
|
81
|
+
|
82
|
+
should "lowercase the known upercase charaters from DTI export" do
|
83
|
+
assert_nil @story.raw_xml =~ /<EM STYLE="BOLD">/
|
84
|
+
assert_nil @story.raw_xml =~ /<\/EM>/
|
85
|
+
assert_nil @story.raw_xml =~ /&/
|
86
|
+
assert_nil @story.raw_xml =~ /<P>/
|
87
|
+
assert_nil @story.raw_xml =~ /<\/P>/
|
88
|
+
end
|
89
|
+
|
90
|
+
should "convert stupid ass unicode from DTI export" do
|
91
|
+
assert_nil @story.raw_xml =~ /<!-- .*?\(unknown\) -->/
|
92
|
+
assert @story.raw_xml =~ /’/
|
93
|
+
assert @story.raw_xml =~ /“/
|
94
|
+
assert @story.raw_xml =~ /”/
|
95
|
+
end
|
96
|
+
|
97
|
+
should "get rid of all tags in hl1 and hl2 fields" do
|
98
|
+
assert @story.raw_xml =~ /<hl1>Master plan to focus on attracting new tenants<\/hl1>/
|
99
|
+
assert @story.raw_xml =~ /<hl2>Optimistic about funding, officials hope to start work on plan in April<\/hl2>/
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "A Story object" do
|
104
|
+
setup do
|
105
|
+
@story = DTI::Story.new(@@xml)
|
106
|
+
end
|
107
|
+
|
108
|
+
should "have a doc_id" do
|
109
|
+
assert @story.doc_id == 13973764
|
110
|
+
end
|
111
|
+
|
112
|
+
should "have a copyright holder" do
|
113
|
+
assert @story.copyright_holder == "Western Communications, Inc."
|
114
|
+
end
|
115
|
+
|
116
|
+
should "have a document name" do
|
117
|
+
assert @story.doc_name == "AIRPORT 021010"
|
118
|
+
end
|
119
|
+
|
120
|
+
should "have a publication data" do
|
121
|
+
assert @story.publication == "The Bulletin"
|
122
|
+
assert @story.section == "LOCAL"
|
123
|
+
assert @story.pub_date == "2010-02-10"
|
124
|
+
assert @story.page == 1
|
125
|
+
end
|
126
|
+
|
127
|
+
should "include all paragraphs" do
|
128
|
+
assert @story.body == "<p> Local officials hope a new plan for the Bend Municipal Airport will encourage economic development and help resolve neighbors’ concerns, including noise from low-flying aircraft. </p><p> Bend officials hope to start work in April on a new airport master plan, which lays out where and how the city’s airport will develop in the future. </p><p> Airport Manager Gary Judd said officials wanted to begin work on the airport master plan a year ago, but the city has struggled to find the money to pay for the project. </p><p> A consultant will likely provide a cost estimate to the city before next Wednesday’s City Council meeting, and Judd said the cost will probably exceed the $150,000 in Federal Aviation Administration money the city will receive this year. </p><p> Officials were optimistic that the city can make up the shortfall. Bend Finance Director Sonia Andrews said the city could get money to cover the remaining cost from grants, airport revenue or the city’s general fund. </p><p> The city also is trying to find another agency that receives FAA money and cannot use all of the money it will receive this year. Bend Municipal Airport could borrow that money this year and pay it back with Bend’s 2011 FAA money, Andrews said. </p><p> An up-to-date plan could make it easier for the city to do development projects at the airport. The airport sits on 415 acres northeast of Bend, on unincorporated land under Deschutes County’s jurisdiction. </p><p> In September 2009, Deschutes County Commissioners Dennis Luke and Tammy Baney said they could not support the city’s proposal to form a 526-acre urban renewal district, which would have redirected a portion of property taxes to fund the district. </p><p> The district would have raised money for runway extensions, a new traffic control tower, highway improvements and other development. </p><p> The plan died before making it to an official vote, and Baney said at the time she would not be ready to vote on the issue until the city updated its airport master plan. </p><p> Baney said Tuesday that it would not have been appropriate to allow development at the airport based on an old plan, and the process of drafting a new plan will provide an opportunity for neighbors and others to give input on the airport’s future. </p><p> Luke said Tuesday that without a more up-to-date airport master plan, he could not determine whether the city needed the renewal district. </p><p> The current airport master plan was completed in 1999, updated in 2002 and covers about 20 years. The process of drafting a new 20-year plan will take about a year and will include public meetings. </p><p> The FAA will give the city input throughout the process, and the city needs the federal agency to sign off on the city’s final vision of how the airport will develop in the future, Judd said. </p><p> Councilor Jim Clinton said the new airport master plan could help resolve questions about what type of businesses belong at the airport and how closely they should be tied to aviation. </p><p> \"I personally like having a place where small businesses are doing some stuff that’s not 100 percent aviation-related,\" Clinton said. The new plan also could set rules for how low aircraft can fly in areas around the airport, and other activities that impact neighbors. </p><p> Councilor Mark Capell said the document is important because the city needs an updated plan to receive federal grants for the airport and because it helps the city prepare for the airport’s future. </p><p> \"The airport is one of the economic engines for our community,\" Capell said. </p><p></p>"
|
129
|
+
end
|
130
|
+
|
131
|
+
should "have a byline" do
|
132
|
+
assert @story.byline == "Hillary Borrud"
|
133
|
+
end
|
134
|
+
|
135
|
+
should "have a paper" do
|
136
|
+
assert @story.paper == "The Bulletin"
|
137
|
+
end
|
138
|
+
|
139
|
+
should "have a headline" do
|
140
|
+
assert @story.hl1 == "Master plan to focus on attracting new tenants"
|
141
|
+
assert @story.hl2 == "Optimistic about funding, officials hope to start work on plan in April"
|
142
|
+
end
|
143
|
+
|
144
|
+
should "should have a tagline" do
|
145
|
+
assert @story.tagline == "Hillary Borrud can be reached at 541-617-7829 or at hborrud@bendbulletin.com."
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dti_nitf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Turner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-19 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thoughtbot-shoulda
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: crack
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.6
|
34
|
+
version:
|
35
|
+
description: Helps you processes the 'XML' (Quotes intentional) from DTI's XML export into valid NITF documents or Story & Media objects
|
36
|
+
email: mark@amerine.net
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- dti_nitf.gemspec
|
52
|
+
- lib/dti_nitf.rb
|
53
|
+
- lib/dti_nitf/lookup_table.yml
|
54
|
+
- lib/dti_nitf/nitf.rb
|
55
|
+
- lib/dti_nitf/story.rb
|
56
|
+
- test/helper.rb
|
57
|
+
- test/test_dti_nitf.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/amerine/dti_nitf
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- --charset=UTF-8
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Process DTI's XML export into valid NITF documents or Story & Media objects
|
86
|
+
test_files:
|
87
|
+
- test/helper.rb
|
88
|
+
- test/test_dti_nitf.rb
|