psu_identity 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,326 @@
1
+ ---
2
+ Style/Alias:
3
+ Description: 'Use alias_method instead of alias.'
4
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
5
+ Enabled: false
6
+
7
+ Style/ArrayJoin:
8
+ Description: 'Use Array#join instead of Array#*.'
9
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
10
+ Enabled: false
11
+
12
+ Style/AsciiComments:
13
+ Description: 'Use only ascii symbols in comments.'
14
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
15
+ Enabled: false
16
+
17
+ Style/Attr:
18
+ Description: 'Checks for uses of Module#attr.'
19
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
20
+ Enabled: false
21
+
22
+ Style/CaseEquality:
23
+ Description: 'Avoid explicit use of the case equality operator(===).'
24
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
25
+ Enabled: false
26
+
27
+ Style/CharacterLiteral:
28
+ Description: 'Checks for uses of character literals.'
29
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
30
+ Enabled: false
31
+
32
+ Style/ClassAndModuleChildren:
33
+ Description: 'Checks style of children classes and modules.'
34
+ Enabled: false
35
+
36
+ Style/ClassVars:
37
+ Description: 'Avoid the use of class variables.'
38
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
39
+ Enabled: true
40
+
41
+ Style/CollectionMethods:
42
+ Enabled: true
43
+ PreferredMethods:
44
+ inject: reduce
45
+ collect: map
46
+ collect!: map!
47
+ find_all: select
48
+ detect: find
49
+
50
+ Style/ColonMethodCall:
51
+ Description: 'Do not use :: for method call.'
52
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
53
+ Enabled: false
54
+
55
+ Style/CommentAnnotation:
56
+ Description: >-
57
+ Checks formatting of special comments
58
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
59
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
60
+ Enabled: false
61
+
62
+ Style/Documentation:
63
+ Description: 'Document classes and non-namespace modules.'
64
+ Enabled: false
65
+
66
+ Style/DoubleNegation:
67
+ Description: 'Checks for uses of double negation (!!).'
68
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
69
+ Enabled: false
70
+
71
+ Style/EachWithObject:
72
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
73
+ Enabled: false
74
+
75
+ Style/EmptyLiteral:
76
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
77
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
78
+ Enabled: false
79
+
80
+ # Checks whether the source file has a utf-8 encoding comment or not
81
+ # AutoCorrectEncodingComment must match the regex
82
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
83
+ Style/Encoding:
84
+ Enabled: false
85
+
86
+ Style/EvenOdd:
87
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
88
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
89
+ Enabled: false
90
+
91
+ Style/FrozenStringLiteralComment:
92
+ Description: >-
93
+ Add the frozen_string_literal comment to the top of files
94
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
95
+ Enabled: true
96
+
97
+ Style/FormatString:
98
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
99
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
100
+ Enabled: false
101
+
102
+ Style/GlobalVars:
103
+ Description: 'Do not introduce global variables.'
104
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
105
+ Enabled: true
106
+
107
+ Style/GuardClause:
108
+ Description: 'Check for conditionals that can be replaced with guard clauses'
109
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
110
+ Enabled: false
111
+
112
+ Style/IfUnlessModifier:
113
+ Description: >-
114
+ Favor modifier if/unless usage when you have a
115
+ single-line body.
116
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
117
+ Enabled: false
118
+
119
+ Style/IfWithSemicolon:
120
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
121
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
122
+ Enabled: false
123
+
124
+ Style/InlineComment:
125
+ Description: 'Avoid inline comments.'
126
+ Enabled: false
127
+
128
+ Style/Lambda:
129
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
130
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
131
+ Enabled: false
132
+
133
+ Style/LambdaCall:
134
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
135
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
136
+ Enabled: false
137
+
138
+ Style/LineEndConcatenation:
139
+ Description: >-
140
+ Use \ instead of + or << to concatenate two string literals at
141
+ line end.
142
+ Enabled: false
143
+
144
+ Style/ModuleFunction:
145
+ Description: 'Checks for usage of `extend self` in modules.'
146
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
147
+ Enabled: false
148
+
149
+ Style/MultilineBlockChain:
150
+ Description: 'Avoid multi-line chains of blocks.'
151
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
152
+ Enabled: false
153
+
154
+ Style/NegatedIf:
155
+ Description: >-
156
+ Favor unless over if for negative conditions
157
+ (or control flow or).
158
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
159
+ Enabled: false
160
+
161
+ Style/NegatedWhile:
162
+ Description: 'Favor until over while for negative conditions.'
163
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
164
+ Enabled: false
165
+
166
+ Style/Next:
167
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
168
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
169
+ Enabled: false
170
+
171
+ Style/NilComparison:
172
+ Description: 'Prefer x.nil? to x == nil.'
173
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
174
+ Enabled: false
175
+
176
+ Style/Not:
177
+ Description: 'Use ! instead of not.'
178
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
179
+ Enabled: false
180
+
181
+ Style/NumericLiterals:
182
+ Description: >-
183
+ Add underscores to large numeric literals to improve their
184
+ readability.
185
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
186
+ Enabled: false
187
+
188
+ Style/OneLineConditional:
189
+ Description: >-
190
+ Favor the ternary operator(?:) over
191
+ if/then/else/end constructs.
192
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
193
+ Enabled: false
194
+
195
+ Style/PercentLiteralDelimiters:
196
+ Description: 'Use `%`-literal delimiters consistently'
197
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
198
+ Enabled: false
199
+
200
+ Style/PerlBackrefs:
201
+ Description: 'Avoid Perl-style regex back references.'
202
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
203
+ Enabled: false
204
+
205
+ Style/Proc:
206
+ Description: 'Use proc instead of Proc.new.'
207
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
208
+ Enabled: false
209
+
210
+ Style/RaiseArgs:
211
+ Description: 'Checks the arguments passed to raise/fail.'
212
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
213
+ Enabled: false
214
+
215
+ Style/RegexpLiteral:
216
+ Description: 'Use / or %r around regular expressions.'
217
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
218
+ Enabled: false
219
+
220
+ Style/SelfAssignment:
221
+ Description: >-
222
+ Checks for places where self-assignment shorthand should have
223
+ been used.
224
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
225
+ Enabled: false
226
+
227
+ Style/SingleLineBlockParams:
228
+ Description: 'Enforces the names of some block params.'
229
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
230
+ Enabled: false
231
+
232
+ Style/SingleLineMethods:
233
+ Description: 'Avoid single-line methods.'
234
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
235
+ Enabled: false
236
+
237
+ Style/SignalException:
238
+ Description: 'Checks for proper usage of fail and raise.'
239
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
240
+ Enabled: false
241
+
242
+ Style/SpecialGlobalVars:
243
+ Description: 'Avoid Perl-style global variables.'
244
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
245
+ Enabled: false
246
+
247
+ Style/StringLiterals:
248
+ Description: 'Checks if uses of quotes match the configured preference.'
249
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
250
+ EnforcedStyle: single_quotes
251
+ Enabled: true
252
+
253
+ Style/TrailingCommaInArguments:
254
+ Description: >-
255
+ Checks for trailing comma in argument lists. Supported styles are:
256
+ comma
257
+ consistent_comma
258
+ no_comma
259
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
260
+ EnforcedStyleForMultiline: no_comma
261
+ Enabled: true
262
+
263
+ Style/TrailingCommaInArrayLiteral:
264
+ Description: >-
265
+ Checks for trailing comma in array and hash literals. Supported styles are:
266
+ comma
267
+ consistent_comma
268
+ no_comma
269
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
270
+ EnforcedStyleForMultiline: no_comma
271
+ Enabled: true
272
+
273
+ Style/TrivialAccessors:
274
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
275
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
276
+ Enabled: false
277
+
278
+ Style/VariableInterpolation:
279
+ Description: >-
280
+ Don't interpolate global, instance and class variables
281
+ directly in strings.
282
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
283
+ Enabled: false
284
+
285
+ Style/WhenThen:
286
+ Description: 'Use when x then ... for one-line cases.'
287
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
288
+ Enabled: false
289
+
290
+ Style/WhileUntilModifier:
291
+ Description: >-
292
+ Favor modifier while/until usage when you have a
293
+ single-line body.
294
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
295
+ Enabled: false
296
+
297
+ Style/WordArray:
298
+ Description: 'Use %w or %W for arrays of words.'
299
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
300
+ Enabled: false
301
+
302
+ Style/SymbolArray:
303
+ Description: This cop checks for array literals made up of symbols that are not using the %i() syntax.
304
+ Enabled: false
305
+
306
+ Style/Sample:
307
+ Description: >-
308
+ Use `sample` instead of `shuffle.first`,
309
+ `shuffle.last`, and `shuffle[Fixnum]`.
310
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
311
+ Enabled: false
312
+
313
+ Style/ExponentialNotation:
314
+ Enabled: true
315
+
316
+ Style/HashEachMethods:
317
+ Enabled: true
318
+
319
+ Style/HashTransformKeys:
320
+ Enabled: false
321
+
322
+ Style/HashTransformValues:
323
+ Enabled: false
324
+
325
+ Style/SlicingWithRange:
326
+ Enabled: true
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ ---
2
+ inherit_from:
3
+ - .niftany/layout.yml
4
+ - .niftany/lint.yml
5
+ - .niftany/metrics.yml
6
+ - .niftany/naming.yml
7
+ - .niftany/niftany_rubocop_rspec.yml
8
+ - .niftany/performance.yml
9
+ - .niftany/style.yml
10
+ - .rubocop_todo.yml
11
+
12
+ AllCops:
13
+ DisplayCopNames: true
14
+ NewCops: enable
15
+
16
+ Metrics/BlockLength:
17
+ Exclude:
18
+ - 'spec/**/*'
19
+ - 'psu_identity.gemspec'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,8 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
+ # on 2021-10-07 14:31:44 UTC using RuboCop version 1.22.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/Gemfile CHANGED
@@ -1,20 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in psu_identity.gemspec
4
6
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem 'faraday', '~> 0.17.0'
8
- # SimpleCov > 0.17 not compatible with Code Climate
9
- gem 'simplecov', '=0.17'
10
- gem 'rubocop', '~> 0.0'
11
- gem 'json'
12
-
13
- group :test do
14
- # Rspec and packages
15
- gem "rspec", "~> 3.0"
16
- gem 'rspec-its'
17
- # Mock external requests
18
- gem 'vcr'
19
- gem 'webmock'
20
- end
data/Gemfile.lock CHANGED
@@ -1,69 +1,103 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- psu_identity (0.1.2)
4
+ psu_identity (0.2.0)
5
+ faraday (~> 1.0)
6
+ json
7
+ rake (>= 12.0)
5
8
 
