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 +12 -8
- data/lib/panlex_client/panlex_client.rb +5 -6
- data/panlex_client.spec +1 -1
- metadata +2 -2
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
|
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 }
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
# @
|
11
|
-
|
12
|
-
|
13
|
-
|
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
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.
|
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-
|
12
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|