rubypress 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubypress/client.rb +9 -3
- data/lib/rubypress/xml_rpc_retryable.rb +21 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cac472ae4175124874fde244b6c7bc08f223adb9
|
4
|
+
data.tar.gz: aa7eec4aa4b679cdf95b92cfc92ad8885bcfe491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db956a9dcdb0d7e37e819b451a8606592de3cfdc46c637a22099bb694d3919afe9e1a221d60ac9d6cc308b50904a5e47c09112ef2f4f70bb402a1ace98ea1449
|
7
|
+
data.tar.gz: f9d429504b809dfdb8d693effc99ab9dbc0f80763046335f226021abf69e67ed6d5c692f422415c13f3a36e54aed87cb43d4222d553ccbe6a331a5239b4fdf0a
|
data/lib/rubypress/client.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'erb'
|
3
|
+
require 'retryable'
|
4
|
+
|
3
5
|
require_relative 'posts'
|
4
6
|
require_relative 'taxonomies'
|
5
7
|
require_relative 'media'
|
6
8
|
require_relative 'comments'
|
7
9
|
require_relative 'options'
|
8
10
|
require_relative 'users'
|
11
|
+
require_relative 'xml_rpc_retryable'
|
9
12
|
|
10
13
|
module Rubypress
|
11
14
|
|
12
15
|
class Client
|
13
16
|
|
14
17
|
attr_reader :connection
|
15
|
-
attr_accessor :port, :host, :path, :username, :password, :use_ssl, :default_post_fields
|
18
|
+
attr_accessor :port, :host, :path, :username, :password, :use_ssl, :default_post_fields
|
19
|
+
attr_accessor :debug, :http_user, :http_password, :retry_timeouts
|
16
20
|
|
17
21
|
def initialize(options = {})
|
18
22
|
{
|
@@ -25,7 +29,8 @@ module Rubypress
|
|
25
29
|
:default_post_fields => %w(post terms custom_fields),
|
26
30
|
:debug => false,
|
27
31
|
:http_user => nil,
|
28
|
-
:http_password => nil
|
32
|
+
:http_password => nil,
|
33
|
+
:retry_timeouts => false
|
29
34
|
}.merge(options).each{ |opt| self.send("#{opt[0]}=", opt[1]) }
|
30
35
|
self
|
31
36
|
end
|
@@ -33,6 +38,8 @@ module Rubypress
|
|
33
38
|
def connection
|
34
39
|
server = XMLRPC::Client.new(self.host, self.path, self.port,nil,nil,self.http_user,self.http_password,self.use_ssl,nil)
|
35
40
|
server.http_header_extra = {'accept-encoding' => 'identity'}
|
41
|
+
server.extend(XMLRPCRetryable) if retry_timeouts
|
42
|
+
|
36
43
|
@connection = server
|
37
44
|
end
|
38
45
|
|
@@ -64,7 +71,6 @@ module Rubypress
|
|
64
71
|
include Options
|
65
72
|
include Users
|
66
73
|
|
67
|
-
|
68
74
|
end
|
69
75
|
|
70
76
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rubypress
|
2
|
+
module XMLRPCRetryable
|
3
|
+
include Retryable
|
4
|
+
|
5
|
+
RETRY_EXCEPTIONS = [
|
6
|
+
Timeout::Error,
|
7
|
+
Net::ReadTimeout
|
8
|
+
]
|
9
|
+
|
10
|
+
def self.extended(instance)
|
11
|
+
instance.singleton_class.send(:alias_method, :call_without_retry, :call)
|
12
|
+
instance.singleton_class.send(:alias_method, :call, :call_with_retry)
|
13
|
+
end
|
14
|
+
|
15
|
+
def call_with_retry(method, *args)
|
16
|
+
retryable on: RETRY_EXCEPTIONS do
|
17
|
+
call_without_retry(method, *args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubypress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Feldman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Easily access WordPress installations through the WordPress XML-RPC API.
|
14
14
|
This gem exactly mirrors the functionality provided by the WordPress XML-RPC API
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- lib/rubypress/posts.rb
|
28
28
|
- lib/rubypress/taxonomies.rb
|
29
29
|
- lib/rubypress/users.rb
|
30
|
+
- lib/rubypress/xml_rpc_retryable.rb
|
30
31
|
homepage: https://github.com/zachfeldman/rubypress
|
31
32
|
licenses:
|
32
33
|
- GPLv2
|