wrxer 0.1.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.
@@ -0,0 +1,6 @@
1
+ module Wrxer
2
+ class PostmetaCollection < WrxerCollection
3
+ xpath "item"
4
+ collection :postmeta, "//wp:postmeta", Postmeta
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ module Wrxer
2
+ class URIParser
3
+ attr_reader :uri, :xml_document, :document
4
+ def initialize(uri)
5
+ @uri = URI.parse(uri)
6
+
7
+ @uri.open do |file|
8
+ @xml_document = Nokogiri::XML(file.read)
9
+ end
10
+ end
11
+
12
+ def call
13
+ @document ||= Document.call(@xml_document)
14
+ end
15
+
16
+ def inspect
17
+ "#<#{self.class}:0x#{self.object_id.to_s(16)}> { uri: #{@uri.to_s}, xml_document: #{@xml_document.class} }"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Wrxer
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,48 @@
1
+ module Wrxer
2
+
3
+ class WrxerCollection < WrxerObject
4
+ include Enumerable
5
+
6
+ def self.call(document, params = {})
7
+ root = @xpath || params[:xpath]
8
+ unless document.name == root
9
+ document = document.xpath(root)
10
+ end
11
+
12
+ document.nil? ? nil : self.coerce(document)
13
+ end
14
+
15
+ def self.collection(value, xpath, parser)
16
+ @collection = Attribute.new(value, xpath, parser)
17
+ end
18
+
19
+ def self.inherited(subclass)
20
+ subclass.instance_variable_set(:@collection, @collection)
21
+ super
22
+ end
23
+
24
+ def collection
25
+ self.class.instance_variable_get(:@collection)
26
+ end
27
+
28
+ def each(&block)
29
+ document.xpath(collection.xpath).each do |item|
30
+ block.call(
31
+ collection.call(item)
32
+ )
33
+ end
34
+ end
35
+
36
+ def data
37
+ lazy
38
+ end
39
+
40
+ def inspect
41
+ "#<#{self.class}:0x#{self.object_id.to_s(16)}> { data: #{data} } }"
42
+ end
43
+
44
+ def to_hash
45
+ { data: data }
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,52 @@
1
+ module Wrxer
2
+ class WrxerObject < Coercion
3
+ def self.attribute(name, xpath = nil, coercion = TextAttribute)
4
+ @attributes ||= []
5
+ @attributes << Attribute.new(name, xpath || name.to_s, coercion)
6
+ end
7
+
8
+ def self.inherited(subclass)
9
+ subclass.instance_variable_set(:@attributes, @attributes)
10
+ super
11
+ end
12
+
13
+ attr_reader :document
14
+ def initialize(document)
15
+ @document = document
16
+ end
17
+
18
+ def attributes
19
+ self.class.instance_variable_get(:@attributes)
20
+ end
21
+
22
+ def [](key)
23
+ attributes.select { |item| item.name == key.to_sym}.first.call(document)
24
+ end
25
+
26
+ def method_missing(name, *args)
27
+ attributes.select { |item| item.name == name }.first.call(document)
28
+ rescue NoMethodError => e
29
+ raise NoMethodError.new("undefined method '#{name}' for #{self.class}")
30
+ end
31
+
32
+ def to_s(*args)
33
+ JSON.pretty_generate(to_hash)
34
+ end
35
+
36
+ def inspect
37
+ "#<#{self.class}:0x#{self.object_id.to_s(16)}> Attributes: " + JSON.pretty_generate(to_hash)
38
+ end
39
+
40
+ def to_json(*args)
41
+ JSON.generate(to_hash)
42
+ end
43
+
44
+ def to_hash
45
+ attributes.inject({}) do |acc, (key, value)|
46
+ value = key.call(document)
47
+ acc[key.name] = value.respond_to?(:to_hash) ? value.to_hash : value
48
+ acc
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,155 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ This is a WordPress eXtended RSS file generated by WordPress as an export of your site.
4
+ It contains information about your site's posts, pages, comments, categories, and other content.
5
+ You may use this file to transfer that content from one site to another.
6
+ This file is not intended to serve as a complete backup of your site.
7
+
8
+ To import this information into a WordPress site follow these steps:
9
+ 1. Log in to that site as an administrator.
10
+ 2. Go to Tools: Import in the WordPress admin panel.
11
+ 3. Install the "WordPress" importer from the list.
12
+ 4. Activate & Run Importer.
13
+ 5. Upload this file using the form provided on that page.
14
+ 6. You will first be asked to map the authors in this export file to users
15
+ on the site. For each author, you may choose to map to an
16
+ existing user on the site or to create a new user.
17
+ 7. WordPress will then import each of the posts, pages, comments, categories, etc.
18
+ contained in this file into your site.
19
+ -->
20
+ <!-- generator="WordPress.com" created="2015-03-24 21:18"-->
21
+ <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.2/">
22
+ <channel>
23
+ <title>Wrxer News</title>
24
+ <link>https://wrxernews.wordpress.com</link>
25
+ <description>The Most Reliable Source For Wrxer News Since 2007.</description>
26
+ <pubDate>Tue, 24 Mar 2015 21:18:58 +0000</pubDate>
27
+ <language>en</language>
28
+ <wp:wxr_version>1.2</wp:wxr_version>
29
+ <wp:base_site_url>http://wordpress.com/</wp:base_site_url>
30
+ <wp:base_blog_url>https://wrxernews.wordpress.com</wp:base_blog_url>
31
+ <wp:author>
32
+ <wp:author_login>wrxernews</wp:author_login>
33
+ <wp:author_email>wrxernews@example.com</wp:author_email>
34
+ <wp:author_display_name><![CDATA[Wrx News]]></wp:author_display_name>
35
+ <wp:author_first_name><![CDATA[]]></wp:author_first_name>
36
+ <wp:author_last_name><![CDATA[]]></wp:author_last_name>
37
+ </wp:author>
38
+ <generator>http://wordpress.com/</generator>
39
+ <image>
40
+ <url>https://secure.gravatar.com/blavatar/foobar</url>
41
+ <title> &#187; Wrx News</title>
42
+ <link>https://wrxernews.wordpress.com</link>
43
+ </image>
44
+ <item>
45
+ <title>Missing post_id, post_name, post_date_gmt, and category</title>
46
+ <link>https://wrxernews.wordpress.com/2007/11/17/welcome-to-wrxer-news/</link>
47
+ <pubDate>Sat, 17 Nov 2007 21:30:51 +0000</pubDate>
48
+ <dc:creator>wrxernews</dc:creator>
49
+ <guid isPermaLink="false">http://wrxernews.wordpress.com/2007/11/17/welcome-to-wrxer-news/</guid>
50
+ <description/>
51
+ <content:encoded><![CDATA[Welcome to <strong>Wrx News</strong> - The most up-to-date and reliable source for Wrxer news.]]></content:encoded>
52
+ <excerpt:encoded><![CDATA[Excerpt Text]]></excerpt:encoded>
53
+ <wp:post_date>2007-11-17 15:30:51</wp:post_date>
54
+ <wp:comment_status>open</wp:comment_status>
55
+ <wp:ping_status>open</wp:ping_status>
56
+ <wp:status>publish</wp:status>
57
+ <wp:post_parent>0</wp:post_parent>
58
+ <wp:menu_order>0</wp:menu_order>
59
+ <wp:post_type>post</wp:post_type>
60
+ <wp:post_password/>
61
+ <wp:is_sticky>0</wp:is_sticky>
62
+ <category></category>
63
+ <wp:postmeta>
64
+ <wp:meta_key>_wpas_skip_4017882</wp:meta_key>
65
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
66
+ </wp:postmeta>
67
+ <wp:postmeta>
68
+ <wp:meta_key>_wpas_skip_47065</wp:meta_key>
69
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
70
+ </wp:postmeta>
71
+ <wp:postmeta>
72
+ <wp:meta_key>geo_public</wp:meta_key>
73
+ <wp:meta_value><![CDATA[0]]></wp:meta_value>
74
+ </wp:postmeta>
75
+ <wp:postmeta>
76
+ <wp:meta_key>_edit_last</wp:meta_key>
77
+ <wp:meta_value><![CDATA[2223113]]></wp:meta_value>
78
+ </wp:postmeta>
79
+ <wp:comment>
80
+ <wp:comment_id>2</wp:comment_id>
81
+ <wp:comment_author><![CDATA[Kid Vengeance]]></wp:comment_author>
82
+ <wp:comment_author_email>user@example.com</wp:comment_author_email>
83
+ <wp:comment_author_url>http://www.example.com/foobar</wp:comment_author_url>
84
+ <wp:comment_author_IP>69.245.96.185</wp:comment_author_IP>
85
+ <wp:comment_date>2007-11-18 11:45:26</wp:comment_date>
86
+ <wp:comment_date_gmt>2007-11-18 17:45:26</wp:comment_date_gmt>
87
+ <wp:comment_content><![CDATA[I feel this is going to be a great site! ]]></wp:comment_content>
88
+ <wp:comment_approved>1</wp:comment_approved>
89
+ <wp:comment_type/>
90
+ <wp:comment_parent>0</wp:comment_parent>
91
+ <wp:comment_user_id>0</wp:comment_user_id>
92
+ <wp:commentmeta>
93
+ <wp:meta_key>_elasticsearch_indexed_on</wp:meta_key>
94
+ <wp:meta_value>2007-11-18 17:45:26</wp:meta_value>
95
+ </wp:commentmeta>
96
+ </wp:comment>
97
+ <wp:comment>
98
+ <wp:comment_id>2900</wp:comment_id>
99
+ <wp:comment_author><![CDATA[iSyn4LiFe]]></wp:comment_author>
100
+ <wp:comment_author_email>user2@example.com</wp:comment_author_email>
101
+ <wp:comment_author_url/>
102
+ <wp:comment_author_IP>76.31.208.107</wp:comment_author_IP>
103
+ <wp:comment_date>2008-11-16 10:12:08</wp:comment_date>
104
+ <wp:comment_date_gmt>2008-11-16 17:12:08</wp:comment_date_gmt>
105
+ <wp:comment_content><![CDATA[I agree with Kid, that this is gonna be a great site so yeah good luck with it!!]]></wp:comment_content>
106
+ <wp:comment_approved>1</wp:comment_approved>
107
+ <wp:comment_type/>
108
+ <wp:comment_parent>0</wp:comment_parent>
109
+ <wp:comment_user_id>0</wp:comment_user_id>
110
+ <wp:commentmeta>
111
+ <wp:meta_key>_elasticsearch_indexed_on</wp:meta_key>
112
+ <wp:meta_value>2008-11-16 17:12:08</wp:meta_value>
113
+ </wp:commentmeta>
114
+ </wp:comment>
115
+ </item>
116
+ <item>
117
+ <title>Missing Category</title>
118
+ <link>https://wrxernews.wordpress.com/2007/11/17/wrxer-on-the-radio/</link>
119
+ <pubDate>Sat, 17 Nov 2007 21:33:08 +0000</pubDate>
120
+ <dc:creator>wrxernews</dc:creator>
121
+ <guid isPermaLink="false">http://wrxernews.wordpress.com/2007/11/17/wrxer-on-the-radio/</guid>
122
+ <description/>
123
+ <content:encoded><![CDATA[On November 19th, <a href="http://www.example.com/wrxer" target="_blank">wrxer</a> will be featured guests on the radio.]]></content:encoded>
124
+ <excerpt:encoded><![CDATA[]]></excerpt:encoded>
125
+ <wp:post_id>5</wp:post_id>
126
+ <wp:post_date>2007-11-17 15:33:08</wp:post_date>
127
+ <wp:post_date_gmt>2007-11-17 21:33:08</wp:post_date_gmt>
128
+ <wp:comment_status>open</wp:comment_status>
129
+ <wp:ping_status>open</wp:ping_status>
130
+ <wp:post_name>wrxer-on-the-radio</wp:post_name>
131
+ <wp:status>publish</wp:status>
132
+ <wp:post_parent>0</wp:post_parent>
133
+ <wp:menu_order>0</wp:menu_order>
134
+ <wp:post_type>post</wp:post_type>
135
+ <wp:post_password/>
136
+ <wp:is_sticky>0</wp:is_sticky>
137
+ <wp:postmeta>
138
+ <wp:meta_key>_edit_last</wp:meta_key>
139
+ <wp:meta_value><![CDATA[2223113]]></wp:meta_value>
140
+ </wp:postmeta>
141
+ <wp:postmeta>
142
+ <wp:meta_key>geo_public</wp:meta_key>
143
+ <wp:meta_value><![CDATA[0]]></wp:meta_value>
144
+ </wp:postmeta>
145
+ <wp:postmeta>
146
+ <wp:meta_key>_wpas_skip_4017882</wp:meta_key>
147
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
148
+ </wp:postmeta>
149
+ <wp:postmeta>
150
+ <wp:meta_key>_wpas_skip_47065</wp:meta_key>
151
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
152
+ </wp:postmeta>
153
+ </item>
154
+ </channel>
155
+ </rss>
@@ -0,0 +1,159 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ This is a WordPress eXtended RSS file generated by WordPress as an export of your site.
4
+ It contains information about your site's posts, pages, comments, categories, and other content.
5
+ You may use this file to transfer that content from one site to another.
6
+ This file is not intended to serve as a complete backup of your site.
7
+
8
+ To import this information into a WordPress site follow these steps:
9
+ 1. Log in to that site as an administrator.
10
+ 2. Go to Tools: Import in the WordPress admin panel.
11
+ 3. Install the "WordPress" importer from the list.
12
+ 4. Activate & Run Importer.
13
+ 5. Upload this file using the form provided on that page.
14
+ 6. You will first be asked to map the authors in this export file to users
15
+ on the site. For each author, you may choose to map to an
16
+ existing user on the site or to create a new user.
17
+ 7. WordPress will then import each of the posts, pages, comments, categories, etc.
18
+ contained in this file into your site.
19
+ -->
20
+ <!-- generator="WordPress.com" created="2015-03-24 21:18"-->
21
+ <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.2/">
22
+ <channel>
23
+ <title>Wrxer News</title>
24
+ <link>https://wrxernews.wordpress.com</link>
25
+ <description>The Most Reliable Source For Wrxer News Since 2007.</description>
26
+ <pubDate>Tue, 24 Mar 2015 21:18:58 +0000</pubDate>
27
+ <language>en</language>
28
+ <wp:wxr_version>1.2</wp:wxr_version>
29
+ <wp:base_site_url>http://wordpress.com/</wp:base_site_url>
30
+ <wp:base_blog_url>https://wrxernews.wordpress.com</wp:base_blog_url>
31
+ <wp:author>
32
+ <wp:author_login>wrxernews</wp:author_login>
33
+ <wp:author_email>wrxernews@example.com</wp:author_email>
34
+ <wp:author_display_name><![CDATA[Wrxer News]]></wp:author_display_name>
35
+ <wp:author_first_name><![CDATA[]]></wp:author_first_name>
36
+ <wp:author_last_name><![CDATA[]]></wp:author_last_name>
37
+ </wp:author>
38
+ <generator>http://wordpress.com/</generator>
39
+ <image>
40
+ <url>https://secure.gravatar.com/blavatar/foobar</url>
41
+ <title> &#187; Wrxer News</title>
42
+ <link>https://wrxernews.wordpress.com</link>
43
+ </image>
44
+ <item>
45
+ <title>Welcome To Wrxer News.</title>
46
+ <link>https://wrxernews.wordpress.com/2007/11/17/welcome-to-wrxer-news/</link>
47
+ <pubDate>Sat, 17 Nov 2007 21:30:51 +0000</pubDate>
48
+ <dc:creator>wrxernews</dc:creator>
49
+ <guid isPermaLink="false">http://wrxernews.wordpress.com/2007/11/17/welcome-to-wrxer-news/</guid>
50
+ <description/>
51
+ <content:encoded><![CDATA[Welcome to <strong>Wrxer News</strong> - The most up-to-date and reliable source for Wrxer news.]]></content:encoded>
52
+ <excerpt:encoded><![CDATA[Excerpt Text]]></excerpt:encoded>
53
+ <wp:post_id>3</wp:post_id>
54
+ <wp:post_date>2007-11-17 15:30:51</wp:post_date>
55
+ <wp:post_date_gmt>2007-11-17 21:30:51</wp:post_date_gmt>
56
+ <wp:comment_status>open</wp:comment_status>
57
+ <wp:ping_status>open</wp:ping_status>
58
+ <wp:post_name>welcome-to-wrxer-news</wp:post_name>
59
+ <wp:status>publish</wp:status>
60
+ <wp:post_parent>0</wp:post_parent>
61
+ <wp:menu_order>0</wp:menu_order>
62
+ <wp:post_type>post</wp:post_type>
63
+ <wp:post_password/>
64
+ <wp:is_sticky>0</wp:is_sticky>
65
+ <category domain="category" nicename="wrxer-news"><![CDATA[Wrxer News]]></category>
66
+ <wp:postmeta>
67
+ <wp:meta_key>_wpas_skip_4017882</wp:meta_key>
68
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
69
+ </wp:postmeta>
70
+ <wp:postmeta>
71
+ <wp:meta_key>_wpas_skip_47065</wp:meta_key>
72
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
73
+ </wp:postmeta>
74
+ <wp:postmeta>
75
+ <wp:meta_key>geo_public</wp:meta_key>
76
+ <wp:meta_value><![CDATA[0]]></wp:meta_value>
77
+ </wp:postmeta>
78
+ <wp:postmeta>
79
+ <wp:meta_key>_edit_last</wp:meta_key>
80
+ <wp:meta_value><![CDATA[2223113]]></wp:meta_value>
81
+ </wp:postmeta>
82
+ <wp:comment>
83
+ <wp:comment_id>2</wp:comment_id>
84
+ <wp:comment_author><![CDATA[Kid Vengeance]]></wp:comment_author>
85
+ <wp:comment_author_email>user@example.com</wp:comment_author_email>
86
+ <wp:comment_author_url>http://www.example.com/foobar</wp:comment_author_url>
87
+ <wp:comment_author_IP>69.245.96.185</wp:comment_author_IP>
88
+ <wp:comment_date>2007-11-18 11:45:26</wp:comment_date>
89
+ <wp:comment_date_gmt>2007-11-18 17:45:26</wp:comment_date_gmt>
90
+ <wp:comment_content><![CDATA[I feel this is going to be a great site! ]]></wp:comment_content>
91
+ <wp:comment_approved>1</wp:comment_approved>
92
+ <wp:comment_type/>
93
+ <wp:comment_parent>0</wp:comment_parent>
94
+ <wp:comment_user_id>0</wp:comment_user_id>
95
+ <wp:commentmeta>
96
+ <wp:meta_key>_elasticsearch_indexed_on</wp:meta_key>
97
+ <wp:meta_value>2007-11-18 17:45:26</wp:meta_value>
98
+ </wp:commentmeta>
99
+ </wp:comment>
100
+ <wp:comment>
101
+ <wp:comment_id>2900</wp:comment_id>
102
+ <wp:comment_author><![CDATA[iSyn4LiFe]]></wp:comment_author>
103
+ <wp:comment_author_email>user2@example.com</wp:comment_author_email>
104
+ <wp:comment_author_url/>
105
+ <wp:comment_author_IP>76.31.208.107</wp:comment_author_IP>
106
+ <wp:comment_date>2008-11-16 10:12:08</wp:comment_date>
107
+ <wp:comment_date_gmt>2008-11-16 17:12:08</wp:comment_date_gmt>
108
+ <wp:comment_content><![CDATA[I agree with Kid, that this is gonna be a great site so yeah good luck with it!!]]></wp:comment_content>
109
+ <wp:comment_approved>1</wp:comment_approved>
110
+ <wp:comment_type/>
111
+ <wp:comment_parent>0</wp:comment_parent>
112
+ <wp:comment_user_id>0</wp:comment_user_id>
113
+ <wp:commentmeta>
114
+ <wp:meta_key>_elasticsearch_indexed_on</wp:meta_key>
115
+ <wp:meta_value>2008-11-16 17:12:08</wp:meta_value>
116
+ </wp:commentmeta>
117
+ </wp:comment>
118
+ </item>
119
+ <item>
120
+ <title>Wrxer on the Radio</title>
121
+ <link>https://wrxernews.wordpress.com/2007/11/17/wrxer-on-the-radio/</link>
122
+ <pubDate>Sat, 17 Nov 2007 21:33:08 +0000</pubDate>
123
+ <dc:creator>wrxernews</dc:creator>
124
+ <guid isPermaLink="false">http://wrxernews.wordpress.com/2007/11/17/wrxer-on-the-radio/</guid>
125
+ <description/>
126
+ <content:encoded><![CDATA[On November 19th, <a href="http://www.example.com/wrxer" target="_blank">wrxer</a> will be featured guests on the radio.]]></content:encoded>
127
+ <excerpt:encoded><![CDATA[]]></excerpt:encoded>
128
+ <wp:post_id>5</wp:post_id>
129
+ <wp:post_date>2007-11-17 15:33:08</wp:post_date>
130
+ <wp:post_date_gmt>2007-11-17 21:33:08</wp:post_date_gmt>
131
+ <wp:comment_status>open</wp:comment_status>
132
+ <wp:ping_status>open</wp:ping_status>
133
+ <wp:post_name>wrxer-on-the-radio</wp:post_name>
134
+ <wp:status>publish</wp:status>
135
+ <wp:post_parent>0</wp:post_parent>
136
+ <wp:menu_order>0</wp:menu_order>
137
+ <wp:post_type>post</wp:post_type>
138
+ <wp:post_password/>
139
+ <wp:is_sticky>0</wp:is_sticky>
140
+ <category domain="category" nicename="radio"><![CDATA[Radio]]></category>
141
+ <wp:postmeta>
142
+ <wp:meta_key>_edit_last</wp:meta_key>
143
+ <wp:meta_value><![CDATA[2223113]]></wp:meta_value>
144
+ </wp:postmeta>
145
+ <wp:postmeta>
146
+ <wp:meta_key>geo_public</wp:meta_key>
147
+ <wp:meta_value><![CDATA[0]]></wp:meta_value>
148
+ </wp:postmeta>
149
+ <wp:postmeta>
150
+ <wp:meta_key>_wpas_skip_4017882</wp:meta_key>
151
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
152
+ </wp:postmeta>
153
+ <wp:postmeta>
154
+ <wp:meta_key>_wpas_skip_47065</wp:meta_key>
155
+ <wp:meta_value><![CDATA[1]]></wp:meta_value>
156
+ </wp:postmeta>
157
+ </item>
158
+ </channel>
159
+ </rss>