ftr_ruby 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: def2bc2018d1d794afabd625f72f2bc5f78fb363dc4a06f87c2fd8cc2967f7e2
4
- data.tar.gz: 6ae0b03ff20569a405c6f34f5e13fd84f6a9bfe9db9d6b67f536ca2cadb4d5e2
3
+ metadata.gz: 3d62219e48ef4691b85401ac885542a5051dbccd7b1071839b8f0eb779ef131f
4
+ data.tar.gz: 2fb72b6cf2765a9f8b2dfe98f1815d1ab5f72482be8e562ac4222c1e02254860
5
5
  SHA512:
6
- metadata.gz: 1f8771dfbcb93530f56ad05f53f2606300f4d829e78d66976f971501bc62d39668eeb5afe67ad0db00adb56dd263964f4d934afc64359285ce889b8389279738
7
- data.tar.gz: 13eaaa05362c0290c13377d1b7f7b2e427bc7e00caa5d83a082e02eac6c404ee4d7f41fcfad9486a5a6e527af57487a2156f9a790240701314b4ff957f434abe
6
+ metadata.gz: 7508a2b075ecdb121212ec3a8eaf0d9662a1aad1a4cae79b12b98f547c84cf31e7748d5da1eb845ed13970a4f12897be59709114754dfc4a0cedffc289665445
7
+ data.tar.gz: 448496de2b06ef443823e142dfb0425a9ea65b32cf6f6cc079630f6ba64031948073afd52606164ea2d17566040c79bd3ed9509c1a4abdbaa5c461a84b3a3072
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FtrRuby
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/openapi.rb CHANGED
@@ -1,77 +1,79 @@
1
- class OpenAPI
2
- attr_accessor :title, :metric, :description, :indicator, :testid,
3
- :organization, :org_url, :version, :creator,
4
- :responsible_developer, :email, :developer_ORCiD, :protocol,
5
- :host, :basePath, :path, :response_description, :schemas, :endpointpath
1
+ module FtrRuby
2
+ class OpenAPI
3
+ attr_accessor :title, :metric, :description, :indicator, :testid,
4
+ :organization, :org_url, :version, :creator,
5
+ :responsible_developer, :email, :developer_ORCiD, :protocol,
6
+ :host, :basePath, :path, :response_description, :schemas, :endpointpath
6
7
 
7
- def initialize(meta:)
8
- indics = [meta[:indicators]] unless meta[:indicators].is_a? Array
9
- @testid = meta[:testid]
10
- @title = meta[:testname]
11
- @version = meta[:testversion]
12
- @metric = meta[:metric]
13
- @description = meta[:description]
14
- @indicator = indics.first
15
- @organization = meta[:organization]
16
- @org_url = meta[:org_url]
17
- @responsible_developer = meta[:responsible_developer]
18
- @email = meta[:email]
19
- @creator = meta[:creator]
20
- @host = meta[:host]
21
- @host = @host.gsub(%r{/$}, "") # remove trailing slash if present
22
- @protocol = meta[:protocol].gsub(%r{[:/]}, "")
23
- @basePath = meta[:basePath].gsub(%r{[:/]}, "")
24
- @basePath = "/#{basePath}" unless basePath[0] == "/" # must start with a slash
25
- @path = meta[:path]
26
- @response_description = meta[:response_description]
27
- @schemas = meta[:schemas]
28
- @endpointpath = "assess/test"
29
- @end_url = "#{protocol}://#{host}#{basePath}/#{endpointpath}/#{testid}" # basepath starts with /
30
- end
8
+ def initialize(meta:)
9
+ indics = [meta[:indicators]] unless meta[:indicators].is_a? Array
10
+ @testid = meta[:testid]
11
+ @title = meta[:testname]
12
+ @version = meta[:testversion]
13
+ @metric = meta[:metric]
14
+ @description = meta[:description]
15
+ @indicator = indics.first
16
+ @organization = meta[:organization]
17
+ @org_url = meta[:org_url]
18
+ @responsible_developer = meta[:responsible_developer]
19
+ @email = meta[:email]
20
+ @creator = meta[:creator]
21
+ @host = meta[:host]
22
+ @host = @host.gsub(%r{/$}, "") # remove trailing slash if present
23
+ @protocol = meta[:protocol].gsub(%r{[:/]}, "")
24
+ @basePath = meta[:basePath].gsub(%r{[:/]}, "")
25
+ @basePath = "/#{basePath}" unless basePath[0] == "/" # must start with a slash
26
+ @path = meta[:path]
27
+ @response_description = meta[:response_description]
28
+ @schemas = meta[:schemas]
29
+ @endpointpath = "assess/test"
30
+ @end_url = "#{protocol}://#{host}#{basePath}/#{endpointpath}/#{testid}" # basepath starts with /
31
+ end
31
32
 
32
- def get_api
33
- <<~"EOF_EOF"
33
+ def get_api
34
+ <<~"EOF_EOF"
34
35
 
35
- openapi: 3.0.0
36
- info:
37
- version: "#{version}"
38
- title: "#{title}"
39
- x-tests_metric: "#{metric}"
40
- description: >-
41
- "#{description}"
42
- x-applies_to_principle: "#{indicator}"
43
- contact:
44
- x-organization: "#{organization}"
45
- url: "#{org_url}"
46
- name: "#{responsible_developer}"
47
- x-role: responsible developer
48
- email: "#{email}"
49
- x-id: "#{creator}"
50
- paths:
51
- "/#{testid}":
52
- post:
53
- requestBody:
54
- content:
55
- application/json:
56
- schema:
57
- $ref: "#/components/schemas/schemas"
58
- required: true
59
- responses:
60
- "200":
61
- description: >-
62
- #{response_description}
63
- servers:
64
- - url: "#{protocol}://#{host}/#{endpointpath}"
65
- components:
66
- schemas:
36
+ openapi: 3.0.0
37
+ info:
38
+ version: "#{version}"
39
+ title: "#{title}"
40
+ x-tests_metric: "#{metric}"
41
+ description: >-
42
+ "#{description}"
43
+ x-applies_to_principle: "#{indicator}"
44
+ contact:
45
+ x-organization: "#{organization}"
46
+ url: "#{org_url}"
47
+ name: "#{responsible_developer}"
48
+ x-role: responsible developer
49
+ email: "#{email}"
50
+ x-id: "#{creator}"
51
+ paths:
52
+ "/#{testid}":
53
+ post:
54
+ requestBody:
55
+ content:
56
+ application/json:
57
+ schema:
58
+ $ref: "#/components/schemas/schemas"
59
+ required: true
60
+ responses:
61
+ "200":
62
+ description: >-
63
+ #{response_description}
64
+ servers:
65
+ - url: "#{protocol}://#{host}/#{endpointpath}"
66
+ components:
67
67
  schemas:
68
- required:
69
- - resource_identifier
70
- properties:
71
- - resource_identifier:
72
- type: string
73
- description: the GUID being tested
68
+ schemas:
69
+ required:
70
+ - resource_identifier
71
+ properties:
72
+ - resource_identifier:
73
+ type: string
74
+ description: the GUID being tested
74
75
 
75
- EOF_EOF
76
+ EOF_EOF
77
+ end
76
78
  end
77
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftr_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - markwilkinson