pitosalas-opmlassist 0.0.2

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/README.textile ADDED
@@ -0,0 +1,15 @@
1
+ h1. Overview
2
+
3
+ THIS IS INCOMPLETE. I AM STILL WORKING ON IT
4
+
5
+ h1. LICENSE
6
+
7
+ Opmlasssit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8
+
9
+ Opmlasssit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10
+
11
+ You should have received a copy of the GNU General Public License along with Opmlasssit. If not, see <http://www.gnu.org/licenses/>.
12
+
13
+ h1. INTRODUCTION
14
+
15
+ A very simple gem to encapsulate how to create OPML files
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 3
3
+ :major: 0
4
+ :minor: 0
data/lib/opmlassist.rb ADDED
@@ -0,0 +1,83 @@
1
+ =begin
2
+ * Name: opmlassist.rb
3
+ * Description: Generate OPML files (will soon be its own Gem)
4
+ * Author: Pito Salas
5
+ * Copyright: (c) R. Pito Salas and Associates, Inc.
6
+ * Date: January 2009
7
+ * License: GPL
8
+
9
+ This file is part of GovSDK.
10
+
11
+ OpmlA is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ GovSDK is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License
22
+ along with GovSDK. If not, see <http://www.gnu.org/licenses/>.
23
+
24
+ require "ruby-debug"
25
+ Debugger.settings[:autolist] = 1 # list nearby lines on stop
26
+ Debugger.settings[:autoeval] = 1
27
+ Debugger.start
28
+
29
+ =end
30
+ require 'rubygems'
31
+ require 'rexml/document'
32
+ require 'pp'
33
+
34
+ include REXML
35
+
36
+ module OpmlAssist
37
+
38
+ class Opml
39
+ attr_accessor :title, :date_modified, :feeds
40
+
41
+ def initialize(opml_name, group_name, options = {})
42
+ @feeds = []
43
+ @opml_name = opml_name
44
+ @group_name = group_name
45
+ @options = options
46
+ end
47
+
48
+ def xml
49
+ doc = Document.new
50
+ doc << XMLDecl.new
51
+ root = doc.add_element "opml"
52
+ if (!@options[:namespace].nil?)
53
+ namespace_options = @options[:namespace]
54
+ root.add_namespace(namespace_options[:namespace], namespace_options[:value])
55
+ end
56
+ head = root.add_element "head"
57
+ head.add_element("title").add_text(@opml_name)
58
+
59
+ body = root.add_element "body"
60
+ outlinegroup = body.add_element("outline")
61
+ outlinegroup.add_attribute('text', @group_name)
62
+ @feeds.each {|otl| outlinegroup.add_element(otl.xml)}
63
+ doc
64
+ end
65
+ end
66
+
67
+ class Feed
68
+ attr_accessor :text, :type, :xmlUrl
69
+
70
+ def initialize(text, type, xmlurl)
71
+ @text = text
72
+ @type = type
73
+ @xmlUrl = xmlurl
74
+ end
75
+
76
+ def xml
77
+ outline_element = Element.new "outline"
78
+ outline_element.add_attributes( {"text" => @text, "type" => @type, "xmlUrl" => @xmlUrl })
79
+ outline_element
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,54 @@
1
+ =begin
2
+ * Name: src_template.rb
3
+ * Description: Standard header for all source files
4
+ * Author: Pito Salas
5
+ * Copyright: (c) 2009 R. Pito Salas and Associates, Inc.
6
+ * Date: January 2009
7
+ * License: GPL
8
+
9
+ This file is part of GovSDK.
10
+
11
+ OpmlAssist is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ OpmlAssist is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License
22
+ along with OpmlAssist. If not, see <http://www.gnu.org/licenses/>.
23
+
24
+ require "ruby-debug"
25
+ Debugger.settings[:autolist] = 1 # list nearby lines on stop
26
+ Debugger.settings[:autoeval] = 1
27
+ Debugger.start
28
+
29
+ =end
30
+
31
+ require File.dirname(__FILE__) + '/test_helper'
32
+
33
+ class OpmlassistTest < Test::Unit::TestCase
34
+ context "Test context" do
35
+ setup do
36
+
37
+ end
38
+
39
+ should "work with minimal opml case" do
40
+ s = String.new
41
+ Opml.new("hello", "world").xml.write(s)
42
+ assert_equal "<?xml version='1.0'?><opml><head><title>hello</title></head><body><outline text='world'/></body></opml>", s
43
+ end
44
+
45
+ should "work with something a little more complicated" do
46
+ s = String.new
47
+ opml = Opml.new("BlogBridge Feeds", "Good Stuff", {:namespace => {:namespace => "xmlns:bb", :value => "http://blogbridge.com/ns/2006/opml"}})
48
+ opml.feeds << Feed.new("Latest News from Congressman Trent Franks Arizona's 2nd District", "rss", "http://www.house.gov/apps/list/press/az02_franks/RSS.xml")
49
+ opml.feeds << Feed.new("Ellen's Illinois Tenth Congressional District Blog", "rss", "http://ellenofthetenth.blogspot.com/feeds/posts/default")
50
+ opml.xml.write(s)
51
+ assert_equal "<?xml version='1.0'?><opml xmlns:bb='http://blogbridge.com/ns/2006/opml'><head><title>BlogBridge Feeds</title></head><body><outline text='Good Stuff'><outline xmlUrl='http://www.house.gov/apps/list/press/az02_franks/RSS.xml' text='Latest News from Congressman Trent Franks Arizona&apos;s 2nd District' type='rss'/><outline xmlUrl='http://ellenofthetenth.blogspot.com/feeds/posts/default' text='Ellen&apos;s Illinois Tenth Congressional District Blog' type='rss'/></outline></body></opml>", s
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'opmlassist'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pitosalas-opmlassist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Pito Salas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-18 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Create and work with OPML files
17
+ email: rps@salas.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README.textile
26
+ - VERSION.yml
27
+ - lib/opmlassist.rb
28
+ - test/opmlassist_test.rb
29
+ - test/test_helper.rb
30
+ has_rdoc: true
31
+ homepage: http://github.com/pitosalas/opmlassist
32
+ post_install_message:
33
+ rdoc_options:
34
+ - --inline-source
35
+ - --charset=UTF-8
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: "0"
43
+ version:
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.2.0
54
+ signing_key:
55
+ specification_version: 2
56
+ summary: TODO
57
+ test_files: []
58
+