opml-parser 1.0.0 → 1.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/.gitignore +2 -0
- data/lib/opml-parser/version.rb +1 -1
- data/lib/opml-parser.rb +9 -9
- metadata +2 -2
data/lib/opml-parser/version.rb
CHANGED
data/lib/opml-parser.rb
CHANGED
@@ -10,24 +10,23 @@ require 'opml-parser/version'
|
|
10
10
|
# Kevin Gillieron <kevin.gillieron@gw-computing.net>
|
11
11
|
#
|
12
12
|
module OpmlParser
|
13
|
-
#
|
13
|
+
# OPML outline element
|
14
14
|
class Outline
|
15
|
-
#
|
16
|
-
# and htmlUrl)
|
15
|
+
# Outline attributes (generally text, title, type, xmlUrl and htmlUrl)
|
17
16
|
attr_reader :attributes
|
18
17
|
|
19
|
-
# Initializes an
|
18
|
+
# Initializes an Outline object
|
20
19
|
#
|
21
20
|
# Arguments:
|
22
21
|
# attributes: (Hash) A Hash table that contains the attributes of the
|
23
22
|
# outline.
|
24
23
|
#
|
25
|
-
def initialize(attributes=
|
24
|
+
def initialize(attributes={})
|
26
25
|
@attributes = attributes
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
#
|
29
|
+
# Convert an OPML String to an array of Outline objects.
|
31
30
|
#
|
32
31
|
# Arguments:
|
33
32
|
# contents: (String) A String that contains the OMPL
|
@@ -40,14 +39,15 @@ module OpmlParser
|
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
|
-
#
|
42
|
+
# Export an OPML String to an array of Outline objects.
|
44
43
|
#
|
45
44
|
# Arguments:
|
46
45
|
# feeds: (Array of Outline) An array of Outline objects
|
47
|
-
|
46
|
+
# title: (String) Title of the OPML document
|
47
|
+
def export(feeds, title="No title")
|
48
48
|
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
49
49
|
xml.opml(version: "1.0") do
|
50
|
-
xml.head { xml.title
|
50
|
+
xml.head { xml.title title }
|
51
51
|
xml.body { feeds.each { |outline| xml.outline(outline.attributes) }}
|
52
52
|
end
|
53
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opml-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05
|
12
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|