wp-api 0.0.3 → 0.0.4

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: e47781bfa7510821225aeb90053dab50a11b7579
4
- data.tar.gz: 74a354808fa1138efa2fcb3ee7a43312c1467ef7
3
+ metadata.gz: 4786dfab68505b62157fbfb015323f2e3f10f738
4
+ data.tar.gz: 79ec8f42be18f457e0a6f47b621bdb689dce23b8
5
5
  SHA512:
6
- metadata.gz: b9d09030d433e7a192488d991ffa4df5bb7805d90817e82fea9e0d7377dae30b432c025c0df98f9ed05569ec34e6daccb8975e5ff0d1e09650370205ee0b1c6c
7
- data.tar.gz: b653ec85e6228bf9c61fa0a40d61a788e56977f6856128917d4f713f0995000a2463ae2fff1f20588541d4f4a571adc73872f33305bb1a21ac81c7f0f61d6f9b
6
+ metadata.gz: 4de8a015333ba781d172277959f0fd6f0730e975c71bd6a2fea7bc04e8e102347f3bd58ec03b67cdd57feaf448a9b82b1dbfef5ec8ac6035aac59d7c1aba424e
7
+ data.tar.gz: df9758a2951ad7a7ab04b8924f3f4fab3ff9a2c365e5659b0ada9943174a3267082bd6ebccfaa7579b7a74ba38661935b763253106412a71c76c8992f0e513c9
data/lib/wp/api/client.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'httparty'
2
2
  require 'addressable/uri'
3
3
  require 'wp/api/endpoints'
4
+ require 'active_support/hash_with_indifferent_access'
4
5
 
5
6
  module WP::API
6
7
  class Client
@@ -18,6 +19,7 @@ module WP::API
18
19
  protected
19
20
 
20
21
  def get(resource, query = {})
22
+ query = ActiveSupport::HashWithIndifferentAccess.new(query)
21
23
  path = url_for(resource, query)
22
24
  response = Client.get(path)
23
25
  if response.empty?
@@ -38,7 +40,7 @@ module WP::API
38
40
 
39
41
  def params(query)
40
42
  uri = Addressable::URI.new
41
- filter_hash = {}
43
+ filter_hash = { page: query.delete('page') || 1 }
42
44
  query.each do |key, value|
43
45
  filter_hash["filter[#{key}]"] = value
44
46
  end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/inflector'
2
- require 'pry'
3
2
 
4
3
  module WP::API
5
4
  class Resource
@@ -50,6 +49,10 @@ module WP::API
50
49
  end
51
50
  end
52
51
 
52
+ def _remove_entities(string)
53
+ HTMLEntities.new.decode(string.gsub('&','&'))
54
+ end
55
+
53
56
  def _downcase_keys(hash)
54
57
  Hash.new.tap do |new_hash|
55
58
  hash.each do |k, v|
@@ -1,5 +1,15 @@
1
+ require 'htmlentities'
2
+
1
3
  module WP::API
2
4
  class Post < Resource
5
+ def title
6
+ _remove_entities(super)
7
+ end
8
+
9
+ def content
10
+ _remove_entities(super)
11
+ end
12
+
3
13
  def categories
4
14
  terms['category'].collect {|cat| WP::API::Category.new(cat) }
5
15
  end
@@ -1,5 +1,5 @@
1
1
  module WP
2
2
  module API
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
data/wp-api.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency 'httparty'
22
22
  spec.add_runtime_dependency 'activesupport'
23
23
  spec.add_runtime_dependency 'addressable'
24
+ spec.add_runtime_dependency 'htmlentities'
24
25
 
25
26
  spec.add_development_dependency "bundler", "~> 1.6"
26
27
  spec.add_development_dependency "yajl-ruby", '~> 1.2.1'
@@ -28,5 +29,4 @@ Gem::Specification.new do |spec|
28
29
  spec.add_development_dependency "rspec", '>= 2.0'
29
30
  spec.add_development_dependency "rspec-its", '>= 1.0.1'
30
31
  spec.add_development_dependency "fakeweb", '~> 1.3', '>= 1.3.0'
31
- spec.add_development_dependency "pry"
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wp-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Young
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: htmlentities
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,20 +156,6 @@ dependencies:
142
156
  - - ">="
143
157
  - !ruby/object:Gem::Version
144
158
  version: 1.3.0
145
- - !ruby/object:Gem::Dependency
146
- name: pry
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '0'
159
159
  description: Makes it incredibly easy and semantic to access Wordpress blogs that
160
160
  have the new, RESTful WP API plugin installed.
161
161
  email: