query_28io 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/query_28io.rb +84 -0
  2. metadata +65 -0
data/lib/query_28io.rb ADDED
@@ -0,0 +1,84 @@
1
+ require 'rubygems'
2
+ require 'rest-client'
3
+
4
+ ##
5
+ # This module allows to run public 28.io queries
6
+ #
7
+ module Query28io
8
+
9
+ ##
10
+ # This method run a public 28.io query at the specified URL
11
+ # and return its results.
12
+ #
13
+ # A GET request will be issued to the specified URL.
14
+ # Optionally, you can specify one or more parameters to be
15
+ # passed to the query. They will be passed to the specified
16
+ # query by means of the request URL.
17
+ #
18
+ # The server response will be returned as an RestClient::Response
19
+ # object.
20
+ # The code, cookies, and body methods can be used to retrieve the
21
+ # server response code, cookies and body respectively.
22
+ # Additional information can be found at
23
+ # http://rubydoc.info/gems/rest-client/1.6.7/frames.
24
+ #
25
+ # Example:
26
+ # >>response = Query28io.runQuery "http://example.28.io/example.jq"
27
+ # >>response.code
28
+ # # => 200
29
+ # >>response.body
30
+ # # => {...}
31
+ #
32
+ # Example, with optional parameters:
33
+ # >>response = Query28io.runQuery "http://example.28.io/example.jq", {:foo => 'bar'}
34
+ # >>response.code
35
+ # # => 200
36
+ # >>response.body
37
+ # # => {...}
38
+ #
39
+ # Arguments:
40
+ # url: the public query URL (String)
41
+ # params: optionally, the query arguments (Hash)
42
+ #
43
+ def self.runQuery(url, params={})
44
+ RestClient.get(url, {:params => params}){|response, request, result| response }
45
+ end
46
+
47
+ ##
48
+ # This method run a public 28.io query at the specified URL
49
+ # and return its results.
50
+ #
51
+ # A POST request will be issued to the specified URL.
52
+ # Optionally, you can specify one or more parameters to be
53
+ # passed to the query. They will be passed to the specified
54
+ # query by means of the request body.
55
+ #
56
+ # The server response will be returned as an RestClient::Response
57
+ # object.
58
+ # The code, cookies, and body methods can be used to retrieve the
59
+ # server response code, cookies and body respectively.
60
+ # Additional information can be found at
61
+ # http://rubydoc.info/gems/rest-client/1.6.7/frames.
62
+ #
63
+ # Example:
64
+ # >>response = Query28io.runQuery "http://example.28.io/example.jq"
65
+ # >>response.code
66
+ # # => 200
67
+ # >>response.body
68
+ # # => {...}
69
+ #
70
+ # Example, with optional parameters:
71
+ # >>response = Query28io.runQuery "http://example.28.io/example.jq", {:foo => 'bar'}
72
+ # >>response.code
73
+ # # => 200
74
+ # >>response.body
75
+ # # => {...}
76
+ #
77
+ # Arguments:
78
+ # url: the public query URL (String)
79
+ # params: optionally, the query arguments (Hash)
80
+ #
81
+ def self.runQueryPost(url, params ={})
82
+ RestClient.post(url, params){|response, request, result| response }
83
+ end
84
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: query_28io
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Federico Cavalieri
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-07-08 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: ==This gem allows to run public queries on 28.io
22
+ email: f@28msec.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/query_28io.rb
31
+ homepage: http://rubygems.org/gems/query_28io
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.15
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: 28.io query API
64
+ test_files: []
65
+