panlex_client 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,21 +3,25 @@ Simple Ruby client for the [public API](http://dev.panlex.org/api/) of the [Panl
3
3
 
4
4
  ## Usage
5
5
 
6
- Right now, there is just a `PanlexClient` module with only one `query` method which accepts three arguments: the URL parameter, the request body and an optional block to process the response and which accept three arguments: response, request and result.
6
+ Right now, there is just a `PanlexClient` module with only one `query` method with two arguments: the URL parameter and the request body. It returns PanLex API response parsed to a Hash.
7
7
 
8
8
  ```ruby
9
9
  require 'panlex_client'
10
10
 
11
- PanlexClient.query 'lv', { :indent => true, :limit => 2 } do |response, request, result|
12
- response_json = JSON.parse(response)
13
- if response_json['status'] == 'OK' then
14
- response_json['result'].each do |language|
15
- puts language.to_s
16
- end
17
- end
11
+ response = PanlexClient.query 'lv', { :indent => true, :limit => 2 }
12
+
13
+ if response['status'] == 'OK' then
14
+ response['result'].each do |language|
15
+ puts language['tt']
16
+ end
18
17
  end
18
+
19
19
  ```
20
20
 
21
+ ## Relase Policy
22
+
23
+ panlex_client follows the principles of [semantic versioning](http://semver.org/). panlex_client is still in an 0.x.y version, so it is not considered stable and anything can change at any moment.
24
+
21
25
  ## LICENSE
22
26
 
23
27
  Copyright 2013 Marc Busqué - <marc@lamarciana.com>
@@ -3,14 +3,13 @@ module PanlexClient
3
3
  # PanLex public API URL
4
4
  API_URL = 'http://api.panlex.org/'
5
5
 
6
- # Send a request to PanLex API.
6
+ # Send a request to PanLex API and return JSON.
7
7
  #
8
8
  # @param param [String] {http://dev.panlex.org/api/#urlparam PanLex API URL parameter}
9
9
  # @param body [#to_json] The request body which includes the query parameters. Look at the {http://dev.panlex.org/api/#globalparam global optional parameter} and the specifics for each URL parameter
10
- # @yieldparam response [String] The response from PanLex, a string you can parse to JSON
11
- # @yieldparam request [RestClient::Request]
12
- # @yieldparam result [Net::HTTPOK]
13
- def self.query(param, body, &block)
14
- RestClient.post API_URL+param, body.to_json, { :content_type => :json, :accept => :json }, &block
10
+ # @return [Hash] {http://dev.panlex.org/api/#globalparam PanLex API response}
11
+ def self.query(param, body)
12
+ response = RestClient.post API_URL+param, body.to_json, { 'content-type' => :json, :accept => :json, 'accept-encoding' => 'gzip' }
13
+ JSON.parse(response)
15
14
  end
16
15
  end
data/panlex_client.spec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'panlex_client'
3
- s.version = '0.1.2'
3
+ s.version = '0.2.0'
4
4
  s.summary = 'Client for the PanLex database public API'
5
5
  s.description = 'https://github.com/laMarciana/panlex_client/'
6
6
  s.license = 'GPL3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panlex_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-10 00:00:00.000000000 Z
12
+ date: 2013-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client