cognitive_faculty 2.0.0 → 3.0.2

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
- SHA1:
3
- metadata.gz: 995e99af7205541fe78e18c123c37bbf5f2be977
4
- data.tar.gz: 814f2f1bc2de288548dcdcfc2f84203cfefbca1e
2
+ SHA256:
3
+ metadata.gz: 95199f718d69e24b6302c44aeab67c290a4555a886f9872dc9ffd2d2b28348e8
4
+ data.tar.gz: 8dd37e0f402640410b7a21617f44d28f661fd795cd8db778e72532a2194cc405
5
5
  SHA512:
6
- metadata.gz: bebe7301cdd5ba1dd0f2eb7538d1633593f39604e6f735ef489fec9f9eab5dabbb985c2e4299ad828791dc0cb706dd9e1453f2c8d65d56ef799ac717b57948db
7
- data.tar.gz: f8377749489ab88f1cd504e1a93967af293d2d2aba2595ba9c27158cb7614e74155e7dc5cd929276884798941f896eda66b23e15ec7d306876e52109290ed174
6
+ metadata.gz: 1921f302cdce5a375f7444f775e91526b24556d5570c7d470ca7d0e4424b996e26d4b49d87fde7ed8382192a00da006f179656872c7797d488132d38fbfcba75
7
+ data.tar.gz: 2023cd3b6b83d3c727645f9852c84227005e9444923cc0bba0888c07bcc51b10f82906e17efd7babb7344ab4e0a396c596ac46c6096c2c203bbf2a01285fd3ac
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cognitive_faculty (1.1.2)
5
- activemodel (~> 6.0.2.1)
6
- activesupport (~> 6.0.2.1)
7
- faraday_middleware (~> 0.12.2)
8
- her (~> 1.1.0)
9
- oauth2 (~> 1.4.0)
4
+ cognitive_faculty (3.0.1)
5
+ activemodel (>= 6.0)
6
+ activesupport (>= 6.0.2.1)
7
+ faraday_middleware (>= 0.12.2)
8
+ her (>= 1.1.0)
9
+ oauth2 (>= 1.4.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activemodel (6.0.2.1)
15
- activesupport (= 6.0.2.1)
16
- activesupport (6.0.2.1)
14
+ activemodel (6.0.3.3)
15
+ activesupport (= 6.0.3.3)
16
+ activesupport (6.0.3.3)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 0.7, < 2)
19
19
  minitest (~> 5.1)
20
20
  tzinfo (~> 1.1)
21
- zeitwerk (~> 2.2)
21
+ zeitwerk (~> 2.2, >= 2.2.2)
22
22
  ast (2.4.0)
23
- concurrent-ruby (1.1.6)
23
+ concurrent-ruby (1.1.7)
24
24
  diff-lcs (1.3)
25
25
  faraday (0.17.3)
26
26
  multipart-post (>= 1.2, < 3)
27
- faraday_middleware (0.12.2)
27
+ faraday_middleware (0.14.0)
28
28
  faraday (>= 0.7.4, < 1.0)
29
29
  her (1.1.0)
30
30
  activemodel (>= 4.2.1)
31
31
  faraday (>= 0.8, < 1.0)
32
32
  multi_json (~> 1.7)
33
- i18n (1.8.2)
33
+ i18n (1.8.5)
34
34
  concurrent-ruby (~> 1.0)
35
35
  jaro_winkler (1.5.4)
36
- jwt (2.2.1)
37
- minitest (5.14.0)
38
- multi_json (1.14.1)
36
+ jwt (2.2.2)
37
+ minitest (5.14.2)
38
+ multi_json (1.15.0)
39
39
  multi_xml (0.6.0)
40
40
  multipart-post (2.1.1)
41
41
  oauth2 (1.4.4)
@@ -48,7 +48,7 @@ GEM
48
48
  parser (2.7.0.4)
49
49
  ast (~> 2.4.0)
50
50
  powerpack (0.1.2)
