Class: Rubypress::Client
- Inherits:
-
Object
- Object
- Rubypress::Client
- Defined in:
- lib/rubypress/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#cookie ⇒ Object
Returns the value of attribute cookie.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#default_post_fields ⇒ Object
Returns the value of attribute default_post_fields.
-
#host ⇒ Object
Returns the value of attribute host.
-
#http_password ⇒ Object
Returns the value of attribute http_password.
-
#http_user ⇒ Object
Returns the value of attribute http_user.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#retry_timeouts ⇒ Object
Returns the value of attribute retry_timeouts.
-
#ssl_port ⇒ Object
Returns the value of attribute ssl_port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(method, options) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Users
#editProfile, #getAuthors, #getProfile, #getUser, #getUsers, #getUsersBlogs
Methods included from Options
Methods included from Comments
#deleteComment, #editComment, #getComment, #getCommentCount, #getCommentStatusList, #getComments, #newComment
Methods included from Media
#getMediaItem, #getMediaLibrary, #uploadFile
Methods included from Taxonomies
#deleteTerm, #editTerm, #getTaxonomies, #getTaxonomy, #getTerm, #getTerms, #newTerm
Methods included from Posts
#deletePost, #editPost, #getPost, #getPostFormats, #getPostStatusList, #getPostType, #getPostTypes, #getPosts, #newPost
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubypress/client.rb', line 21 def initialize( = {}) { :port => 80, :ssl_port => 443, :use_ssl => false, :host => nil, :path => '/xmlrpc.php', :username => nil, :password => nil, :default_post_fields => %w(post terms custom_fields), :debug => false, :http_user => nil, :http_password => nil, :retry_timeouts => false, :timeout => 30, :cookie => nil }.merge().each{ |opt| self.send("#{opt[0]}=", opt[1]) } self end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
17 18 19 |
# File 'lib/rubypress/client.rb', line 17 def connection @connection end |
#cookie ⇒ Object
Returns the value of attribute cookie.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def @cookie end |
#debug ⇒ Object
Returns the value of attribute debug.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def debug @debug end |
#default_post_fields ⇒ Object
Returns the value of attribute default_post_fields.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def default_post_fields @default_post_fields end |
#host ⇒ Object
Returns the value of attribute host.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def host @host end |
#http_password ⇒ Object
Returns the value of attribute http_password.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def http_password @http_password end |
#http_user ⇒ Object
Returns the value of attribute http_user.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def http_user @http_user end |
#password ⇒ Object
Returns the value of attribute password.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def port @port end |
#retry_timeouts ⇒ Object
Returns the value of attribute retry_timeouts.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def retry_timeouts @retry_timeouts end |
#ssl_port ⇒ Object
Returns the value of attribute ssl_port.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def ssl_port @ssl_port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def timeout @timeout end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def use_ssl @use_ssl end |
#username ⇒ Object
Returns the value of attribute username.
18 19 20 |
# File 'lib/rubypress/client.rb', line 18 def username @username end |
Class Method Details
.default ⇒ Object
52 53 54 |
# File 'lib/rubypress/client.rb', line 52 def self.default self.new(:host => ENV['WORDPRESS_HOST'], :port => 80, :username => ENV['WORDPRESS_USERNAME'], :password => ENV['WORDPRESS_PASSWORD'], :use_ssl => false) end |
Instance Method Details
#execute(method, options) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rubypress/client.rb', line 56 def execute(method, ) args = [] = { :blog_id => 0, :username => self.username, :password => self.password } .deep_merge!().each{|option| args.push(option[1]) if !option[1].nil?} method = "wp.#{method}" unless method.include?('.') if self.debug connection.set_debug server = self.connection.call(method, args) pp server else self.connection.call(method, args) end end |