berkeley_library-util 0.1.5 → 0.1.6

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
2
  SHA256:
3
- metadata.gz: 9eac060e7b0956b965455bddb8cc6c9721d5af784ac421766c2d791d99632927
4
- data.tar.gz: a68fecb0b685ddffa3cb0fff6a46180e377efeb71b1cc5d23a389117c27be72d
3
+ metadata.gz: a17e4e3e2e6e03e0dda795450e724650a0a7f7ae44db3b7a558bc371d8bed1b7
4
+ data.tar.gz: 106ff7e21c1e9568f4bdabc116023c292878f4fd629e5ee3ada934b2c2a10b43
5
5
  SHA512:
6
- metadata.gz: 052c93d1c09d569479d4bec70ffa9413e3ab0404f19482955b89552891c7058ab76ec11191456aa79016e1e2c98403eb355c89982ffe31f31d37f650517970b2
7
- data.tar.gz: 530542deae99ffbd089cfc294b614d9560e2298ed4f7a20161970185935155a620b578bd99066a219e7d0410305d525e354c9b811162adbefdf3dda35c904427
6
+ metadata.gz: b4fbde8aa9e43a7ad7c414b92b488c5d2af1ae29c7f28a7ecd8f6ceb308e42c3c27a2256994362b15cba5133ec00feb32d5fe76f0b774577b292be6c2ba08528
7
+ data.tar.gz: 23c41cbed1b0befc458c8989792c45cf7429905b06e2deec72a88478f8eb7676a6e3be96dae5fa308239bb4f70b19acae421593711c20dd22d305f55262b0f64
@@ -1,18 +1,30 @@
1
1
  name: Build
2
- on: [ push, pull_request ]
2
+ on: [ push, pull_request, workflow_dispatch ]
3
3
  jobs:
4
4
  test:
5
5
  strategy:
6
6
  fail-fast: false
7
7
  matrix:
8
8
  os: [ ubuntu-latest, macos-latest ]
9
- ruby: [ '2.7', '3.0' ]
9
+ ruby: [ '2.7', '3.0', '3.1' ]
10
10
  runs-on: ${{ matrix.os }}
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@v2
14
- - uses: ruby/setup-ruby@v1
13
+ - name: Check out repository
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
15
18
  with:
16
19
  ruby-version: ${{ matrix.ruby }}
