Skip to content

Massive overhaul #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 92 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
71192e4
Add gemspec.
May 9, 2013
dc16140
Modified gemspec, removed unnecessary files, using env variables for …
May 9, 2013
545b371
Testing passes, test for posts added, erb in YAML file for ENV vars.
May 9, 2013
7be6cfd
Add deep_merge, test_client method, and newPost method.
May 10, 2013
24a706c
NewPost and getUsersBlogs tests integrated
May 10, 2013
378c1ac
Added ALL THE METHODS and NONE OF THE TESTS
May 10, 2013
dce062a
Fix readme
May 13, 2013
b73f249
Add VCR, README updates.
May 15, 2013
6c27aae
Update README format.
May 15, 2013
3931bb7
Term fixes.
May 21, 2013
77a3061
Major major refactor.
Jun 4, 2013
1ee706c
Some testing stuff, added debug mode to see request.
Jun 4, 2013
dacb112
All specs passing with VCR
Jun 5, 2013
61d9fba
Final cleanup, version bump to 1.0.0.
Jun 5, 2013
d850822
Changed homepage.
Jun 5, 2013
55e7ff3
Fix for Ruby 2.0.0 XML-RPC issues. See http://bugs.ruby-lang.org/issu…
Jul 2, 2013
8953496
Updated README.
Jul 8, 2013
d6a7b81
README updates.
zachfeldman Aug 13, 2013
7c5fc58
Minor gemspec change.
Sep 3, 2013
ee4ed6e
Minor README updates.
Sep 3, 2013
74d4226
Remove githalytics from now
zachfeldman Sep 20, 2013
8037f9d
Deleted .gem file
seuros Oct 5, 2013
3a1dee3
Merge pull request #1 from seuros/master
zachfeldman Oct 5, 2013
0d08719
Add contributors to the README, minor version bump.
zachfeldman Oct 5, 2013
a328c30
[#2] Add license to gemspec, is GPLv2
bf4 Nov 13, 2013
aebf381
Merge pull request #3 from bf4/add_license_to_gemspe
zachfeldman Nov 13, 2013
86c2fe8
Update README.md
alexdantas Nov 22, 2013
7e89d94
Add host note.
zachfeldman Nov 22, 2013
4ff9fec
added :filename to uploadFile
Dec 2, 2013
d908996
Merge pull request #8 from pacop/add_filename_to_uploadFile
zachfeldman Dec 3, 2013
df56eca
Added our good friend Travis CI.
zachfeldman Dec 3, 2013
e2190ce
moving spec files
pseudomuto Jan 18, 2014
8f031ff
loading .env if it exists for rspec
pseudomuto Jan 18, 2014
3683fcb
README updates compliments of @pseudomoto.
zachfeldman Jan 22, 2014
83df0c2
Minor version bump for .env file addition.
zachfeldman Jan 22, 2014
6390eca
Minor README updates.
zachfeldman Jan 22, 2014
1b75eb9
Add support for HTTP auth
borc Jan 24, 2014
1215e24
Write tests for HTTP Auth
borc Jan 29, 2014
593e414
Major testing overhaul to make tests as idempotent as possible. Versi…
zachfeldman Feb 8, 2014
a8b948e
Add Teemu to the README.
zachfeldman Feb 12, 2014
6faad9d
retrying requests that time out
pseudomuto Mar 13, 2014
ae4a574
Merge pull request #13 from pseudomuto/retryable_rpc_timeouts
zachfeldman Apr 15, 2014
f384489
Minor README update, remove pry from Gemfile.lock, version bump to 1.0.5
zachfeldman Apr 15, 2014
44b82b4
Gemfile.lock should not be included
seuros Apr 15, 2014
5af2573
removed duplicate 'attr_accessor'
seuros Apr 15, 2014
286fea8
Merge pull request #15 from seuros/master
zachfeldman Apr 16, 2014
02814f2
Version bump for depedency issues.
zachfeldman Apr 16, 2014
af1d6d4
Added ruby 2.1.1 to travis
seuros Apr 16, 2014
7ba9bab
Merge pull request #16 from seuros/master
zachfeldman Apr 16, 2014
8dadbc7
Added travis cache
seuros Apr 16, 2014
a9de5cd
Version bump to fix the build, props to @seuros.
zachfeldman Apr 16, 2014
68a1eec
Merge pull request #17 from seuros/master
zachfeldman Apr 20, 2014
0d65991
Nest modules within rubypress namespace
KieranP May 13, 2014
69addcd
Merge pull request #19 from KieranP/master
zachfeldman May 13, 2014
0681aad
Support version 1.9.2 and 1.9.3 of ruby
punkle Aug 6, 2014
beeba79
Merge pull request #24 from punkle/readtimeout
zachfeldman Aug 8, 2014
a019978
Support version 1.9.2 in tests
punkle Aug 11, 2014
a20b6ec
Remove support for ruby 1.9.2
punkle Sep 3, 2014
ec3d27c
Merge pull request #26 from punkle/remove192support
zachfeldman Sep 4, 2014
5a7d271
Version bump, update README with @punkie
zachfeldman Sep 4, 2014
3a8e600
Merge pull request #25 from punkle/192tests
zachfeldman Sep 14, 2014
74270fe
Revert "Support version 1.9.2 in tests"
zachfeldman Sep 14, 2014
f18fd2f
Merge pull request #27 from zachfeldman/revert-25-192tests
zachfeldman Sep 14, 2014
e65a491
updating to use the correct default ssl port, ability to use alternat…
coreydaley Oct 10, 2014
8a01c66
Merge pull request #29 from developercorey/master
zachfeldman Oct 10, 2014
c3fb318
README updates, version bump.
Oct 10, 2014
51a1440
updating readme adding example
coreydaley Oct 14, 2014
1227b87
Merge pull request #30 from developercorey/master
zachfeldman Oct 14, 2014
7aca602
new uploadFile patch
mibamur Nov 15, 2014
d491627
Merge pull request #32 from mibamur/patch-2
zachfeldman Nov 15, 2014
3a62cb4
fix - skip '})' in source demo uploading file
mibamur Nov 15, 2014
88bb1fc
Merge pull request #33 from mibamur/patch-3
zachfeldman Nov 15, 2014
81af09e
Cache the created XMLRPC connection
sevenseacat Nov 27, 2014
e57f987
Merge pull request #34 from karpah/patch-1
zachfeldman Nov 30, 2014
b169161
Update VCR usage to calculate content length
Jan 29, 2015
71595b3
Update to include support for cookies
Jan 29, 2015
700e308
Fix #38 - Allow tests to run against HTTPS servers
botimer Feb 2, 2015
17cd8b7
Fix #37 - Allow custom prefixes on method names
botimer Feb 2, 2015
ed572b5
Merge pull request #39 from botimer/https-tests
zachfeldman Feb 2, 2015
7bbfcb4
Merge pull request #40 from botimer/custom-prefix
zachfeldman Feb 2, 2015
ef6a8df
Merge pull request #36 from caseyhadden/cookie-support
zachfeldman Feb 2, 2015
865abda
Version bump, add contributors to README
Feb 2, 2015
f1a1e5c
Catch 'Errno::EPIPE: Broken pipe' and reconnect.
cpcerrato Jul 12, 2015
f3aeaf8
Write test for broken pipe error
cpcerrato Jul 12, 2015
a45b438
Merge pull request #45 from lastko/master
zachfeldman Aug 4, 2015
ef44bda
Update README.
Aug 4, 2015
b9af8cc
[#46] - Fix getPostStatusList
ericgascoine Feb 2, 2016
e640c44
Merge pull request #47 from ericgascoine/bugfix-46_fix_getPostStatusList
zachfeldman Feb 2, 2016
c1c6e60
Version bump, readme update.
Feb 2, 2016
33f55bf
Add configurable timeouts (#51)
mcolyer Jun 30, 2016
f436652
Credit where credit is due. Deployed new gem version.
Jun 30, 2016
3b4d5a0
Added xmlrpc dependency for ruby >= 2.4.0 support (#55)
mysticaltech Feb 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .document

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.tmp
*.swp
wordpress.yml
.env
Gemfile.lock
*.gem
.DS_Store
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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+9NFJ0qN7HkmhgD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OabXaaGpz3OpszO2kI1NvlddOfWScB213JqMyPegkWDjQFyybKPYjNUGgp3alMhlEn6jrvD96tHbdwwfWJc16lSEy1hdVA8KnqEYb0wU5RHBCIxdSM7kdxE3xmTGVJNVXt5narqikMeQ60="
- secure: "hFdTzn9BWNddcGcf/hvj9Mz3peQgGo6VdRlAVdSrOiiUoArUM2Jhjtyl5Zmsv8yNhooAp9rDxQM6KQc/RmvHWpDnOhlJxO5uWDqOWnRvYEC1CfdTST4InJKWNgJwcXYqshpsMKLAvKNmUZzLSJ6TNPQWTBhgWlfk92adiUIvxuQ="
11 changes: 2 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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
37 changes: 0 additions & 37 deletions Gemfile.lock

This file was deleted.

202 changes: 202 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 => "[email protected]",
: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 => "[email protected]",
: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 => "[email protected]",
: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 => "[email protected]",
: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 => "[email protected]",
: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
[email protected]
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.

<!--
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/ed093654d3f4ac89d05750e3def34190 "githalytics.com")](http://githalytics.com/zachfeldman/rubypress) -->
22 changes: 0 additions & 22 deletions README.rdoc

This file was deleted.

52 changes: 5 additions & 47 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"
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
Loading