diff --git a/.document b/.document deleted file mode 100644 index 3d618dd..0000000 --- a/.document +++ /dev/null @@ -1,5 +0,0 @@ -lib/**/*.rb -bin/* -- -features/**/*.feature -LICENSE.txt diff --git a/.gitignore b/.gitignore index 6826498..d4b6c7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *.tmp *.swp -wordpress.yml +.env +Gemfile.lock +*.gem +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..49c0faa --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: ruby +rvm: + - 1.9.3 + - 2.0.0 + - 2.1.1 +git: + depth: 1 +cache: bundler +env: + global: + - secure: "Foe5JrG+j5kd3Sy1TY0ovB2yPnncqKlYdPsDfjV95cCy/2iImh1vvKxsdkBrK7/WjcADO7DjF96hItoH53hzmou4+Fz3/Z25h84gClavnqQmpTUWWmyZou+S47uu8st3bujtrKMBwVCkO+eG1mcfhG3V++08dUFjrLnWMmgkTRM=" + - secure: "HeL/ulGnSAQeDR+pxWkOc18EUjVlkRGgeLHzyq9SxrdB6Vy59s+3HASB0PI/doEd0M1HtC5pmuXuldLVGYCjS5HrWmIidwm+w7f9kr6jCs0enqpAfc/4PGpum7LMuAO+J7dbok17hsXDGYIXxaEDftaTvi50gHdnJEbzhciZruY=" + - secure: "NFfr6gan+9NFJ0qN7HkmhgDIwQ45MZNWBeu05TuNs/E9u4sngnkVlBjpBNNdOGGA1ftv2EO2a+o70YWxoZ2fVKBt5Kjd2HozZAmkx1wQoehU0dDQHrS99UMykSaFmjh4sdmU4fDghOSSrr+HzYv+Fn3RaGOy/fG2DnyAIruFKic=" + - secure: "P2tGa/mLy18Q+uZF6y+6UyYAJaSK456EeRpwHZb6aKEkC6OUb5zthQlhqMCOElvCUhY07vqs+OtAA4v/rkMHjxwgPCc4ym1sEqZIzBbYcj9Gry0emtIe7BsRLQVHv/zw2mDAMDKIDdKoASNiiTTENdkCjgy+T6zr8KDL22m/hBE=" + - secure: "g+JDYCPtGPPRb4Zc2sirASHsgs0oCSyHoB92nuXZnl3gxs9j8jzOVIIlrFZ4EBLknPt5PlTz7+d0p48liq/JYT9R2HcybNcYy6AYTtoQuBJq9/5XOp7BAFuJpiGQuDidcTegSS7DlH10SVjwqPIsL97vdOwGwXb8igNkGXgHwE0=" + - secure: "l4LjlUj9eKZfe4GnL+5ELbnaNSmFKIBpzSWELvNyS8rkgS/LxctFixWJSPTIeqeihjEaYeqvIojUOOaIwenlIt71jNfTCbLKigFWdSIGnTt/qn8kpzj4gfuK6aadXoqtAe/1XWc6vfBswvrywWGZKk9TyBlfiJo4hOow9vXTQrc=" + - secure: "hkT4n/WjrrZ+qFRrdTVb3BDTWVEaQqIaSXb/ueEhQKul7voDIRTwcYRL9M4uML9IaWb3QMqYmsED8e8FgDWc2nTaBGWgd9V5vPn0vYDmG/4TQcvcA5pQjuHiwgN0OHbfg650IgUx4ddTIdZOC+ZqjL5IAwjxQZm1E/Ak3cJCL98=" + - secure: "ZM1TRbksrOtXG8VGwkp2brRsME2YdjQTEvRzjZpj3TXtxWDLc+Ng2WsAAbd9UzDJ9wbUREhY9SrmzB0ZV2iTFriuN0gC/tNrp5aRS+oACes7qU9Vodjt0S+Q1+KAiUbL3CcZRKkP6m4F8YDsug687fKGd34Vk7DR56OygWfvEpE=" + - secure: "DCiatNlzhcuMxlHL00ZL/ql+V4vDBOabXaaGpz3OpszO2kI1NvlddOfWScB213JqMyPegkWDjQFyybKPYjNUGgp3alMhlEn6jrvD96tHbdwwfWJc16lSEy1hdVA8KnqEYb0wU5RHBCIxdSM7kdxE3xmTGVJNVXt5narqikMeQ60=" + - secure: "hFdTzn9BWNddcGcf/hvj9Mz3peQgGo6VdRlAVdSrOiiUoArUM2Jhjtyl5Zmsv8yNhooAp9rDxQM6KQc/RmvHWpDnOhlJxO5uWDqOWnRvYEC1CfdTST4InJKWNgJwcXYqshpsMKLAvKNmUZzLSJ6TNPQWTBhgWlfk92adiUIvxuQ=" diff --git a/Gemfile b/Gemfile index bf9029f..817f62a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,2 @@ -source "http://rubygems.org" - -group :development do - gem "rspec" - gem "rdoc" - gem "bundler" - gem "jeweler" - gem "simplecov" -end +source 'http://rubygems.org' +gemspec diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index f1ed0bb..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,37 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - diff-lcs (1.1.3) - git (1.2.5) - jeweler (1.8.3) - bundler (~> 1.0) - git (>= 1.2.5) - rake - rdoc - json (1.6.5) - multi_json (1.0.4) - rake (0.9.2) - rdoc (3.12) - json (~> 1.4) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) - simplecov (0.5.4) - multi_json (~> 1.0.3) - simplecov-html (~> 0.5.3) - simplecov-html (0.5.3) - -PLATFORMS - ruby - -DEPENDENCIES - bundler - jeweler - rdoc - rspec - simplecov diff --git a/README.md b/README.md new file mode 100644 index 0000000..3eb0173 --- /dev/null +++ b/README.md @@ -0,0 +1,202 @@ +# rubypress + +[![Gem Version](https://badge.fury.io/rb/rubypress.png)](http://badge.fury.io/rb/rubypress) + +[![Build Status](https://travis-ci.org/zachfeldman/rubypress.png)](https://travis-ci.org/zachfeldman/rubypress) + +This implements the [WordPress XML RPC API](http://codex.wordpress.org/XML-RPC_WordPress_API) as released in version 3.4. + +WARNING: SSL is NOT enabled by default for ease of testing for those running OS X systems without setup SSL certs. If this is important to you, checkout the options for instantiating a new client where you can set :use_ssl to true. + + +# Getting Started + +## Installing rubypress + +### System installation + + gem install rubypress + +### Using Bundler + + # Add this to your Gemfile + gem 'rubypress' + +## Using rubypress + +### In a script + + require 'rubypress' + +## Usage Examples + +### Create a new client + + wp = Rubypress::Client.new(:host => "yourwordpresssite.com", + :username => "yourwordpressuser@wordpress.com", + :password => "yourwordpresspassword") +### Automatically retry timeouts + +When creating the client, you can optionally pass `:retry_timeouts => true` to rescue Timeout::Error and Net::ReadTimeout errors and retry the call. + + wp = Rubypress::Client.new(:host => "yourwordpresssite.com", + :username => "yourwordpressuser@wordpress.com", + :password => "yourwordpresspassword", + :retry_timeouts => true) +### Non-standard `xmlrpc.php` location + +NOTE: If your `xmlrpc.php` is not on the host root directory, you need to +specify it's path. For example, to connect to `myhostedwordpresssite.net/path/to/blog`: + + + wp = Rubypress::Client.new(:host => "myhostedwordpresssite.net", + :username => "yourwordpressuser@wordpress.com", + :password => "yourwordpresspassword", + :path => "/path/to/blog/xmlrpc.php") + + + +## Making requests +(Based off of the [WordPress XML RPC API Documentation](http://codex.wordpress.org/XML-RPC_WordPress_API)) + +### Getting Options + + wp.getOptions + + # Returns a hash of options from the wp_options table + => {"software_name"=>{"desc"=>"Software Name", + "readonly"=>true, + "value"=>"WordPress"}} + +(just a small excerpt of actual options for the sake of the whole [brevity thing](http://3-akamai.tapcdn.com/images/thumbs/taps/2012/06/demotivational-poster-the-dude-or-the-dude-his-dudeness-el-duderino-if-you-re-not-into-the-whole-brevity-thing-3410281f-sz640x523-animate.jpg)) + +### Creating a new post + + wp.newPost( :blog_id => "your_blog_id", # 0 unless using WP Multi-Site, then use the blog id + :content => { + :post_status => "publish", + :post_date => Time.now, + :post_content => "This is the body", + :post_title => "RubyPress is the best!", + :post_name => "/rubypress-is-the-best", + :post_author => 1, # 1 if there is only the admin user, otherwise the user's id + :terms_names => { + :category => ['Category One','Category Two','Category Three'], + :post_tag => ['Tag One','Tag Two', 'Tag Three'] + } + } + ) + + # Returns the newly created posts ID if successful + => "24" + +### Using SSL to connect +Use the default SSL port of 443 + + wp = Rubypress::Client.new(:host => "myhostedwordpresssite.net", + :username => "yourwordpressuser@wordpress.com", + :password => "yourwordpresspassword", + :use_ssl => true) + + +Use a non-default ssl port of your choosing (must be setup on your server correctly) + + wp = Rubypress::Client.new(:host => "myhostedwordpresssite.net", + :username => "yourwordpressuser@wordpress.com", + :password => "yourwordpresspassword", + :use_ssl => true, + :ssl_port => 995) + +### Uploading a file + +```ruby +FILENAME='myFile.png' +wp.uploadFile(:data => { + :name => FILENAME, + :type => MIME::Types.type_for(FILENAME).first.to_s, + :bits => XMLRPC::Base64.new(IO.read(FILENAME)) + }) +``` + +To make further requests, check out the documentation - this gem should follow the exact format of the [WordPress XML RPC API](http://codex.wordpress.org/XML-RPC_WordPress_API). For even further clarification on what requests are available, take a look in the spec folder. + +## Contributing to rubypress + +Pull requests welcome. + +* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. +* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it. +* Fork the project. +* Start a feature/bugfix branch. +* Commit and push until you are happy with your contribution. +* Make sure to add tests for it. This is important so we don't break it in a future version unintentionally. +* Submit a pull request + +## Testing + +### Environment Variables + +The test suite requires that the following environment variables are set: + +* WORDPRESS_HOST +* WORDPRESS_USERNAME +* WORDPRESS_PASSWORD + +Optionally, you can create a file in the working directory called _.env_ and add the following to it: + + + WORDPRESS_HOST=myhostedwordpresssite.net + WORDPRESS_PORT=80 + WORDPRESS_USE_SSL=false + WORDPRESS_USERNAME=yourwordpressuser@wordpress.com + WORDPRESS_PASSWORD=yourwordpresspassword + + +or use the sample-dot-env file as a base. .env will not be committed. When RSpec runs it will set the environment variables for you. +If you use a port other than 80, specify it with `WORDPRESS_PORT` and use `WORDPRESS_USE_SSL=true` for HTTPS servers. Be sure to set +the port to 443 for standard HTTPS servers. + +If you'd like to run the tests to test a server with plain HTTP authentication, use these environment vars: + + + WORDPRESS_HTTP_LOGIN=yourhttplogin + WORDPRESS_HTTP_PASS=yourhttppass + WORDPRESS_HTTP_USERNAME=yourwordpressusername + WORDPRESS_HTTP_PASSWORD=yourwordpresspassword + WORDPRESS_HTTP_HOST=yourhost.com + WORDPRESS_HTTP_PORT=80 + WORDPRESS_HTTP_USE_SSL=false + WORDPRESS_HTTP_PATH=/path/to/xmlrpc.php + +The Basic Authentication settings also allow a custom port and whether to use SSL/HTTPS. Note that, like the host and path, these +variable names include `HTTP_` and can be set to the same or different values as needed. + +## Credits + +* Zach Feldman [@zachfeldman](http://zfeldman.com) - current maintainer, majority of codebase +* Dan Collis-Puro [@djcp](https://github.com/djcp) - original project creator + +## Contributors + +* Abdelkader Boudih [@seuros](https://github.com/seuros) (Removed deep_merge monkeypatch if ActiveSupport is defined, small refactors, fixed dependency issue with retry) +* Alex Dantas [@alexdantas](https://github.com/alexdantas) (README edits re: host option) +* Pacop [@pacop](https://github.com/pacop) (Added a far easier way to upload files than the default method chain) +* David Muto [@pseudomuto](https://github.com/pseudomuto) (Added ability to use a .env file and to retry failed requests) +* Teemu Pääkkönen [@borc](https://github.com/borc) (Added HTTP authentication and tests for it) +* Brian Fletcher [@punkie](https://github.com/punkle) (Did work to try to get to 1.9.2 compat with tests, VCR issues prevented this. Now only officially support 1.9.3 and up) +* Corey [@developercorey](https://github.com/developercorey) (Added ability to change SSL port, README updates) +* Michael [@mibamur](https://github.com/mibamur) (Patched uploadFile method) +* Rebecca Skinner [@sevenseacat](https://github.com/sevenseacat) (Cached the XMLRPC connection to save resources) +* Casey Hadden [@caseyhadden](https://github.com/caseyhadden) (Added support for cookie-based authentication schemes) +* Noah Botimer [@botimer](https://github.com/botimer) (Allowed custom prefixes on method names and tests to run against https servers on any port) +* Carlos Pérez Cerrato [@lastko](https://github.com/lastko) (Caught Errno::EPIPE: Broken pipe errors) +* Eric Gascoine [@ericgascoine](https://github.com/ericgascoine) (Fixed getPostStatusList) +* Matt Colyer [@mcoyler](https://github.com/mcolyer) (Added configurable timeouts) +* Karim Naufal [@rimkashox](https://github.com/rimkashox) (Added support for Ruby >= 2.4.0) + +## License + +Licensed under the same terms as WordPress itself - GPLv2. + + diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index 2132b5f..0000000 --- a/README.rdoc +++ /dev/null @@ -1,22 +0,0 @@ -= rubypress - -This implements the WordPress xmlrpc api as released in version 3.4. - -== Contributing to rubypress - -* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. -* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it. -* Fork the project. -* Start a feature/bugfix branch. -* Commit and push until you are happy with your contribution. -* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. -* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. - -== Credits - -* Dan Collis-Puro (dan@collispuro.com) - -== Copyright and License - -Copyright (c) 2012 Dan Collis-Puro -Licensed under the same terms as WordPress itself - GPLv2. diff --git a/Rakefile b/Rakefile index ed47356..f41cae0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,49 +1,7 @@ -# encoding: utf-8 - -require 'rubygems' -require 'bundler' -begin - Bundler.setup(:default, :development) -rescue Bundler::BundlerError => e - $stderr.puts e.message - $stderr.puts "Run `bundle install` to install missing gems" - exit e.status_code -end +require "bundler/gem_tasks" require 'rake' - -require 'jeweler' -Jeweler::Tasks.new do |gem| - # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options - gem.name = "rubypress" - gem.homepage = "http://github.com/djcp/rubypress" - gem.license = "GPLv2" - gem.summary = %Q{The WordPress xmlrpc api in ruby} - gem.description = %Q{This is an implementation of the WordPress xmlrpc api introduced in version 3.4.} - gem.email = "dan@collispuro.com" - gem.authors = ["djcp"] - # dependencies defined in Gemfile -end -Jeweler::RubygemsDotOrgTasks.new - -require 'rspec/core' require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = FileList['spec/**/*_spec.rb'] -end - -RSpec::Core::RakeTask.new(:rcov) do |spec| - spec.pattern = 'spec/**/*_spec.rb' - spec.rcov = true -end - -task :default => :spec - -require 'rdoc/task' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "rubypress #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec \ No newline at end of file diff --git a/lib/rubypress.rb b/lib/rubypress.rb index d3a5f3a..0295fa8 100644 --- a/lib/rubypress.rb +++ b/lib/rubypress.rb @@ -1,6 +1,31 @@ -# encoding: UTF-8 - $LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__)) require 'xmlrpc/client' require 'rubypress/client' + +unless defined?(ActiveSupport) + class Hash + + def deep_merge!(other_hash) + other_hash.each_pair do |k, v| + tv = self[k] + self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v + end + self + end + + def deep_merge(other_hash) + dup.deep_merge!(other_hash) + end + + end +end + + +require 'pp' + +class XMLRPC::Client + def set_debug + @http.set_debug_output($stderr); + end +end diff --git a/lib/rubypress/client.rb b/lib/rubypress/client.rb index 42af9fa..3bba609 100644 --- a/lib/rubypress/client.rb +++ b/lib/rubypress/client.rb @@ -1,82 +1,83 @@ -# encoding: UTF-8 +require 'yaml' +require 'erb' +require 'retryable' + +require_relative 'posts' +require_relative 'taxonomies' +require_relative 'media' +require_relative 'comments' +require_relative 'options' +require_relative 'users' +require_relative 'xml_rpc_retryable' module Rubypress class Client + attr_reader :connection - attr_accessor :port, :host, :path, :username, :password, :use_ssl, :default_post_fields + attr_accessor :port, :ssl_port, :host, :path, :username, :password, :use_ssl, :default_post_fields, + :debug, :http_user, :http_password, :retry_timeouts, :timeout, :cookie def initialize(options = {}) - opts = { + { :port => 80, - :use_ssl => true, + :ssl_port => 443, + :use_ssl => false, :host => nil, :path => '/xmlrpc.php', :username => nil, :password => nil, - :default_post_fields => ['post','terms','custom_fields'] - }.merge(options) - self.port = opts[:port] - self.host = opts[:host] - self.path = opts[:path] - self.username = opts[:username] - self.password = opts[:password] - self.use_ssl = opts[:use_ssl] - self.default_post_fields = opts[:default_post_fields] - self.connect + :default_post_fields => %w(post terms custom_fields), + :debug => false, + :http_user => nil, + :http_password => nil, + :retry_timeouts => false, + :timeout => 30, + :cookie => nil + }.merge(options).each{ |opt| self.send("#{opt[0]}=", opt[1]) } self end - def connect - @connection = XMLRPC::Client.new(self.host, self.path, self.port,nil,nil,nil,nil,self.use_ssl,nil) + def connection + if @connection.nil? + @connection = XMLRPC::Client.new(self.host, self.path, (self.use_ssl ? self.ssl_port : self.port),nil,nil,self.http_user,self.http_password,self.use_ssl,self.timeout) + @connection.http_header_extra = {'accept-encoding' => 'identity'} + @connection.extend(XMLRPCRetryable) if retry_timeouts + @connection.cookie = self.cookie unless self.cookie.nil? + end + + @connection end - def get_options(options = {}) - opts = { - :blog_id => 0, - :username => self.username, - :password => self.password, - :options => [] - }.merge(options) - self.connection.call( - "wp.getOptions", - opts[:blog_id], - opts[:username], - opts[:password], - opts[:options] - ) + def self.default + self.new(:host => ENV['WORDPRESS_HOST'], :port => 80, :username => ENV['WORDPRESS_USERNAME'], :password => ENV['WORDPRESS_PASSWORD'], :use_ssl => false) end - def recent_posts(options = {}) - opts = { + def execute(method, options) + args = [] + options_final = { :blog_id => 0, :username => self.username, - :password => self.password, - :post_type => 'post', - :post_status => 'publish', - :number => 10, - :offset => 0, - :orderby => 'post_date', - :order => 'asc', - :default_post_fields => self.default_post_fields - }.merge(options) - self.connection.call( - "wp.getPosts", - opts[:blog_id], - opts[:username], - opts[:password], - { - :post_type => opts[:post_type], - :post_status => opts[:post_status], - :number => opts[:number], - :offset => opts[:offset], - :orderby => opts[:orderby], - :order => opts[:order] - }, - opts[:default_post_fields] - ) + :password => self.password + } + options_final.deep_merge!(options).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 + include Posts + include Taxonomies + include Media + include Comments + include Options + include Users + end end diff --git a/lib/rubypress/comments.rb b/lib/rubypress/comments.rb new file mode 100644 index 0000000..d2de7b3 --- /dev/null +++ b/lib/rubypress/comments.rb @@ -0,0 +1,55 @@ +module Rubypress + + module Comments + + def getCommentCount(options = {}) + default_options = { + :post_id => nil + }.deep_merge!(options) + execute('getCommentCount', default_options) + end + + def getComment(options = {}) + default_options = { + :comment_id => nil + }.deep_merge!(options) + execute('getComment', default_options) + end + + def getComments(options = {}) + default_options = { + :filter => {} + }.deep_merge!(options) + execute('getComments', default_options) + end + + def newComment(options = {}) + default_options = { + :post_id => nil, + :comment => {} + }.deep_merge!(options) + execute('newComment', default_options) + end + + def editComment(options = {}) + default_options = { + :comment_id => nil, + :comment => {} + }.deep_merge!(options) + execute('editComment', default_options) + end + + def deleteComment(options = {}) + default_options = { + :comment_id => nil + }.deep_merge!(options) + execute('deleteComment', default_options) + end + + def getCommentStatusList(options = {}) + execute('getCommentStatusList', options) + end + + end + +end diff --git a/lib/rubypress/media.rb b/lib/rubypress/media.rb new file mode 100644 index 0000000..24d6c67 --- /dev/null +++ b/lib/rubypress/media.rb @@ -0,0 +1,29 @@ +module Rubypress + + module Media + + def getMediaItem(options = {}) + default_options = { + :attachment_id => nil + }.deep_merge!(options) + execute('getMediaItem', default_options) + end + + def getMediaLibrary(options = {}) + default_options = { + :filter => {} + }.deep_merge!(options) + execute('getMediaLibrary', default_options) + end + + def uploadFile(options = {}) + default_options = { + :data => {} + }.deep_merge!(options) + default_options[:data][:bits] = XMLRPC::Base64.new(File.read(default_options.delete(:filename))) if options.include?(:filename) and File.readable?(options[:filename]) + execute('uploadFile', default_options) + end + + end + +end diff --git a/lib/rubypress/options.rb b/lib/rubypress/options.rb new file mode 100644 index 0000000..6325f07 --- /dev/null +++ b/lib/rubypress/options.rb @@ -0,0 +1,21 @@ +module Rubypress + + module Options + + def getOptions(options = {}) + default_options = { + :options => [] + }.deep_merge!(options) + execute('getOptions', default_options) + end + + def setOptions(options = {}) + default_options = { + :options => [] + }.deep_merge!(options) + execute('setOptions', default_options) + end + + end + +end diff --git a/lib/rubypress/posts.rb b/lib/rubypress/posts.rb new file mode 100644 index 0000000..68f0b84 --- /dev/null +++ b/lib/rubypress/posts.rb @@ -0,0 +1,76 @@ +module Rubypress + + module Posts + + def getPost(options = {}) + default_options = { + :post_id => nil, + :fields => self.default_post_fields + }.deep_merge!(options) + execute('getPost', default_options) + end + + def getPosts(options = {}) + default_options = { + :filter => { + :post_type => 'post', + :orderby => 'post_date', + :order => 'asc', + :fields => self.default_post_fields + } + }.deep_merge!(options) + execute('getPosts', default_options) + end + + def newPost(options = {}) + default_options = { + :content => {} + }.deep_merge!(options) + execute('newPost', default_options) + end + + def editPost(options = {}) + default_options = { + :post_id => nil, + :content => {} + }.deep_merge!(options) + execute('editPost', default_options) + end + + def deletePost(options = {}) + default_options = { + :post_id => nil + }.deep_merge!(options) + execute('deletePost', default_options) + end + + def getPostType(options = {}) + default_options = { + :post_type_name => nil, + :fields => [] + }.deep_merge!(options) + execute('getPostType', default_options) + end + + def getPostTypes(options = {}) + default_options = { + :filter => {}, + :fields => [] + }.deep_merge!(options) + execute('getPostTypes', default_options) + end + + def getPostFormats(options = {}) + default_options = { + :filter => {} + }.deep_merge!(options) + execute('getPostFormats', default_options) + end + + def getPostStatusList(options = {}) + execute('getPostStatusList', options) + end + + end + +end diff --git a/lib/rubypress/taxonomies.rb b/lib/rubypress/taxonomies.rb new file mode 100644 index 0000000..b7525be --- /dev/null +++ b/lib/rubypress/taxonomies.rb @@ -0,0 +1,57 @@ +module Rubypress + + module Taxonomies + + def getTaxonomy(options = {}) + default_options = { + :taxonomy => 'category' + }.deep_merge!(options) + execute('getTaxonomy', default_options) + end + + def getTaxonomies(options = {}) + execute('getTaxonomies', options) + end + + def getTerm(options = {}) + default_options = { + :taxonomy => 'category', + :term_id => nil + }.deep_merge!(options) + execute('getTerm', default_options) + end + + def getTerms(options = {}) + default_options = { + :taxonomy => 'category', + :filter => {} + }.deep_merge!(options) + execute('getTerms', default_options) + end + + def newTerm(options = {}) + default_options = { + :content => {} + }.deep_merge!(options) + execute('newTerm', default_options) + end + + def editTerm(options = {}) + default_options = { + :term_id => nil, + :content => {} + }.deep_merge!(options) + execute('editTerm', default_options) + end + + def deleteTerm(options = {}) + default_options = { + :taxonomy => nil, + :term_id => nil + }.deep_merge!(options) + execute('deleteTerm', default_options) + end + + end + +end diff --git a/lib/rubypress/users.rb b/lib/rubypress/users.rb new file mode 100644 index 0000000..8870ae1 --- /dev/null +++ b/lib/rubypress/users.rb @@ -0,0 +1,44 @@ +module Rubypress + + module Users + + def getUsersBlogs + self.connection.call('wp.getUsersBlogs', self.username, self.password) + end + + def getUser(options = {}) + default_options = { + :user_id => nil, + :fields => [] + }.deep_merge!(options) + execute('getUser', default_options) + end + + def getUsers(options = {}) + default_options = { + :filter => {} + }.deep_merge!(options) + execute('getUsers', default_options) + end + + def getProfile(options = {}) + default_options = { + :fields => [] + }.deep_merge!(options) + execute('getProfile', default_options) + end + + def editProfile(options = {}) + default_options = { + :content => {} + }.deep_merge!(options) + execute('editProfile', default_options) + end + + def getAuthors(options = {}) + execute('getAuthors', options) + end + + end + +end diff --git a/lib/rubypress/xml_rpc_retryable.rb b/lib/rubypress/xml_rpc_retryable.rb new file mode 100644 index 0000000..bc8ef79 --- /dev/null +++ b/lib/rubypress/xml_rpc_retryable.rb @@ -0,0 +1,23 @@ +module Rubypress + module XMLRPCRetryable + include Retryable + + RUBY_EXCEPTIONS = [ + Timeout::Error, + Errno::EPIPE + ] + + RUBY_EXCEPTIONS << Net::ReadTimeout if Net.const_defined?(:ReadTimeout) + + def self.extended(instance) + instance.singleton_class.send(:alias_method, :call_without_retry, :call) + instance.singleton_class.send(:alias_method, :call, :call_with_retry) + end + + def call_with_retry(method, *args) + retryable on: RUBY_EXCEPTIONS do + call_without_retry(method, *args) + end + end + end +end diff --git a/rubypress.gemspec b/rubypress.gemspec new file mode 100644 index 0000000..1cc6ee6 --- /dev/null +++ b/rubypress.gemspec @@ -0,0 +1,31 @@ +$LOAD_PATH.push File.expand_path('../lib', __FILE__) + +Gem::Specification.new do |s| + s.name = 'rubypress' + s.version = '1.2.2' + s.platform = Gem::Platform::RUBY + s.author = 'Zach Feldman' + s.email = ['zachfeldman@gmail.com'] + s.homepage = 'https://github.com/zachfeldman/rubypress' + s.summary = 'Easily access WordPress installations through the WordPress XML-RPC API.' + s.description = 'Easily access WordPress installations through the WordPress XML-RPC API. This gem exactly mirrors the functionality provided by the WordPress XML-RPC API in Ruby.' + s.license = 'GPLv2' + + s.required_ruby_version = '>= 1.9.3' + + s.files = 'lib/rubypress.rb' + s.files += Dir['lib/rubypress/**'] + + s.add_dependency 'retryable-rb' + s.add_dependency 'xmlrpc' + + s.add_development_dependency 'rspec' + s.add_development_dependency 'rdoc' + s.add_development_dependency 'bundler' + s.add_development_dependency 'jeweler' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'webmock' + s.add_development_dependency 'vcr' + + +end diff --git a/rubypress.rb b/rubypress.rb deleted file mode 100644 index 36055a9..0000000 --- a/rubypress.rb +++ /dev/null @@ -1,9 +0,0 @@ -# encoding: UTF-8 - -$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__)) - -require 'lib/rubypress' - -cl = Rubypress::Client.new(:host => 'wordpress-trunk', :path => '/xmlrpc.php', :port => 80, :username => 'admin', :password => 'foobar', :use_ssl => false) - -puts cl.recent_posts(:number => 1) diff --git a/sample-dot-env b/sample-dot-env new file mode 100644 index 0000000..eb566b3 --- /dev/null +++ b/sample-dot-env @@ -0,0 +1,14 @@ +WORDPRESS_HOST= +WORDPRESS_PATH= +WORDPRESS_PORT= +WORDPRESS_USE_SSL= +WORDPRESS_USERNAME= +WORDPRESS_PASSWORD= +WORDPRESS_HTTP_LOGIN= +WORDPRESS_HTTP_PASS= +WORDPRESS_HTTP_USERNAME= +WORDPRESS_HTTP_PASSWORD= +WORDPRESS_HTTP_HOST= +WORDPRESS_HTTP_PORT= +WORDPRESS_HTTP_USE_SSL= +WORDPRESS_HTTP_PATH= diff --git a/spec/cassettes/deleteComment.yml b/spec/cassettes/deleteComment.yml new file mode 100644 index 0000000..042b0ce --- /dev/null +++ b/spec/cassettes/deleteComment.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.deleteComment0gxB06s8Z13 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '292' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:30 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:30 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/deletePost.yml b/spec/cassettes/deletePost.yml new file mode 100644 index 0000000..c40420b --- /dev/null +++ b/spec/cassettes/deletePost.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.deletePost0gxB06s8Z40 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '297' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:46 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:46 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/deleteTerm.yml b/spec/cassettes/deleteTerm.yml new file mode 100644 index 0000000..aa2346e --- /dev/null +++ b/spec/cassettes/deleteTerm.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.deleteTerm0gxB06s8Zcategory12 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '337' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:07:00 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:07:01 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/editComment.yml b/spec/cassettes/editComment.yml new file mode 100644 index 0000000..be7b04e --- /dev/null +++ b/spec/cassettes/editComment.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.editComment0gxB06s8Z13comment_parentcontentThis is a test thing here.authorJohn Adamsauthor_urlhttp://johnadamsforpresidentnow.comauthor_emailjohnadams@whitehouse.gov + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '776' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:25 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:27 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/editPost.yml b/spec/cassettes/editPost.yml new file mode 100644 index 0000000..d44ddaf --- /dev/null +++ b/spec/cassettes/editPost.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.editPost0gxB06s8Z40post_typepostpost_statusdraftpost_title5 Ways to Know You're Coolpost_contentI don't always write tests, but when I do, I use RSpec. + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '707' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:45 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:46 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/editProfile.yml b/spec/cassettes/editProfile.yml new file mode 100644 index 0000000..bac9eb0 --- /dev/null +++ b/spec/cassettes/editProfile.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.editProfile0gxB06s8Zfirst_nameJohnson + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '375' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:07:03 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:07:04 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/editTerm.yml b/spec/cassettes/editTerm.yml new file mode 100644 index 0000000..93a04ec --- /dev/null +++ b/spec/cassettes/editTerm.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.editTerm0gxB06s8Z12namegazellestaxonomycategory + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '479' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:59 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '178' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 1 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:07:00 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getAuthors.yml b/spec/cassettes/getAuthors.yml new file mode 100644 index 0000000..06fb30b --- /dev/null +++ b/spec/cassettes/getAuthors.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getAuthors0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '263' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:07:04 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '458' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + user_id1 + user_login + display_name + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:07:05 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getComment.yml b/spec/cassettes/getComment.yml new file mode 100644 index 0000000..01195d1 --- /dev/null +++ b/spec/cassettes/getComment.yml @@ -0,0 +1,72 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getComment0gxB06s8Z13 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '289' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:28 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '1431' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + date_created_gmt20140208T23:06:24 + user_id1 + comment_id13 + parent0 + statusapprove + contentThis is a test thing here. + linkhttp:///wordpress3dot7noauth/?p=1#comment-13 + post_id1 + post_titleHello world! + authorJohn Adams + author_urlhttp://johnadamsforpresidentnow.com + author_emailjohnadams@whitehouse.gov + author_ip174.109.227.206 + type + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:29 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getCommentCount.yml b/spec/cassettes/getCommentCount.yml new file mode 100644 index 0000000..5fa4683 --- /dev/null +++ b/spec/cassettes/getCommentCount.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getCommentCount0gxB06s8Z1 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '293' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:27 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '467' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + approved2 + awaiting_moderation0 + spam0 + total_comments2 + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:28 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getCommentStatusList.yml b/spec/cassettes/getCommentStatusList.yml new file mode 100644 index 0000000..e19b1ab --- /dev/null +++ b/spec/cassettes/getCommentStatusList.yml @@ -0,0 +1,61 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getCommentStatusList0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '273' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:31 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '408' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + holdUnapproved + approveApproved + spamSpam + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:32 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getComments.yml b/spec/cassettes/getComments.yml new file mode 100644 index 0000000..7075724 --- /dev/null +++ b/spec/cassettes/getComments.yml @@ -0,0 +1,91 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getComments0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '288' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:29 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '2839' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + date_created_gmt20140208T23:06:24 + user_id1 + comment_id13 + parent0 + statusapprove + contentThis is a test thing here. + linkhttp:///wordpress3dot7noauth/?p=1#comment-13 + post_id1 + post_titleHello world! + authorJohn Adams + author_urlhttp://johnadamsforpresidentnow.com + author_emailjohnadams@whitehouse.gov + author_ip174.109.227.206 + type + + + date_created_gmt20140202T16:53:06 + user_id0 + comment_id1 + parent0 + statusapprove + contentHi, this is a comment. + To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them. + linkhttp:///wordpress3dot7noauth/?p=1#comment-1 + post_id1 + post_titleHello world! + authorMr WordPress + author_urlhttp://wordpress.org/ + author_email + author_ip + type + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:30 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getMediaItem.yml b/spec/cassettes/getMediaItem.yml new file mode 100644 index 0000000..311da69 --- /dev/null +++ b/spec/cassettes/getMediaItem.yml @@ -0,0 +1,67 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getMediaItem0gxB06s8Z38 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '299' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:39 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '1061' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + attachment_id38 + date_created_gmt20140208T23:06:37 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file16.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file16.png + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:39 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getMediaLibrary.yml b/spec/cassettes/getMediaLibrary.yml new file mode 100644 index 0000000..354be36 --- /dev/null +++ b/spec/cassettes/getMediaLibrary.yml @@ -0,0 +1,234 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getMediaLibrary0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '292' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:40 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '14905' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + attachment_id39 + date_created_gmt20140208T23:06:38 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file17.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file17.png + + + attachment_id38 + date_created_gmt20140208T23:06:37 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file16.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file16.png + + + attachment_id35 + date_created_gmt20140208T21:04:42 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file15.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file15.png + + + attachment_id34 + date_created_gmt20140208T21:04:41 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file14.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file14.png + + + attachment_id31 + date_created_gmt20140208T21:03:05 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file13.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file13.png + + + attachment_id30 + date_created_gmt20140208T21:03:05 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file12.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file12.png + + + attachment_id29 + date_created_gmt20140208T21:02:46 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file11.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file11.png + + + attachment_id28 + date_created_gmt20140208T21:02:45 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file10.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file10.png + + + attachment_id25 + date_created_gmt20140208T21:01:08 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file9.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file9.png + + + attachment_id22 + date_created_gmt20140208T20:28:40 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file8.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file8.png + + + attachment_id19 + date_created_gmt20140208T20:16:21 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file7.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file7.png + + + attachment_id16 + date_created_gmt20140208T20:01:42 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file6.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file6.png + + + attachment_id15 + date_created_gmt20140208T19:46:58 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file5.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file5.png + + + attachment_id10 + date_created_gmt20140208T19:39:47 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file4.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file4.png + + + attachment_id7 + date_created_gmt20140208T19:30:43 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file3.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file3.png + + + attachment_id4 + date_created_gmt20140202T17:03:20 + parent0 + linkhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file2.png + titletest_file.png + caption + description + metadata + thumbnailhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file2.png + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:40 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getOptions.yml b/spec/cassettes/getOptions.yml new file mode 100644 index 0000000..3bf3f71 --- /dev/null +++ b/spec/cassettes/getOptions.yml @@ -0,0 +1,193 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getOptions0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '300' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:40 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '9019' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + software_name + descSoftware Name + readonly1 + valueWordPress + + software_version + descSoftware Version + readonly1 + value3.7.1 + + blog_url + descWordPress Address (URL) + readonly1 + valuehttp:///wordpress3dot7noauth + + home_url + descSite Address (URL) + readonly1 + valuehttp:///wordpress3dot7noauth + + login_url + descLogin Address (URL) + readonly1 + valuehttp:///wordpress3dot7noauth/wp-login.php + + _url + descThe URL to the area + readonly1 + valuehttp:///wordpress3dot7noauth/wp-/ + + image_default_link_type + descImage default link type + readonly1 + valuefile + + image_default_size + descImage default size + readonly1 + value + + image_default_align + descImage default align + readonly1 + value + + template + descTemplate + readonly1 + valuetwentythirteen + + stylesheet + descStylesheet + readonly1 + valuetwentythirteen + + post_thumbnail + descPost Thumbnail + readonly1 + value1 + + time_zone + descTime Zone + readonly0 + value0 + + blog_title + descSite Title + readonly0 + valueWordpress 3 Dot 7 No Auth + + blog_tagline + descSite Tagline + readonly0 + valueThis is a great tagline + + date_format + descDate Format + readonly0 + valueF j, Y + + time_format + descTime Format + readonly0 + valueg:i a + + users_can_register + descAllow new users to sign up + readonly0 + value0 + + thumbnail_size_w + descThumbnail Width + readonly0 + value150 + + thumbnail_size_h + descThumbnail Height + readonly0 + value150 + + thumbnail_crop + descCrop thumbnail to exact dimensions + readonly0 + value1 + + medium_size_w + descMedium size image width + readonly0 + value300 + + medium_size_h + descMedium size image height + readonly0 + value300 + + large_size_w + descLarge size image width + readonly0 + value1024 + + large_size_h + descLarge size image height + readonly0 + value1024 + + default_comment_status + descAllow people to post comments on new articles + readonly0 + valueopen + + default_ping_status + descAllow link notifications from other blogs (pingbacks and trackbacks) + readonly0 + valueopen + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:41 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getPost.yml b/spec/cassettes/getPost.yml new file mode 100644 index 0000000..c90cf9d --- /dev/null +++ b/spec/cassettes/getPost.yml @@ -0,0 +1,97 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getPost0gxB06s8Z40posttermscustom_fields + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '455' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:43 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '3183' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + post_id40 + post_title5 Ways to Know You're Cool + post_date20140208T23:06:43 + post_date_gmt20140208T23:06:43 + post_modified20140208T23:06:43 + post_modified_gmt20140208T23:06:43 + post_statusdraft + post_typepost + post_name + post_author1 + post_password + post_excerpt + post_contentI don't always write tests, but when I do, I use RSpec. + post_parent0 + post_mime_type + linkhttp:///wordpress3dot7noauth/?p=40 + guidhttp:///wordpress3dot7noauth/?p=40 + menu_order0 + comment_statusclosed + ping_statusopen + sticky0 + post_thumbnail + + post_formatstandard + terms + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + custom_fields + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:44 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getPostFormats.yml b/spec/cassettes/getPostFormats.yml new file mode 100644 index 0000000..26b3925 --- /dev/null +++ b/spec/cassettes/getPostFormats.yml @@ -0,0 +1,68 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getPostFormats0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '291' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:51 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '934' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + standardStandard + asideAside + chatChat + galleryGallery + linkLink + imageImage + quoteQuote + statusStatus + videoVideo + audioAudio + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:52 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getPostStatusList.yml b/spec/cassettes/getPostStatusList.yml new file mode 100644 index 0000000..a2754a5 --- /dev/null +++ b/spec/cassettes/getPostStatusList.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getPostFormats0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '267' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:52 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '934' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + draftDraft + pendingPending Review + privatePrivate + publishPublished + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:53 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getPostType.yml b/spec/cassettes/getPostType.yml new file mode 100644 index 0000000..65621fd --- /dev/null +++ b/spec/cassettes/getPostType.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getPostType0gxB06s8Zpost + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '337' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:47 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '1547' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + namepost + labelPosts + hierarchical0 + public1 + show_ui1 + _builtin1 + has_archive0 + supports + title1 + editor1 + author1 + thumbnail1 + excerpt1 + trackbacks1 + custom-fields1 + comments1 + revisions1 + post-formats1 + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:48 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getPostTypes.yml b/spec/cassettes/getPostTypes.yml new file mode 100644 index 0000000..7dd1779 --- /dev/null +++ b/spec/cassettes/getPostTypes.yml @@ -0,0 +1,137 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getPostTypes0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '326' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:48 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '5438' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + post + namepost + labelPosts + hierarchical0 + public1 + show_ui1 + _builtin1 + has_archive0 + supports + title1 + editor1 + author1 + thumbnail1 + excerpt1 + trackbacks1 + custom-fields1 + comments1 + revisions1 + post-formats1 + + + page + namepage + labelPages + hierarchical1 + public1 + show_ui1 + _builtin1 + has_archive0 + supports + title1 + editor1 + author1 + thumbnail1 + page-attributes1 + custom-fields1 + comments1 + revisions1 + + + attachment + nameattachment + labelMedia + hierarchical0 + public1 + show_ui1 + _builtin1 + has_archive0 + supports + title1 + author1 + comments1 + + + revision + namerevision + labelRevisions + hierarchical0 + public0 + show_ui0 + _builtin1 + has_archive0 + supports + author1 + + + nav_menu_item + namenav_menu_item + labelNavigation Menu Items + hierarchical0 + public0 + show_ui0 + _builtin1 + has_archive0 + supports + title1 + editor1 + + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:49 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getPosts.yml b/spec/cassettes/getPosts.yml new file mode 100644 index 0000000..4f8c399 --- /dev/null +++ b/spec/cassettes/getPosts.yml @@ -0,0 +1,263 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getPosts0gxB06s8Zpost_typepostorderbypost_dateorderascfieldsposttermscustom_fields + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '713' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:44 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '15421' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + post_id1 + post_titleHello world! + post_date20140202T16:53:06 + post_date_gmt20140202T16:53:06 + post_modified20140202T16:53:06 + post_modified_gmt20140202T16:53:06 + post_statuspublish + post_typepost + post_namehello-world + post_author1 + post_password + post_excerpt + post_contentWelcome to WordPress. This is your first post. Edit or delete it, then start blogging! + post_parent0 + post_mime_type + linkhttp:///wordpress3dot7noauth/?p=1 + guidhttp:///wordpress3dot7noauth/?p=1 + menu_order0 + comment_statusopen + ping_statusopen + sticky0 + post_thumbnail + + post_formatstandard + terms + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + custom_fields + + + + post_id5 + post_title5 Ways to Know You're Cool + post_date20140202T17:03:24 + post_date_gmt20140202T17:03:24 + post_modified20140202T17:03:24 + post_modified_gmt20140202T17:03:24 + post_statusdraft + post_typepost + post_name + post_author1 + post_password + post_excerpt + post_contentI don't always write tests, but when I do, I use RSpec. + post_parent0 + post_mime_type + linkhttp:///wordpress3dot7noauth/?p=5 + guidhttp:///wordpress3dot7noauth/?p=5 + menu_order0 + comment_statusclosed + ping_statusopen + sticky0 + post_thumbnail + + post_formatstandard + terms + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + custom_fields + + + + post_id8 + post_title5 Ways to Know You're Cool + post_date20140208T19:30:47 + post_date_gmt20140208T19:30:47 + post_modified20140208T19:30:47 + post_modified_gmt20140208T19:30:47 + post_statusdraft + post_typepost + post_name + post_author1 + post_password + post_excerpt + post_contentI don't always write tests, but when I do, I use RSpec. + post_parent0 + post_mime_type + linkhttp:///wordpress3dot7noauth/?p=8 + guidhttp:///wordpress3dot7noauth/?p=8 + menu_order0 + comment_statusclosed + ping_statusopen + sticky0 + post_thumbnail + + post_formatstandard + terms + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + custom_fields + + + + post_id11 + post_title5 Ways to Know You're Cool + post_date20140208T19:43:25 + post_date_gmt20140208T19:43:25 + post_modified20140208T19:43:25 + post_modified_gmt20140208T19:43:25 + post_statusdraft + post_typepost + post_name + post_author1 + post_password + post_excerpt + post_contentI don't always write tests, but when I do, I use RSpec. + post_parent0 + post_mime_type + linkhttp:///wordpress3dot7noauth/?p=11 + guidhttp:///wordpress3dot7noauth/?p=11 + menu_order0 + comment_statusclosed + ping_statusopen + sticky0 + post_thumbnail + + post_formatstandard + terms + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + custom_fields + + + + post_id40 + post_title5 Ways to Know You're Cool + post_date20140208T23:06:43 + post_date_gmt20140208T23:06:43 + post_modified20140208T23:06:43 + post_modified_gmt20140208T23:06:43 + post_statusdraft + post_typepost + post_name + post_author1 + post_password + post_excerpt + post_contentI don't always write tests, but when I do, I use RSpec. + post_parent0 + post_mime_type + linkhttp:///wordpress3dot7noauth/?p=40 + guidhttp:///wordpress3dot7noauth/?p=40 + menu_order0 + comment_statusclosed + ping_statusopen + sticky0 + post_thumbnail + + post_formatstandard + terms + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + custom_fields + + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:45 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getProfile.yml b/spec/cassettes/getProfile.yml new file mode 100644 index 0000000..b42a89d --- /dev/null +++ b/spec/cassettes/getProfile.yml @@ -0,0 +1,59 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getProfile0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '300' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:07:03 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '249' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + user_id1 + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:07:03 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getTaxonomies.yml b/spec/cassettes/getTaxonomies.yml new file mode 100644 index 0000000..9331768 --- /dev/null +++ b/spec/cassettes/getTaxonomies.yml @@ -0,0 +1,169 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getTaxonomies0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '266' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:57 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '8329' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + namecategory + labelCategories + hierarchical1 + public1 + show_ui1 + _builtin1 + labels + nameCategories + singular_nameCategory + search_itemsSearch Categories + popular_items + all_itemsAll Categories + parent_itemParent Category + parent_item_colonParent Category: + edit_itemEdit Category + view_itemView Category + update_itemUpdate Category + add_new_itemAdd New Category + new_item_nameNew Category Name + separate_items_with_commas + add_or_remove_items + choose_from_most_used + not_found + menu_nameCategories + name__barcategory + + cap + manage_termsmanage_categories + edit_termsmanage_categories + delete_termsmanage_categories + assign_termsedit_posts + + object_type + post + + + + namepost_tag + labelTags + hierarchical0 + public1 + show_ui1 + _builtin1 + labels + nameTags + singular_nameTag + search_itemsSearch Tags + popular_itemsPopular Tags + all_itemsAll Tags + parent_item + parent_item_colon + edit_itemEdit Tag + view_itemView Tag + update_itemUpdate Tag + add_new_itemAdd New Tag + new_item_nameNew Tag Name + separate_items_with_commasSeparate tags with commas + add_or_remove_itemsAdd or remove tags + choose_from_most_usedChoose from the most used tags + not_foundNo tags found. + menu_nameTags + name__barpost_tag + + cap + manage_termsmanage_categories + edit_termsmanage_categories + delete_termsmanage_categories + assign_termsedit_posts + + object_type + post + + + + namepost_format + labelFormat + hierarchical0 + public1 + show_ui0 + _builtin1 + labels + nameFormat + singular_nameFormat + search_itemsSearch Tags + popular_itemsPopular Tags + all_itemsFormat + parent_item + parent_item_colon + edit_itemEdit Tag + view_itemView Tag + update_itemUpdate Tag + add_new_itemAdd New Tag + new_item_nameNew Tag Name + separate_items_with_commasSeparate tags with commas + add_or_remove_itemsAdd or remove tags + choose_from_most_usedChoose from the most used tags + not_foundNo tags found. + menu_nameFormat + name__barFormat + + cap + manage_termsmanage_categories + edit_termsmanage_categories + delete_termsmanage_categories + assign_termsedit_posts + + object_type + post + + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:57 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getTaxonomy.yml b/spec/cassettes/getTaxonomy.yml new file mode 100644 index 0000000..fb645fa --- /dev/null +++ b/spec/cassettes/getTaxonomy.yml @@ -0,0 +1,93 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getTaxonomy0gxB06s8Zcategory + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '304' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:54 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '2846' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + namecategory + labelCategories + hierarchical1 + public1 + show_ui1 + _builtin1 + labels + nameCategories + singular_nameCategory + search_itemsSearch Categories + popular_items + all_itemsAll Categories + parent_itemParent Category + parent_item_colonParent Category: + edit_itemEdit Category + view_itemView Category + update_itemUpdate Category + add_new_itemAdd New Category + new_item_nameNew Category Name + separate_items_with_commas + add_or_remove_items + choose_from_most_used + not_found + menu_nameCategories + name__barcategory + + cap + manage_termsmanage_categories + edit_termsmanage_categories + delete_termsmanage_categories + assign_termsedit_posts + + object_type + post + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:55 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getTerm.yml b/spec/cassettes/getTerm.yml new file mode 100644 index 0000000..fba7a10 --- /dev/null +++ b/spec/cassettes/getTerm.yml @@ -0,0 +1,67 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getTerm0gxB06s8Zcategory1 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '325' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:58 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '865' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:58 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getTerms.yml b/spec/cassettes/getTerms.yml new file mode 100644 index 0000000..9f70a95 --- /dev/null +++ b/spec/cassettes/getTerms.yml @@ -0,0 +1,80 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getTerms0gxB06s8Zcategory + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '325' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:59 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '1629' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + term_id12 + nameGeraffes + sluggeraffes + term_group0 + term_taxonomy_id12 + taxonomycategory + description + parent0 + count0 + + + term_id1 + nameUncategorized + sluguncategorized + term_group0 + term_taxonomy_id1 + taxonomycategory + description + parent0 + count1 + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:59 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getUsers.yml b/spec/cassettes/getUsers.yml new file mode 100644 index 0000000..2d1fe3c --- /dev/null +++ b/spec/cassettes/getUsers.yml @@ -0,0 +1,74 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getUsers0gxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '285' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:07:02 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '1237' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + user_id1 + username + first_nameJohnson + last_name + registered20140202T16:53:06 + bio + emailzachfeldman@gmail.com + nickname + nicename + url + display_name + roles + istrator + + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:07:02 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/getUsersBlogs.json b/spec/cassettes/getUsersBlogs.json new file mode 100644 index 0000000..d116887 --- /dev/null +++ b/spec/cassettes/getUsersBlogs.json @@ -0,0 +1 @@ +{"http_interactions":[{"request":{"method":"post","uri":"http://","body":{"encoding":"UTF-8","base64_string":"PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxtZXRob2RDYWxsPjxtZXRob2ROYW1l\nPndwLmdldFVzZXJzQmxvZ3M8L21ldGhvZE5hbWU+PHBhcmFtcz48cGFyYW0+\nPHZhbHVlPjxzdHJpbmc+PFdPUkRQUkVTU19VU0VSTkFNRT48L3N0cmluZz48\nL3ZhbHVlPjwvcGFyYW0+PHBhcmFtPjx2YWx1ZT48c3RyaW5nPmd4QjA2czha\nPC9zdHJpbmc+PC92YWx1ZT48L3BhcmFtPjwvcGFyYW1zPjwvbWV0aG9kQ2Fs\nbD4K\n"},"headers":{"User-Agent":["XMLRPC::Client (Ruby 2.0.0)"],"Content-Type":["text/xml; charset=utf-8"],"Content-Length":["213"],"Connection":["keep-alive"],"Accept-Encoding":["identity"],"Accept":["*/*"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Date":["Wed, 12 Feb 2014 03:53:17 GMT"],"Server":["Apache/2.2.22"],"X-Powered-By":["PHP/5.3.27"],"Connection":["close"],"Content-Length":["707"],"Vary":["User-Agent,Accept-Encoding"],"Content-Type":["text/xml; charset=UTF-8"]},"body":{"encoding":"UTF-8","base64_string":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG1ldGhv\nZFJlc3BvbnNlPgogIDxwYXJhbXM+CiAgICA8cGFyYW0+CiAgICAgIDx2YWx1\nZT4KICAgICAgPGFycmF5PjxkYXRhPgogIDx2YWx1ZT48c3RydWN0PgogIDxt\nZW1iZXI+PG5hbWU+aXNBZG1pbjwvbmFtZT48dmFsdWU+PGJvb2xlYW4+MTwv\nYm9vbGVhbj48L3ZhbHVlPjwvbWVtYmVyPgogIDxtZW1iZXI+PG5hbWU+dXJs\nPC9uYW1lPjx2YWx1ZT48c3RyaW5nPmh0dHA6Ly88V09SRFBSRVNTX0hPU1Q+\nL3dvcmRwcmVzczNkb3Q3bm9hdXRoLzwvc3RyaW5nPjwvdmFsdWU+PC9tZW1i\nZXI+CiAgPG1lbWJlcj48bmFtZT5ibG9naWQ8L25hbWU+PHZhbHVlPjxzdHJp\nbmc+MTwvc3RyaW5nPjwvdmFsdWU+PC9tZW1iZXI+CiAgPG1lbWJlcj48bmFt\nZT5ibG9nTmFtZTwvbmFtZT48dmFsdWU+PHN0cmluZz5Xb3JkcHJlc3MgMyBE\nb3QgNyBObyBBdXRoPC9zdHJpbmc+PC92YWx1ZT48L21lbWJlcj4KICA8bWVt\nYmVyPjxuYW1lPnhtbHJwYzwvbmFtZT48dmFsdWU+PHN0cmluZz5odHRwOi8v\nPFdPUkRQUkVTU19IT1NUPjxXT1JEUFJFU1NfUEFUSD48L3N0cmluZz48L3Zh\nbHVlPjwvbWVtYmVyPgo8L3N0cnVjdD48L3ZhbHVlPgo8L2RhdGE+PC9hcnJh\neT4KICAgICAgPC92YWx1ZT4KICAgIDwvcGFyYW0+CiAgPC9wYXJhbXM+Cjwv\nbWV0aG9kUmVzcG9uc2U+Cg==\n"},"http_version":null},"recorded_at":"Wed, 12 Feb 2014 03:53:18 GMT"}],"recorded_with":"VCR 2.5.0"} \ No newline at end of file diff --git a/spec/cassettes/getUsersBlogs.yml b/spec/cassettes/getUsersBlogs.yml new file mode 100644 index 0000000..f384675 --- /dev/null +++ b/spec/cassettes/getUsersBlogs.yml @@ -0,0 +1,65 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.getUsersBlogsgxB06s8Z + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '213' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 12 Feb 2014 03:52:16 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '707' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + + isAdmin1 + urlhttp:///wordpress3dot7noauth/ + blogid1 + blogNameWordpress 3 Dot 7 No Auth + xmlrpchttp:// + + + + + + + http_version: + recorded_at: Wed, 12 Feb 2014 03:52:17 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/httpAuthInvalid.yml b/spec/cassettes/httpAuthInvalid.yml new file mode 100644 index 0000000..c23e507 --- /dev/null +++ b/spec/cassettes/httpAuthInvalid.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: http://:wrongpass@ + body: + encoding: UTF-8 + string: | + wp.getOptions0 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '300' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 401 + message: Authorization Required + headers: + Date: + - Sat, 08 Feb 2014 23:06:36 GMT + Server: + - Apache/2.2.22 + Www-Authenticate: + - Basic realm="protected area" + Vary: + - Accept-Encoding + Content-Length: + - '474' + Keep-Alive: + - timeout=5, max=100 + Connection: + - Keep-Alive + Content-Type: + - text/html; charset=iso-8859-1 + body: + encoding: UTF-8 + string: | + + + 401 Authorization Required + +

