Skip to content

Commit 296bc9c

Browse files
author
Mattia Roccoberton
committed
feat: RBS support
1 parent 36bb4b9 commit 296bc9c

37 files changed

+509
-1
lines changed

.github/workflows/specs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ jobs:
3232
run: cd spec/dummy_rails && bundle exec rails db:migrate
3333

3434
- name: Run tests
35-
run: bundle exec rspec --profile
35+
env:
36+
RUBYOPT: '-rbundler/setup -rrbs/test/setup'
37+
RBS_TEST_TARGET: 'TinyAdmin::*'
38+
run: bin/rspec --profile

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ group :development, :test do
1313
gem 'warden'
1414
gem 'webrick'
1515

16+
gem 'rbs'
17+
1618
# Testing
1719
gem 'capybara'
1820
gem 'capybara-screenshot'

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
lint:
2+
bin/rubocop
3+
4+
test:
5+
bin/rspec
6+
7+
test_rbs:
8+
RUBYOPT='-rbundler/setup -rrbs/test/setup' RBS_TEST_TARGET='TinyAdmin::*' bin/rspec

bin/rbs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rbs' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12+
13+
bundle_binstub = File.expand_path("bundle", __dir__)
14+
15+
if File.file?(bundle_binstub)
16+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
17+
load(bundle_binstub)
18+
else
19+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
end
22+
end
23+
24+
require "rubygems"
25+
require "bundler/setup"
26+
27+
load Gem.bin_path("rbs", "rbs")

sig/tiny_admin.rbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module TinyAdmin
2+
VERSION: String
3+
4+
def configure: () { (Settings) -> untyped } -> untyped
5+
6+
def configure_from_file: (String) -> void
7+
8+
def route_for: (String, reference: String?, action: String?, query: String?) -> String
9+
10+
def settings: -> Settings
11+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module TinyAdmin
2+
module Actions
3+
class BasicAction
4+
def attribute_options: (Array[untyped]?) -> Hash[untyped, untyped]?
5+
end
6+
end
7+
end

sig/tiny_admin/actions/index.rbs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module TinyAdmin
2+
module Actions
3+
class Index
4+
attr_reader context: untyped
5+
attr_reader current_page: Integer
6+
attr_reader fields_options: untyped
7+
attr_reader links: untyped
8+
attr_reader options: untyped
9+
attr_reader pagination: Integer
10+
attr_reader pages: untyped
11+
attr_reader params: untyped
12+
attr_reader query_string: String
13+
attr_reader repository: untyped
14+
15+
def call: (app: BasicApp, context: Context, options: Hash[Symbol, untyped]) -> void
16+
17+
private
18+
19+
def evaluate_options: (Hash[Symbol, untyped]) -> void
20+
21+
def prepare_filters: (Hash[untyped, untyped]) -> void
22+
23+
def setup_pagination: (untyped, untyped, total_count: Integer) -> void
24+
end
25+
end
26+
end

sig/tiny_admin/actions/show.rbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module TinyAdmin
2+
module Actions
3+
class Show
4+
def call: (app: BasicApp, context: Context, options: Hash[Symbol, untyped]) -> void
5+
end
6+
end
7+
end

sig/tiny_admin/authentication.rbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module TinyAdmin
2+
class Authentication
3+
private
4+
5+
def render_login: (?notices: Array[String]?, ?warnings: Array[String]?, ?errors: Array[String]?) -> void
6+
end
7+
end

sig/tiny_admin/basic_app.rbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module TinyAdmin
2+
class BasicApp
3+
def self.authentication_plugin: () -> void
4+
end
5+
end

0 commit comments

Comments
 (0)