6
9
  GEM
7
10
  remote: https://rubygems.org/
8
11
  specs:
9
- addressable (2.7.0)
12
+ addressable (2.8.0)
10
13
  public_suffix (>= 2.0.2, < 5.0)
11
- ast (2.4.0)
12
- crack (0.4.3)
13
- safe_yaml (~> 1.0.0)
14
- diff-lcs (1.3)
15
- docile (1.3.2)
16
- faraday (0.17.3)
14
+ ast (2.4.2)
15
+ byebug (11.1.3)
16
+ coderay (1.1.3)
17
+ crack (0.4.5)
18
+ rexml
19
+ diff-lcs (1.4.4)
20
+ docile (1.4.0)
21
+ faraday (1.8.0)
22
+ faraday-em_http (~> 1.0)
23
+ faraday-em_synchrony (~> 1.0)
24
+ faraday-excon (~> 1.1)
25
+ faraday-httpclient (~> 1.0.1)
26
+ faraday-net_http (~> 1.0)
27
+ faraday-net_http_persistent (~> 1.1)
28
+ faraday-patron (~> 1.0)
29
+ faraday-rack (~> 1.0)
17
30
  multipart-post (>= 1.2, < 3)
31
+ ruby2_keywords (>= 0.0.4)
32
+ faraday-em_http (1.0.0)
33
+ faraday-em_synchrony (1.0.0)
34
+ faraday-excon (1.1.0)
35
+ faraday-httpclient (1.0.1)
36
+ faraday-net_http (1.0.1)
37
+ faraday-net_http_persistent (1.2.0)
38
+ faraday-patron (1.0.0)
39
+ faraday-rack (1.0.0)
18
40
  hashdiff (1.0.1)
