watir_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watir_api.rb +24 -10
- data/watir_api.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb25e51df99ac53a5b6b1dcc2f9be372bb96332d
|
4
|
+
data.tar.gz: f61459b4cccb2601e10f0d69c58d6d6ec301f72e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ede385d5cd5d0d0e903ae9395cfc82a847798f1cc14656f0bc59dac97cd3957c5a746b8d3d6249ddb8022c8337b087b24a9b530fa2dc028bdc24bb0465bcf7b
|
7
|
+
data.tar.gz: c296a167491f4fa69b12bc8cd7daf2de7caa22b61b710ae3e8fddff567c926f0eacc9847f9e0e33a8235003ebb95d99ebbce90d9869cd2ea41489f214488d8c4
|
data/lib/watir_api.rb
CHANGED
@@ -6,23 +6,31 @@ module WatirApi
|
|
6
6
|
class << self
|
7
7
|
|
8
8
|
def index(opt = {})
|
9
|
-
new rest_call(:get,
|
9
|
+
new rest_call({method: :get,
|
10
|
+
url: route}.merge opt)
|
10
11
|
end
|
11
12
|
|
12
13
|
def show(id:, **opt)
|
13
|
-
new rest_call(:get,
|
14
|
+
new rest_call({method: :get,
|
15
|
+
url: "#{route}/#{id}"}.merge opt)
|
14
16
|
end
|
15
17
|
|
16
18
|
def create(obj = nil)
|
17
|
-
new rest_call(:post,
|
19
|
+
new rest_call(method: :post,
|
20
|
+
url: route,
|
21
|
+
payload: generate_payload(obj),
|
22
|
+
headers: headers)
|
18
23
|
end
|
19
24
|
|
20
25
|
def destroy(id:, **opt)
|
21
|
-
new rest_call(:delete,
|
26
|
+
new rest_call({method: :delete,
|
27
|
+
url: "#{route}/#{id}"}.merge opt)
|
22
28
|
end
|
23
29
|
|
24
30
|
def update(id:, with:, **opt)
|
25
|
-
new rest_call(:put,
|
31
|
+
new rest_call({method: :put,
|
32
|
+
url: "#{route}/#{id}",
|
33
|
+
payload: generate_payload(with)}.merge opt)
|
26
34
|
end
|
27
35
|
|
28
36
|
def base_url=(base_url)
|
@@ -47,10 +55,10 @@ module WatirApi
|
|
47
55
|
|
48
56
|
private
|
49
57
|
|
50
|
-
def rest_call(
|
51
|
-
RestClient.
|
52
|
-
|
53
|
-
|
58
|
+
def rest_call(opt)
|
59
|
+
RestClient::Request.execute(opt) do |response, request, result|
|
60
|
+
[response, request, result]
|
61
|
+
end
|
54
62
|
end
|
55
63
|
|
56
64
|
def generate_payload(obj)
|
@@ -65,13 +73,19 @@ module WatirApi
|
|
65
73
|
obj.to_json
|
66
74
|
end
|
67
75
|
end
|
76
|
+
|
77
|
+
def headers
|
78
|
+
{content_type: :json}
|
79
|
+
end
|
68
80
|
end
|
69
81
|
|
70
82
|
attr_reader :data, :code, :response
|
71
83
|
|
72
|
-
def initialize(
|
84
|
+
def initialize(args)
|
85
|
+
response, request, _result = *args
|
73
86
|
@response = response
|
74
87
|
@code = response.code
|
88
|
+
@header = request.instance_variable_get('@header')
|
75
89
|
@data = JSON.parse(response.body, symbolize_names: true) rescue nil
|
76
90
|
@data = (convert_to_model(@data) || @data) unless @data.nil? || !(defined? model_object.new)
|
77
91
|
end
|
data/watir_api.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "watir_api"
|
6
|
-
spec.version = "0.1.
|
6
|
+
spec.version = "0.1.1"
|
7
7
|
spec.authors = ["Titus Fortner"]
|
8
8
|
spec.email = ["titusfortner@gmail.com"]
|
9
9
|
|
@@ -26,7 +26,7 @@ compare test data with what is input and displayed via UI.}
|
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
spec.add_runtime_dependency "rest-client"
|
28
28
|
spec.add_runtime_dependency "faker"
|
29
|
-
spec.add_runtime_dependency "watir_model", "~> 0.
|
29
|
+
spec.add_runtime_dependency "watir_model", "~> 0.5.0"
|
30
30
|
|
31
31
|
spec.add_development_dependency "bundler", "~> 1.16"
|
32
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.5.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|