wordpress-wxr 0.5.2 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca849d840d5742c4224586ca255abcabccc5d68a
4
- data.tar.gz: 008077700d75be02a58e6f65d9906d4700f13151
3
+ metadata.gz: 9ec932de8ceddb6cb6ff5b5eb55518ef77f8c9b0
4
+ data.tar.gz: d1c3f6372506d72d8882a2166e5c6a485f4c2484
5
5
  SHA512:
6
- metadata.gz: 4f647aa4f3a5fb7b75dc362c26a4082df2311b20832e18943f3f0a6fcc937fd7b83e6210d82bdf75d12302fd558d700d9a355e7b571f697f4d5ece68963bf1b0
7
- data.tar.gz: 8c210f3f26a04cec693c681591bd577e1574a48904c856858da1f36f93b16d2792576924ab761cc023370cf8f057b12c2c87c2d94bd774335e49cecaf84d8b23
6
+ metadata.gz: 742fb23f7f346afde7ef3beaef893b3c81e90806d89fae6907e9c3035d1424e5ef1b7d1ca3441c5b5ebfa8b1386e52979a846d91a06e810949374ea2767fec9d
7
+ data.tar.gz: a80ebcc775f5638719c552f94798b4e50f6745593d1e0508c8096c1ebe239862faa4e5b6bcad0be91478a5cdf4779e065022f6ba4c26651eb906c7ad38b5a6a2
@@ -5,23 +5,35 @@ module Wordpress
5
5
  class WXR
6
6
  class DirectoryListing < Item
7
7
  def content
8
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_company_bio']").at_xpath('wp:meta_value').text
8
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_company_bio']").at_xpath('wp:meta_value').try(:text)
9
9
  end
10
10
 
11
11
  def directory_name
12
- node.xpath("//wp:postmeta[wp:meta_key = 'directory_type']").at_xpath('wp:meta_value').text
12
+ node.xpath("wp:postmeta[wp:meta_key = 'directory_type']").at_xpath('wp:meta_value').try(:text)
13
13
  end
14
14
 
15
15
  def contact_name
16
- node.xpath("//wp:postmeta[wp:meta_key = 'contact_details_0_contact_name']").at_xpath('wp:meta_value').text
16
+ node.xpath("wp:postmeta[wp:meta_key = 'contact_details_0_contact_name']").at_xpath('wp:meta_value').try(:text)
17
17
  end
18
18
 
19
19
  def contact_email
20
- node.xpath("//wp:postmeta[wp:meta_key = 'contact_details_0_email']").at_xpath('wp:meta_value').text
20
+ node.xpath("wp:postmeta[wp:meta_key = 'contact_details_0_email']").at_xpath('wp:meta_value').try(:text)
21
21
  end
22
22
 
23
23
  def contact_phone
24
- node.xpath("//wp:postmeta[wp:meta_key = 'contact_details_0_phone']").at_xpath('wp:meta_value').text
24
+ node.xpath("wp:postmeta[wp:meta_key = 'contact_details_0_phone']").at_xpath('wp:meta_value').try(:text)
25
+ end
26
+
27
+ def country
28
+ unserialize('company_details_0_country_of_origin', 'country_name')
29
+ end
30
+
31
+ def state
32
+ unserialize('company_details_0_state_of_origin', 'state_name')
33
+ end
34
+
35
+ def city
36
+ unserialize('company_details_0_city_of_origin', 'city_name')
25
37
  end
26
38
 
27
39
  def country
@@ -37,59 +49,72 @@ module Wordpress
37
49
  end
38
50
 
39
51
  def website
40
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_company_website']").at_xpath('wp:meta_value').text
52
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_company_website']").at_xpath('wp:meta_value').try(:text)
41
53
  end
42
54
 
43
55
  def years_established
44
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_number_of_years_established']").at_xpath('wp:meta_value').text
56
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_number_of_years_established']").at_xpath('wp:meta_value').try(:text)
45
57
  end
46
58
 
47
59
  def founder
48
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_founder']").at_xpath('wp:meta_value').text
60
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_founder']").at_xpath('wp:meta_value').try(:text)
49
61
  end
50
62
 
51
63
  def ceo
52
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_ceo']").at_xpath('wp:meta_value').text
64
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_ceo']").at_xpath('wp:meta_value').try(:text)
53
65
  end
54
66
 
55
67
  def coo
56
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_coo']").at_xpath('wp:meta_value').text
68
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_coo']").at_xpath('wp:meta_value').try(:text)
57
69
  end
58
70
 
59
71
  def cto
60
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_cto']").at_xpath('wp:meta_value').text
72
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_cto']").at_xpath('wp:meta_value').try(:text)
61
73
  end
62
74
 
63
75
  def cfo
64
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_cfo']").at_xpath('wp:meta_value').text
76
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_cfo']").at_xpath('wp:meta_value').try(:text)
65
77
  end
66
78
 
67
79
  def annual_revenues
68
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_annual_revenues']").at_xpath('wp:meta_value').text
80
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_annual_revenues']").at_xpath('wp:meta_value').try(:text)
69
81
  end
70
82
 
71
83
  def market_segment
72
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_portal_market_segment']").at_xpath('wp:meta_value').text
84
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_portal_market_segment']").at_xpath('wp:meta_value').try(:text)
73
85
  end
74
86
 
75
87
  def business_model
76
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_portal_business_model']").at_xpath('wp:meta_value').text
88
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_portal_business_model']").at_xpath('wp:meta_value').try(:text)
77
89
  end
78
90
 
79
91
  def market_coverage
80
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_portal_market_coverage']").at_xpath('wp:meta_value').text
92
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_portal_market_coverage']").at_xpath('wp:meta_value').try(:text)
81
93
  end
82
94
 
83
95
  def average_monthly_traffic
84
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_average_monthly_traffic']").at_xpath('wp:meta_value').text
96
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_average_monthly_traffic']").at_xpath('wp:meta_value').try(:text)
85
97
  end
86
98
 
87
99
  def data_source
88
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_data_source']").at_xpath('wp:meta_value').text
100
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_data_source']").at_xpath('wp:meta_value').try(:text)
89
101
  end
90
102
 
91
103
  def technology_platform
92
- node.xpath("//wp:postmeta[wp:meta_key = 'company_details_0_technology_platform']").at_xpath('wp:meta_value').text
104
+ node.xpath("wp:postmeta[wp:meta_key = 'company_details_0_technology_platform']").at_xpath('wp:meta_value').try(:text)
105
+ end
106
+
107
+ private
108
+
109
+ def unserialize(xml_field_name, key)
110
+ return unless node.xpath("wp:postmeta[wp:meta_key = '#{xml_field_name}']").at_xpath('wp:meta_value')
111
+ serialized_php = node.xpath("wp:postmeta[wp:meta_key = '#{xml_field_name}']").at_xpath('wp:meta_value').text
112
+ begin
113
+ unserialized_php = PHP.unserialize(serialized_php)
114
+ !!unserialized_php[key] && !unserialized_php[key].empty? ? unserialized_php[key] : ''
115
+ rescue
116
+ ''
117
+ end
93
118
  end
94
119
 
95
120
  private
@@ -1,5 +1,5 @@
1
1
  module Wordpress
2
2
  class WXR
3
- VERSION = '0.5.2'.freeze
3
+ VERSION = '0.6'.freeze
4
4
  end
5
5
  end
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.5.2
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - ePublishing, inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler