wp-api 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/wp/api/endpoints.rb +36 -6
- data/lib/wp/api/resources/page.rb +4 -0
- data/lib/wp/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a72d49b5150ec356d93679a0327a678dfe1cb2a
|
4
|
+
data.tar.gz: ac756f4350f9fce2b2dc42f1b77b631401deb884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f56e888f106c21ac212a0454e90b7836ba5cc9a5d3671b91c4512f7b0dd4fae9ca1038099be7271b7c6e2173864f1e323f46611ab62f798b3cb49b6dc13f424
|
7
|
+
data.tar.gz: d72cdba3386dcffaad68f8375f09e9fa3e29e21ef0b2c8ccdc9139e2a6db2bc65c9d63b158aaac2ee000ff563000e8a9cc72b1c516e85e6af6bbdbdafaf5e6fc
|
data/lib/wp/api/endpoints.rb
CHANGED
@@ -2,18 +2,48 @@ module WP::API
|
|
2
2
|
module Endpoints
|
3
3
|
|
4
4
|
def posts(query = {})
|
5
|
-
|
6
|
-
posts.collect do |hash|
|
7
|
-
WP::API::Post.new(hash, headers)
|
8
|
-
end
|
5
|
+
resources('posts', query)
|
9
6
|
end
|
10
7
|
|
11
8
|
def post(id, query = {})
|
12
|
-
|
9
|
+
resource('posts', id, query)
|
13
10
|
end
|
14
11
|
|
15
12
|
def post_named(slug)
|
16
|
-
posts
|
13
|
+
resource_named('posts', slug)
|
14
|
+
end
|
15
|
+
|
16
|
+
def pages(query = {})
|
17
|
+
resources('pages', query)
|
18
|
+
end
|
19
|
+
|
20
|
+
def page(id, query = {})
|
21
|
+
resource('pages', id, query)
|
22
|
+
end
|
23
|
+
|
24
|
+
def page_named(slug)
|
25
|
+
resource_named('pages', slug)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def resources(res, query = {})
|
31
|
+
resources, headers = get(res, query)
|
32
|
+
resources.collect do |hash|
|
33
|
+
resource_class(res).new(hash, headers)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def resource(res, id, query = {})
|
38
|
+
resource_class(res).new *get("#{res}/#{id}", query)
|
39
|
+
end
|
40
|
+
|
41
|
+
def resource_named(res, slug)
|
42
|
+
resources(res, name: slug).first
|
43
|
+
end
|
44
|
+
|
45
|
+
def resource_class(res)
|
46
|
+
WP::API::const_get(res.classify)
|
17
47
|
end
|
18
48
|
|
19
49
|
end
|
data/lib/wp/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wp-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Young
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/wp/api/resource.rb
|
180
180
|
- lib/wp/api/resources/author.rb
|
181
181
|
- lib/wp/api/resources/category.rb
|
182
|
+
- lib/wp/api/resources/page.rb
|
182
183
|
- lib/wp/api/resources/post.rb
|
183
184
|
- lib/wp/api/version.rb
|
184
185
|
- spec/endpoints/post_spec.rb
|