wp-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4c9c3faed41acdd43fd383185f27f860accb3a1
4
- data.tar.gz: ed29bcb49bccd0103de686b97baf0def3fa38f91
3
+ metadata.gz: 3a72d49b5150ec356d93679a0327a678dfe1cb2a
4
+ data.tar.gz: ac756f4350f9fce2b2dc42f1b77b631401deb884
5
5
  SHA512:
6
- metadata.gz: 9b7873a290e6886bbe870ade0a8b9d34aca4b5c55bf396c68e4c3deb54f3c1169681df3bebedc2cf975f11865fea3d85fa92fe030da68219570403d0cfee232a
7
- data.tar.gz: 80b0e704c626de24b670ea50cf2372695d22463bc1ce872a033c5fc4369f7043370dfad94599aa1da37739afd36b9da05417e386ec34c57b67903bc741826d31
6
+ metadata.gz: 3f56e888f106c21ac212a0454e90b7836ba5cc9a5d3671b91c4512f7b0dd4fae9ca1038099be7271b7c6e2173864f1e323f46611ab62f798b3cb49b6dc13f424
7
+ data.tar.gz: d72cdba3386dcffaad68f8375f09e9fa3e29e21ef0b2c8ccdc9139e2a6db2bc65c9d63b158aaac2ee000ff563000e8a9cc72b1c516e85e6af6bbdbdafaf5e6fc
@@ -2,18 +2,48 @@ module WP::API
2
2
  module Endpoints
3
3
 
4
4
  def posts(query = {})
5
- posts, headers = get("posts", query)
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
- WP::API::Post.new *get("posts/#{id}", query)
9
+ resource('posts', id, query)
13
10
  end
14
11
 
15
12
  def post_named(slug)
16
- posts(name: slug).first
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
@@ -0,0 +1,4 @@
1
+ module WP::API
2
+ class Page < Resource
3
+ end
4
+ end
@@ -1,5 +1,5 @@
1
1
  module WP
2
2
  module API
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
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.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-18 00:00:00.000000000 Z
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