formhub_ruby 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +17 -0
- data/lib/formhub_ruby/api_connector.rb +48 -11
- data/lib/formhub_ruby/version.rb +1 -1
- data/spec/api_connectior_spec.rb +56 -11
- data/spec/fixtures/vcr_cassettes/age_query.yml +60 -0
- data/spec/fixtures/vcr_cassettes/query_limit.yml +60 -0
- data/spec/fixtures/vcr_cassettes/query_start.yml +60 -0
- data/spec/fixtures/vcr_cassettes/successful_connection.yml +69 -0
- data/spec/spec_helper.rb +10 -17
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e40696a5df2916c66b1c0147d072f249745cd3
|
4
|
+
data.tar.gz: b75207dbede97b2e27594c4f441afd39b4503139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e779da0e015cf45314fe0a3f25014366e11dafee2ada6503ce7bfe0cc42888d33d0ecbdd5d5982a821ce8c8acc1b04b10c3ca0fead91bb2d9f0885fb0589fe1
|
7
|
+
data.tar.gz: 3bea5ec656654992ab7e089e7f2adda6c04aa080738be73ef44f071890cb932d07537bcd8ad723efb55c626e613790edd9bf7a276427517f2072bb817c337e25
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.0
|
4
|
+
- 2.0.0
|
5
|
+
- 1.9.3
|
6
|
+
script:
|
7
|
+
- bundle exec rspec spec/
|
8
|
+
|
9
|
+
bundler_args: --binstubs=./bundler_stubs
|
10
|
+
|
11
|
+
# addons:
|
12
|
+
# code_climate:
|
13
|
+
# repo_token: 161c371501ee0f5ff7656178f8265702fd9f6a069652bcbeeee38002a3add8c9
|
14
|
+
branches:
|
15
|
+
only:
|
16
|
+
- master
|
17
|
+
- develop
|
@@ -1,21 +1,27 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
|
+
require 'cgi'
|
3
4
|
module FormhubRuby
|
4
5
|
class ApiConnector
|
5
6
|
attr_reader :formname, :filetype, :username, :password, :data
|
7
|
+
attr_accessor :query, :start, :limit
|
6
8
|
|
7
|
-
|
9
|
+
|
10
|
+
def initialize(args)
|
8
11
|
@username = args[:username] || FormhubRuby.configuration.username
|
9
12
|
@password = args[:password] || FormhubRuby.configuration.password
|
10
|
-
@formname = args[:formname]
|
11
13
|
@filetype = args[:filetype] || 'json'
|
14
|
+
@formname = args[:formname]
|
15
|
+
@query = args[:query]
|
16
|
+
@start = args[:start]
|
17
|
+
@limit = args[:limit]
|
12
18
|
end
|
13
19
|
|
14
20
|
def fetch
|
15
21
|
# CAN DO THAT A LATER STAGE: Define different url format
|
16
22
|
# for different data point formats
|
17
23
|
# uri = URI(form_uri)
|
18
|
-
uri = URI(
|
24
|
+
uri = URI(api_uri)
|
19
25
|
req = Net::HTTP::Get.new(uri)
|
20
26
|
req.basic_auth @username, @password
|
21
27
|
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
@@ -31,15 +37,46 @@ module FormhubRuby
|
|
31
37
|
|
32
38
|
# private
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
def api_uri
|
41
|
+
"http://formhub.org/#{@username}/forms/#{@formname}/api" + api_parameters.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def api_parameters
|
45
|
+
if api_parameters_array.any?
|
46
|
+
"?#{api_parameters_joined}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def api_query
|
51
|
+
if @query
|
52
|
+
"query=#{CGI.escape stringify_hash_values(@query).to_json}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def api_parameters_array
|
57
|
+
[api_query, start, limit]
|
58
|
+
end
|
59
|
+
|
60
|
+
def api_parameters_joined
|
61
|
+
api_parameters_array.compact.join('&')
|
62
|
+
end
|
63
|
+
|
64
|
+
def start
|
65
|
+
if @start
|
66
|
+
"start=#{@start.to_s}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def limit
|
71
|
+
if @limit
|
72
|
+
"limit=#{@limit.to_s}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def stringify_hash_values(hash)
|
77
|
+
hash.merge(hash){|k,hashv|hashv.to_s}
|
78
|
+
end
|
36
79
|
|
37
|
-
# def form_uri
|
38
|
-
# case @filetype.downcase
|
39
|
-
# when 'json' then "http://formhub.org/#{@username}/forms/#{@formname}/api"
|
40
|
-
# when 'csv' then "http://formhub.org/#{@username}/forms/#{@formname}/data.csv"
|
41
|
-
# when 'xls' then "http://formhub.org/#{@username}/forms/#{@formname}/data.xls"
|
42
|
-
# end
|
43
80
|
# end
|
44
81
|
end
|
45
82
|
end
|
data/lib/formhub_ruby/version.rb
CHANGED
data/spec/api_connectior_spec.rb
CHANGED
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
describe FormhubRuby::ApiConnector do
|
6
|
-
|
7
6
|
before :each do
|
8
7
|
credentials = YAML.load_file('spec/fixtures/test_credentials.yml')
|
9
8
|
FormhubRuby.configure do |config|
|
@@ -11,20 +10,66 @@ describe FormhubRuby::ApiConnector do
|
|
11
10
|
config.password = credentials['password']
|
12
11
|
end
|
13
12
|
end
|
13
|
+
|
14
|
+
|
15
|
+
context 'when connecting to the API' do
|
16
|
+
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
it 'successfully connects to the FormHub API and retrieve JSON Data' do
|
19
|
+
VCR.use_cassette 'successful_connection' do
|
20
|
+
connection = FormhubRuby::ApiConnector.new(formname: 'survey')
|
21
|
+
connection.fetch
|
22
|
+
connection.data.should be_a_kind_of(Array)
|
23
|
+
connection.data[0].should be_a_kind_of(Object)
|
24
|
+
end
|
21
25
|
end
|
22
|
-
end
|
23
26
|
|
24
|
-
|
25
|
-
stub_request(:any, "http://formhub.org/#{FormhubRuby.configuration.username}/forms/survey/api").to_return(:body =>
|
27
|
+
it 'displays appropriate message if the JSON data is not successfully retrieved' do
|
28
|
+
stub_request(:any, "http://formhub.org/#{FormhubRuby.configuration.username}/forms/survey/api").to_return(:body => 'NO JSON HERE')
|
26
29
|
connection = FormhubRuby::ApiConnector.new(formname: 'fake')
|
27
|
-
expect {connection.fetch}.to raise_error(
|
30
|
+
expect {connection.fetch}.to raise_error('API connection error')
|
31
|
+
end
|
28
32
|
end
|
33
|
+
|
34
|
+
context 'when formulating a more complex query string' do
|
35
|
+
|
36
|
+
let(:connection) {FormhubRuby::ApiConnector.new(formname: 'survey')}
|
37
|
+
let(:username) {FormhubRuby.configuration.username}
|
38
|
+
|
39
|
+
it "does not add any extraneaous query" do
|
40
|
+
connection = FormhubRuby::ApiConnector.new(formname: 'survey')
|
41
|
+
connection.api_uri.should == "http://formhub.org/#{username}/forms/survey/api"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "does form a simple query" do
|
45
|
+
connection.query = {age: 12}
|
46
|
+
connection.api_uri.should == "http://formhub.org/#{username}/forms/survey/api?query=%7B%22age%22%3A%2212%22%7D"
|
47
|
+
VCR.use_cassette 'age_query' do
|
48
|
+
connection.fetch
|
49
|
+
connection.data.length.should == 1
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
it "formulates a query with a start" do
|
55
|
+
connection.start = 1
|
56
|
+
connection.api_uri.should == "http://formhub.org/#{username}/forms/survey/api?start=1"
|
57
|
+
VCR.use_cassette 'query_start' do
|
58
|
+
connection.fetch
|
59
|
+
connection.data.length.should == 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "formulates a query with a limit" do
|
64
|
+
connection.limit = 1
|
65
|
+
connection.api_uri.should == "http://formhub.org/#{username}/forms/survey/api?limit=1"
|
66
|
+
VCR.use_cassette 'query_limit' do
|
67
|
+
connection.fetch
|
68
|
+
connection.data.length.should == 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
29
74
|
end
|
30
75
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://<USERNAME>:<PASSWORD>@formhub.org/<USERNAME>/forms/survey/api?query=%7B%22age%22:%2212%22%7D
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- formhub.org
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Fri, 23 May 2014 11:41:14 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Server:
|
32
|
+
- gunicorn/0.15.0
|
33
|
+
Access-Control-Allow-Headers:
|
34
|
+
- Accept, Origin, X-Requested-With, Authorization
|
35
|
+
Content-Language:
|
36
|
+
- en-us
|
37
|
+
Vary:
|
38
|
+
- Accept-Language, Cookie
|
39
|
+
Etag:
|
40
|
+
- "\"a8b3103fef34948c7ead4c8335e29543\""
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- "*"
|
43
|
+
Access-Control-Allow-Methods:
|
44
|
+
- GET
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=31536000
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: "[{\"meta/instanceID\": \"uuid:be1b882a-b377-4cf0-95d3-c2acc8d04e7a\",
|
50
|
+
\"name\": \"georges\", \"_submission_time\": \"2014-05-15T16:29:00\", \"age\":
|
51
|
+
\"12\", \"_uuid\": \"be1b882a-b377-4cf0-95d3-c2acc8d04e7a\", \"_bamboo_dataset_id\":
|
52
|
+
\"\", \"_tags\": [], \"_attachments\": [], \"_geolocation\": [null, null],
|
53
|
+
\"end_time\": \"2014-05-15T17:28:59.000+01:00\", \"_xform_id_string\": \"survey\",
|
54
|
+
\"imei\": \"enketo.formhub.org:fSucCmZ5zwzNcTe1\", \"phonenumber\": \"no phonenumber
|
55
|
+
property in enketo\", \"_status\": \"submitted_via_web\", \"_id\": 3318651,
|
56
|
+
\"start_time\": \"2014-05-15T17:28:43.000+01:00\", \"today\": \"2014-05-15\",
|
57
|
+
\"formhub/uuid\": \"1bfb7222748a4ee98106ea7d7a9c72cf\"}]"
|
58
|
+
http_version:
|
59
|
+
recorded_at: Fri, 23 May 2014 11:41:39 GMT
|
60
|
+
recorded_with: VCR 2.9.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://<USERNAME>:<PASSWORD>@formhub.org/<USERNAME>/forms/survey/api?limit=1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- formhub.org
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Fri, 23 May 2014 11:46:21 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Server:
|
32
|
+
- gunicorn/0.15.0
|
33
|
+
Access-Control-Allow-Headers:
|
34
|
+
- Accept, Origin, X-Requested-With, Authorization
|
35
|
+
Content-Language:
|
36
|
+
- en-us
|
37
|
+
Vary:
|
38
|
+
- Accept-Language, Cookie
|
39
|
+
Etag:
|
40
|
+
- "\"a8b3103fef34948c7ead4c8335e29543\""
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- "*"
|
43
|
+
Access-Control-Allow-Methods:
|
44
|
+
- GET
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=31536000
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: "[{\"meta/instanceID\": \"uuid:be1b882a-b377-4cf0-95d3-c2acc8d04e7a\",
|
50
|
+
\"name\": \"georges\", \"_submission_time\": \"2014-05-15T16:29:00\", \"age\":
|
51
|
+
\"12\", \"_uuid\": \"be1b882a-b377-4cf0-95d3-c2acc8d04e7a\", \"_bamboo_dataset_id\":
|
52
|
+
\"\", \"_tags\": [], \"_attachments\": [], \"_geolocation\": [null, null],
|
53
|
+
\"end_time\": \"2014-05-15T17:28:59.000+01:00\", \"_xform_id_string\": \"survey\",
|
54
|
+
\"imei\": \"enketo.formhub.org:fSucCmZ5zwzNcTe1\", \"phonenumber\": \"no phonenumber
|
55
|
+
property in enketo\", \"_status\": \"submitted_via_web\", \"_id\": 3318651,
|
56
|
+
\"start_time\": \"2014-05-15T17:28:43.000+01:00\", \"today\": \"2014-05-15\",
|
57
|
+
\"formhub/uuid\": \"1bfb7222748a4ee98106ea7d7a9c72cf\"}]"
|
58
|
+
http_version:
|
59
|
+
recorded_at: Fri, 23 May 2014 11:46:46 GMT
|
60
|
+
recorded_with: VCR 2.9.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://<USERNAME>:<PASSWORD>@formhub.org/<USERNAME>/forms/survey/api?start=1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- formhub.org
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Fri, 23 May 2014 11:47:06 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Server:
|
32
|
+
- gunicorn/0.15.0
|
33
|
+
Access-Control-Allow-Headers:
|
34
|
+
- Accept, Origin, X-Requested-With, Authorization
|
35
|
+
Content-Language:
|
36
|
+
- en-us
|
37
|
+
Vary:
|
38
|
+
- Accept-Language, Cookie
|
39
|
+
Etag:
|
40
|
+
- "\"cca3b5eba43f81971965707f51c4882b\""
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- "*"
|
43
|
+
Access-Control-Allow-Methods:
|
44
|
+
- GET
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=31536000
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: "[{\"meta/instanceID\": \"uuid:2aebfa29-6284-4c3a-9c3f-6eb604f89194\",
|
50
|
+
\"age\": \"23\", \"name\": \"loic\", \"_submission_time\": \"2014-05-15T16:28:19\",
|
51
|
+
\"start_time\": \"2014-05-15T17:27:57.000+01:00\", \"_uuid\": \"2aebfa29-6284-4c3a-9c3f-6eb604f89194\",
|
52
|
+
\"_bamboo_dataset_id\": \"\", \"_tags\": [], \"_attachments\": [], \"imei\":
|
53
|
+
\"enketo.formhub.org:fSucCmZ5zwzNcTe1\", \"_geolocation\": [null, null], \"end_time\":
|
54
|
+
\"2014-05-15T17:28:18.000+01:00\", \"gender\": \"female\", \"_xform_id_string\":
|
55
|
+
\"survey\", \"phonenumber\": \"no phonenumber property in enketo\", \"_status\":
|
56
|
+
\"submitted_via_web\", \"_id\": 3318647, \"pizza_fan\": \"no\", \"today\":
|
57
|
+
\"2014-05-15\", \"formhub/uuid\": \"1bfb7222748a4ee98106ea7d7a9c72cf\"}]"
|
58
|
+
http_version:
|
59
|
+
recorded_at: Fri, 23 May 2014 11:47:31 GMT
|
60
|
+
recorded_with: VCR 2.9.0
|
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://<USERNAME>:<PASSWORD>@formhub.org/<USERNAME>/forms/survey/api
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- formhub.org
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Fri, 23 May 2014 10:45:15 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Server:
|
32
|
+
- gunicorn/0.15.0
|
33
|
+
Access-Control-Allow-Headers:
|
34
|
+
- Accept, Origin, X-Requested-With, Authorization
|
35
|
+
Content-Language:
|
36
|
+
- en-us
|
37
|
+
Vary:
|
38
|
+
- Accept-Language, Cookie
|
39
|
+
Etag:
|
40
|
+
- "\"29c06f8ea5b6a1ac0301ef2e10305bea\""
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- "*"
|
43
|
+
Access-Control-Allow-Methods:
|
44
|
+
- GET
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=31536000
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: "[{\"meta/instanceID\": \"uuid:be1b882a-b377-4cf0-95d3-c2acc8d04e7a\",
|
50
|
+
\"name\": \"georges\", \"_submission_time\": \"2014-05-15T16:29:00\", \"age\":
|
51
|
+
\"12\", \"_uuid\": \"be1b882a-b377-4cf0-95d3-c2acc8d04e7a\", \"_bamboo_dataset_id\":
|
52
|
+
\"\", \"_tags\": [], \"_attachments\": [], \"_geolocation\": [null, null],
|
53
|
+
\"end_time\": \"2014-05-15T17:28:59.000+01:00\", \"_xform_id_string\": \"survey\",
|
54
|
+
\"imei\": \"enketo.formhub.org:fSucCmZ5zwzNcTe1\", \"phonenumber\": \"no phonenumber
|
55
|
+
property in enketo\", \"_status\": \"submitted_via_web\", \"_id\": 3318651,
|
56
|
+
\"start_time\": \"2014-05-15T17:28:43.000+01:00\", \"today\": \"2014-05-15\",
|
57
|
+
\"formhub/uuid\": \"1bfb7222748a4ee98106ea7d7a9c72cf\"}, {\"meta/instanceID\":
|
58
|
+
\"uuid:2aebfa29-6284-4c3a-9c3f-6eb604f89194\", \"age\": \"23\", \"name\":
|
59
|
+
\"loic\", \"_submission_time\": \"2014-05-15T16:28:19\", \"start_time\": \"2014-05-15T17:27:57.000+01:00\",
|
60
|
+
\"_uuid\": \"2aebfa29-6284-4c3a-9c3f-6eb604f89194\", \"_bamboo_dataset_id\":
|
61
|
+
\"\", \"_tags\": [], \"_attachments\": [], \"imei\": \"enketo.formhub.org:fSucCmZ5zwzNcTe1\",
|
62
|
+
\"_geolocation\": [null, null], \"end_time\": \"2014-05-15T17:28:18.000+01:00\",
|
63
|
+
\"gender\": \"female\", \"_xform_id_string\": \"survey\", \"phonenumber\":
|
64
|
+
\"no phonenumber property in enketo\", \"_status\": \"submitted_via_web\",
|
65
|
+
\"_id\": 3318647, \"pizza_fan\": \"no\", \"today\": \"2014-05-15\", \"formhub/uuid\":
|
66
|
+
\"1bfb7222748a4ee98106ea7d7a9c72cf\"}]"
|
67
|
+
http_version:
|
68
|
+
recorded_at: Fri, 23 May 2014 10:45:40 GMT
|
69
|
+
recorded_with: VCR 2.9.0
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'vcr'
|
2
2
|
require 'webmock'
|
3
3
|
require 'webmock/rspec'
|
4
|
-
require '
|
4
|
+
require 'yaml'
|
5
|
+
require 'cgi'
|
5
6
|
|
6
7
|
RSpec.configure do |config|
|
7
|
-
FactoryGirl.find_definitions
|
8
|
-
|
9
8
|
config.include WebMock::API
|
10
9
|
config.before(:each) do
|
11
10
|
WebMock.reset!
|
@@ -13,22 +12,16 @@ RSpec.configure do |config|
|
|
13
12
|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
14
13
|
c.allow_http_connections_when_no_cassette = true
|
15
14
|
c.hook_into :webmock
|
16
|
-
# c.before_record do |i|
|
17
|
-
|
18
|
-
# i.response.headers.delete('Set-Cookie')
|
19
|
-
# i.request.headers.delete('Authorization')
|
20
|
-
|
21
|
-
# u = URI.parse(i.request.uri)
|
22
|
-
# i.request.uri.sub!(%r{:\/\/.*#{Regexp.escape(u.host)}}, "://#{u.host}")
|
23
15
|
|
24
|
-
#
|
16
|
+
# Created a yml file with credentials
|
17
|
+
# ignored by git repository
|
18
|
+
credentials = YAML.load_file('spec/fixtures/test_credentials.yml')
|
19
|
+
|
20
|
+
c.filter_sensitive_data('<USERNAME>') { credentials['username'] }
|
21
|
+
c.filter_sensitive_data('<PASSWORD>') { CGI.escape credentials['password'] }
|
22
|
+
c.filter_sensitive_data('<PASSWORD>') { credentials['password'] }
|
25
23
|
|
26
|
-
|
27
|
-
# auth string (https://user:pass@domain.tld)
|
28
|
-
# c.register_request_matcher :anonymized_uri do |request_1, request_2|
|
29
|
-
# (URI(request_1.uri).port == URI(request_2.uri).port) &&
|
30
|
-
# URI(request_1.uri).path == URI(request_2.uri).path
|
31
|
-
# end
|
24
|
+
|
32
25
|
end
|
33
26
|
|
34
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formhub_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loïc Seigland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -172,6 +172,7 @@ extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
174
|
- ".gitignore"
|
175
|
+
- ".travis.yml"
|
175
176
|
- Gemfile
|
176
177
|
- Guardfile
|
177
178
|
- LICENSE.txt
|
@@ -184,6 +185,10 @@ files:
|
|
184
185
|
- lib/formhub_ruby/version.rb
|
185
186
|
- spec/api_connectior_spec.rb
|
186
187
|
- spec/client_spec.rb
|
188
|
+
- spec/fixtures/vcr_cassettes/age_query.yml
|
189
|
+
- spec/fixtures/vcr_cassettes/query_limit.yml
|
190
|
+
- spec/fixtures/vcr_cassettes/query_start.yml
|
191
|
+
- spec/fixtures/vcr_cassettes/successful_connection.yml
|
187
192
|
- spec/spec_helper.rb
|
188
193
|
homepage: http://loicseigland.ie
|
189
194
|
licenses:
|
@@ -212,4 +217,8 @@ summary: Simple Client for the Formhub API
|
|
212
217
|
test_files:
|
213
218
|
- spec/api_connectior_spec.rb
|
214
219
|
- spec/client_spec.rb
|
220
|
+
- spec/fixtures/vcr_cassettes/age_query.yml
|
221
|
+
- spec/fixtures/vcr_cassettes/query_limit.yml
|
222
|
+
- spec/fixtures/vcr_cassettes/query_start.yml
|
223
|
+
- spec/fixtures/vcr_cassettes/successful_connection.yml
|
215
224
|
- spec/spec_helper.rb
|