19
- json (2.3.0)
41
+ json (2.5.1)
42
+ method_source (1.0.0)
20
43
  multipart-post (2.1.1)
21
- parallel (1.19.1)
22
- parser (2.7.1.3)
23
- ast (~> 2.4.0)
24
- public_suffix (4.0.4)
44
+ parallel (1.21.0)
45
+ parser (3.0.2.0)
46
+ ast (~> 2.4.1)
47
+ pry (0.13.1)
48
+ coderay (~> 1.1)
49
+ method_source (~> 1.0)
50
+ pry-byebug (3.9.0)
51
+ byebug (~> 11.0)
52
+ pry (~> 0.13.0)
53
+ public_suffix (4.0.6)
25
54
  rainbow (3.0.0)
26
- rake (12.3.3)
27
- regexp_parser (1.7.0)
28
- rexml (3.2.4)
29
- rspec (3.9.0)
30
- rspec-core (~> 3.9.0)
31
- rspec-expectations (~> 3.9.0)
32
- rspec-mocks (~> 3.9.0)
33
- rspec-core (3.9.2)
34
- rspec-support (~> 3.9.3)
35
- rspec-expectations (3.9.1)
55
+ rake (13.0.6)
56
+ regexp_parser (2.1.1)
57
+ rexml (3.2.5)
58
+ rspec (3.10.0)
59
+ rspec-core (~> 3.10.0)
60
+ rspec-expectations (~> 3.10.0)
61
+ rspec-mocks (~> 3.10.0)
62
+ rspec-core (3.10.1)
63
+ rspec-support (~> 3.10.0)
64
+ rspec-expectations (3.10.1)
36
65
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.9.0)
66
+ rspec-support (~> 3.10.0)
38
67
  rspec-its (1.3.0)