51
- rack (2.2.2)
51
+ rack (2.2.3)
52
52
  rainbow (3.0.0)
53
53
  rake (10.5.0)
54
54
  rspec (3.9.0)
@@ -74,10 +74,10 @@ GEM
74
74
  unicode-display_width (~> 1.0, >= 1.0.1)
75
75
  ruby-progressbar (1.10.1)
76
76
  thread_safe (0.3.6)
77
- tzinfo (1.2.6)
77
+ tzinfo (1.2.7)
78
78
  thread_safe (~> 0.1)
79
79
  unicode-display_width (1.7.0)
80
- zeitwerk (2.3.0)
80
+ zeitwerk (2.4.0)
81
81
 
82
82
  PLATFORMS
83
83
  ruby
data/README.md CHANGED
@@ -20,16 +20,19 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ Your application must be configured in AppID (NOTE: Single-Page App's do not work because they don't provide you a secret).
24
+
25
+ To use this service, you will need to supply a client ID, secret, and oauth server URL. See below for implementation, or __[click here for more information on how to obtain AppID config info](https://cloud.ibm.com/docs/appid?topic=appid-obtain-tokens#credentials-gui)__.
26
+
23
27
  ```ruby
28
+ # example implementation
24
29
  require 'cognitive_faculty'
25
30
 
26
31
  CognitiveFaculty.configure do |c|
27
- c.url = "https://platform.cognitivefaculty.com/api"
28
- c.auth.url = "https://accounts.cognitivefaculty.com"
29
- c.auth.client_id = "client id"
30
- c.auth.client_secret = "secret"
31
- c.auth.username = "username"
32
- c.auth.password = "password"
32
+ c.url = "https://platform.skills.network/api"
33
+ c.auth.client_id = "<AppID Client ID>"
34
+ c.auth.client_secret = "<AppID Secret>"
35
+ c.auth.oauth_server_url = "<AppID oauth Server URL>"
33
36
  end
34
37
 
35
38
  CognitiveFaculty::Offer.all.each do |o|
@@ -42,3 +45,7 @@ end
42
45
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
46
 
44
47
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ### Testing
50
+
51
+ Fill out the values in `testy/main.rb` and then run `ruby testy/main.rb` for an easy way to test the Platform API.
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
25
  spec.add_development_dependency "rubocop", "~> 0.58.2"
26
26
 
27
- spec.add_dependency "activemodel", "~> 6.0.2.1"
28
- spec.add_dependency "activesupport", "~> 6.0.2.1"
29
- spec.add_dependency "faraday_middleware", "~> 0.12.2"
30
- spec.add_dependency "her", "~> 1.1.0"
31
- spec.add_dependency "oauth2", "~> 1.4.0"
27
+ spec.add_dependency "activemodel", ">= 6.0"
28
+ spec.add_dependency "activesupport", ">= 6.0.2.1"
29
+ spec.add_dependency "faraday_middleware", ">= 0.12.2"
30
+ spec.add_dependency "her", ">= 1.1.0"
31
+ spec.add_dependency "oauth2", ">= 1.4.0"
32
32
  end
@@ -10,12 +10,10 @@ require "cognitive_faculty/configuration/configuration"
10
10
  #
11
11
  # Usage:
12
12
  # CognitiveFaculty.configure do |c|
13
- # c.url = "https://platform.cognitivefaculty.com/api"
14
- # c.auth.url = "https://accounts.cognitivefaculty.com"
15
- # c.auth.client_id = "client id"
16
- # c.auth.client_secret = "secret"
17
- # c.auth.username = "username"
18
- # c.auth.password = "password"
13
+ # c.url = "https://platform.skills.network/api"
14
+ # c.auth.client_id = "<AppID Client ID>"
15
+ # c.auth.client_secret = "<AppID Secret>"
16
+ # c.auth.oauth_server_url = "<AppID oauth Server URL>"
19
17
  # end
20
18
  #
21
19
  # CognitiveFaculty::Offer.all.each do |o|
@@ -39,7 +37,7 @@ module CognitiveFaculty
39
37
  c.use Faraday::Response::Logger, nil, body: true
40
38
 
41
39
  # Adapter
42
- c.use Faraday::Adapter::NetHttp
40
+ c.adapter Faraday::Adapter::NetHttp
43
41
  end
44
42
  require "cognitive_faculty/models"
45
43
  api
@@ -7,16 +7,13 @@ module CognitiveFaculty
7
7
  # Authorization configuration for Cognitive Faculty Platform API.
8
8
  #
9
9
  # Attributes:
10
- # +url+: URL for authorization server.
11
10
  # +client_id+: Client ID used to request an acces token.
12
11
  # +client_secret+: Client secret used to request an access token.
13
- # +username+: Username for requesting a token using the +password+ strategy.
14
- # +password+: Password for requesting a token using the +password+ strategy.
15
- # +realm+: Keycloak realm to use. Deafults to +master+.
12
+ # +tenant_id+: AppID tenant id
13
+ # +oauth_server_url+: AppID oauth server URL
16
14
  # +token+: (read-only) OIDC access token.
17
15
  class Auth
18
- attr_accessor :url, :client_id, :client_secret, :username, :password,
19
- :realm
16
+ attr_accessor :client_id, :client_secret, :tenant_id, :oauth_server_url
20
17
  attr_reader :token
21
18
 
22
19
  def initialize
@@ -29,12 +26,9 @@ module CognitiveFaculty
29
26
  end
30
27
 
31
28
  def update_token
32
- opts = {
33
- site: url,
34
- token_url: "/auth/realms/#{realm}/protocol/openid-connect/token"
35
- }
29
+ opts = { token_url: "#{oauth_server_url}/token" }
36
30
  oauth2 = OAuth2::Client.new(client_id, client_secret, opts)
37
- @token = oauth2.password.get_token(username, password)
31
+ @token = oauth2.client_credentials.get_token(:username => client_id, :password => client_secret)
38
32
  end
39
33
  end
40
34
  end
@@ -1,3 +1,3 @@
1
1
  module CognitiveFaculty
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "3.0.2".freeze
3
3
  end
data/testy/main.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'cognitive_faculty'
2
+
3
+ CognitiveFaculty.configure do |c|
4
+ c.url = "http://localhost:8080/api"
5
+ c.auth.client_id = "<client_id>"
6
+ c.auth.client_secret = "<client_secret>"
7
+ c.auth.oauth_server_url = "<oauth server url>"
8
+ end
9
+
10
+ CognitiveFaculty::Offer.all.each do |o|
11
+ puts o.name
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cognitive_faculty
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Aoqui
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-19 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,70 +70,70 @@ dependencies:
70
70
  name: activemodel
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 6.0.2.1
75
+ version: '6.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 6.0.2.1
82
+ version: '6.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: activesupport
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 6.0.2.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 6.0.2.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faraday_middleware
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.12.2
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.12.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: her
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.1.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.1.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: oauth2
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.4.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.4.0
139
139
  description: Ruby gem for the Cognitive Faculty API.
@@ -162,10 +162,11 @@ files:
162
162
  - lib/cognitive_faculty/models/code.rb
163
163
  - lib/cognitive_faculty/models/offer.rb
164
164
  - lib/cognitive_faculty/version.rb
165
+ - testy/main.rb
165
166
  homepage: https://cognitivefaculty.com
166
167
  licenses: []
167
168
  metadata: {}
168
- post_install_message:
169
+ post_install_message:
169
170
  rdoc_options: []
170
171
  require_paths:
171
172
  - lib
@@ -180,9 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  - !ruby/object:Gem::Version
181
182
  version: '0'
182
183
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.6.14
185
- signing_key:
184
+ rubygems_version: 3.0.3
185
+ signing_key:
186
186
  specification_version: 4
187
187
  summary: Cognitive Faculty Ruby SDK
188
188
  test_files: []