cognitive_faculty 2.0.1 → 3.0.0

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: 6c0bdcc9243201647e209f9611ec098d946931cc
4
- data.tar.gz: a46e75e49154267d6d120353a091a3ffc0442510
2
+ SHA256:
3
+ metadata.gz: b9e38316fa235a461b08865f23d0bc70a397dc8a3eab31345a02f8bbfb851985
4
+ data.tar.gz: ea8fc496a435a2c3a64e31eb89c9678831328f0609f2b7858e8bde93dfd1d379
5
5
  SHA512:
6
- metadata.gz: 49e9ffdd2b8719efed005d4fe8a69d458cc393ec0f3d0e0602985d27a7ee0816225de4a00efd1f88347c274528c2ec1f44cb15d37da14f67947e60816f722d84
7
- data.tar.gz: 79fc5edb12eef9595375ec190d16cdbcb4e85dca9608779536f8db45391b1d6117272a9f78905d917326c65d2614290bbb01896ff19360983c53e5a4c7e5290d
6
+ metadata.gz: 7f6026419cfd1429bae4f66e267a6e253d4e6f17dcf56face2f0796e697a3552f3bf3fe695235d7a48c242a923526ca9dea52c74201a140989b993bddfb0593f
7
+ data.tar.gz: 4c1562cc84360b754b4053f25946080746b84c6c43263c2a6316d1298982901a37d5ae220a819122dfb4ffef304a67ad62f73bee2bcba6d89972ea41afc24e89
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cognitive_faculty (1.1.2)
4
+ cognitive_faculty (3.0.0)
5
5
  activemodel (~> 6.0.2.1)
6
6
  activesupport (~> 6.0.2.1)
7
7
  faraday_middleware (~> 0.12.2)
@@ -11,9 +11,9 @@ PATH
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.2.2)
15
+ activesupport (= 6.0.2.2)
16
+ activesupport (6.0.2.2)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 0.7, < 2)
19
19
  minitest (~> 5.1)
@@ -30,11 +30,11 @@ GEM
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.3)
34
34
  concurrent-ruby (~> 1.0)
35
35
  jaro_winkler (1.5.4)
36
36
  jwt (2.2.1)
37
- minitest (5.14.0)
37
+ minitest (5.14.1)
38
38
  multi_json (1.14.1)
39
39
  multi_xml (0.6.0)
40
40
  multipart-post (2.1.1)
@@ -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,7 +74,7 @@ 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
80
  zeitwerk (2.3.0)
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,8 +24,8 @@ 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"
27
+ spec.add_dependency "activemodel", "~> 6.0.2.1"
28
+ spec.add_dependency "activesupport", "~> 6.0.2.1"
29
29
  spec.add_dependency "faraday_middleware", "~> 0.12.2"
30
30
  spec.add_dependency "her", "~> 1.1.0"
31
31
  spec.add_dependency "oauth2", "~> 1.4.0"
@@ -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|
@@ -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.1".freeze
2
+ VERSION = "3.0.0".freeze
3
3
  end
@@ -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: 3.0.0
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: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 6.0.3.2
75
+ version: 6.0.2.1
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.2.1
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
@@ -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.1.2
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Cognitive Faculty Ruby SDK