rspec-sorbet 1.5.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +48 -0
- data/.gitignore +3 -1
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -5
- data/README.md +5 -1
- data/bin/tapioca +29 -0
- data/generate_require_files.rb +1 -0
- data/lib/rspec/all.rb +1 -0
- data/lib/rspec/sorbet/all.rb +1 -0
- data/lib/rspec/sorbet/doubles.rb +35 -13
- data/lib/rspec/sorbet/version.rb +2 -1
- data/lib/rspec/sorbet.rb +1 -0
- data/nix/sources.json +14 -0
- data/nix/sources.nix +174 -0
- data/rspec-sorbet.gemspec +2 -2
- data/run_ci.sh +7 -0
- data/shell.nix +20 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +54 -0
- data/sorbet/rbi/gems/byebug@11.1.3.rbi +1568 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +1005 -0
- data/sorbet/rbi/gems/diff-lcs@1.4.4.rbi +9 -0
- data/sorbet/rbi/gems/docile@1.4.0.rbi +54 -0
- data/sorbet/rbi/gems/em-websocket@0.5.2.rbi +8 -0
- data/sorbet/rbi/gems/eventmachine@1.2.7.rbi +45 -0
- data/sorbet/rbi/gems/ffaker@2.20.0.rbi +3171 -0
- data/sorbet/rbi/gems/ffi@1.15.4.rbi +8 -0
- data/sorbet/rbi/gems/formatador@0.3.0.rbi +8 -0
- data/sorbet/rbi/gems/guard-compat@1.2.1.rbi +31 -0
- data/sorbet/rbi/gems/guard-livereload@2.5.2.rbi +8 -0
- data/sorbet/rbi/gems/guard-rspec@4.7.3.rbi +211 -0
- data/sorbet/rbi/gems/guard@2.18.0.rbi +8 -0
- data/sorbet/rbi/gems/http_parser.rb@0.6.0.rbi +8 -0
- data/sorbet/rbi/gems/listen@3.7.0.rbi +8 -0
- data/sorbet/rbi/gems/lumberjack@1.2.8.rbi +8 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +72 -0
- data/sorbet/rbi/gems/multi_json@1.15.0.rbi +8 -0
- data/sorbet/rbi/gems/nenv@0.3.0.rbi +8 -0
- data/sorbet/rbi/gems/notiffany@0.1.3.rbi +8 -0
- data/sorbet/rbi/gems/parallel@1.21.0.rbi +113 -0
- data/sorbet/rbi/gems/parser@3.0.2.0.rbi +1189 -0
- data/sorbet/rbi/gems/pry-byebug@3.8.0.rbi +458 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +2486 -0
- data/sorbet/rbi/gems/rainbow@3.0.0.rbi +153 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +795 -0
- data/sorbet/rbi/gems/rb-fsevent@0.11.0.rbi +8 -0
- data/sorbet/rbi/gems/rb-inotify@0.10.1.rbi +8 -0
- data/sorbet/rbi/gems/rbi@0.0.6.rbi +1405 -0
- data/sorbet/rbi/gems/regexp_parser@2.1.1.rbi +1120 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +672 -0
- data/sorbet/rbi/gems/rspec-core@3.10.1.rbi +2455 -0
- data/sorbet/rbi/gems/rspec-expectations@3.10.1.rbi +1574 -0
- data/sorbet/rbi/gems/rspec-mocks@3.10.2.rbi +1462 -0
- data/sorbet/rbi/gems/rspec-support@3.10.2.rbi +509 -0
- data/sorbet/rbi/gems/rspec@3.10.0.rbi +38 -0
- data/sorbet/rbi/gems/rubocop-ast@1.12.0.rbi +1938 -0
- data/sorbet/rbi/gems/rubocop-rspec@2.5.0.rbi +1786 -0
- data/sorbet/rbi/gems/rubocop@1.22.1.rbi +13252 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +405 -0
- data/sorbet/rbi/gems/shellany@0.0.1.rbi +8 -0
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +89 -0
- data/sorbet/rbi/gems/simplecov@0.21.2.rbi +577 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.3.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.1.5.rbi +1241 -0
- data/sorbet/rbi/gems/stackprof@0.2.17.rbi +98 -0
- data/sorbet/rbi/gems/tapioca@0.5.2.rbi +949 -0
- data/sorbet/rbi/gems/thor@1.1.0.rbi +839 -0
- data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +26 -0
- data/sorbet/rbi/gems/unparser@0.6.0.rbi +8 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +72 -17
- data/.github/workflows/rspec.yml +0 -22
- data/.reek.yml +0 -32
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d35ae78f068312d7be093df0738b370c73b9a9e27e9949230a4fc0abc779c5b
|
4
|
+
data.tar.gz: 2b3d38f4de42ca8ec002160c646c1bf3906cda6066c1603fb7b6da00f30314e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74de415e920f3b98d82460ded292fb392219726e9abad758db444e3324784bbf8ea9d44efc728ef9ec4fd4f771246bf368de85ee956ad4e536b4727b897c30c5
|
7
|
+
data.tar.gz: 56544eab93fb2d158ecfa38111236517c50e70800ddfc694ae0c6b6a6ec0edb88dd3839a8f9987e8169485160db34933acca2ae93d5f540df0e53cbb66e09223
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
name: Continuous Integration
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches-ignore:
|
6
|
+
- refs/tags/*_staging
|
7
|
+
- refs/tags/*_production
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
runs-on: ubuntu-18.04
|
11
|
+
steps:
|
12
|
+
- name: Checkout branch
|
13
|
+
uses: actions/checkout@v2
|
14
|
+
- name: Extract branch name
|
15
|
+
shell: bash
|
16
|
+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
17
|
+
id: extract_branch
|
18
|
+
- name: Cache gems
|
19
|
+
uses: actions/cache@v2
|
20
|
+
with:
|
21
|
+
path: vendor/bundle
|
22
|
+
key: "${{ runner.OS }}-gem-cache-${{ hashFiles('**/*.gemspec')
|
23
|
+
}}"
|
24
|
+
restore-keys: "${{ runner.OS }}-gem-cache-\n"
|
25
|
+
- uses: "cachix/install-nix-action@8d6d5e949675fbadb765c6b1a975047fa5f09b27"
|
26
|
+
with:
|
27
|
+
extra_nix_config: |
|
28
|
+
post-build-hook = /etc/nix/upload-to-cache.sh
|
29
|
+
substituters = https://cache.nixos.org/
|
30
|
+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
|
31
|
+
nix_path: nixpkgs=channel:nixos-21.05
|
32
|
+
- name: Run CI through nix-shell
|
33
|
+
env:
|
34
|
+
GEMFURY_DEPLOY_TOKEN: ${{ secrets.GEMFURY_DEPLOY_TOKEN }}
|
35
|
+
run: nix-shell --run "chmod 755 ./run_ci.sh && ./run_ci.sh"
|
36
|
+
- name: Post to Slack if build fails
|
37
|
+
if: failure() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
|
38
|
+
|| github.ref == 'refs/heads/stable')
|
39
|
+
uses: pullreminders/slack-action@a5a262c896a1cc80dcbae59ba95513e2dfb21439
|
40
|
+
env:
|
41
|
+
SLACK_BOT_TOKEN: "${{ secrets.SLACK_BOT_TOKEN }}"
|
42
|
+
with:
|
43
|
+
args: '{\"channel\":\"C33574SJJ\",\"text\":\"* ${{ github.repository }} BUILD
|
44
|
+
FAILURE*\", \"attachments\": [{ \"fallback\": \"Failure summary\", \"color\":
|
45
|
+
\"#ff0000\", \"fields\": [{\"title\": \"Branch\", \"value\":\"${{ steps.extract_branch.outputs.branch
|
46
|
+
}}\"}, {\"title\": \"Who broke it\", \"value\":\"${{ github.actor }}\"},
|
47
|
+
{ \"title\": \"Build output\", \"value\": \"https://github.com/${{ github.repository
|
48
|
+
}}/commit/${{ github.sha }}/checks\", \"short\": false }]}]}'
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
1.8.1
|
2
|
+
|
3
|
+
* [BUGFIX] Fix processing T.let type mismatch messages when there are digits in module name
|
4
|
+
|
5
|
+
1.8.0
|
6
|
+
|
7
|
+
* Fixed issues around union types referencing typed enumerables.
|
8
|
+
|
9
|
+
1.7.0
|
10
|
+
|
11
|
+
* Added support `T.class_of`.
|
12
|
+
|
13
|
+
1.6.0
|
14
|
+
|
15
|
+
* Non-verifying double support improved.
|
16
|
+
|
1
17
|
1.5.0
|
2
18
|
|
3
19
|
* Added support for `T.cast`.
|
data/Gemfile
CHANGED
@@ -8,15 +8,11 @@ group :development, :test do
|
|
8
8
|
gem 'guard-rspec'
|
9
9
|
gem 'pry-byebug'
|
10
10
|
gem 'rb-fsevent', require: false
|
11
|
-
gem 'rb-readline'
|
12
|
-
gem 'reek'
|
13
11
|
gem 'rspec'
|
14
12
|
gem 'rubocop-rspec'
|
15
13
|
gem 'rubocop'
|
16
|
-
gem 'shoulda-matchers', require: false
|
17
|
-
gem 'sqlite3'
|
18
14
|
gem 'stackprof'
|
19
|
-
gem '
|
15
|
+
gem 'tapioca'
|
20
16
|
end
|
21
17
|
|
22
18
|
group :test do
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
![rspec-sorbet](https://user-images.githubusercontent.com/2643026/63100456-02c12c00-bf6f-11e9-8430-630a27bc6e42.png)
|
2
2
|
|
3
|
-
# RSpec Sorbet [![Gem Version](https://badge.fury.io/rb/rspec-sorbet.svg)](https://badge.fury.io/rb/rspec-sorbet) ![CI Badge](https://github.com/tricycle/rspec-sorbet/workflows/
|
3
|
+
# RSpec Sorbet [![Gem Version](https://badge.fury.io/rb/rspec-sorbet.svg)](https://badge.fury.io/rb/rspec-sorbet) ![CI Badge](https://github.com/tricycle/rspec-sorbet/workflows/Continuous%20Integration/badge.svg)
|
4
4
|
|
5
5
|
A small gem consisting of helpers for using Sorbet & RSpec together.
|
6
6
|
|
@@ -30,3 +30,7 @@ Drop the following into your `spec_helper.rb` to allow doubles to be used withou
|
|
30
30
|
```ruby
|
31
31
|
RSpec::Sorbet.allow_doubles!
|
32
32
|
```
|
33
|
+
|
34
|
+
### `eq` matcher usage with `T::Struct`'s
|
35
|
+
|
36
|
+
Using the [`eq` matcher](https://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FMatchers:eq) to compare [`T::Struct`'s](https://sorbet.org/docs/tstruct) might not behave as you'd expect whereby two separate instances of the same struct class with identical attributes are not `==` out of the box. The standalone [sorbet-struct-comparable](https://github.com/tricycle/sorbet-struct-comparable) gem may be of interest if you are looking for a simple attribute based comparison that will help make the `eq` matcher behave as you expect.
|
data/bin/tapioca
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'tapioca' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("tapioca", "tapioca")
|
data/generate_require_files.rb
CHANGED
data/lib/rspec/all.rb
CHANGED
data/lib/rspec/sorbet/all.rb
CHANGED
data/lib/rspec/sorbet/doubles.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'sorbet-runtime'
|
@@ -20,34 +21,49 @@ module RSpec
|
|
20
21
|
private
|
21
22
|
|
22
23
|
INLINE_DOUBLE_REGEX =
|
23
|
-
/T.(let|cast): Expected type (T.(any|nilable)\()?(?<
|
24
|
+
/T.(?:let|cast): Expected type (?:T.(?<t_method>any|nilable|class_of)\()?(?<expected_types>[a-zA-Z0-9:: ,]*)(\))?, got (?:type .* with value )?#<(?<double_type>Instance|Class|Object)?Double([\(]|[ ])(?<doubled_type>[a-zA-Z0-9:: ,]*)(\))?/.freeze
|
24
25
|
|
25
26
|
def inline_type_error_handler(error)
|
26
27
|
case error
|
27
28
|
when TypeError
|
28
29
|
message = error.message
|
29
|
-
return if
|
30
|
+
return if unable_to_check_type_for_message?(message)
|
30
31
|
|
31
|
-
|
32
|
-
raise error unless expected_types_string && doubled_module_string
|
32
|
+
raise error unless (match = message.match(INLINE_DOUBLE_REGEX))
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
t_method = match[:t_method]
|
35
|
+
expected_types = match[:expected_types].split(',').map do |expected_type|
|
36
|
+
Object.const_get(expected_type.strip)
|
36
37
|
end
|
37
|
-
|
38
|
+
double_type = match[:double_type]
|
39
|
+
return if double_type.nil?
|
40
|
+
doubled_type = Object.const_get(match[:doubled_type])
|
38
41
|
|
39
|
-
|
40
|
-
|
42
|
+
if double_type == 'Class'
|
43
|
+
raise error if t_method != 'class_of'
|
44
|
+
|
45
|
+
valid = expected_types.any? do |expected_type|
|
46
|
+
doubled_type <= expected_type
|
47
|
+
end
|
48
|
+
raise error unless valid
|
41
49
|
end
|
42
50
|
|
51
|
+
valid = expected_types.any? do |expected_type|
|
52
|
+
doubled_type.ancestors.include?(expected_type)
|
53
|
+
end
|
43
54
|
raise error unless valid
|
44
55
|
else
|
45
56
|
raise error
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
60
|
+
def unable_to_check_type_for_message?(message)
|
61
|
+
double_message_with_ellipsis?(message) ||
|
62
|
+
typed_array_message?(message)
|
63
|
+
end
|
64
|
+
|
49
65
|
VERIFYING_DOUBLE_OR_DOUBLE =
|
50
|
-
/(RSpec::Mocks::(Instance|Class|Object)VerifyingDouble|(Instance|Class|Object)Double)/.freeze
|
66
|
+
/(RSpec::Mocks::(Instance|Class|Object)VerifyingDouble|(Instance|Class|Object)?Double)/.freeze
|
51
67
|
|
52
68
|
def double_message_with_ellipsis?(message)
|
53
69
|
message.include?('...') && message.match?(VERIFYING_DOUBLE_OR_DOUBLE)
|
@@ -66,7 +82,9 @@ module RSpec
|
|
66
82
|
if message.match?(VERIFYING_DOUBLE_OR_DOUBLE)
|
67
83
|
typing = opts[:type]
|
68
84
|
value = opts[:value].is_a?(Array) ? opts[:value].first : opts[:value]
|
69
|
-
target = value.instance_variable_get(:@doubled_module)
|
85
|
+
target = value.instance_variable_get(:@doubled_module)&.target
|
86
|
+
|
87
|
+
return if target.nil?
|
70
88
|
|
71
89
|
case typing
|
72
90
|
when T::Types::TypedArray, T::Types::TypedEnumerable
|
@@ -74,11 +92,15 @@ module RSpec
|
|
74
92
|
end
|
75
93
|
|
76
94
|
case typing
|
95
|
+
when T::Types::ClassOf
|
96
|
+
should_raise = !(target <= typing.type)
|
77
97
|
when T::Types::Simple
|
78
98
|
should_raise = !target.ancestors.include?(typing.raw_type)
|
79
99
|
when T::Types::Union
|
80
|
-
valid = typing.types.
|
81
|
-
|
100
|
+
valid = typing.types.any? do |type|
|
101
|
+
next false unless type.respond_to?(:raw_type)
|
102
|
+
|
103
|
+
target.ancestors.include?(type.raw_type)
|
82
104
|
end
|
83
105
|
should_raise = !valid
|
84
106
|
else
|
data/lib/rspec/sorbet/version.rb
CHANGED
data/lib/rspec/sorbet.rb
CHANGED
data/nix/sources.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"nixpkgs": {
|
3
|
+
"branch": "nixos-21.05",
|
4
|
+
"description": "Nix packages collection",
|
5
|
+
"homepage": "https://github.com/NixOS/nixpkgs",
|
6
|
+
"owner": "NixOS",
|
7
|
+
"repo": "nixpkgs",
|
8
|
+
"rev": "e85f0175e3effe9ba191d66c09e8f1b7d6362d5e",
|
9
|
+
"sha256": "1qr2hmymbzwj8jrz6smcgc04scgwp2v5070x22k4fvh261g1n4zw",
|
10
|
+
"type": "tarball",
|
11
|
+
"url": "https://github.com/NixOS/nixpkgs/archive/e85f0175e3effe9ba191d66c09e8f1b7d6362d5e.tar.gz",
|
12
|
+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
13
|
+
}
|
14
|
+
}
|
data/nix/sources.nix
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# This file has been generated by Niv.
|
2
|
+
|
3
|
+
let
|
4
|
+
|
5
|
+
#
|
6
|
+
# The fetchers. fetch_<type> fetches specs of type <type>.
|
7
|
+
#
|
8
|
+
|
9
|
+
fetch_file = pkgs: name: spec:
|
10
|
+
let
|
11
|
+
name' = sanitizeName name + "-src";
|
12
|
+
in
|
13
|
+
if spec.builtin or true then
|
14
|
+
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
15
|
+
else
|
16
|
+
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
17
|
+
|
18
|
+
fetch_tarball = pkgs: name: spec:
|
19
|
+
let
|
20
|
+
name' = sanitizeName name + "-src";
|
21
|
+
in
|
22
|
+
if spec.builtin or true then
|
23
|
+
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
24
|
+
else
|
25
|
+
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
26
|
+
|
27
|
+
fetch_git = name: spec:
|
28
|
+
let
|
29
|
+
ref =
|
30
|
+
if spec ? ref then spec.ref else
|
31
|
+
if spec ? branch then "refs/heads/${spec.branch}" else
|
32
|
+
if spec ? tag then "refs/tags/${spec.tag}" else
|
33
|
+
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
34
|
+
in
|
35
|
+
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
36
|
+
|
37
|
+
fetch_local = spec: spec.path;
|
38
|
+
|
39
|
+
fetch_builtin-tarball = name: throw
|
40
|
+
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
41
|
+
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
42
|
+
|
43
|
+
fetch_builtin-url = name: throw
|
44
|
+
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
45
|
+
$ niv modify ${name} -a type=file -a builtin=true'';
|
46
|
+
|
47
|
+
#
|
48
|
+
# Various helpers
|
49
|
+
#
|
50
|
+
|
51
|
+
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
52
|
+
sanitizeName = name:
|
53
|
+
(
|
54
|
+
concatMapStrings (s: if builtins.isList s then "-" else s)
|
55
|
+
(
|
56
|
+
builtins.split "[^[:alnum:]+._?=-]+"
|
57
|
+
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
58
|
+
)
|
59
|
+
);
|
60
|
+
|
61
|
+
# The set of packages used when specs are fetched using non-builtins.
|
62
|
+
mkPkgs = sources: system:
|
63
|
+
let
|
64
|
+
sourcesNixpkgs =
|
65
|
+
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
66
|
+
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
67
|
+
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
68
|
+
in
|
69
|
+
if builtins.hasAttr "nixpkgs" sources
|
70
|
+
then sourcesNixpkgs
|
71
|
+
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
72
|
+
import <nixpkgs> {}
|
73
|
+
else
|
74
|
+
abort
|
75
|
+
''
|
76
|
+
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
77
|
+
add a package called "nixpkgs" to your sources.json.
|
78
|
+
'';
|
79
|
+
|
80
|
+
# The actual fetching function.
|
81
|
+
fetch = pkgs: name: spec:
|
82
|
+
|
83
|
+
if ! builtins.hasAttr "type" spec then
|
84
|
+
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
85
|
+
else if spec.type == "file" then fetch_file pkgs name spec
|
86
|
+
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
87
|
+
else if spec.type == "git" then fetch_git name spec
|
88
|
+
else if spec.type == "local" then fetch_local spec
|
89
|
+
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
90
|
+
else if spec.type == "builtin-url" then fetch_builtin-url name
|
91
|
+
else
|
92
|
+
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
93
|
+
|
94
|
+
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
95
|
+
# the path directly as opposed to the fetched source.
|
96
|
+
replace = name: drv:
|
97
|
+
let
|
98
|
+
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
99
|
+
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
100
|
+
in
|
101
|
+
if ersatz == "" then drv else
|
102
|
+
# this turns the string into an actual Nix path (for both absolute and
|
103
|
+
# relative paths)
|
104
|
+
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
105
|
+
|
106
|
+
# Ports of functions for older nix versions
|
107
|
+
|
108
|
+
# a Nix version of mapAttrs if the built-in doesn't exist
|
109
|
+
mapAttrs = builtins.mapAttrs or (
|
110
|
+
f: set: with builtins;
|
111
|
+
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
112
|
+
);
|
113
|
+
|
114
|
+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
115
|
+
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
116
|
+
|
117
|
+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
118
|
+
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
119
|
+
|
120
|
+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
121
|
+
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
122
|
+
concatMapStrings = f: list: concatStrings (map f list);
|
123
|
+
concatStrings = builtins.concatStringsSep "";
|
124
|
+
|
125
|
+
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
126
|
+
optionalAttrs = cond: as: if cond then as else {};
|
127
|
+
|
128
|
+
# fetchTarball version that is compatible between all the versions of Nix
|
129
|
+
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
130
|
+
let
|
131
|
+
inherit (builtins) lessThan nixVersion fetchTarball;
|
132
|
+
in
|
133
|
+
if lessThan nixVersion "1.12" then
|
134
|
+
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
135
|
+
else
|
136
|
+
fetchTarball attrs;
|
137
|
+
|
138
|
+
# fetchurl version that is compatible between all the versions of Nix
|
139
|
+
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
140
|
+
let
|
141
|
+
inherit (builtins) lessThan nixVersion fetchurl;
|
142
|
+
in
|
143
|
+
if lessThan nixVersion "1.12" then
|
144
|
+
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
145
|
+
else
|
146
|
+
fetchurl attrs;
|
147
|
+
|
148
|
+
# Create the final "sources" from the config
|
149
|
+
mkSources = config:
|
150
|
+
mapAttrs (
|
151
|
+
name: spec:
|
152
|
+
if builtins.hasAttr "outPath" spec
|
153
|
+
then abort
|
154
|
+
"The values in sources.json should not have an 'outPath' attribute"
|
155
|
+
else
|
156
|
+
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
157
|
+
) config.sources;
|
158
|
+
|
159
|
+
# The "config" used by the fetchers
|
160
|
+
mkConfig =
|
161
|
+
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
162
|
+
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
163
|
+
, system ? builtins.currentSystem
|
164
|
+
, pkgs ? mkPkgs sources system
|
165
|
+
}: rec {
|
166
|
+
# The sources, i.e. the attribute set of spec name to spec
|
167
|
+
inherit sources;
|
168
|
+
|
169
|
+
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
170
|
+
inherit pkgs;
|
171
|
+
};
|
172
|
+
|
173
|
+
in
|
174
|
+
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
data/rspec-sorbet.gemspec
CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler'
|
29
29
|
spec.add_development_dependency 'pry'
|
30
|
-
spec.add_development_dependency 'rake', '
|
31
|
-
spec.add_development_dependency 'rspec', '
|
30
|
+
spec.add_development_dependency 'rake', '>= 13.0'
|
31
|
+
spec.add_development_dependency 'rspec', '>= 3.0'
|
32
32
|
end
|
data/run_ci.sh
ADDED
data/shell.nix
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{ sources ? import ./nix/sources.nix }:
|
2
|
+
let
|
3
|
+
nixpkgs = import sources.nixpkgs { };
|
4
|
+
in
|
5
|
+
nixpkgs.mkShell {
|
6
|
+
name = "bellroy-gem-env";
|
7
|
+
buildInputs = with nixpkgs; [
|
8
|
+
bundler
|
9
|
+
libnotify
|
10
|
+
niv
|
11
|
+
pkg-config
|
12
|
+
readline
|
13
|
+
ruby_2_7
|
14
|
+
zlib
|
15
|
+
]
|
16
|
+
++ (if stdenv.hostPlatform.isDarwin then [ libiconv darwin.apple_sdk.frameworks.CoreServices ] else [ ]);
|
17
|
+
shellHook = ''
|
18
|
+
bundle config --local path "$PWD/vendor/bundle"
|
19
|
+
'';
|
20
|
+
}
|
data/sorbet/config
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# DO NOT EDIT MANUALLY
|
2
|
+
# This is an autogenerated file for types exported from the `ast` gem.
|
3
|
+
# Please instead update this file by running `bin/tapioca gem ast`.
|
4
|
+
|
5
|
+
# typed: true
|
6
|
+
|
7
|
+
module AST; end
|
8
|
+
|
9
|
+
class AST::Node
|
10
|
+
def initialize(type, children = T.unsafe(nil), properties = T.unsafe(nil)); end
|
11
|
+
|
12
|
+
def +(array); end
|
13
|
+
def <<(element); end
|
14
|
+
def ==(other); end
|
15
|
+
def append(element); end
|
16
|
+
def children; end
|
17
|
+
def clone; end
|
18
|
+
def concat(array); end
|
19
|
+
def deconstruct; end
|
20
|
+
def dup; end
|
21
|
+
def eql?(other); end
|
22
|
+
def hash; end
|
23
|
+
def inspect(indent = T.unsafe(nil)); end
|
24
|
+
def to_a; end
|
25
|
+
def to_ast; end
|
26
|
+
def to_s(indent = T.unsafe(nil)); end
|
27
|
+
def to_sexp(indent = T.unsafe(nil)); end
|
28
|
+
def to_sexp_array; end
|
29
|
+
def type; end
|
30
|
+
def updated(type = T.unsafe(nil), children = T.unsafe(nil), properties = T.unsafe(nil)); end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def assign_properties(properties); end
|
35
|
+
def fancy_type; end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def original_dup; end
|
40
|
+
end
|
41
|
+
|
42
|
+
class AST::Processor
|
43
|
+
include ::AST::Processor::Mixin
|
44
|
+
end
|
45
|
+
|
46
|
+
module AST::Processor::Mixin
|
47
|
+
def handler_missing(node); end
|
48
|
+
def process(node); end
|
49
|
+
def process_all(nodes); end
|
50
|
+
end
|
51
|
+
|
52
|
+
module AST::Sexp
|
53
|
+
def s(type, *children); end
|
54
|
+
end
|