cognitive_faculty 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6c0bdcc9243201647e209f9611ec098d946931cc
4
- data.tar.gz: a46e75e49154267d6d120353a091a3ffc0442510
2
+ SHA256:
3
+ metadata.gz: 6ed4682b8c1e3207d344e10935134dc80f75499796be38e1bafa8da0fc49e5b6
4
+ data.tar.gz: 1dbe0e60f094188f50bc0d3de745bf69306e275ec81bb922725155094bf67f4e
5
5
  SHA512:
6
- metadata.gz: 49e9ffdd2b8719efed005d4fe8a69d458cc393ec0f3d0e0602985d27a7ee0816225de4a00efd1f88347c274528c2ec1f44cb15d37da14f67947e60816f722d84
7
- data.tar.gz: 79fc5edb12eef9595375ec190d16cdbcb4e85dca9608779536f8db45391b1d6117272a9f78905d917326c65d2614290bbb01896ff19360983c53e5a4c7e5290d
6
+ metadata.gz: 8382a3b7d136398479a6d4f704efefa6e97fb22ce3cffe28a4aa6e67ce611ac87713981370b943977bb3643a7677478032625cc3a1313e641d9093274ad9cc74
7
+ data.tar.gz: '08b042ad1982123a6bc3a1a8332d64871e6a39d9854a63817cc12cf44e967d92b41c42cd1991f4ec6a1b271c8faff6c19383e62d60b37985fe8d0a43e11571d7'
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.3.2"
28
- spec.add_dependency "activesupport", "~> 6.0.3.2"
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
@@ -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
@@ -27,8 +27,6 @@ module CognitiveFaculty
27
27
  end
28
28
  end
29
29
 
30
- private
31
-
32
30
  def eligible?(lp_certs_url, learning_path, user)
33
31
  self.class.get_raw("#{lp_certs_url}/certificates/#{user[:username]}/#{learning_path[:slug]}/status") do |status|
34
32
  status[:data][:eligible]
@@ -1,3 +1,3 @@
1
1
  module CognitiveFaculty
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.0.2".freeze
3
3
  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|
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.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Aoqui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2021-10-29 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.3.2
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.3.2
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
- version: 6.0.3.2
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
- version: 6.0.3.2
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,6 +162,7 @@ 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: {}
@@ -180,8 +181,7 @@ 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
184
+ rubygems_version: 3.0.3
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Cognitive Faculty Ruby SDK