wpdb_activerecord 1.03 → 1.05
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wpdb_activerecord/comment.rb +9 -0
- data/lib/wpdb_activerecord/configuration.rb +3 -1
- data/lib/wpdb_activerecord/option.rb +4 -0
- data/lib/wpdb_activerecord/post.rb +2 -0
- data/lib/wpdb_activerecord/term.rb +3 -0
- data/lib/wpdb_activerecord/term_taxonomy.rb +1 -0
- data/lib/wpdb_activerecord/user.rb +1 -0
- data/lib/wpdb_activerecord/version.rb +1 -1
- data/lib/wpdb_activerecord.rb +1 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76dddf73540269d61aa4d20d085f0c42082b1249
|
4
|
+
data.tar.gz: 297cf92b16e4397ae181fe164dbeda860045718a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fde98b5fa0f3c7f54b0d4f68e114f20a82a8729ad7d04af9b848988d588291554491df512699a4e6aa0404c9866c1a091c233edcc37fb2dd1dac5a4b70c36c
|
7
|
+
data.tar.gz: 83245acf24d0e6315f7888a34a5fcae5763fe184f07df053b85fe837c8a885674a4eee1fcfdba555f9767fabba7acce662fd4d5f0225a3406f8d74203b702878
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module WPDB
|
2
|
+
class Comment < ActiveRecord::Base
|
3
|
+
self.table_name = "#{WPDB.configuration.prefix}comments"
|
4
|
+
self.primary_key = :comment_ID
|
5
|
+
|
6
|
+
belongs_to :post, foreign_key: "comment_post_ID", class_name: WPDB.configuration.post_class
|
7
|
+
belongs_to :user, foreign_key: "user_id", class_name: WPDB.configuration.user_class
|
8
|
+
end
|
9
|
+
end
|
@@ -9,7 +9,7 @@ module WPDB
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class Configuration
|
12
|
-
attr_accessor :prefix, :post_class, :postmeta_class, :term_class,
|
12
|
+
attr_accessor :prefix, :option_class, :comment_class, :post_class, :postmeta_class, :term_class,
|
13
13
|
:term_relationship_class, :term_taxonomy_class,
|
14
14
|
:user_class, :usermeta_class
|
15
15
|
|
@@ -17,6 +17,8 @@ module WPDB
|
|
17
17
|
path = File.join(root, "config", "wpdb_config.yml")
|
18
18
|
config = File.exists?(path) ? YAML.load_file(path) : Hash.new
|
19
19
|
@prefix = config["WPDB_PREFIX"] || "wp_"
|
20
|
+
@option_class = config["WPDB_OPTION_CLASS"] || "WPDB::Option"
|
21
|
+
@comment_class = config["WPDB_COMMENT_CLASS"] || "WPDB::Comment"
|
20
22
|
@post_class = config["WPDB_POST_CLASS"] || "WPDB::Post"
|
21
23
|
@postmeta_class = config["WPDB_POSTMETA_CLASS"] || "WPDB::Postmeta"
|
22
24
|
@term_class = config["WPDB_TERM_CLASS"] || "WPDB::Term"
|
@@ -6,6 +6,8 @@ module WPDB
|
|
6
6
|
belongs_to :author, class_name: WPDB.configuration.user_class, foreign_key: "post_author"
|
7
7
|
belongs_to :parent, class_name: WPDB.configuration.post_class
|
8
8
|
|
9
|
+
has_many :comments, foreign_key: "comment_post_ID", class_name: WPDB.configuration.comment_class
|
10
|
+
|
9
11
|
# tag / category
|
10
12
|
has_many :term_relationships, foreign_key: "object_id", class_name: WPDB.configuration.term_relationship_class
|
11
13
|
has_many :terms, through: :term_relationships, foreign_key: "term_id", class_name: WPDB.configuration.term_class
|
@@ -4,7 +4,10 @@ module WPDB
|
|
4
4
|
self.primary_key = :term_id
|
5
5
|
|
6
6
|
has_one :term_taxonomy, foreign_key: "term_id", class_name: WPDB.configuration.term_taxonomy_class
|
7
|
+
has_one :parent, through: :term_taxonomy, foreign_key: "parent", class_name: WPDB.configuration.term_class
|
7
8
|
has_many :term_taxonomies, foreign_key: "term_id", class_name: WPDB.configuration.term_taxonomy_class
|
9
|
+
has_many :term_relationships, through: :term_taxonomies, foreign_key: "term_taxonomy_id", class_name: WPDB.configuration.term_taxonomy_class
|
10
|
+
has_many :posts, through: :term_relationships, foreign_key: "object_id", class_name: WPDB.configuration.post_class
|
8
11
|
|
9
12
|
scope :tag, -> { joins(:term_taxonomy).where("#{WPDB.configuration.term_taxonomy_class.constantize.table_name}.taxonomy = 'post_tag'") }
|
10
13
|
scope :category, -> { joins(:term_taxonomy).where("#{WPDB.configuration.term_taxonomy_class.constantize.table_name}.taxonomy = 'category'") }
|
@@ -4,6 +4,7 @@ module WPDB
|
|
4
4
|
self.primary_key = :term_taxonomy_id
|
5
5
|
|
6
6
|
belongs_to :term, foreign_key: "term_id", class_name: WPDB.configuration.term_class
|
7
|
+
belongs_to :parent, foreign_key: "parent", class_name: WPDB.configuration.term_class
|
7
8
|
has_many :term_relationships, foreign_key: "term_taxonomy_id", class_name: WPDB.configuration.term_relationship_class
|
8
9
|
|
9
10
|
has_many :posts, through: :term_relationships, class_name: WPDB.configuration.post_class
|
@@ -4,6 +4,7 @@ module WPDB
|
|
4
4
|
self.primary_key = :ID
|
5
5
|
|
6
6
|
has_many :posts, foreign_key: "post_author", class_name: WPDB.configuration.post_class
|
7
|
+
has_many :comments, foreign_key: "user_id", class_name: WPDB.configuration.comment_class
|
7
8
|
has_many :usermetas, foreign_key: "user_id", class_name: WPDB.configuration.usermeta_class
|
8
9
|
|
9
10
|
def check_password?(password)
|
data/lib/wpdb_activerecord.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "wpdb_activerecord/configuration"
|
2
2
|
|
3
3
|
require_relative "wpdb_activerecord/option"
|
4
|
+
require_relative "wpdb_activerecord/comment"
|
4
5
|
require_relative "wpdb_activerecord/post"
|
5
6
|
require_relative "wpdb_activerecord/postmeta"
|
6
7
|
require_relative "wpdb_activerecord/term"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wpdb_activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.05'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hothero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: php-serialize
|
@@ -42,28 +42,28 @@ dependencies:
|
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mysql2
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.3.0
|
69
69
|
description: WpdbActiverecord gives you a painless way to access and interact with
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- Rakefile
|
81
81
|
- lib/tasks/wpdb_activerecord_tasks.rake
|
82
82
|
- lib/wpdb_activerecord.rb
|
83
|
+
- lib/wpdb_activerecord/comment.rb
|
83
84
|
- lib/wpdb_activerecord/configuration.rb
|
84
85
|
- lib/wpdb_activerecord/option.rb
|
85
86
|
- lib/wpdb_activerecord/post.rb
|
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
113
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.11
|
114
115
|
signing_key:
|
115
116
|
specification_version: 4
|
116
117
|
summary: A ActiveRecord ORM wrapper for WordPress
|