monkeyhelper-nitfy 0.0.1

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ nbproject
7
+ test.rb
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 robl
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,27 @@
1
+ = nitfy
2
+
3
+ A NITF document parser (http://www.nitf.org/).
4
+
5
+ = Usage
6
+
7
+ #!/usr/bin/ruby
8
+
9
+ require 'rubygems'
10
+ require 'nitfy'
11
+
12
+ xml_string = File.read(ARGV[0])
13
+ doc = Nitfy::Document.parse(xml_string, :single => true)
14
+
15
+ # Head
16
+ puts doc.head.metas.first.name
17
+ puts doc.head.keylist.keywords.first.key
18
+
19
+ # Body
20
+ puts doc.body.head.title
21
+ puts doc.body.head.headline.hl1
22
+ puts doc.body.content
23
+
24
+
25
+ == Copyright
26
+
27
+ Copyright (c) 2009 robl. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "nitfy"
8
+ gem.summary = "NITF file parser"
9
+ gem.email = "robl at monkeyhelper.com"
10
+ gem.homepage = "http://github.com/monkeyhelper/nitfy"
11
+ gem.authors = ["robl"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "nitfy #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/lib/nitfy.rb ADDED
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'happymapper'
3
+ require 'pp'
4
+
5
+ module Nitfy
6
+
7
+ class Keyword
8
+ include HappyMapper
9
+ tag 'keyword'
10
+
11
+ attribute :key, String
12
+ end
13
+
14
+ class KeyList
15
+ include HappyMapper
16
+ tag 'key-list'
17
+
18
+ has_many :keywords, Keyword
19
+ end
20
+
21
+
22
+ class Meta
23
+ include HappyMapper
24
+ tag 'meta'
25
+
26
+ attribute :name, String
27
+ attribute :content, String
28
+
29
+ end
30
+
31
+ class Head
32
+ include HappyMapper
33
+ tag 'head'
34
+
35
+ has_one :title, String
36
+ has_one :keylist, KeyList, :tag => 'key-list'
37
+
38
+ has_many :metas, Meta
39
+ end
40
+
41
+ class Headline
42
+ include HappyMapper
43
+ tag 'hedline'
44
+
45
+ has_one :hl1, String, :tag => 'hl1'
46
+ end
47
+
48
+ class BodyHead
49
+ include HappyMapper
50
+ tag 'body.head'
51
+
52
+ has_one :headline, Headline, :tag => 'hedline'
53
+ end
54
+
55
+ class Body
56
+ include HappyMapper
57
+ tag 'body'
58
+
59
+ has_one :content, String, :tag => 'body.content'
60
+ has_one :head, BodyHead
61
+ end
62
+
63
+ class Document
64
+ include HappyMapper
65
+ tag 'nitf'
66
+
67
+ has_one :head, Head
68
+ has_one :body, Body
69
+ end
70
+
71
+ end
72
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class NitfyTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'nitfy'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monkeyhelper-nitfy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - robl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: robl at monkeyhelper.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - lib/nitfy.rb
33
+ - test/nitfy_test.rb
34
+ - test/test_helper.rb
35
+ has_rdoc: false
36
+ homepage: http://github.com/monkeyhelper/nitfy
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.2.0
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: NITF file parser
61
+ test_files:
62
+ - test/nitfy_test.rb
63
+ - test/test_helper.rb