cognitive_faculty 1.1.0 → 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
2
  SHA256:
3
- metadata.gz: e2d252f53af2287701ad74a9c9037a337cd476a7c173c0512dbcf04308d92d34
4
- data.tar.gz: ef1d662f15d69ed61a52fc960822b8c3c6482aadbee9ea67026203ef6dcf386e
3
+ metadata.gz: b9e38316fa235a461b08865f23d0bc70a397dc8a3eab31345a02f8bbfb851985
4
+ data.tar.gz: ea8fc496a435a2c3a64e31eb89c9678831328f0609f2b7858e8bde93dfd1d379
5
5
  SHA512:
6
- metadata.gz: 72ad0ca29b84c36ff88c985681a4772608634885dd0bb70a0842236225ee39bfcb469cbdfe747dbc9b089dbcddb94c21f4660ee6c5111ffb3ae99fa7547fb396
7
- data.tar.gz: 75f267074dabbf2f6613f15e887905a353c74d191d78947da90aa47df1618c75d3b169e0bafaaf15358d8964fb97bc87b138a8b9868eb9cc3a7c7d0c5d4213f4
6
+ metadata.gz: 7f6026419cfd1429bae4f66e267a6e253d4e6f17dcf56face2f0796e697a3552f3bf3fe695235d7a48c242a923526ca9dea52c74201a140989b993bddfb0593f
7
+ data.tar.gz: 4c1562cc84360b754b4053f25946080746b84c6c43263c2a6316d1298982901a37d5ae220a819122dfb4ffef304a67ad62f73bee2bcba6d89972ea41afc24e89
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 1.17.3
5
- before_install: gem install bundler -v 1.17.3
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -1,23 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cognitive_faculty (1.1.0)
5
- activemodel (= 5.0.0)
6
- activesupport (= 5.0.0)
4
+ cognitive_faculty (3.0.0)
5
+ activemodel (~> 6.0.2.1)
6
+ activesupport (~> 6.0.2.1)
7
7
  faraday_middleware (~> 0.12.2)
8
- her (~> 0.8.0)
8
+ her (~> 1.1.0)
9
9
  oauth2 (~> 1.4.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activemodel (5.0.0)
15
- activesupport (= 5.0.0)
16
- activesupport (5.0.0)
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
- i18n (~> 0.7)
18
+ i18n (>= 0.7, < 2)
19
19
  minitest (~> 5.1)
20
20
  tzinfo (~> 1.1)
21
+ zeitwerk (~> 2.2)
21
22
  ast (2.4.0)
22
23
  concurrent-ruby (1.1.6)
23
24
  diff-lcs (1.3)
@@ -25,16 +26,15 @@ GEM
25
26
  multipart-post (>= 1.2, < 3)
26
27
  faraday_middleware (0.12.2)
27
28
  faraday (>= 0.7.4, < 1.0)
28
- her (0.8.6)
29
- activemodel (>= 3.0.0, <= 6.0.0)
30
- activesupport (>= 3.0.0, <= 6.0.0)
29
+ her (1.1.0)
30
+ activemodel (>= 4.2.1)
31
31
  faraday (>= 0.8, < 1.0)
32
32
  multi_json (~> 1.7)
33
- i18n (0.9.5)
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)
@@ -45,10 +45,10 @@ GEM
45
45
  multi_xml (~> 0.5)
46
46
  rack (>= 1.2, < 3)
47
47
  parallel (1.19.1)
48
- parser (2.7.1.1)
48
+ parser (2.7.0.4)
49
49
  ast (~> 2.4.0)
50
- psych (3.1.0)
51
- rack (2.2.2)
50
+ powerpack (0.1.2)
51
+ rack (2.2.3)
52
52
  rainbow (3.0.0)
53
53
  rake (10.5.0)
54
54
  rspec (3.9.0)
@@ -64,29 +64,30 @@ GEM
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.9.0)
66
66
  rspec-support (3.9.2)
67
- rubocop (0.67.2)
67
+ rubocop (0.58.2)
68
68
  jaro_winkler (~> 1.5.1)
69
69
  parallel (~> 1.10)
70
70
  parser (>= 2.5, != 2.5.1.1)
71
- psych (>= 3.1.0)
71
+ powerpack (~> 0.1)
72
72
  rainbow (>= 2.2.2, < 4.0)
73
73
  ruby-progressbar (~> 1.7)
74
- unicode-display_width (>= 1.4.0, < 1.6)
74
+ unicode-display_width (~> 1.0, >= 1.0.1)
75
75
  ruby-progressbar (1.10.1)
76
76
  thread_safe (0.3.6)
77
77
  tzinfo (1.2.7)
78
78
  thread_safe (~> 0.1)
79
- unicode-display_width (1.5.0)
79
+ unicode-display_width (1.7.0)
80
+ zeitwerk (2.3.0)
80
81
 
81
82
  PLATFORMS
82
83
  ruby
83
84
 
84
85
  DEPENDENCIES
85
- bundler (~> 1.17.3)
86
+ bundler (~> 2.1.4)
86
87
  cognitive_faculty!
87
88
  rake (~> 10.0)
88
89
  rspec (~> 3.0)
89
- rubocop (~> 0.67.0)
90
+ rubocop (~> 0.58.2)
90
91
 
91
92
  BUNDLED WITH
92
- 1.17.3
93
+ 2.1.4
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.
@@ -19,14 +19,14 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.17.3"
22
+ spec.add_development_dependency "bundler", "~> 2.1.4"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
- spec.add_development_dependency "rubocop", "~> 0.67.0"
25
+ spec.add_development_dependency "rubocop", "~> 0.58.2"
26
26
 
27
- spec.add_dependency "activemodel", "= 5.0.0"
28
- spec.add_dependency "activesupport", "= 5.0.0"
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
- spec.add_dependency "her", "~> 0.8.0"
30
+ spec.add_dependency "her", "~> 1.1.0"
31
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|
@@ -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 = "1.1.0".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: 1.1.0
4
+ version: 3.0.0
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-04-26 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.17.3
19
+ version: 2.1.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.17.3
26
+ version: 2.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.67.0
61
+ version: 0.58.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.67.0
68
+ version: 0.58.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activemodel
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 5.0.0
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: 5.0.0
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: 5.0.0
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: 5.0.0
96
+ version: 6.0.2.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faraday_middleware
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.8.0
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
- version: 0.8.0
124
+ version: 1.1.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: oauth2
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -181,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
182
  version: '0'
182
183
  requirements: []
183
184
  rubygems_version: 3.1.2
184
- signing_key:
185
+ signing_key:
185
186
  specification_version: 4
186
187
  summary: Cognitive Faculty Ruby SDK
187
188
  test_files: []