wordpress-xmlrpc 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +25 -0
- data/Gemfile +9 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/features/publish.feature +18 -0
- data/features/step_definitions/basic_steps.rb +28 -0
- data/features/step_definitions/mysql_steps.rb +7 -0
- data/features/support/env.rb +14 -0
- data/lib/blog.rb +61 -0
- data/lib/exceptions.rb +3 -0
- data/lib/loggable.rb +20 -0
- data/lib/params_check.rb +6 -0
- data/lib/post.rb +58 -0
- data/lib/wordpress-xmlrpc.rb +13 -0
- data/spec/blog_spec.rb +113 -0
- data/spec/post_spec.rb +91 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +18 -0
- data/wordpress-xmlrpc.gemspec +67 -0
- metadata +106 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
## PROJECT::SPECIFIC
|
22
|
+
.bundle
|
23
|
+
wordpress
|
24
|
+
webrat.log
|
25
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Alexander Naumenko
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= wordpress-xmlrpc
|
2
|
+
|
3
|
+
This gem is very fresh and under hard development. Please contact me directly before forking it ;)
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Alexander Naumenko. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "wordpress-xmlrpc"
|
9
|
+
gem.summary = %Q{This gem is supposed to simplify wordpress xmlrpc interaction}
|
10
|
+
gem.description = %Q{Please do not fork it before directly contacint}
|
11
|
+
gem.email = "alecnmk@gmail.com"
|
12
|
+
gem.homepage = "http://github.com/alecnmk/wordpress-xmlrpc"
|
13
|
+
gem.authors = ["Alexander Naumenko"]
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "wordpress-xmlrpc #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Publish post
|
2
|
+
In order to make a posts
|
3
|
+
I will need to call my client on blog API
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I have a blog control
|
7
|
+
And all posts and comments cleaned out
|
8
|
+
|
9
|
+
Scenario: Load wordpress home page
|
10
|
+
When I go to wordpress "home" page
|
11
|
+
Then I should see "wordpress"
|
12
|
+
When make following post:
|
13
|
+
| title | content | publish_date |
|
14
|
+
| hey ho | this is my first post | 01.08.2010 |
|
15
|
+
And I go to wordpress "home" page
|
16
|
+
Then I should see "hey ho"
|
17
|
+
And I should see "this is my first post"
|
18
|
+
And I should see "Posted on August 1, 2010 by admin"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
When /^I go to wordpress "([^\"]*)" page$/ do |page|
|
2
|
+
case page
|
3
|
+
when "home"
|
4
|
+
visit("/")
|
5
|
+
else
|
6
|
+
raise "Undefined page #{page}"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I wait for (\d+) seconds+$/ do |seconds|
|
11
|
+
sleep(seconds.to_i)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^I should see "([^\"]*)"$/ do |expected_content|
|
15
|
+
page.should have_content(expected_content)
|
16
|
+
end
|
17
|
+
|
18
|
+
Given /^I have a blog control$/ do
|
19
|
+
@blog = Wordpress::Blog.new(:host => "http://localhost", :user => "admin", :password => "wordpress-xmlrpc")
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^make following post:$/ do |table|
|
23
|
+
table.hashes.each do |hash|
|
24
|
+
hash['publish_date'] = Date.parse(hash.delete('publish_date')) if hash['publish_date']
|
25
|
+
post = Wordpress::Post.new(hash)
|
26
|
+
@blog.publish(post)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Given /^all posts and comments cleaned out$/ do
|
2
|
+
mysql = Mysql.new("localhost", "root", "", "wordpress_xmlrpc")
|
3
|
+
mysql.query("delete from wp_posts")
|
4
|
+
mysql.query("delete from wp_postmeta")
|
5
|
+
mysql.query("delete from wp_comments")
|
6
|
+
mysql.query("delete from wp_commentmeta")
|
7
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'capybara/cucumber'
|
2
|
+
require 'selenium/webdriver'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
5
|
+
require 'wordpress-xmlrpc'
|
6
|
+
|
7
|
+
require 'mysql'
|
8
|
+
|
9
|
+
Capybara.default_driver = :selenium
|
10
|
+
Capybara.app_host = "http://localhost"
|
11
|
+
Capybara.default_selector = :css
|
12
|
+
Capybara.default_wait_time = 3
|
13
|
+
Capybara.ignore_hidden_elements = true
|
14
|
+
|
data/lib/blog.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'xmlrpc/client'
|
2
|
+
require 'params_check'
|
3
|
+
|
4
|
+
module Wordpress
|
5
|
+
class Blog
|
6
|
+
include ParamsCheck
|
7
|
+
include Loggable
|
8
|
+
|
9
|
+
def initialize(params = {})
|
10
|
+
@blog_uri = URI.parse(check_param(params, :blog_uri))
|
11
|
+
|
12
|
+
@xmlrpc_path = params[:xmlrpc_path] || "xmlrpc"
|
13
|
+
|
14
|
+
@id = params[:blog_id] || 0
|
15
|
+
|
16
|
+
@user = check_param(params, :user)
|
17
|
+
|
18
|
+
@password = check_param(params, :password)
|
19
|
+
|
20
|
+
@client = XMLRPC::Client.new2(URI.join(@blog_uri.to_s, @xmlrpc_path).to_s)
|
21
|
+
end #initialize
|
22
|
+
|
23
|
+
def get_post(post_id)
|
24
|
+
Post.new(api_call("metaWeblog.getPost", post_id, @user, @password))
|
25
|
+
end #get_post
|
26
|
+
|
27
|
+
def recent_posts(number_of_posts)
|
28
|
+
blog_api_call("metaWeblog.getRecentPosts", number_of_posts).collect do |struct|
|
29
|
+
Post.from_struct(struct)
|
30
|
+
end
|
31
|
+
end #recent_posts
|
32
|
+
|
33
|
+
def publish(post)
|
34
|
+
post.id = blog_api_call("metaWeblog.newPost", post.to_struct, true).to_i
|
35
|
+
post.published = true
|
36
|
+
end #publish
|
37
|
+
|
38
|
+
def update_post(post)
|
39
|
+
return api_call("metaWeblog.editPost", post.id, @user, @password, post.to_struct, post.published)
|
40
|
+
end #update_post
|
41
|
+
|
42
|
+
private
|
43
|
+
def api_call(method_name, *args)
|
44
|
+
begin
|
45
|
+
return @client.call(method_name, *args)
|
46
|
+
rescue XMLRPC::FaultException
|
47
|
+
log.log_exception "Error while calling #{method_name}", $!
|
48
|
+
raise APICallException, "Error while calling #{method_name}"
|
49
|
+
end
|
50
|
+
end #api_call
|
51
|
+
|
52
|
+
def blog_api_call(method_name, *args)
|
53
|
+
begin
|
54
|
+
return @client.call(method_name, @id, @user, @password, *args)
|
55
|
+
rescue XMLRPC::FaultException
|
56
|
+
log.log_exception "Error while calling #{method_name}", $!
|
57
|
+
raise APICallException, "Error while calling #{method_name}"
|
58
|
+
end
|
59
|
+
end #call_client
|
60
|
+
end
|
61
|
+
end
|
data/lib/exceptions.rb
ADDED
data/lib/loggable.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
module Loggable
|
5
|
+
Log4r::Logger.class_eval do
|
6
|
+
define_method :log_exception do |message, exception|
|
7
|
+
error {"#{message} (#{exception.message})"}
|
8
|
+
debug {exception.backtrace.pretty_inspect}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included(mod)
|
13
|
+
@@log = Log4r::Logger.new mod.name
|
14
|
+
@@log.outputters = Log4r::Outputter.stdout
|
15
|
+
end #included
|
16
|
+
|
17
|
+
def log
|
18
|
+
@@log
|
19
|
+
end #log
|
20
|
+
end
|
data/lib/params_check.rb
ADDED
data/lib/post.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Wordpress
|
2
|
+
class Post
|
3
|
+
ATTRIBUTE_MATCHES = {
|
4
|
+
:title => :title,
|
5
|
+
:content => :description,
|
6
|
+
:excerpt => :mt_excerpt,
|
7
|
+
:creation_date => :dateCreated,
|
8
|
+
:id => :postid
|
9
|
+
}
|
10
|
+
|
11
|
+
attr_accessor(
|
12
|
+
:id,
|
13
|
+
:title,
|
14
|
+
:content,
|
15
|
+
:excerpt,
|
16
|
+
:creation_date,
|
17
|
+
:published
|
18
|
+
)
|
19
|
+
|
20
|
+
def initialize(attributes = {})
|
21
|
+
attributes.each do |attribute, value|
|
22
|
+
accessor_name = "#{attribute}="
|
23
|
+
send(accessor_name, value) if respond_to?(accessor_name)
|
24
|
+
end
|
25
|
+
end #initialize
|
26
|
+
|
27
|
+
def self.from_struct(struct)
|
28
|
+
post = Post.new
|
29
|
+
ATTRIBUTE_MATCHES.each do |post_attribute, struct_attribute|
|
30
|
+
post.send("#{post_attribute}=", struct[struct_attribute])
|
31
|
+
end
|
32
|
+
post.published = struct[:post_state] == "publish"
|
33
|
+
post
|
34
|
+
end #self.from_struct
|
35
|
+
|
36
|
+
def to_struct
|
37
|
+
struct = {}
|
38
|
+
ATTRIBUTE_MATCHES.each do |post_attribute, struct_attribute|
|
39
|
+
value = self.send(post_attribute)
|
40
|
+
struct[struct_attribute] = value if value
|
41
|
+
end
|
42
|
+
struct
|
43
|
+
end #to_struct
|
44
|
+
|
45
|
+
def creation_date=(value)
|
46
|
+
case value
|
47
|
+
when String
|
48
|
+
@creation_date = Date.parse(value)
|
49
|
+
when Date
|
50
|
+
@creation_date = value
|
51
|
+
when nil
|
52
|
+
@creation_date = value
|
53
|
+
else
|
54
|
+
raise ArgumentError, "Date or String expected instead of #{value.class.name}"
|
55
|
+
end
|
56
|
+
end #publish_date=
|
57
|
+
end
|
58
|
+
end
|
data/spec/blog_spec.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Wordpress::Blog do
|
4
|
+
describe "initialize" do
|
5
|
+
before(:each) do
|
6
|
+
@valid_params = {
|
7
|
+
:blog_uri => "http://localhost",
|
8
|
+
:user => "admin",
|
9
|
+
:password => "password"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should require error without host param provided" do
|
14
|
+
@valid_params.delete :blog_uri
|
15
|
+
lambda{
|
16
|
+
Wordpress::Blog.new(@valid_params)
|
17
|
+
}.should raise_error ArgumentError, ":blog_uri param is required"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise error without user param provided" do
|
21
|
+
@valid_params.delete :user
|
22
|
+
lambda{
|
23
|
+
Wordpress::Blog.new(@valid_params)
|
24
|
+
}.should raise_error ArgumentError, ":user param is required"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise error without password param provided" do
|
28
|
+
@valid_params.delete :password
|
29
|
+
lambda{
|
30
|
+
Wordpress::Blog.new(@valid_params)
|
31
|
+
}.should raise_error ArgumentError, ":password param is required"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should require valid blog URI" do
|
35
|
+
lambda{
|
36
|
+
Wordpress::Blog.new(:blog_uri => "invalid uri")
|
37
|
+
}.should raise_error URI::InvalidURIError
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should create new blog instance with valid host param provided" do
|
41
|
+
blog = Wordpress::Blog.new(@valid_params)
|
42
|
+
blog.should_not be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "api calls" do
|
47
|
+
before(:each) do
|
48
|
+
@client_mock = mock("client")
|
49
|
+
XMLRPC::Client.should_receive(:new2).with("http://localhost/xmlrpc").and_return(@client_mock)
|
50
|
+
|
51
|
+
@blog = Wordpress::Blog.new(
|
52
|
+
:blog_uri => "http://localhost",
|
53
|
+
:user => "admin",
|
54
|
+
:password => "wordpress-xmlrpc",
|
55
|
+
:blog_id => 0
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "publish" do
|
60
|
+
it "should make appropriate call to xmlrpc api" do
|
61
|
+
|
62
|
+
post = Wordpress::Post.new(
|
63
|
+
:title => "Hey ho",
|
64
|
+
:content => "Content",
|
65
|
+
:excerpt => "Excerpt",
|
66
|
+
:publish_date => Date.parse("01.08.2010"))
|
67
|
+
|
68
|
+
@client_mock.should_receive(:call).with("metaWeblog.newPost", 0, "admin", "wordpress-xmlrpc", post.to_struct, true).and_return("123")
|
69
|
+
|
70
|
+
@blog.publish(post).should be_true
|
71
|
+
post.id.should == 123
|
72
|
+
post.published.should be_true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "recent_posts" do
|
77
|
+
it "should make appropriate call to xmlrpc api and return list of posts" do
|
78
|
+
post_structs = (1..10).collect do |index|
|
79
|
+
{
|
80
|
+
:title => "Post #{index}"
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
@client_mock.should_receive(:call).with("metaWeblog.getRecentPosts", 0, "admin", "wordpress-xmlrpc", 10).and_return(post_structs)
|
85
|
+
|
86
|
+
recent_posts = @blog.recent_posts(10)
|
87
|
+
recent_posts.size.should == 10
|
88
|
+
recent_posts[0].title.should == "Post 1"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "get_post" do
|
93
|
+
it "should return post for provided post_id" do
|
94
|
+
post_struct = {
|
95
|
+
:title => "Post title"
|
96
|
+
}
|
97
|
+
@client_mock.should_receive(:call).with("metaWeblog.getPost", 54, "admin", "wordpress-xmlrpc").and_return(post_struct)
|
98
|
+
post = @blog.get_post(54)
|
99
|
+
post.should_not be_nil
|
100
|
+
post.title.should == "Post title"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "update_post" do
|
105
|
+
it "should submit post update" do
|
106
|
+
post = Wordpress::Post.new(:id => 54, :title => "Updated post", :published => true)
|
107
|
+
@client_mock.should_receive(:call).with("metaWeblog.editPost", 54, "admin", "wordpress-xmlrpc", post.to_struct, true).and_return(true)
|
108
|
+
@blog.update_post(post).should be_true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
data/spec/post_spec.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Wordpress::Post do
|
4
|
+
describe "initialize" do
|
5
|
+
it "should populate title from params" do
|
6
|
+
post = Wordpress::Post.new(:title => "Hey ho")
|
7
|
+
post.title.should == "Hey ho"
|
8
|
+
end
|
9
|
+
it "should populate content from params" do
|
10
|
+
post = Wordpress::Post.new(:content => "This is a content")
|
11
|
+
post.content.should == "This is a content"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "to_struct" do
|
16
|
+
it "should return struct hash reflecting all post params" do
|
17
|
+
post = Wordpress::Post.new(
|
18
|
+
:id => 99,
|
19
|
+
:title => "Post title",
|
20
|
+
:content => "Post content",
|
21
|
+
:excerpt => "Post excerpt",
|
22
|
+
:creation_date => Date.parse("01.08.2010")
|
23
|
+
)
|
24
|
+
post.to_struct.should == {
|
25
|
+
:postid => 99,
|
26
|
+
:title => "Post title",
|
27
|
+
:description => "Post content",
|
28
|
+
:mt_excerpt => "Post excerpt",
|
29
|
+
:dateCreated => Date.parse("01.08.2010")
|
30
|
+
}
|
31
|
+
end
|
32
|
+
it "should return incomplete struct for params without params that are nil" do
|
33
|
+
post = Wordpress::Post.new(:title => "Post title")
|
34
|
+
post.to_struct.should == {
|
35
|
+
:title => "Post title"
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "from_struct" do
|
41
|
+
it "should create post from RPC struct" do
|
42
|
+
post = Wordpress::Post.from_struct({
|
43
|
+
:postid => 99,
|
44
|
+
:title => "Post title",
|
45
|
+
:description => "Post content",
|
46
|
+
:mt_excerpt => "Post excerpt",
|
47
|
+
:dateCreated => "01.08.2010",
|
48
|
+
:post_state => "publish"
|
49
|
+
})
|
50
|
+
post.id.should == 99
|
51
|
+
post.title.should == "Post title"
|
52
|
+
post.content.should == "Post content"
|
53
|
+
post.excerpt.should == "Post excerpt"
|
54
|
+
post.creation_date.should == Date.parse("01.08.2010")
|
55
|
+
post.published.should be_true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "creation_date=" do
|
60
|
+
before(:each) do
|
61
|
+
@post = Wordpress::Post.new
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should convert string to date" do
|
65
|
+
@post.creation_date = "01.08.2010"
|
66
|
+
@post.creation_date.should == Date.parse("01.08.2010")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should assign date as is if kind_of? Date provided" do
|
70
|
+
date = Date.parse("01.08.2010")
|
71
|
+
@post.creation_date = date
|
72
|
+
@post.creation_date.should == date
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should raise error if string could not be parsed to date" do
|
76
|
+
lambda{
|
77
|
+
@post.creation_date = "abracadabra"
|
78
|
+
}.should raise_error ArgumentError, "invalid date"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should raise exception if object is not a string and not a date" do
|
82
|
+
lambda{
|
83
|
+
@post.creation_date = Integer(10)
|
84
|
+
}.should raise_error ArgumentError, "Date or String expected instead of Fixnum"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
# to avoid logging while executing tests we need to preload bundled gems
|
5
|
+
# and set log level to FATAL
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
require 'log4r'
|
9
|
+
# Log4r::Logger.root.level = Log4r::FATAL
|
10
|
+
|
11
|
+
require 'spec'
|
12
|
+
require 'spec/autorun'
|
13
|
+
|
14
|
+
require 'wordpress-xmlrpc'
|
15
|
+
|
16
|
+
Spec::Runner.configure do |config|
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{wordpress-xmlrpc}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alexander Naumenko"]
|
12
|
+
s.date = %q{2010-09-15}
|
13
|
+
s.description = %q{Please do not fork it before directly contacint}
|
14
|
+
s.email = %q{alecnmk@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"features/publish.feature",
|
28
|
+
"features/step_definitions/basic_steps.rb",
|
29
|
+
"features/step_definitions/mysql_steps.rb",
|
30
|
+
"features/support/env.rb",
|
31
|
+
"lib/blog.rb",
|
32
|
+
"lib/exceptions.rb",
|
33
|
+
"lib/loggable.rb",
|
34
|
+
"lib/params_check.rb",
|
35
|
+
"lib/post.rb",
|
36
|
+
"lib/wordpress-xmlrpc.rb",
|
37
|
+
"spec/blog_spec.rb",
|
38
|
+
"spec/post_spec.rb",
|
39
|
+
"spec/spec.opts",
|
40
|
+
"spec/spec_helper.rb",
|
41
|
+
"wordpress-xmlrpc.gemspec"
|
42
|
+
]
|
43
|
+
s.homepage = %q{http://github.com/alecnmk/wordpress-xmlrpc}
|
44
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubygems_version = %q{1.3.7}
|
47
|
+
s.summary = %q{This gem is supposed to simplify wordpress xmlrpc interaction}
|
48
|
+
s.test_files = [
|
49
|
+
"spec/spec_helper.rb",
|
50
|
+
"spec/blog_spec.rb",
|
51
|
+
"spec/post_spec.rb"
|
52
|
+
]
|
53
|
+
|
54
|
+
if s.respond_to? :specification_version then
|
55
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
|
+
s.specification_version = 3
|
57
|
+
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordpress-xmlrpc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alexander Naumenko
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-15 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Please do not fork it before directly contacint
|
38
|
+
email: alecnmk@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- LICENSE
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- .document
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.rdoc
|
52
|
+
- Rakefile
|
53
|
+
- VERSION
|
54
|
+
- features/publish.feature
|
55
|
+
- features/step_definitions/basic_steps.rb
|
56
|
+
- features/step_definitions/mysql_steps.rb
|
57
|
+
- features/support/env.rb
|
58
|
+
- lib/blog.rb
|
59
|
+
- lib/exceptions.rb
|
60
|
+
- lib/loggable.rb
|
61
|
+
- lib/params_check.rb
|
62
|
+
- lib/post.rb
|
63
|
+
- lib/wordpress-xmlrpc.rb
|
64
|
+
- spec/blog_spec.rb
|
65
|
+
- spec/post_spec.rb
|
66
|
+
- spec/spec.opts
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
- wordpress-xmlrpc.gemspec
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/alecnmk/wordpress-xmlrpc
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options:
|
75
|
+
- --charset=UTF-8
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.3.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: This gem is supposed to simplify wordpress xmlrpc interaction
|
103
|
+
test_files:
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/blog_spec.rb
|
106
|
+
- spec/post_spec.rb
|