39
68
  rspec-core (>= 3.0.0)
40
69
  rspec-expectations (>= 3.0.0)
41
- rspec-mocks (3.9.1)
70
+ rspec-mocks (3.10.2)
42
71
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-support (3.9.3)
45
- rubocop (0.85.0)
72
+ rspec-support (~> 3.10.0)
73
+ rspec-support (3.10.2)
74
+ rubocop (1.22.1)
46
75
  parallel (~> 1.10)
47
- parser (>= 2.7.0.1)
76
+ parser (>= 3.0.0.0)
48
77
  rainbow (>= 2.2.2, < 4.0)
49
- regexp_parser (>= 1.7)
78
+ regexp_parser (>= 1.8, < 3.0)
50
79
  rexml
51
- rubocop-ast (>= 0.0.3)
80
+ rubocop-ast (>= 1.12.0, < 2.0)
52
81
  ruby-progressbar (~> 1.7)
53
- unicode-display_width (>= 1.4.0, < 2.0)
54
- rubocop-ast (0.0.3)
55
- parser (>= 2.7.0.1)
56
- ruby-progressbar (1.10.1)
57
- safe_yaml (1.0.5)
82
+ unicode-display_width (>= 1.4.0, < 3.0)
83
+ rubocop-ast (1.12.0)
84
+ parser (>= 3.0.1.1)
85
+ rubocop-performance (1.11.5)
86
+ rubocop (>= 1.7.0, < 2.0)
87
+ rubocop-ast (>= 0.4.0)
88
+ rubocop-rspec (2.5.0)
89
+ rubocop (~> 1.19)
90
+ ruby-progressbar (1.11.0)
91
+ ruby2_keywords (0.0.5)
58
92
  simplecov (0.17.0)
59
93
  docile (~> 1.1)
60
94
  json (>= 1.8, < 3)
61
95
  simplecov-html (~> 0.10.0)
62
96
  simplecov-html (0.10.2)
63
- unicode-display_width (1.7.0)
64
- vcr (5.1.0)
65
- webmock (3.8.3)
66
- addressable (>= 2.3.6)
97
+ unicode-display_width (2.1.0)
98
+ vcr (6.0.0)
99
+ webmock (3.14.0)
100
+ addressable (>= 2.8.0)
67
101
  crack (>= 0.3.2)
68
102
  hashdiff (>= 0.4.0, < 2.0.0)
69
103
 
