wordpress_import 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.
- checksums.yaml +7 -0
- data/lib/wordpress_import.rb +44 -0
- data/lib/wordpress_import/about.rb +23 -0
- data/lib/wordpress_import/attachment.rb +19 -0
- data/lib/wordpress_import/author.rb +12 -0
- data/lib/wordpress_import/category.rb +12 -0
- data/lib/wordpress_import/post.rb +26 -0
- data/lib/wordpress_import/tag.rb +11 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89b8eb5dc1faaec8051844ecc779e37d614b837b
|
4
|
+
data.tar.gz: 8724ee25e9da3ac95de9f0e2560e0e77614d4895
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 318af8dc3d719f9f617512fa854ab572676f502d361fad19f4e1ac5b6c81aecb17988f443239c74cc9eab6adb5ae789eb2cc9aba675842ca65777d1ee4d5c4c7
|
7
|
+
data.tar.gz: d2ddb1d3d41745955757057bb6a53f506d22e066e9a5a9610681ae3ed9ae61b3292ab8dffff7a87573035f8b2fea72b8bd99c84206fe546e1def857ef32fe4f8
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
require 'wordpress_import/author'
|
5
|
+
require 'wordpress_import/category'
|
6
|
+
require 'wordpress_import/tag'
|
7
|
+
require 'wordpress_import/attachment'
|
8
|
+
require 'wordpress_import/about'
|
9
|
+
require 'wordpress_import/post'
|
10
|
+
|
11
|
+
module WordpressImport
|
12
|
+
class << self
|
13
|
+
def new(content)
|
14
|
+
@doc = Nokogiri::XML(content)
|
15
|
+
puts @doc.errors
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def authors
|
20
|
+
@doc.xpath('//wp:author').map { |author| Author.new(author) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def categories
|
24
|
+
@doc.xpath('//wp:category').map { |category| Category.new(category) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def tags
|
28
|
+
@doc.xpath('//wp:tag').map { |tag| Tag.new(tag) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def items
|
32
|
+
@doc.xpath('//item').map do |item|
|
33
|
+
case item.xpath('wp:post_type').first.content
|
34
|
+
when 'attachment'
|
35
|
+
Attachment.new(item)
|
36
|
+
when 'about'
|
37
|
+
About.new(item)
|
38
|
+
when 'post'
|
39
|
+
Post.new(item)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module WordpressImport
|
2
|
+
class About
|
3
|
+
attr_accessor :id, :parent, :link, :date, :creator, :name, :title, :content, :excerpt, :meta
|
4
|
+
|
5
|
+
def initialize(node)
|
6
|
+
@id = node.xpath('wp:post_id').first.content
|
7
|
+
@parent = node.xpath('wp:post_parent').first.content
|
8
|
+
@link = node.xpath('link').first.content
|
9
|
+
@date = node.xpath('wp:post_date').first.content
|
10
|
+
@creator = node.xpath('dc:creator').first.content
|
11
|
+
@name = node.xpath('wp:post_name').first.content
|
12
|
+
|
13
|
+
@title = node.xpath('title').first.content
|
14
|
+
@content = node.xpath('content:encoded').first.content
|
15
|
+
@excerpt = node.xpath('excerpt:encoded').first.content
|
16
|
+
|
17
|
+
@meta = {}
|
18
|
+
node.xpath('wp:postmeta').each do |postmeta|
|
19
|
+
@meta[postmeta.xpath('wp:meta_key').first.content] = postmeta.xpath('wp:meta_value').first.content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module WordpressImport
|
2
|
+
class Attachment
|
3
|
+
attr_accessor :id, :parent, :url, :date, :creator, :name, :meta
|
4
|
+
|
5
|
+
def initialize(node)
|
6
|
+
@id = node.xpath('wp:post_id').first.content.to_i
|
7
|
+
@parent = node.xpath('wp:post_parent').first.content
|
8
|
+
@url = node.xpath('wp:attachment_url').first.content
|
9
|
+
@date = node.xpath('wp:post_date').first.content
|
10
|
+
@creator = node.xpath('dc:creator').first.content
|
11
|
+
@name = node.xpath('wp:post_name').first.content
|
12
|
+
|
13
|
+
@meta = {}
|
14
|
+
node.xpath('wp:postmeta').each do |postmeta|
|
15
|
+
@meta[postmeta.xpath('wp:meta_key').first.content] = postmeta.xpath('wp:meta_value').first.content
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module WordpressImport
|
2
|
+
class Author
|
3
|
+
attr_accessor :id, :login, :email, :display_name
|
4
|
+
|
5
|
+
def initialize(node)
|
6
|
+
@id = node.xpath('wp:author_id').first.content
|
7
|
+
@login = node.xpath('wp:author_login').first.content
|
8
|
+
@email = node.xpath('wp:author_email').first.content
|
9
|
+
@display_name = node.xpath('wp:author_display_name').first.content
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module WordpressImport
|
2
|
+
class Category
|
3
|
+
attr_accessor :id, :nicename, :parent, :name
|
4
|
+
|
5
|
+
def initialize(node)
|
6
|
+
@id = node.xpath('wp:term_id').first.content
|
7
|
+
@nicename = node.xpath('wp:category_nicename').first.content
|
8
|
+
@parent = node.xpath('wp:category_parent').first.content
|
9
|
+
@name = node.xpath('wp:cat_name').first.content
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module WordpressImport
|
2
|
+
class Post
|
3
|
+
attr_accessor :id, :parent, :link, :date, :creator, :name, :title, :content, :excerpt, :status, :meta, :tags, :categories
|
4
|
+
|
5
|
+
def initialize(node)
|
6
|
+
@id = node.xpath('wp:post_id').first.content
|
7
|
+
@parent = node.xpath('wp:post_parent').first.content
|
8
|
+
@link = node.xpath('link').first.content
|
9
|
+
@date = node.xpath('wp:post_date').first.content
|
10
|
+
@creator = node.xpath('dc:creator').first.content
|
11
|
+
@name = node.xpath('wp:post_name').first.content
|
12
|
+
@status = node.xpath('wp:status').first.content
|
13
|
+
|
14
|
+
@title = node.xpath('title').first.content
|
15
|
+
@content = node.xpath('content:encoded').first.content
|
16
|
+
@excerpt = node.xpath('excerpt:encoded').first.content
|
17
|
+
|
18
|
+
@tags = node.xpath('category[@domain="post_tag"]').map { |t| t.attr('nicename') }
|
19
|
+
@categories = node.xpath('category[@domain="category"]').map { |t| t.attr('nicename') }
|
20
|
+
@meta = {}
|
21
|
+
node.xpath('wp:postmeta').each do |postmeta|
|
22
|
+
@meta[postmeta.xpath('wp:meta_key').first.content] = postmeta.xpath('wp:meta_value').first.content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module WordpressImport
|
2
|
+
class Tag
|
3
|
+
attr_accessor :id, :slug, :name
|
4
|
+
|
5
|
+
def initialize(node)
|
6
|
+
@id = node.xpath('wp:term_id').first.content
|
7
|
+
@slug = node.xpath('wp:tag_slug').first.content
|
8
|
+
@name = node.xpath('wp:tag_name').first.content
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordpress_import
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Valentin Arkhipov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
description: Parse wordpress export file into structured ruby
|
28
|
+
email: hello@madespecial.co.uk
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/wordpress_import.rb
|
34
|
+
- lib/wordpress_import/about.rb
|
35
|
+
- lib/wordpress_import/attachment.rb
|
36
|
+
- lib/wordpress_import/author.rb
|
37
|
+
- lib/wordpress_import/category.rb
|
38
|
+
- lib/wordpress_import/post.rb
|
39
|
+
- lib/wordpress_import/tag.rb
|
40
|
+
homepage: https://github.com/adaline/wordpress_import
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.5.1
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Import wordpress exports!
|
64
|
+
test_files: []
|