Authorization Required

+

This server could not verify that you + are authorized to access the document + requested. Either you supplied the wrong + credentials (e.g., bad password), or your + browser doesn't understand how to supply + the credentials required.

+
+
Apache/2.2.22 Server at Port 80
+ + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:36 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/httpAuthValid.yml b/spec/cassettes/httpAuthValid.yml new file mode 100644 index 0000000..4c0ad99 --- /dev/null +++ b/spec/cassettes/httpAuthValid.yml @@ -0,0 +1,193 @@ +--- +http_interactions: +- request: + method: post + uri: http://:@ + body: + encoding: UTF-8 + string: | + wp.getOptions0 + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '300' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:34 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '8987' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + software_name + descSoftware Name + readonly1 + valueWordPress + + software_version + descSoftware Version + readonly1 + value3.7.1 + + blog_url + descWordPress Address (URL) + readonly1 + valuehttp:///wordpress3dot7 + + home_url + descSite Address (URL) + readonly1 + valuehttp:///wordpress3dot7 + + login_url + descLogin Address (URL) + readonly1 + valuehttp:///wordpress3dot7/wp-login.php + + _url + descThe URL to the area + readonly1 + valuehttp:///wordpress3dot7/wp-/ + + image_default_link_type + descImage default link type + readonly1 + valuefile + + image_default_size + descImage default size + readonly1 + value + + image_default_align + descImage default align + readonly1 + value + + template + descTemplate + readonly1 + valuetwentythirteen + + stylesheet + descStylesheet + readonly1 + valuetwentythirteen + + post_thumbnail + descPost Thumbnail + readonly1 + value1 + + time_zone + descTime Zone + readonly0 + value0 + + blog_title + descSite Title + readonly0 + valueWordpress 3 Dot 7 + + blog_tagline + descSite Tagline + readonly0 + valueThis is a great tagline + + date_format + descDate Format + readonly0 + valueF j, Y + + time_format + descTime Format + readonly0 + valueg:i a + + users_can_register + descAllow new users to sign up + readonly0 + value0 + + thumbnail_size_w + descThumbnail Width + readonly0 + value150 + + thumbnail_size_h + descThumbnail Height + readonly0 + value150 + + thumbnail_crop + descCrop thumbnail to exact dimensions + readonly0 + value1 + + medium_size_w + descMedium size image width + readonly0 + value300 + + medium_size_h + descMedium size image height + readonly0 + value300 + + large_size_w + descLarge size image width + readonly0 + value1024 + + large_size_h + descLarge size image height + readonly0 + value1024 + + default_comment_status + descAllow people to post comments on new articles + readonly0 + valueopen + + default_ping_status + descAllow link notifications from other blogs (pingbacks and trackbacks) + readonly0 + valueopen + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:36 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/newComment.yml b/spec/cassettes/newComment.yml new file mode 100644 index 0000000..77f5f11 --- /dev/null +++ b/spec/cassettes/newComment.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.newComment0gxB06s8Z1comment_parentcontentThis is a test thing here.authorJohn Adamsauthor_urlhttp://johnadamsforpresidentnow.comauthor_emailjohnadams@whitehouse.gov + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '774' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:22 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '171' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 13 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:25 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/newPost.yml b/spec/cassettes/newPost.yml new file mode 100644 index 0000000..3a74e67 --- /dev/null +++ b/spec/cassettes/newPost.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.newPost0gxB06s8Zpost_typepostpost_statusdraftpost_title5 Ways to Know You're Coolpost_contentI don't always write tests, but when I do, I use RSpec. + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '672' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:43 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '177' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 40 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:43 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/newTerm.yml b/spec/cassettes/newTerm.yml new file mode 100644 index 0000000..94e641d --- /dev/null +++ b/spec/cassettes/newTerm.yml @@ -0,0 +1,57 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.newTerm0gxB06s8ZnameGeraffestaxonomycategory + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '444' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:53 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '177' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + 12 + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:54 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/setOptions.yml b/spec/cassettes/setOptions.yml new file mode 100644 index 0000000..3c5a0f0 --- /dev/null +++ b/spec/cassettes/setOptions.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.setOptions0gxB06s8Zblog_taglineThis is a great tagline + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '392' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:41 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '504' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + blog_tagline + descSite Tagline + readonly0 + valueThis is a great tagline + + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:42 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/uploadFile.yml b/spec/cassettes/uploadFile.yml new file mode 100644 index 0000000..f0121cf --- /dev/null +++ b/spec/cassettes/uploadFile.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.uploadFile0gxB06s8Zidnametest_file.pngbits"\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\b\x03\x00\x00\x00\xBA\xEC?\x8F\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xC9e<\x00\x00\x00\fPLTE\xAC\xAC\xAC\x87\x87\x87aaa\xFF\xFF\xFF\xF2\xB3\r\x90\x00\x00\x00\x04tRNS\xFF\xFF\xFF\x00@*\xA9\xF4\x00\x00\x004IDATx\xDAl\x8D1\x12\x00 \f\xC2\x02\xFE\xFF\xCF\x82\x0Eu0\x03\x97r\xD7\x96U\xDC\xE0\x98;\xE1@\xDB$ \xA7\xACJ\x1F\xD5h\xD0]{\x8E\xCD\x8B-\xC0\x00/\x88\x00\xDF$\xC9\x85\\x00\x00\x00\x00IEND\xAEB`\x82" + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '984' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:37 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '551' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + id38 + filetest_file.png + urlhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file16.png + type + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:37 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/cassettes/uploadFile2.yml b/spec/cassettes/uploadFile2.yml new file mode 100644 index 0000000..a3e1a0c --- /dev/null +++ b/spec/cassettes/uploadFile2.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: post + uri: http:// + body: + encoding: UTF-8 + string: | + wp.uploadFile0gxB06s8Zidnametest_file.pngbits + headers: + User-Agent: + - XMLRPC::Client (Ruby 2.0.0) + Content-Type: + - text/xml; charset=utf-8 + Content-Length: + - '504' + Connection: + - keep-alive + Accept-Encoding: + - identity + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 08 Feb 2014 23:06:38 GMT + Server: + - Apache/2.2.22 + X-Powered-By: + - PHP/5.3.27 + Connection: + - close + Content-Length: + - '551' + Vary: + - User-Agent,Accept-Encoding + Content-Type: + - text/xml; charset=UTF-8 + body: + encoding: UTF-8 + string: | + + + + + + + id39 + filetest_file.png + urlhttp:///wordpress3dot7noauth/wp-content/uploads/2014/02/test_file17.png + type + + + + + + http_version: + recorded_at: Sat, 08 Feb 2014 23:06:38 GMT +recorded_with: VCR 2.5.0 diff --git a/spec/client_spec.rb b/spec/client_spec.rb new file mode 100644 index 0000000..5ae2b19 --- /dev/null +++ b/spec/client_spec.rb @@ -0,0 +1,105 @@ +require_relative 'spec_helper' + +describe "#client" do + + it '#initialize' do + CLIENT.class.should == Rubypress::Client + end + + it "#execute" do + Rubypress::Client.any_instance.stub_chain(:connection, :call){ [{"user_id"=>"46917508", "user_login"=>"johnsmith", "display_name"=>"john"}, {"user_id"=>"33333367", "user_login"=>"johnsmith", "display_name"=>"johnsmith"}] } + expect(CLIENT.execute("wp.getAuthors", {})).to eq( [{"user_id"=>"46917508", "user_login"=>"johnsmith", "display_name"=>"john"}, {"user_id"=>"33333367", "user_login"=>"johnsmith", "display_name"=>"johnsmith"}] ) + end + + it "#execute adds wp prefix to bare method name" do + connection = CLIENT.connection + allow(connection).to receive(:call) do |method, args| + expect(method).to eq('wp.getAuthors') + end + CLIENT.execute("getAuthors", {}) + end + + it "#execute does not modify wp prefix on method name" do + connection = CLIENT.connection + allow(connection).to receive(:call) do |method, args| + expect(method).to eq('wp.getAuthors') + end + CLIENT.execute("wp.getAuthors", {}) + end + + it "#execute does not modify method with custom prefix" do + connection = CLIENT.connection + allow(connection).to receive(:call) do |method, args| + expect(method).to eq("wpx.getAuthors") + end + CLIENT.execute("wpx.getAuthors", {}) + end + + it '#execute only sets up retries for the current instance' do + retryable_connection = Rubypress::Client.new(CLIENT_OPTS.merge(retry_timeouts: true)).connection + standard_connection = Rubypress::Client.new(CLIENT_OPTS).connection + + expect(retryable_connection).to respond_to(:call_with_retry) + expect(standard_connection).to_not respond_to(:call_with_retry) + end + + it '#execute retries timeouts when retry_timeouts option is true' do + client = Rubypress::Client.new(CLIENT_OPTS.merge(retry_timeouts: true)) + connection = client.connection + client.stub(:connection).and_return(connection) + + expect(connection).to receive(:call_without_retry).twice.and_raise(Timeout::Error) + expect { client.execute('newComment', {}) }.to raise_error(Timeout::Error) + end + + it '#execute retries when catch broken pipe exception and retry_timeouts option is true' do + client = Rubypress::Client.new(CLIENT_OPTS.merge(retry_timeouts: true)) + connection = client.connection + client.stub(:connection).and_return(connection) + + expect(connection).to receive(:call_without_retry).twice.and_raise(Errno::EPIPE) + expect { client.execute('newComment', {}) }.to raise_error(Errno::EPIPE) + end + + + it '#execute does not retry timeouts by default' do + client = Rubypress::Client.new(CLIENT_OPTS) + expect(client).to_not receive(:call_with_retry) + expect { client.execute('newComment', {}) }.to raise_error(VCR::Errors::UnhandledHTTPRequestError) + end + + it "#connection does not include cookies by default" do + client = Rubypress::Client.new(CLIENT_OPTS) + connection = client.connection + expect(connection.cookie).to eq nil + end + + it "#connection includes cookies when set" do + client = Rubypress::Client.new(CLIENT_OPTS.merge(cookie: "foo=bar")) + connection = client.connection + expect(connection.cookie).to include("foo=bar") + end + + it "#httpAuth" do + conn = HTTP_AUTH_CLIENT.connection + + expect( conn.user ).to eq HTTP_AUTH_CLIENT_OPTS[ :http_user ] + expect( conn.password ).to eq HTTP_AUTH_CLIENT_OPTS[ :http_password ] + + expect( conn.user.nil? ).to be false + expect( conn.password.nil? ).to be false + + end + + it "#connection defaults the timeout to 30s" do + client = Rubypress::Client.new(CLIENT_OPTS) + connection = client.connection + expect(connection.timeout).to eq 30 + end + + it "#connection timeout can be overridden" do + client = Rubypress::Client.new(CLIENT_OPTS.merge(timeout: 60)) + connection = client.connection + expect(connection.timeout).to eq 60 + end +end diff --git a/spec/comments_spec.rb b/spec/comments_spec.rb new file mode 100644 index 0000000..37a5040 --- /dev/null +++ b/spec/comments_spec.rb @@ -0,0 +1,51 @@ +require_relative 'spec_helper' + +describe "#comments" do + + let(:post_id){ 1 } + let(:comment){ {:comment_parent => "", :content => "This is a test thing here.", :author => "John Adams", :author_url => "http://johnadamsforpresidentnow.com", :author_email => "johnadams@whitehouse.gov"} } + + it "#newComment" do + VCR.use_cassette("newComment") do + COMMENT_ID = CLIENT.newComment({:post_id => post_id, :comment => comment}) + COMMENT_ID.class.should eq(Fixnum) + end + end + + it "#editComment" do + VCR.use_cassette("editComment") do + CLIENT.editComment({:comment_id => COMMENT_ID, :comment => comment}).class.should eq(TrueClass) + end + end + + it "#getCommentCount" do + VCR.use_cassette("getCommentCount") do + CLIENT.getCommentCount({:post_id => post_id}).should include("approved") + end + end + + it "#getComment" do + VCR.use_cassette("getComment") do + CLIENT.getComment({:comment_id => COMMENT_ID}).should include("content" => "This is a test thing here.") + end + end + + it "#getComments" do + VCR.use_cassette("getComments") do + CLIENT.getComments[0].should include("post_id" => post_id.to_s) + end + end + + it "#deleteComment" do + VCR.use_cassette("deleteComment") do + CLIENT.deleteComment({:comment_id => COMMENT_ID}).class.should eq(TrueClass) + end + end + + it "#getCommentStatusList" do + VCR.use_cassette("getCommentStatusList") do + CLIENT.getCommentStatusList.should include("hold" => "Unapproved") + end + end + +end \ No newline at end of file diff --git a/spec/http_auth_spec.rb b/spec/http_auth_spec.rb new file mode 100644 index 0000000..c53109d --- /dev/null +++ b/spec/http_auth_spec.rb @@ -0,0 +1,26 @@ +require_relative 'spec_helper' + +describe "#httpAuth" do + + Rubypress::Client.class_eval do + def rspec_connection + @connection + end + end + + it "#validAuth" do + VCR.use_cassette("httpAuthValid") do + HTTP_AUTH_CLIENT.getOptions + expect( HTTP_AUTH_CLIENT.rspec_connection.http_last_response.code ).to eq "200" + end + end + + it "#invalidAuth" do + VCR.use_cassette("httpAuthInvalid") do + HTTP_AUTH_CLIENT.http_password = "wrongpass" + expect{ HTTP_AUTH_CLIENT.getOptions }.to raise_error(RuntimeError) + expect( HTTP_AUTH_CLIENT.rspec_connection.http_last_response.code ).to eq "401" + end + end + +end \ No newline at end of file diff --git a/spec/media_spec.rb b/spec/media_spec.rb new file mode 100644 index 0000000..a4cd180 --- /dev/null +++ b/spec/media_spec.rb @@ -0,0 +1,37 @@ +require_relative 'spec_helper' + +describe "#media" do + + let(:file){ {:id => "", :name => "test_file.png", :bits => '"\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\b\x03\x00\x00\x00\xBA\xEC?\x8F\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xC9e<\x00\x00\x00\fPLTE\xAC\xAC\xAC\x87\x87\x87aaa\xFF\xFF\xFF\xF2\xB3\r\x90\x00\x00\x00\x04tRNS\xFF\xFF\xFF\x00@*\xA9\xF4\x00\x00\x004IDATx\xDAl\x8D1\x12\x00 \f\xC2\x02\xFE\xFF\xCF\x82\x0Eu0\x03\x97r\xD7\x96U\xDC\xE0\x98;\xE1@\xDB$ \xA7\xACJ\x1F\xD5h\xD0]{\x8E\xCD\x8B-\xC0\x00/\x88\x00\xDF$\xC9\x85\\\x00\x00\x00\x00IEND\xAEB`\x82"'}} + let(:tmp) do + tmp = Tempfile.new(file[:name]) + File.open(tmp, 'wb').write(file[:bits]) + tmp + end + + + it "#uploadFile" do + VCR.use_cassette("uploadFile") do + attachment = CLIENT.uploadFile({:data => file}) + ATTACHMENT_ID = attachment["id"] + attachment.should include("file" => "test_file.png") + end + + VCR.use_cassette("uploadFile2") do + CLIENT.uploadFile({:filename => tmp, :data => file}).should include("file" => "test_file.png") + end + end + + it "#getMediaItem" do + VCR.use_cassette("getMediaItem") do + CLIENT.getMediaItem({:attachment_id => ATTACHMENT_ID}).should include("title" => "test_file.png") + end + end + + it "#getMediaLibrary" do + VCR.use_cassette("getMediaLibrary") do + CLIENT.getMediaLibrary[0].should include("title" => "test_file.png") + end + end + +end \ No newline at end of file diff --git a/spec/options_spec.rb b/spec/options_spec.rb new file mode 100644 index 0000000..2b49a46 --- /dev/null +++ b/spec/options_spec.rb @@ -0,0 +1,17 @@ +describe "#options" do + + let(:options){ { "blog_tagline" => "This is a great tagline" } } + + it "#getOptions" do + VCR.use_cassette("getOptions") do + CLIENT.getOptions.should include("time_zone" => {"desc"=>"Time Zone", "readonly"=>false, "value"=>"0"}) + end + end + + it "#setOptions" do + VCR.use_cassette("setOptions") do + CLIENT.setOptions({:options => options}).should include("blog_tagline" => {"desc"=>"Site Tagline", "readonly"=>false, "value"=>"This is a great tagline"}) + end + end + +end \ No newline at end of file diff --git a/spec/posts_spec.rb b/spec/posts_spec.rb new file mode 100644 index 0000000..37a64ec --- /dev/null +++ b/spec/posts_spec.rb @@ -0,0 +1,62 @@ +require_relative 'spec_helper' + +describe "#post" do + + let(:post){ {:post_type => "post", :post_status => "draft", :post_title => "5 Ways to Know You're Cool", :post_content => "I don't always write tests, but when I do, I use RSpec."} } + + it "#newPost" do + VCR.use_cassette("newPost") do + POST_ID = CLIENT.newPost({:content => post}) + POST_ID.should =~ STRING_NUMBER_REGEX + end + end + + it "#getPost" do + VCR.use_cassette("getPost") do + CLIENT.getPost({:post_id => POST_ID}).should include("post_id" => POST_ID) + end + end + + it "#getPosts" do + VCR.use_cassette("getPosts") do + CLIENT.getPosts[0].should include("post_id") + end + end + + it "#editPost" do + VCR.use_cassette("editPost") do + CLIENT.editPost({:post_id => POST_ID, :content => post}).should eq(true) + end + end + + it "#deletePost" do + VCR.use_cassette("deletePost") do + CLIENT.deletePost({:post_id => POST_ID}).should eq(true) + end + end + + it "#getPostType" do + VCR.use_cassette("getPostType") do + CLIENT.getPostType({:post_type_name => "post"}).should include("name"=>"post") + end + end + + it "#getPostTypes" do + VCR.use_cassette("getPostTypes") do + CLIENT.getPostTypes.should include("page") + end + end + + it "#getPostFormats" do + VCR.use_cassette("getPostFormats") do + CLIENT.getPostFormats.should include("image" => "Image") + end + end + + it "#getPostStatusList" do + VCR.use_cassette("getPostStatusList") do + CLIENT.getPostStatusList.should include("draft"=>"Draft") + end + end + +end \ No newline at end of file diff --git a/spec/rubypress_spec.rb b/spec/rubypress_spec.rb deleted file mode 100644 index 36954f1..0000000 --- a/spec/rubypress_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/spec_helper') - -describe "Rubypress" do - - it 'can instantiate' do - init_wp_admin_connection.class.should == Rubypress::Client - end - - it 'can connect' do - init_wp_admin_connection.class.should == Rubypress::Client - init_wp_admin_connection.connection.class.should == XMLRPC::Client - - init_wp_editor_connection.get_options.class.should == Hash - - expect { init_wp_invalid_connection.get_options }.should raise_error(XMLRPC::FaultException) - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8ffcd2b..28f9091 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,38 +1,49 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' -require 'yaml' require 'rubypress' +require 'tempfile' +require_relative 'vcr_setup' -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} +def load_env(filename = '.env') + return unless File.exists?(filename) -RSpec.configure do |config| - -end + File.foreach(filename) do |line| + next if line.chomp.size == 0 -def load_config - YAML.load_file((File.exists?('./wordpress.yml')) ? './wordpress.yml' : './wordpress.yml.example') + setting = line.split('=') + key = setting.shift + ENV[key] = setting.join('').chomp + end end -def init_wp_admin_connection - config = load_config - Rubypress::Client.new( - config[:wordpress_admin] - ) +RSpec.configure do |config| + load_env end -def init_wp_editor_connection - config = load_config - Rubypress::Client.new( - config[:wordpress_editor] - ) -end +CLIENT_OPTS = { + :port => ENV['WORDPRESS_PORT'] || 80, + :host => ENV['WORDPRESS_HOST'], + :username => ENV['WORDPRESS_USERNAME'], + :password => ENV['WORDPRESS_PASSWORD'], + :path => ENV['WORDPRESS_PATH'], + :use_ssl => ENV['WORDPRESS_USE_SSL'] == 'true' +} -def init_wp_invalid_connection - config = load_config - Rubypress::Client.new( - config[:wordpress_invalid] - ) -end +HTTP_AUTH_CLIENT_OPTS = CLIENT_OPTS.merge( + :http_user => ENV['WORDPRESS_HTTP_LOGIN'] || 'test', + :http_password => ENV['WORDPRESS_HTTP_PASS'] || 'test', + :host => ENV['WORDPRESS_HTTP_HOST'], + :port => ENV['WORDPRESS_HTTP_PORT'] || 80, + :username => ENV['WORDPRESS_HTTP_USERNAME'], + :password => ENV['WORDPRESS_HTTP_PASSWORD'], + :path=> ENV['WORDPRESS_HTTP_PATH'], + :use_ssl => ENV['WORDPRESS_HTTP_USE_SSL'] == 'true' +) + + +CLIENT = Rubypress::Client.new( CLIENT_OPTS ) + +HTTP_AUTH_CLIENT = Rubypress::Client.new( HTTP_AUTH_CLIENT_OPTS ) + +STRING_NUMBER_REGEX = /^[-+]?[0-9]+$/ diff --git a/spec/taxonomies_spec.rb b/spec/taxonomies_spec.rb new file mode 100644 index 0000000..bfb39bc --- /dev/null +++ b/spec/taxonomies_spec.rb @@ -0,0 +1,51 @@ +require_relative 'spec_helper' + +describe "#taxonomies" do + + let(:term){ {:name => "Geraffes", :taxonomy => "category"} } + let(:edited_term){ {:name => "gazelles", :taxonomy => "category"} } + + it "#newTerm" do + VCR.use_cassette("newTerm") do + TERM_ID = CLIENT.newTerm({:content => term}) + TERM_ID.should =~ STRING_NUMBER_REGEX + end + end + + it "#getTaxonomy" do + VCR.use_cassette("getTaxonomy") do + CLIENT.getTaxonomy.should include("label" => "Categories") + end + end + + it "#getTaxonomies" do + VCR.use_cassette("getTaxonomies") do + CLIENT.getTaxonomies[0].should include("name"=>"category") + end + end + + it "#getTerm" do + VCR.use_cassette("getTerm") do + CLIENT.getTerm({:term_id => 1}).should include("name"=>"Uncategorized") + end + end + + it "#getTerms" do + VCR.use_cassette("getTerms") do + CLIENT.getTerms[0].should include("taxonomy"=>"category") + end + end + + it "#editTerm" do + VCR.use_cassette("editTerm") do + CLIENT.editTerm({:term_id => TERM_ID, :content => edited_term}).should eq(true) + end + end + + it "#deleteTerm" do + VCR.use_cassette("deleteTerm") do + CLIENT.deleteTerm({:term_id => TERM_ID, :taxonomy => "category"}).should eq(true) + end + end + +end \ No newline at end of file diff --git a/spec/users_spec.rb b/spec/users_spec.rb new file mode 100644 index 0000000..542ec7b --- /dev/null +++ b/spec/users_spec.rb @@ -0,0 +1,35 @@ +describe "#users" do + + let(:edited_profile_content){ {:first_name => "Johnson"} } + + it "#getUsersBlogs" do + VCR.use_cassette("getUsersBlogs", :tag => :getUsersBlogs) do + CLIENT.getUsersBlogs[0].should include("blogid") + end + end + + it "#getUsers" do + VCR.use_cassette("getUsers") do + CLIENT.getUsers[0].should include("user_id") + end + end + + it "#getProfile" do + VCR.use_cassette("getProfile") do + CLIENT.getProfile.should include("user_id") + end + end + + it "#editProfile" do + VCR.use_cassette("editProfile") do + CLIENT.editProfile({:content => edited_profile_content}).should eq(true) + end + end + + it "#getAuthors" do + VCR.use_cassette("getAuthors") do + CLIENT.getAuthors[0].should include("user_id") + end + end + +end diff --git a/spec/vcr_setup.rb b/spec/vcr_setup.rb new file mode 100644 index 0000000..15ddb19 --- /dev/null +++ b/spec/vcr_setup.rb @@ -0,0 +1,31 @@ +require 'vcr' + +sensitive_data = [ + 'WORDPRESS_HOST', + 'WORDPRESS_PATH', + 'WORDPRESS_USERNAME', + 'WORDPRESS_HTTP_PASSWORD', + 'WORDPRESS_HTTP_LOGIN', + 'WORDPRESS_HTTP_PASS', + 'WORDPRESS_HTTP_USERNAME', + 'WORDPRESS_HTTP_PASSWORD', + 'WORDPRESS_HTTP_HOST', + 'WORDPRESS_HTTP_PATH' +] + +VCR.configure do |c| + c.cassette_library_dir = 'spec/cassettes' + c.hook_into :webmock + sensitive_data.each do |data| + c.filter_sensitive_data("<#{data}>") do + CGI::escape(ENV[data]) if ENV[data] + end + c.filter_sensitive_data("<#{data}>") do + ENV[data] + end + end + c.default_cassette_options = { match_requests_on: [:method] } + c.before_playback(){|interaction| + interaction.response.update_content_length_header + } +end diff --git a/wordpress.yml.example b/wordpress.yml.example deleted file mode 100644 index 8dfc2c9..0000000 --- a/wordpress.yml.example +++ /dev/null @@ -1,21 +0,0 @@ -:wordpress_admin: - :host: blog.example.com - :path: /xmlrpc.php - :port: 80 - :username: admin - :password: foobar - :use_ssl: false -:wordpress_editor: - :host: blog.example.com - :path: /xmlrpc.php - :port: 80 - :username: foo - :password: foobar - :use_ssl: false -:wordpress_invalid: - :host: blog.example.com - :path: /xmlrpc.php - :port: 80 - :username: fasddfasdoo - :password: foobar - :use_ssl: false