@@ -71,16 +105,16 @@ PLATFORMS
71
105
  ruby
72
106
 
73
107
  DEPENDENCIES
74
- faraday (~> 0.17.0)
75
- json
108
+ pry-byebug
76
109
  psu_identity!
77
- rake (~> 12.0)
78
110
  rspec (~> 3.0)
79
111
  rspec-its
80
- rubocop (~> 0.0)
112
+ rubocop (~> 1.22)
113
+ rubocop-performance (~> 1.11)
114
+ rubocop-rspec (~> 2.5)
81
115
  simplecov (= 0.17)
82
116
  vcr
83
117
  webmock
84
118
 
85
119
  BUNDLED WITH
86
- 2.1.4
120
+ 2.2.28
data/README.md CHANGED
@@ -26,23 +26,23 @@ Or install it yourself as:
26
26
 
27
27
  Add this to the top of your code:
28
28
 
29
- require 'penn_state/search_service'
29
+ require 'psu_identity'
30
30
 
31
31
  To query the search service by name:
32
32
 
33
33
  # Takes a hash as parameter with 'text:' as the key
34
34
 
35
- PennState::SearchService::Client.new.search(text: 'Jimmy Tester')
35
+ PsuIdentity::SearchService::Client.new.search(text: 'Jimmy Tester')
36
36
 
37
- ***This will return an array of PennState::SearchService::Person objects matching the query***
37
+ ***This will return an array of PsuIdentity::SearchService::Person objects matching the query***
38
38
 
39
39
  To query the search service by userid:
40
40
 
41
41
  # Takes a string as a parameter
42
42
 
43
- PennState::SearchService::Client.new.userid('abc123')
43
+ PsuIdentity::SearchService::Client.new.userid('abc123')
44
44
 
45
- ***This will return a single PennState::SearchService::Person object matching the query***
45
+ ***This will return a single PsuIdentity::SearchService::Person object matching the query***
46
46
 
47
47
  ## Development
48
48
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "psu_identity"
4
+ require 'bundler/setup'
5
+ require 'psu_identity'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "psu_identity"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'ostruct'
3
2
 
4
- module PennState::SearchService
3
+ module PsuIdentity::SearchService
5
4
  class AtomicLink < OpenStruct
6
5
  def to_s
7
6
  href
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @abstract Client for querying Penn State's identity API: https://identity.apps.psu.edu/search-service/resources
4
+ module PsuIdentity::SearchService
5
+ class Client
6
+ class Error < StandardError; end
7
+
8
+ attr_reader :base_url
9
+
10
+ # @param [String] base_url
11
+ def initialize(base_url: '/search-service/resources')
12
+ @base_url = base_url
13
+ end
14
+
15
+ # @param [Hash] args of options to pass to the endpoint
16
+ # @option args [String] :text to search for
17
+ def search(**args)
18
+ process_response connection.get("#{base_url}/people", args)
19
+ end
20
+
21
+ # @param [Hash] args of options to pass to the endpoint
22
+ # @option args [String] :userid of the person
23
+ def userid(userid)
24
+ process_userid_response connection.get("#{base_url}/people/userid/#{userid}")
25
+ end
26
+
27
+ private
28
+
29
+ # @return Array<PsuIdentity::SearchService::Person>
30
+ def process_response(response)
31
+ raise Error.new(response.body) unless response.success?
32
+
33
+ JSON.parse(response.body).map { |result| Person.new(result) }
34
+ rescue JSON::ParserError
35
+ []
36
+ end
37
+
38
+ # @return [PsuIdentity::SearchService::Person, nil]
39
+ def process_userid_response(response)
40
+ return if response.status == 404
41
+
42
+ raise Error.new(response.body) unless response.success?
43
+
44
+ Person.new(JSON.parse(response.body))
45
+ rescue JSON::ParserError
46
+ end
47
+
48
+ def connection
49
+ @connection ||= Faraday.new(url: endpoint) do |conn|
50
+ conn.adapter :net_http
51
+ end
52
+ end
53
+
54
+ def endpoint
55
+ @endpoint ||= ENV.fetch('IDENTITY_ENDPOINT', 'https://identity.apps.psu.edu')
56
+ end
57
+ end
58
+ end