ruby-wpdb 1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +8 -0
- data/README.md +97 -0
- data/data/query.log +26431 -0
- data/lib/ruby-wpdb/comments.rb +32 -0
- data/lib/ruby-wpdb/gravityforms.rb +208 -0
- data/lib/ruby-wpdb/links.rb +8 -0
- data/lib/ruby-wpdb/options.rb +24 -0
- data/lib/ruby-wpdb/posts.rb +67 -0
- data/lib/ruby-wpdb/terms.rb +49 -0
- data/lib/ruby-wpdb/users.rb +39 -0
- data/lib/ruby-wpdb/version.rb +3 -0
- data/lib/ruby-wpdb.rb +51 -0
- data/test/comments_test.rb +40 -0
- data/test/gravityforms_test.rb +25 -0
- data/test/links_test.rb +28 -0
- data/test/options_test.rb +26 -0
- data/test/posts_test.rb +50 -0
- data/test/readme_test.rb +43 -0
- data/test/terms_test.rb +42 -0
- data/test/test_helper.rb +17 -0
- data/test/users_test.rb +47 -0
- metadata +180 -0
data/test/readme_test.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
# Examples from the README; it's obviously important that they work
|
4
|
+
# since they're people's first exposure to the project!
|
5
|
+
describe "README" do
|
6
|
+
it "performs more complex queries" do
|
7
|
+
post = WPDB::Post.create(:post_title => 'aaaaa', :post_author => 1)
|
8
|
+
post.add_postmeta(:meta_key => 'image', :meta_value => 'test')
|
9
|
+
post.save
|
10
|
+
|
11
|
+
meta_value = WPDB::Post.first(:post_title => /^[a-z]+$/, :ID => post.ID)
|
12
|
+
.postmeta_dataset.first(:meta_key => 'image').meta_value
|
13
|
+
assert_equal 'test', meta_value
|
14
|
+
|
15
|
+
post.destroy
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates records" do
|
19
|
+
post = WPDB::Post.create(:post_title => 'Test', :post_content => 'Testing, testing, 123', :post_author => 1)
|
20
|
+
assert post.ID
|
21
|
+
post.destroy
|
22
|
+
end
|
23
|
+
|
24
|
+
it "creates posts, users, and tags all in one go" do
|
25
|
+
author = WPDB::User.create(
|
26
|
+
:user_login => 'fred',
|
27
|
+
:user_email => 'fred@example.com'
|
28
|
+
)
|
29
|
+
|
30
|
+
term = WPDB::Term.create(:name => 'Fred Stuff')
|
31
|
+
|
32
|
+
post = WPDB::Post.create(
|
33
|
+
:post_title => 'Hello from Fred',
|
34
|
+
:post_content => 'Hello, world',
|
35
|
+
:author => author
|
36
|
+
)
|
37
|
+
post.add_term(term, 'tag')
|
38
|
+
|
39
|
+
author.destroy
|
40
|
+
term.destroy
|
41
|
+
post.destroy
|
42
|
+
end
|
43
|
+
end
|
data/test/terms_test.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe WPDB::Term do
|
4
|
+
before do
|
5
|
+
@term = WPDB::Term.create(:name => 'test')
|
6
|
+
@term_taxonomy = WPDB::TermTaxonomy.create(:term_id => @term.term_id, :taxonomy => 'category')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "saves terms" do
|
10
|
+
assert @term.term_id
|
11
|
+
end
|
12
|
+
|
13
|
+
it "attaches terms to posts" do
|
14
|
+
post = WPDB::Post.create(:post_title => 'test', :post_author => 1)
|
15
|
+
post.add_termtaxonomy(@term_taxonomy)
|
16
|
+
post.save
|
17
|
+
|
18
|
+
assert post.ID
|
19
|
+
assert post.termtaxonomy.length
|
20
|
+
assert_equal @term.term_id, post.termtaxonomy.first.term_id
|
21
|
+
assert_equal 'category', post.termtaxonomy.first.taxonomy
|
22
|
+
|
23
|
+
post.destroy
|
24
|
+
end
|
25
|
+
|
26
|
+
it "attaches terms to posts with the shorthand" do
|
27
|
+
post = WPDB::Post.create(:post_title => 'test', :post_author => 1)
|
28
|
+
post.add_term(@term, 'category')
|
29
|
+
post.save
|
30
|
+
|
31
|
+
assert post.ID
|
32
|
+
assert post.termtaxonomy.length
|
33
|
+
assert_equal @term.term_id, post.termtaxonomy.first.term_id
|
34
|
+
assert_equal 'category', post.termtaxonomy.first.taxonomy
|
35
|
+
|
36
|
+
post.destroy
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
@term.destroy
|
41
|
+
end
|
42
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
require 'letters'
|
7
|
+
|
8
|
+
require 'sequel'
|
9
|
+
|
10
|
+
require 'ruby-wpdb'
|
11
|
+
|
12
|
+
WPDB.from_config
|
13
|
+
|
14
|
+
require 'logger'
|
15
|
+
WPDB.db.logger = Logger.new('data/query.log')
|
16
|
+
|
17
|
+
require 'minitest/autorun'
|
data/test/users_test.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe WPDB::User do
|
4
|
+
before do
|
5
|
+
@user = WPDB::User.create(
|
6
|
+
:user_login => 'test',
|
7
|
+
:user_pass => 'test',
|
8
|
+
:user_nicename => 'Testy Testerson',
|
9
|
+
:user_email => 'test@example.com',
|
10
|
+
:user_registered => DateTime.now
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "creates a new user" do
|
15
|
+
assert @user.ID
|
16
|
+
end
|
17
|
+
|
18
|
+
it "adds usermeta" do
|
19
|
+
@user.add_usermeta(:meta_key => 'test', :meta_value => 'test')
|
20
|
+
@user.save
|
21
|
+
|
22
|
+
user = WPDB::User.where(:ID => @user.ID).first
|
23
|
+
meta_value = user.usermeta.first.meta_value
|
24
|
+
assert_equal 'test', meta_value
|
25
|
+
end
|
26
|
+
|
27
|
+
it "hashes passwords" do
|
28
|
+
@user.save
|
29
|
+
assert_equal Digest::MD5.hexdigest('test'), @user.user_pass
|
30
|
+
end
|
31
|
+
|
32
|
+
it "registers the authorship of posts" do
|
33
|
+
post = WPDB::Post.create(:post_title => "Testy's first post")
|
34
|
+
@user.add_post(post)
|
35
|
+
@user.reload
|
36
|
+
|
37
|
+
assert_equal "Testy's first post", @user.posts.first.post_title
|
38
|
+
|
39
|
+
assert_equal @user.ID, post.post_author
|
40
|
+
|
41
|
+
post.destroy
|
42
|
+
end
|
43
|
+
|
44
|
+
after do
|
45
|
+
@user.destroy
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-wpdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Miller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mysql2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.11
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sequel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sequel_sluggable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.6
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.6
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: php-serialize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 10.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 10.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: letters
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.4.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.4.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.12
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.12
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-debugger
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.2.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.2.2
|
125
|
+
description: ruby-wpdb gives you a painless way to access and interact with WordPress
|
126
|
+
from Ruby, accessing posts, tags, and all other WordPress concepts as plain-old
|
127
|
+
Ruby objects.
|
128
|
+
email: rob@bigfish.co.uk
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- lib/ruby-wpdb/comments.rb
|
134
|
+
- lib/ruby-wpdb/gravityforms.rb
|
135
|
+
- lib/ruby-wpdb/links.rb
|
136
|
+
- lib/ruby-wpdb/options.rb
|
137
|
+
- lib/ruby-wpdb/posts.rb
|
138
|
+
- lib/ruby-wpdb/terms.rb
|
139
|
+
- lib/ruby-wpdb/users.rb
|
140
|
+
- lib/ruby-wpdb/version.rb
|
141
|
+
- lib/ruby-wpdb.rb
|
142
|
+
- data/query.log
|
143
|
+
- test/comments_test.rb
|
144
|
+
- test/gravityforms_test.rb
|
145
|
+
- test/links_test.rb
|
146
|
+
- test/options_test.rb
|
147
|
+
- test/posts_test.rb
|
148
|
+
- test/readme_test.rb
|
149
|
+
- test/terms_test.rb
|
150
|
+
- test/test_helper.rb
|
151
|
+
- test/users_test.rb
|
152
|
+
- LICENSE
|
153
|
+
- README.md
|
154
|
+
- Gemfile
|
155
|
+
homepage: http://github.com/robmiller/ruby-wpdb
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
metadata: {}
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - '>'
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 1.3.1
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 2.0.3
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: A Ruby ORM wrapper for WordPress
|
179
|
+
test_files: []
|
180
|
+
has_rdoc:
|