wordpress-wxr 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/lib/wordpress/wxr/attachment.rb +18 -1
- data/lib/wordpress/wxr/item.rb +10 -0
- data/lib/wordpress/wxr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39fb32a9a5dc0807f09ab1ecc70675e2c14f5347
|
4
|
+
data.tar.gz: 52775664ca45caa9ed25277d2d87b1d6871ecdb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 830e02fb518a56caa2c0fcc8a43ea27b66c8f2659a29c0829720ea702aa1178a6fd05178339eb03e4ab55aee1c4db57a560a7529bde91338d0337a39cc3ce48b
|
7
|
+
data.tar.gz: c655f2ba6a9db861a611e22b0a5135003ad96ee2d02c90b83f99e3f081df346e5e0d86e3c1b4996a2acbf121984c1928e819be055f7200283d5973b8eef7c60e
|
@@ -1,11 +1,28 @@
|
|
1
1
|
require 'wordpress/wxr/item'
|
2
|
+
require 'cgi'
|
2
3
|
require 'uri'
|
3
4
|
|
4
5
|
module Wordpress
|
5
6
|
class WXR
|
6
7
|
class Attachment < Item
|
8
|
+
# Internal: Add methods to normalize potential utf-8 encodings into
|
9
|
+
# standard ASCII escaping to feed into URI which dies on utf-8 characters.
|
10
|
+
module Refinements
|
11
|
+
refine String do
|
12
|
+
def replace_spaces_with_hex_encoding
|
13
|
+
gsub(/\s/, '%20')
|
14
|
+
end
|
15
|
+
|
16
|
+
def percent_encode_non_ascii
|
17
|
+
encode(Encoding.find('ASCII'), invalid: :replace, fallback: ->(char) { CGI.escape(char) })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
using Refinements
|
23
|
+
|
7
24
|
def url
|
8
|
-
URI(node.xpath('wp:attachment_url').text)
|
25
|
+
URI(String(node.xpath('wp:attachment_url').text).replace_spaces_with_hex_encoding.percent_encode_non_ascii)
|
9
26
|
end
|
10
27
|
end
|
11
28
|
end
|
data/lib/wordpress/wxr/item.rb
CHANGED
@@ -81,6 +81,10 @@ module Wordpress
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
def attachments
|
85
|
+
wxr.attachments.select { |attachment| attachment.parent_id == id }
|
86
|
+
end
|
87
|
+
|
84
88
|
def pages
|
85
89
|
wxr.pages.select { |page| page.parent_id == id }
|
86
90
|
end
|
@@ -89,6 +93,12 @@ module Wordpress
|
|
89
93
|
Integer(node.xpath('wp:post_parent').text)
|
90
94
|
end
|
91
95
|
|
96
|
+
def meta
|
97
|
+
node.xpath('wp:postmeta').each_with_object({}) { |meta, hash|
|
98
|
+
hash[meta.xpath('wp:meta_key').text] = meta.xpath('wp:meta_value').text
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
92
102
|
# def comments
|
93
103
|
# node.xpath('wp:comment').map do |comment_node|
|
94
104
|
# Comment.new(comment_node)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordpress-wxr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ePublishing, inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|