17
20
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18
- - run: bundle exec rake
21
+
22
+ - name: Run checks
23
+ run: bundle exec rake
24
+
25
+ - name: Upload artifacts
26
+ if: ${{ always() }}
27
+ uses: actions/upload-artifact@v3
28
+ with:
29
+ name: artifacts
30
+ path: artifacts/**
@@ -11,6 +11,7 @@
11
11
  <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
12
12
  <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
13
13
  <inspection_tool class="RubyCaseWithoutElseBlockInspection" enabled="false" level="WARNING" enabled_by_default="false" />
14
+ <inspection_tool class="RubyMismatchedArgumentType" enabled="true" level="INFORMATION" enabled_by_default="true" />
14
15
  <inspection_tool class="RubyMismatchedReturnType" enabled="true" level="WARNING" enabled_by_default="true">
15
16
  <option name="myCheckNilability" value="false" />
16
17
  </inspection_tool>
data/.idea/util.iml CHANGED
@@ -5,83 +5,83 @@
5
5
  </component>
6
6
  <component name="NewModuleRootManager" inherit-compiler-output="true">
7
7
  <exclude-output />
8
- <content url="file://$MODULE_DIR$" />
8
+ <content url="file://$MODULE_DIR$">
9
+ <excludeFolder url="file://$MODULE_DIR$/artifacts" />
10
+ </content>
9
11
  <orderEntry type="jdk" jdkName="RVM: ruby-2.7.4" jdkType="RUBY_SDK" />
10
12
  <orderEntry type="sourceFolder" forTests="false" />
11
- <orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.3, RVM: ruby-2.7.4) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.3, RVM: ruby-2.7.4) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.3, RVM: ruby-2.7.4) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, RVM: ruby-2.7.4) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.1, RVM: ruby-2.7.4) [gem]" level="application" />
15
17
  <orderEntry type="library" scope="PROVIDED" name="amazing_print (v1.4.0, RVM: ruby-2.7.4) [gem]" level="application" />
16
18
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="berkeley_library-logging (v0.2.6, RVM: ruby-2.7.4) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="berkeley_library-logging (v0.2.7, RVM: ruby-2.7.4) [gem]" level="application" />
18
20
  <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, RVM: ruby-2.7.4) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="bundle-audit (v0.1.0, RVM: ruby-2.7.4) [gem]" level="application" />
20
21
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.31, RVM: ruby-2.7.4) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="bundler-audit (v0.9.0.1, RVM: ruby-2.7.4) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="ci_reporter (v2.0.0, RVM: ruby-2.7.4) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="ci_reporter (v2.1.0, RVM: ruby-2.7.4) [gem]" level="application" />
23
23
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter_rspec (v1.0.0, RVM: ruby-2.7.4) [gem]" level="application" />
24
24
  <orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, RVM: ruby-2.7.4) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, RVM: ruby-2.7.4) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.2, RVM: ruby-2.7.4) [gem]" level="application" />
26
26
  <orderEntry type="library" scope="PROVIDED" name="crack (v0.4.5, RVM: ruby-2.7.4) [gem]" level="application" />
27
27
  <orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, RVM: ruby-2.7.4) [gem]" level="application" />
28
28
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.4) [gem]" level="application" />
29
29
  <orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-2.7.4) [gem]" level="application" />
30
30
  <orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20190701, RVM: ruby-2.7.4) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.7.6, RVM: ruby-2.7.4) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="erubi (v1.10.0, RVM: ruby-2.7.4) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.8.1, RVM: ruby-2.7.4) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="erubi (v1.12.0, RVM: ruby-2.7.4) [gem]" level="application" />
33
33
  <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, RVM: ruby-2.7.4) [gem]" level="application" />
34
34
  <orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.7.4) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.4, RVM: ruby-2.7.4) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.4) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.5, RVM: ruby-2.7.4) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.12.0, RVM: ruby-2.7.4) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.6.3, RVM: ruby-2.7.4) [gem]" level="application" />
37
38
  <orderEntry type="library" scope="PROVIDED" name="lograge (v0.12.0, RVM: ruby-2.7.4) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="loofah (v2.18.0, RVM: ruby-2.7.4) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="loofah (v2.19.1, RVM: ruby-2.7.4) [gem]" level="application" />
39
40
  <orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, RVM: ruby-2.7.4) [gem]" level="application" />
40
41
  <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, RVM: ruby-2.7.4) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, RVM: ruby-2.7.4) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-2.7.4) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2023.0218.1, RVM: ruby-2.7.4) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.18.0, RVM: ruby-2.7.4) [gem]" level="application" />
43
44
  <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
44
- <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.6, RVM: ruby-2.7.4) [gem]" level="application" />
45
- <orderEntry type="library" scope="PROVIDED" name="oj (v3.13.11, RVM: ruby-2.7.4) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.14.2, RVM: ruby-2.7.4) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="oj (v3.14.2, RVM: ruby-2.7.4) [gem]" level="application" />
46
47
  <orderEntry type="library" scope="PROVIDED" name="ougai (v1.9.1, RVM: ruby-2.7.4) [gem]" level="application" />
47
48
  <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-2.7.4) [gem]" level="application" />
48
- <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.0, RVM: ruby-2.7.4) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.7, RVM: ruby-2.7.4) [gem]" level="application" />
50
- <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, RVM: ruby-2.7.4) [gem]" level="application" />
51
- <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, RVM: ruby-2.7.4) [gem]" level="application" />
52
- <orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, RVM: ruby-2.7.4) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.2.1.1, RVM: ruby-2.7.4) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.1, RVM: ruby-2.7.4) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.2, RVM: ruby-2.7.4) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.6.3, RVM: ruby-2.7.4) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v2.0.2, RVM: ruby-2.7.4) [gem]" level="application" />
53
54
  <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, RVM: ruby-2.7.4) [gem]" level="application" />
54
- <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
55
- <orderEntry type="library" scope="PROVIDED" name="railties (v7.0.3, RVM: ruby-2.7.4) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.5.0, RVM: ruby-2.7.4) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="railties (v7.0.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
56
57
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.4) [gem]" level="application" />
57
58
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.4) [gem]" level="application" />
58
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.3.1, RVM: ruby-2.7.4) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.7.0, RVM: ruby-2.7.4) [gem]" level="application" />
59
60
  <orderEntry type="library" scope="PROVIDED" name="request_store (v1.5.1, RVM: ruby-2.7.4) [gem]" level="application" />
60
61
  <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-2.7.4) [gem]" level="application" />
61
62
  <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.4) [gem]" level="application" />
62
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
63
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
64
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
65
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, RVM: ruby-2.7.4) [gem]" level="application" />
66
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
67
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
68
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.17.0, RVM: ruby-2.7.4) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, RVM: ruby-2.7.4) [gem]" level="application" />
64
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.1, RVM: ruby-2.7.4) [gem]" level="application" />
65
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.2, RVM: ruby-2.7.4) [gem]" level="application" />
66
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.3, RVM: ruby-2.7.4) [gem]" level="application" />
67
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.0, RVM: ruby-2.7.4) [gem]" level="application" />
68
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.39.0, RVM: ruby-2.7.4) [gem]" level="application" />
69
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.27.0, RVM: ruby-2.7.4) [gem]" level="application" />
69
70
  <orderEntry type="library" scope="PROVIDED" name="rubocop-rake (v0.6.0, RVM: ruby-2.7.4) [gem]" level="application" />
70
71
  <orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v2.4.0, RVM: ruby-2.7.4) [gem]" level="application" />
71
72
  <orderEntry type="library" scope="PROVIDED" name="ruby-prof (v0.17.0, RVM: ruby-2.7.4) [gem]" level="application" />
72
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.4) [gem]" level="application" />
73
- <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.21.2, RVM: ruby-2.7.4) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, RVM: ruby-2.7.4) [gem]" level="application" />
74
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.22.0, RVM: ruby-2.7.4) [gem]" level="application" />
74
75
  <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-2.7.4) [gem]" level="application" />
75
- <orderEntry type="library" scope="PROVIDED" name="simplecov-rcov (v0.3.1, RVM: ruby-2.7.4) [gem]" level="application" />
76
76
  <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, RVM: ruby-2.7.4) [gem]" level="application" />
77
77
  <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.4) [gem]" level="application" />
78
- <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.0, RVM: ruby-2.7.4) [gem]" level="application" />
79
- <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.4) [gem]" level="application" />
78
+ <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.1, RVM: ruby-2.7.4) [gem]" level="application" />
79
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, RVM: ruby-2.7.4) [gem]" level="application" />
80
80
  <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.7.4) [gem]" level="application" />
81
- <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.1, RVM: ruby-2.7.4) [gem]" level="application" />
82
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-2.7.4) [gem]" level="application" />
83
- <orderEntry type="library" scope="PROVIDED" name="webmock (v3.14.0, RVM: ruby-2.7.4) [gem]" level="application" />
84
- <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.4, RVM: ruby-2.7.4) [gem]" level="application" />
81
+ <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.2, RVM: ruby-2.7.4) [gem]" level="application" />
82
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.4.2, RVM: ruby-2.7.4) [gem]" level="application" />
83
+ <orderEntry type="library" scope="PROVIDED" name="webmock (v3.18.1, RVM: ruby-2.7.4) [gem]" level="application" />
84
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.6.7, RVM: ruby-2.7.4) [gem]" level="application" />
85
85
  </component>
86
86
  <component name="RModuleSettingsStorage">
87
87
  <LOAD_PATH number="2" string0="$MODULE_DIR$/lib" string1="$MODULE_DIR$/spec" />
@@ -91,19 +91,16 @@
91
91
  <option name="myRootTask">
92
92
  <RakeTaskImpl id="rake">
93
93
  <subtasks>
94
- <RakeTaskImpl id="bundle">
95
- <subtasks>
96
- <RakeTaskImpl description="Updates the ruby-advisory-db then runs bundle-audit" fullCommand="bundle:audit" id="audit" />
97
- </subtasks>
98
- </RakeTaskImpl>
99
94
  <RakeTaskImpl description="Run all specs in spec directory, with coverage" fullCommand="coverage" id="coverage" />
100
- <RakeTaskImpl description="Run tests, check test coverage, check code style, check for vulnerabilities, build gem" fullCommand="default" id="default" />
101
- <RakeTaskImpl description="Build berkeley_library-util.gemspec as berkeley_library-util-0.1.4.gem" fullCommand="gem" id="gem" />
95
+ <RakeTaskImpl description="Run tests, check test coverage, check code style, build gem" fullCommand="default" id="default" />
96
+ <RakeTaskImpl description="Build berkeley_library-util.gemspec as berkeley_library-util-0.1.6.gem" fullCommand="gem" id="gem" />
102
97
  <RakeTaskImpl description="Run RuboCop with auto-correct, and output results to console" fullCommand="ra" id="ra" />
103
98
  <RakeTaskImpl description="Run rubocop with HTML output" fullCommand="rubocop" id="rubocop" />
104
99
  <RakeTaskImpl id="rubocop">
105
100
  <subtasks>
106
- <RakeTaskImpl description="Auto-correct RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
101
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
102
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
103
+ <RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
107
104
  </subtasks>
108
105
  </RakeTaskImpl>
109
106
  <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
data/.rubocop.yml CHANGED
@@ -332,7 +332,162 @@ Style/SwapValues: # (new in 1.1)
332
332
  ############################################################
333
333
  # Added in RuboCop 1.10
334
334
 
335
- Gemspec/DateAssignment: # (new in 1.10)
336
- Enabled: true
337
335
  Style/HashConversion: # (new in 1.10)
338
336
  Enabled: true
337
+
338
+ ############################################################
339
+ # Added in RuboCop 1.12
340
+
341
+ Style/StringChars: # (new in 1.12)
342
+ Enabled: true
343
+
344
+ ############################################################
345
+ # Added in RuboCop 1.16
346
+
347
+ Lint/EmptyInPattern: # (new in 1.16)
348
+ Enabled: true
349
+ Style/InPatternThen: # (new in 1.16)
350
+ Enabled: true
351
+ Style/MultilineInPatternThen: # (new in 1.16)
352
+ Enabled: true
353
+ Style/QuotedSymbols: # (new in 1.16)
354
+ Enabled: true
355
+
356
+ ############################################################
357
+ # Added in RuboCop 1.18
358
+
359
+ Layout/LineEndStringConcatenationIndentation: # (new in 1.18)
360
+ Enabled: true
361
+
362
+ ############################################################
363
+ # Added in RuboCop 1.19
364
+
365
+ Lint/AmbiguousRange: # (new in 1.19)
366
+ Enabled: true
367
+ Style/RedundantSelfAssignmentBranch: # (new in 1.19)
368
+ Enabled: true
369
+
370
+ ############################################################
371
+ # Added in RuboCop 1.21
372
+
373
+ Lint/AmbiguousOperatorPrecedence: # (new in 1.21)
374
+ Enabled: true
375
+ Lint/IncompatibleIoSelectWithFiberScheduler: # (new in 1.21)
376
+ Enabled: true
377
+
378
+ ############################################################
379
+ # Added in RuboCop 1.22
380
+
381
+ Lint/RequireRelativeSelfPath: # (new in 1.22)
382
+ Enabled: true
383
+ Security/IoMethods: # (new in 1.22)
384
+ Enabled: true
385
+ Style/NumberedParameters: # (new in 1.22)
386
+ Enabled: true
387
+ Style/NumberedParametersLimit: # (new in 1.22)
388
+ Enabled: true
389
+ Style/SelectByRegexp: # (new in 1.22)
390
+ Enabled: true
391
+
392
+ ############################################################
393
+ # Added in RuboCop 1.23
394
+
395
+ Gemspec/RequireMFA: # (new in 1.23)
396
+ Enabled: true
397
+ Lint/UselessRuby2Keywords: # (new in 1.23)
398
+ Enabled: true
399
+ Style/OpenStructUse: # (new in 1.23)
400
+ Enabled: true
401
+
402
+ ############################################################
403
+ # Added in RuboCop 1.24
404
+
405
+ Naming/BlockForwarding: # (new in 1.24)
406
+ Enabled: true
407
+ Style/FileRead: # (new in 1.24)
408
+ Enabled: true
409
+ Style/FileWrite: # (new in 1.24)
410
+ Enabled: true
411
+ Style/MapToHash: # (new in 1.24)
412
+ Enabled: true
413
+
414
+ ############################################################
415
+ # Added in RuboCop 1.26
416
+
417
+ Style/NestedFileDirname: # (new in 1.26)
418
+ Enabled: true
419
+
420
+ ############################################################
421
+ # Added in RuboCop 1.27
422
+
423
+ Lint/RefinementImportMethods: # (new in 1.27)
424
+ Enabled: true
425
+ Style/RedundantInitialize: # (new in 1.27)
426
+ Enabled: true
427
+
428
+ ############################################################
429
+ # Added in RuboCop 1.28
430
+
431
+ Security/CompoundHash: # (new in 1.28)
432
+ Enabled: true
433
+ Style/FetchEnvVar: # (new in 1.28)
434
+ Enabled: true
435
+ Style/ObjectThen: # (new in 1.28)
436
+ Enabled: true
437
+
438
+ ############################################################
439
+ # Added in RuboCop 1.29
440
+
441
+ Style/EnvHome: # (new in 1.29)
442
+ Enabled: true
443
+
444
+ ############################################################
445
+ # Added in RuboCop 1.30
446
+
447
+ Gemspec/DeprecatedAttributeAssignment: # (new in 1.30)
448
+ Enabled: true
449
+ Style/MapCompactWithConditionalBlock: # (new in 1.30)
450
+ Enabled: true
451
+
452
+ ############################################################
453
+ # Added in RuboCop 1.31
454
+
455
+ Layout/LineContinuationLeadingSpace: # (new in 1.31)
456
+ Enabled: true
457
+ Layout/LineContinuationSpacing: # (new in 1.31)
458
+ Enabled: true
459
+ Lint/ConstantOverwrittenInRescue: # (new in 1.31)
460
+ Enabled: true
461
+ Lint/NonAtomicFileOperation: # (new in 1.31)
462
+ Enabled: true
463
+
464
+ ############################################################
465
+ # Added in RuboCop 1.32
466
+
467
+ Lint/RequireRangeParentheses: # (new in 1.32)
468
+ Enabled: true
469
+ Style/EmptyHeredoc: # (new in 1.32)
470
+ Enabled: true
471
+
472
+ ############################################################
473
+ # Added in RuboCop 1.35
474
+
475
+ Style/MagicCommentFormat: # (new in 1.35)
476
+ Enabled: true
477
+
478
+ ############################################################
479
+ # Added in RuboCop 1.37
480
+
481
+ Lint/DuplicateMagicComment: # (new in 1.37)
482
+ Enabled: true
483
+ Style/OperatorMethodCall: # (new in 1.37)
484
+ Enabled: true
485
+ Style/RedundantStringEscape: # (new in 1.37)
486
+ Enabled: true
487
+
488
+ ############################################################
489
+ # Added in RuboCop 1.38
490
+
491
+ Style/RedundantEach: # (new in 1.38)
492
+ Enabled: true
493
+
data/.simplecov CHANGED
@@ -1,8 +1,7 @@
1
- require 'simplecov-rcov'
2
-
3
- SimpleCov.start 'rails' do
1
+ SimpleCov.start do
4
2
  add_filter 'module_info.rb'
5
- coverage_dir 'artifacts'
6
- formatter SimpleCov::Formatter::RcovFormatter
7
- minimum_coverage 100
3
+ coverage_dir 'artifacts/coverage'
4
+
5
+ enable_coverage :branch
6
+ minimum_coverage line: 100, branch: 100
8
7
  end
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 0.1.6 (2023-03-09)
2
+
3
+ - Fix issue in `Requester` where query parameters would not be appended properly
4
+ to URLs that already included a query string.
5
+ - Fix issue in `URIs#append` (and `Appender`) where `?` would not be accepted in
6
+ query strings or fragments, contrary to RFC 3986 §3.
7
+ - Fix documentation for `Arrays#find_indices`.
8
+ - Fix issue where `Arrays#find_index` would raise a confusing `NameError`
9
+ instead of a helpful `ArgumentError` if passed too many arguments.
10
+
1
11
  # 0.1.5 (2022-09-16)
2
12
 
3
13
  - Adds `URIs#path_escape` to escape URL path segments
data/Rakefile CHANGED
@@ -16,5 +16,5 @@ ENV['RAILS_ENV'] = 'test' if ENV['CI']
16
16
  # ------------------------------------------------------------
17
17
  # Custom tasks
18
18
 
19
- desc 'Run tests, check test coverage, check code style, check for vulnerabilities, build gem'
20
- task default: %i[coverage rubocop bundle:audit gem]
19
+ desc 'Run tests, check test coverage, check code style, build gem'
20
+ task default: %i[coverage rubocop gem]
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.homepage = BerkeleyLibrary::Util::ModuleInfo::HOMEPAGE
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0")
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
20
  spec.require_paths = ['lib']
22
21
 
23
22
  spec.required_ruby_version = ruby_version
@@ -26,17 +25,17 @@ Gem::Specification.new do |spec|
26
25
  spec.add_dependency 'rest-client', '~> 2.1'
27
26
  spec.add_dependency 'typesafe_enum', '~> 0.3'
28
27
 
29
- spec.add_development_dependency 'bundle-audit', '~> 0.1'
30
28
  spec.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
31
29
  spec.add_development_dependency 'colorize', '~> 0.8'
32
30
  spec.add_development_dependency 'dotenv', '~> 2.7'
33
31
  spec.add_development_dependency 'rake', '~> 13.0'
34
32
  spec.add_development_dependency 'rspec', '~> 3.10'
35
- spec.add_development_dependency 'rubocop', '= 1.11'
36
- spec.add_development_dependency 'rubocop-rake', '~> 0.5'
37
- spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
33
+ spec.add_development_dependency 'rubocop', '= 1.39'
34
+ spec.add_development_dependency 'rubocop-rake', '= 0.6.0'
35
+ spec.add_development_dependency 'rubocop-rspec', '= 2.4.0'
38
36
  spec.add_development_dependency 'ruby-prof', '~> 0.17.0'
39
37
  spec.add_development_dependency 'simplecov', '~> 0.21'
40
- spec.add_development_dependency 'simplecov-rcov', '~> 0.2'
41
38
  spec.add_development_dependency 'webmock', '~> 3.12'
39
+
40
+ spec.metadata['rubygems_mfa_required'] = 'true'
42
41
  end
@@ -45,7 +45,7 @@ module BerkeleyLibrary
45
45
  # returns an array the length of the subset, containing for each element in
46
46
  # the subset the index of the corresponding element in the superset.
47
47
  #
48
- # @overload find_matching_indices(for_array:, in_array:)
48
+ # @overload find_indices(for_array:, in_array:)
49
49
  # For each value in `for_array`, finds the index of the first equal value
50
50
  # in `in_array` after the previously matched value.
51
51
  # @param in_array [Array] the list of values to look in
@@ -53,7 +53,7 @@ module BerkeleyLibrary
53
53
  # @return [Array<Integer>, nil] the indices in `in_array` of each value in `for_array`,
54
54
  # or `nil` if not all values could be found
55
55
  #
56
- # @overload find_matching_indices(for_array:, in_array:)
56
+ # @overload find_indices(for_array:, in_array:)
57
57
  # For each value in `for_array`, finds the index of the first value
58
58
  # in `in_array` after the previously matched value that matches
59
59
  # the specified match function.
@@ -90,7 +90,7 @@ module BerkeleyLibrary
90
90
  # @param start_index [Integer] the index to start with
91
91
  # @return [Enumerator] a new enumerator
92
92
  def find_index(*args, in_array:, start_index: 0, &block)
93
- raise ArgumentError, "wrong number of arguments (given #{value.length}, expected 0..1" if args.size > 1
93
+ raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0..1" if args.size > 1
94
94
  return Enumerator.new { |y| find_index(in_array: in_array, start_index: start_index, &y) } if args.empty? && !block_given?
95
95
  return unless (relative_index = in_array[start_index..].find_index(*args, &block))
96
96
 
@@ -11,8 +11,8 @@ module BerkeleyLibrary
11
11
  end
12
12
 
13
13
  def parent_exists?(path)
14
- path.respond_to?(:parent) && path.parent.exist? ||
15
- path.respond_to?(:to_str) && Pathname.new(path).parent.exist?
14
+ (path.respond_to?(:parent) && path.parent.exist?) ||
15
+ (path.respond_to?(:to_str) && Pathname.new(path).parent.exist?)
16
16
  end
17
17
 
18
18
  # Returns true if `obj` is close enough to an IO object for Nokogiri
@@ -7,7 +7,7 @@ module BerkeleyLibrary
7
7
  SUMMARY = 'Miscellaneous Ruby utilities for the UC Berkeley Library'.freeze
8
8
  DESCRIPTION = 'A collection of miscellaneous Ruby routines for the UC Berkeley Library.'.freeze
9
9
  LICENSE = 'MIT'.freeze
10
- VERSION = '0.1.5'.freeze
10
+ VERSION = '0.1.6'.freeze
11
11
  HOMEPAGE = 'https://github.com/BerkeleyLibrary/util'.freeze
12
12
  end
13
13
  end
@@ -22,10 +22,7 @@ module BerkeleyLibrary
22
22
 
23
23
  @elements = elements.map(&:to_s)
24
24
  @elements.each_with_index do |element, elem_index|
25
- next start_query_at(elem_index) if element.include?('?')
26
- next start_fragment_at(elem_index) if element.include?('#')
27
-
28
- add_element(element)
25
+ handle_element(element, elem_index)
29
26
  end
30
27
  end
31
28
 
@@ -44,6 +41,16 @@ module BerkeleyLibrary
44
41
 
45
42
  private
46
43
 
44
+ def handle_element(element, elem_index)
45
+ h_index = element.index('#')
46
+ q_index = element.index('?')
47
+ # per RFC 3986 §3, fragment (or query) can contain '?', but query can't contain '#'
48
+ return start_fragment_at(elem_index) if h_index && (q_index.nil? || h_index < q_index)
49
+ return start_query_at(elem_index) if q_index && !(in_query? || in_fragment?)
50
+
51
+ add_element(element)
52
+ end
53
+
47
54
  def state
48
55
  @state ||= :path
49
56
  end
@@ -77,24 +84,21 @@ module BerkeleyLibrary
77
84
  end
78
85
 
79
86
  def start_query_at(elem_index)
80
- raise URI::InvalidComponentError, err_query_after_fragment(elem_index) if in_fragment?
81
- raise URI::InvalidComponentError, err_too_many_queries(elem_index) unless query_elements.empty?
82
-
83
87
  handle_query_start(elem_index)
84
88
  @state = :query
85
89
  end
86
90
 
87
91
  def start_fragment_at(elem_index)
88
92
  raise URI::InvalidComponentError, err_too_many_fragments(elem_index) unless fragment_elements.empty?
89
- raise URI::InvalidComponentError, err_query_after_fragment(elem_index) if query_after_fragment?(elem_index)
93
+ raise URI::InvalidComponentError, err_too_many_fragments(elem_index) if too_many_fragments?(elem_index)
90
94
 
91
95
  handle_fragment_start(elem_index)
92
96
  @state = :fragment
93
97
  end
94
98
 
95
- def query_after_fragment?(elem_index)
99
+ def too_many_fragments?(elem_index)
96
100
  e = elements[elem_index]
97
- e.index('?', e.index('#'))
101
+ e.index('#', 1 + e.index('#'))
98
102
  end
99
103
 
100
104
  def add_element(e)
@@ -122,7 +126,7 @@ module BerkeleyLibrary
122
126
  return q_start unless (f_index = q_start.index('#'))
123
127
 
124
128
  next_index = elem_index + 1
125
- q_start, q_next = split_around(q_start, f_index) # NOTE: this doesn't return the '#'
129
+ q_start, q_next = split_around(q_start, f_index) # NOTE: this doesn't return the '#'
126
130
  elements[next_index] = "##{q_next}#{elements[next_index]}" # so we prepend one here
127
131
  q_start
128
132
  end
@@ -146,14 +150,6 @@ module BerkeleyLibrary
146
150
  [s[0...i], s[(i + 1)..]]
147
151
  end
148
152
 
149
- def err_too_many_queries(elem_index)
150
- "#{elements[elem_index].inspect}: URI already has a query string: #{query.inspect}"
151
- end
152
-
153
- def err_query_after_fragment(elem_index)
154
- "#{elements[elem_index].inspect}: Query delimiter '?' cannot follow fragment delimeter '#'"
155
- end
156
-
157
153
  def err_too_many_fragments(elem_index)
158
154
  "#{elements[elem_index].inspect}: URI already has a fragment: #{fragment.inspect}"
159
155
  end
@@ -68,14 +68,14 @@ module BerkeleyLibrary
68
68
  req_resp_or_raise(method, url_str, headers)
69
69
  end
70
70
 
71
- def url_str_with_params(uri, params)
72
- raise ArgumentError, 'uri cannot be nil' unless (url_str = Validator.url_str_or_nil(uri))
71
+ def url_str_with_params(url, params)
72
+ raise ArgumentError, 'url cannot be nil' unless (uri = Validator.uri_or_nil(url))
73
73
 
74
74
  elements = [].tap do |ee|
75
- ee << url_str
75
+ ee << uri
76
76
  next if params.empty?
77
77
 
78
- ee << '?' unless url_str.include?('?')
78
+ ee << (uri.query ? '&' : '?')
79
79
  ee << URI.encode_www_form(params)
80
80
  end
81
81
 
@@ -115,7 +115,7 @@ module BerkeleyLibrary
115
115
 
116
116
  def should_escape?(b, mode)
117
117
  return false if unreserved?(b)
118
- return false if ALLOWED_BYTES_BY_MODE[mode]&.include?(b)
118
+ return false if ALLOWED_BYTES_BY_MODE[mode].include?(b)
119
119
 
120
120
  true
121
121
  end
@@ -0,0 +1,4 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ require:
4
+ - rubocop-rake
data/spec/.rubocop.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  inherit_from: ../.rubocop.yml
2
2
 
3
+ require:
4
+ - rubocop-rspec
5
+
3
6
  AllCops:
4
7
  # Exclude generated files
5
8
  Exclude:
@@ -38,3 +41,89 @@ Metrics/MethodLength:
38
41
  # Sometimes we're testing the operator
39
42
  Lint/BinaryOperatorWithIdenticalOperands:
40
43
  Enabled: false
44
+
45
+ ############################################################
46
+ # rubocop-rspec
47
+
48
+ # believe me, it wasn't by choice
49
+ RSpec/AnyInstance:
50
+ Enabled: false
51
+
52
+ # we meant to do that
53
+ RSpec/BeforeAfterAll:
54
+ Enabled: false
55
+
56
+ # more words != more readable
57
+ RSpec/ContextWording:
58
+ Enabled: false
59
+
60
+ # explicit >>> implicit
61
+ RSpec/DescribedClass:
62
+ Enabled: false
63
+
64
+ # more punctuation != more readable
65
+ RSpec/DescribeSymbol:
66
+ Enabled: false
67
+
68
+ # setup cost / time >>> failure granularity
69
+ RSpec/ExampleLength:
70
+ Max: 15
71
+ CountAsOne:
72
+ - array
73
+ - hash
74
+ - heredoc
75
+
76
+ # we meant to do that
77
+ RSpec/ExpectInHook:
78
+ Enabled: false
79
+
80
+ # your naming scheme is not in possession of all the facts
81
+ RSpec/FilePath:
82
+ Enabled: false
83
+
84
+ # explicit >>> implicit
85
+ RSpec/InstanceVariable:
86
+ Enabled: false
87
+
88
+ # maybe when 'all' has a corresponding 'none' matcher
89
+ RSpec/IteratedExpectation:
90
+ Enabled: false
91
+
92
+ # we meant to do that
93
+ RSpec/MessageSpies:
94
+ Enabled: false
95
+
96
+ # too late now
97
+ RSpec/MultipleMemoizedHelpers:
98
+ Enabled: false
99
+
100
+ # setup cost / time >>> failure granularity
101
+ RSpec/MultipleExpectations:
102
+ Enabled: false
103
+
104
+ # cure is worse than the disease
105
+ RSpec/NestedGroups:
106
+ Enabled: false
107
+
108
+ # more quotation marks != more readable
109
+ RSpec/SharedExamples:
110
+ Enabled: false
111
+
112
+ # we meant to do that
113
+ RSpec/StubbedMock:
114
+ Enabled: false
115
+
116
+ # we meant to do that
117
+ RSpec/VerifiedDoubles:
118
+ Enabled: false
119
+
120
+ ############################################################
121
+ # rubocop-rspec
122
+
123
+ # enable newer rubocop-rspec cops
124
+
125
+ RSpec/IdenticalEqualityAssertion: # new in 2.4
126
+ Enabled: true
127
+
128
+ RSpec/Rails/AvoidSetupHook: # new in 2.4
129
+ Enabled: true
@@ -113,12 +113,13 @@ module BerkeleyLibrary::Util
113
113
  ]
114
114
  sources.each do |source|
115
115
  expect(Arrays.find_indices(for_array: source, in_array: target)).to be_nil
116
+ expect(Arrays.find_indices(for_array: source, in_array: target) { |s, t| t == s.to_s }).to be_nil
116
117
  end
117
118
  end
118
119
 
119
120
  it 'takes a comparison block' do
120
121
  sub = %i[a c e]
121
- expect(Arrays.find_indices(for_array: sub, in_array: target) { |source, target| target == source.to_s }).to eq([0, 2, 4])
122
+ expect(Arrays.find_indices(for_array: sub, in_array: target) { |s, t| t == s.to_s }).to eq([0, 2, 4])
122
123
  end
123
124
  end
124
125
 
@@ -145,6 +146,10 @@ module BerkeleyLibrary::Util
145
146
  expect(Arrays.find_index(in_array: arr, start_index: 2) { |x| x < 4 }).to be_nil
146
147
  end
147
148
 
149
+ it 'raises ArgumentError if given extra arguments' do
150
+ expect { Arrays.find_index(1, 2, 3, in_array: [1, 2, 3]) }.to raise_error(ArgumentError)
151
+ end
152
+
148
153
  # rubocop:disable Lint/Void
149
154
  it 'returns an enumerator if given no arguments' do
150
155
  e = Arrays.find_index(in_array: arr)
@@ -327,6 +332,10 @@ module BerkeleyLibrary::Util
327
332
  expect(Arrays.invert([0, 2, 3])).to eq([0, nil, 1, 2])
328
333
  end
329
334
 
335
+ it 'returns nil if given nil' do
336
+ expect(Arrays.invert(nil)).to be_nil
337
+ end
338
+
330
339
  it 'fails if values are not ints' do
331
340
  # noinspection RubyYardParamTypeMatch
332
341
  expect { Arrays.invert(%i[a b c]) }.to raise_error(TypeError)
@@ -8,6 +8,7 @@ module BerkeleyLibrary
8
8
  attr_reader :tmpdir
9
9
 
10
10
  before { @tmpdir = Dir.mktmpdir(basename) }
11
+
11
12
  after { FileUtils.remove_entry(tmpdir) }
12
13
 
13
14
  describe :file_exists? do
@@ -16,6 +16,13 @@ module BerkeleyLibrary
16
16
  end
17
17
  end
18
18
 
19
+ it 'reads from the end if given a negative index' do
20
+ bytes.reverse.each_with_index do |b, i|
21
+ end_offset = i + 1
22
+ expect(StringIOs.getbyte(sio, -end_offset)).to eq(b)
23
+ end
24
+ end
25
+
19
26
  it 'resets the current offset' do
20
27
  StringIOs.getbyte(sio, bytes.size / 2)
21
28
  expect(sio.pos).to eq(0)
@@ -41,6 +41,10 @@ module BerkeleyLibrary
41
41
  expect(Strings.diff_index(s, s)).to be_nil
42
42
  end
43
43
 
44
+ it 'returns nil for non-strings' do
45
+ expect(Strings.diff_index(2, ['2'])).to be_nil
46
+ end
47
+
44
48
  it 'returns the index for different strings' do
45
49
  s1 = 'elvis aaron presley'
46
50
  s2 = 'elvis nikita presley'
@@ -33,6 +33,10 @@ module BerkeleyLibrary
33
33
  # noinspection RubyYardParamTypeMatch
34
34
  expect { Times.ensure_utc(Object.new) }.to raise_error(ArgumentError)
35
35
  end
36
+
37
+ it 'returns nil for nil' do
38
+ expect(Times.ensure_utc(nil)).to be_nil
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -97,6 +97,17 @@ module BerkeleyLibrary
97
97
  expect(result).to eq(expected_status)
98
98
  end
99
99
 
100
+ it 'appends query parameters to URL with existing params' do
101
+ url = 'https://example.org/endpoint?foo=bar'
102
+ params = { p1: 1, p2: 2 }
103
+ url_with_query = "#{url}&#{URI.encode_www_form(params)}"
104
+ expected_status = 203
105
+ stub_request(:head, url_with_query).to_return(status: expected_status)
106
+
107
+ result = Requester.head(url, params: params)
108
+ expect(result).to eq(expected_status)
109
+ end
110
+
100
111
  it 'sends request headers' do
101
112
  url = 'https://example.org/'
102
113
  headers = { 'X-help' => 'I am trapped in a unit test' }
@@ -129,6 +140,10 @@ module BerkeleyLibrary
129
140
  result = Requester.head(url1)
130
141
  expect(result).to eq(expected_status)
131
142
  end
143
+
144
+ it 'rejects a nil URI' do
145
+ expect { Requester.head(nil) }.to raise_error(ArgumentError)
146
+ end
132
147
  end
133
148
  end
134
149
  end
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  module BerkeleyLibrary::Util
4
4
  describe URIs do
5
5
  describe :append do
6
+ it 'rejects a nil URI' do
7
+ expect { URIs.append(nil, 'foo') }.to raise_error(ArgumentError)
8
+ end
9
+
6
10
  it 'appends paths' do
7
11
  original_uri = URI('https://example.org/foo/bar')
8
12
  new_uri = URIs.append(original_uri, 'qux', 'corge', 'garply')
@@ -92,29 +96,67 @@ module BerkeleyLibrary::Util
92
96
  expect(new_uri).to eq(URI('https://example.org/foo/bar/qux/corge/garply?baz=qux#grault'))
93
97
  end
94
98
 
95
- it 'rejects a query string if the original URI already has one' do
96
- original_uri = URI('https://example.org/foo/bar?baz=qux')
97
- expect { URIs.append(original_uri, '/qux?corge') }.to raise_error(URI::InvalidComponentError)
98
- end
99
-
100
99
  it 'rejects a fragment if the original URI already has one' do
101
100
  original_uri = URI('https://example.org/foo/bar#baz')
102
101
  expect { URIs.append(original_uri, '/qux#corge') }.to raise_error(URI::InvalidComponentError)
103
102
  end
104
103
 
105
- it 'rejects appending multiple queries' do
104
+ # Per RFC3986, "3.4. Query"
105
+ it 'allows queries containing ?' do
106
+ original_uri = URI('https://example.org/foo/bar')
107
+ expected_url = "#{original_uri}/baz?qux=corge?grault?plugh=xyzzy"
108
+ expected_uri = URI.parse(expected_url)
109
+
110
+ uri1 = URIs.append(original_uri, 'baz?qux=corge', '?grault?plugh=xyzzy')
111
+ expect(uri1).to eq(expected_uri)
112
+
113
+ uri2 = URIs.append(original_uri, 'baz?qux=corge?grault?plugh=xyzzy')
114
+ expect(uri2).to eq(expected_uri)
115
+ end
116
+
117
+ # Per RFC3986, "3.4. Query"
118
+ it 'allows queries containing /' do
106
119
  original_uri = URI('https://example.org/foo/bar')
107
- expect { URIs.append(original_uri, 'baz?qux=corge', 'grault?plugh=xyzzy') }.to raise_error(URI::InvalidComponentError)
120
+ expected_url = "#{original_uri}/baz?qux=corge/grault/plugh=xyzzy"
121
+ expected_uri = URI.parse(expected_url)
122
+
123
+ uri1 = URIs.append(original_uri, 'baz?qux=corge', '/grault/plugh=xyzzy')
124
+ expect(uri1).to eq(expected_uri)
125
+
126
+ uri2 = URIs.append(original_uri, 'baz?qux=corge/grault/plugh=xyzzy')
127
+ expect(uri2).to eq(expected_uri)
108
128
  end
109
129
 
110
- it 'rejects appending multiple fragments' do
130
+ it 'rejects fragments containing #' do
111
131
  original_uri = URI('https://example.org/foo/bar')
112
132
  expect { URIs.append(original_uri, 'baz#qux', 'grault#plugh') }.to raise_error(URI::InvalidComponentError)
133
+ expect { URIs.append(original_uri, 'baz#qux#plugh') }.to raise_error(URI::InvalidComponentError)
113
134
  end
114
135
 
115
- it 'rejects queries after fragments' do
136
+ # Per RFC3986, "3.5. Fragment"
137
+ it 'allows fragments containing ?' do
116
138
  original_uri = URI('https://example.org/foo/bar')
117
- expect { URIs.append(original_uri, 'baz#qux', '?grault=plugh') }.to raise_error(URI::InvalidComponentError)
139
+ expected_url = "#{original_uri}/baz#qux?grault=plugh"
140
+ expected_uri = URI.parse(expected_url)
141
+
142
+ uri1 = URIs.append(original_uri, 'baz#qux', '?grault=plugh')
143
+ expect(uri1).to eq(expected_uri)
144
+
145
+ uri2 = URIs.append(original_uri, 'baz#qux?grault=plugh')
146
+ expect(uri2).to eq(expected_uri)
147
+ end
148
+
149
+ # Per RFC3986, "3.5. Fragment"
150
+ it 'allows fragments containing /' do
151
+ original_uri = URI('https://example.org/foo/bar')
152
+ expected_url = "#{original_uri}/baz#qux/grault=plugh"
153
+ expected_uri = URI.parse(expected_url)
154
+
155
+ uri1 = URIs.append(original_uri, 'baz#qux', '/grault=plugh')
156
+ expect(uri1).to eq(expected_uri)
157
+
158
+ uri2 = URIs.append(original_uri, 'baz#qux/grault=plugh')
159
+ expect(uri2).to eq(expected_uri)
118
160
  end
119
161
 
120
162
  it 'correctly handles fragments in mid-path-segment' do
@@ -147,6 +189,15 @@ module BerkeleyLibrary::Util
147
189
  expected_url = "https://example.org/#{encoded_segment}/foo.html"
148
190
  expect(new_uri).to eq(URI(expected_url))
149
191
  end
192
+
193
+ it 'accepts path segments with allowed punctuation' do
194
+ original_uri = URI('https://example.org/')
195
+ path = 'foo/bar/baz@qux&corge=garply+grault$waldo/fred'
196
+ new_uri = URIs.append(original_uri, path, 'plugh')
197
+ expected_url = "#{original_uri}#{path}/plugh"
198
+ expect(new_uri).to eq(URI(expected_url))
199
+ end
200
+
150
201
  end
151
202
 
152
203
  describe 'requests' do
@@ -266,6 +317,7 @@ module BerkeleyLibrary::Util
266
317
  'foo+bar' => 'foo+bar',
267
318
  'qux/quux' => 'qux%2Fquux',
268
319
  'foo bar baz' => 'foo%20bar%20baz',
320
+ 'Corge-Grault.Fred_Waldo~Plugh' => 'Corge-Grault.Fred_Waldo~Plugh',
269
321
  '25%' => '25%25',
270
322
  "\t !\"#$%&'()*+,/:;<=>?@[\\]^`{|}☺" => '%09%20%21%22%23$%25&%27%28%29%2A+%2C%2F:%3B%3C=%3E%3F@%5B%5C%5D%5E%60%7B%7C%7D%E2%98%BA',
271
323
  '精力善用' => '%E7%B2%BE%E5%8A%9B%E5%96%84%E7%94%A8'
data/spec/spec_helper.rb CHANGED
@@ -13,8 +13,8 @@ RSpec.configure do |config|
13
13
  config.color = true
14
14
  config.tty = true
15
15
  config.formatter = :documentation
16
- config.before(:each) { WebMock.disable_net_connect!(allow_localhost: true) }
17
- config.after(:each) { WebMock.allow_net_connect! }
16
+ config.before { WebMock.disable_net_connect!(allow_localhost: true) }
17
+ config.after { WebMock.allow_net_connect! }
18
18
  config.mock_with :rspec do |mocks|
19
19
  mocks.verify_partial_doubles = true
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkeley_library-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-16 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: berkeley_library-logging
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.3'
55
- - !ruby/object:Gem::Dependency
56
- name: bundle-audit
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.1'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: ci_reporter_rspec
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -142,42 +128,42 @@ dependencies:
142
128
  requirements:
143
129
  - - '='
144
130
  - !ruby/object:Gem::Version
145
- version: '1.11'
131
+ version: '1.39'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - '='
151
137
  - !ruby/object:Gem::Version
152
- version: '1.11'
138
+ version: '1.39'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rubocop-rake
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
- - - "~>"
143
+ - - '='
158
144
  - !ruby/object:Gem::Version
159
- version: '0.5'
145
+ version: 0.6.0
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
- - - "~>"
150
+ - - '='
165
151
  - !ruby/object:Gem::Version
166
- version: '0.5'
152
+ version: 0.6.0
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: rubocop-rspec
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
- - - "~>"
157
+ - - '='
172
158
  - !ruby/object:Gem::Version
173
- version: '2.2'
159
+ version: 2.4.0
174
160
  type: :development
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
- - - "~>"
164
+ - - '='
179
165
  - !ruby/object:Gem::Version
180
- version: '2.2'
166
+ version: 2.4.0
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: ruby-prof
183
169
  requirement: !ruby/object:Gem::Requirement
@@ -206,20 +192,6 @@ dependencies:
206
192
  - - "~>"
207
193
  - !ruby/object:Gem::Version
208
194
  version: '0.21'
209
- - !ruby/object:Gem::Dependency
210
- name: simplecov-rcov
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '0.2'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '0.2'
223
195
  - !ruby/object:Gem::Dependency
224
196
  name: webmock
225
197
  requirement: !ruby/object:Gem::Requirement
@@ -271,7 +243,7 @@ files:
271
243
  - lib/berkeley_library/util/uris/appender.rb
272
244
  - lib/berkeley_library/util/uris/requester.rb
273
245
  - lib/berkeley_library/util/uris/validator.rb
274
- - rakelib/bundle.rake
246
+ - rakelib/.rubocop.yml
275
247
  - rakelib/coverage.rake
276
248
  - rakelib/gem.rake
277
249
  - rakelib/rubocop.rake
@@ -290,7 +262,8 @@ files:
290
262
  homepage: https://github.com/BerkeleyLibrary/util
291
263
  licenses:
292
264
  - MIT
293
- metadata: {}
265
+ metadata:
266
+ rubygems_mfa_required: 'true'
294
267
  post_install_message:
295
268
  rdoc_options: []
296
269
  require_paths:
@@ -310,15 +283,4 @@ rubygems_version: 3.1.6
310
283
  signing_key:
311
284
  specification_version: 4
312
285
  summary: Miscellaneous Ruby utilities for the UC Berkeley Library
313
- test_files:
314
- - spec/.rubocop.yml
315
- - spec/berkeley_library/util/arrays_spec.rb
316
- - spec/berkeley_library/util/files_spec.rb
317
- - spec/berkeley_library/util/paths_spec.rb
318
- - spec/berkeley_library/util/stringios_spec.rb
319
- - spec/berkeley_library/util/strings_spec.rb
320
- - spec/berkeley_library/util/times_spec.rb
321
- - spec/berkeley_library/util/uris/requester_spec.rb
322
- - spec/berkeley_library/util/uris/validator_spec.rb
323
- - spec/berkeley_library/util/uris_spec.rb
324
- - spec/spec_helper.rb
286
+ test_files: []
data/rakelib/bundle.rake DELETED
@@ -1,8 +0,0 @@
1
- namespace :bundle do
2
- desc 'Updates the ruby-advisory-db then runs bundle-audit'
3
- task :audit do
4
- require 'bundler/audit/cli'
5
- Bundler::Audit::CLI.start ['update']
6
- Bundler::Audit::CLI.start %w[check --ignore CVE-2015-9284]
7
- end
8
- end