rbs2ts 1.0.0.pre.alpha.2 → 1.0.0.pre.alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +18 -0
- data/.gitignore +1 -2
- data/Gemfile +2 -0
- data/README.md +16 -0
- data/lib/rbs2ts/cli.rb +4 -2
- data/lib/rbs2ts/converter/declarations.rb +1 -1
- data/lib/rbs2ts/converter/types.rb +15 -0
- data/lib/rbs2ts/version.rb +1 -1
- data/rbs2ts.gemspec +2 -17
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1b221a5b895071e46b77dcf36fd1df3e789b0af6f91cb78adbfef7aa633c1c
|
4
|
+
data.tar.gz: 1a452ee8992929e84d0cfde11006e1b9918a4dbfb5cd597506523d6491199c7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6242c6655d8ab4d43267c4fb4d7a99471d27047b5b1ea04025aada0066f272b61ffa353a06bcd238a11890d3a65ff5bf32cb6471543a00d5036b734e5b84cba
|
7
|
+
data.tar.gz: 9a9d8d78d4eadd2cd9999063d841d878259f5bc52ccfbb0ea02b4691ef0a3133d8c8ab4cb954767925d0564e0c930697b1cd0017a4d476704a8f08515933bfd1
|
@@ -0,0 +1,18 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:3
|
9
|
+
executor: ruby/default
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: Bundle Install
|
14
|
+
command: bundle -v
|
15
|
+
- ruby/bundle-install
|
16
|
+
- run:
|
17
|
+
name: RSpec
|
18
|
+
command: bundle exec rspec
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Rbs2ts
|
2
2
|
|
3
|
+
[](LINK)
|
4
|
+
|
3
5
|
Convert RBS to TypeScript type definition.
|
4
6
|
|
5
7
|
## Installation
|
@@ -13,3 +15,17 @@ gem install rbs2ts
|
|
13
15
|
```
|
14
16
|
rbs2ts convert type.rbs
|
15
17
|
```
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
## ToDo
|
22
|
+
|
23
|
+
- [x] Literal type
|
24
|
+
- [ ] Interface type
|
25
|
+
- [ ] Literal type
|
26
|
+
- [ ] Tuple Type
|
27
|
+
- [ ] Base Types
|
28
|
+
- [ ] Method Type (Argument Types and Return Types)
|
29
|
+
- [ ] Class declaration
|
30
|
+
- [ ] Module declaration
|
31
|
+
- [ ] Interface declaration
|
data/lib/rbs2ts/cli.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "rbs2ts/converter"
|
3
|
-
|
3
|
+
|
4
4
|
module Rbs2ts
|
5
5
|
class Cli < Thor
|
6
6
|
desc "convert rbs to ts", "convert rbs to ts"
|
7
7
|
def convert(path)
|
8
|
+
::RBS.logger_level = :error
|
9
|
+
|
8
10
|
loader = ::RBS::EnvironmentLoader.new(core_root: nil)
|
9
11
|
|
10
12
|
loader.add(path: Pathname(path))
|
11
13
|
|
12
14
|
env = ::RBS::Environment.from_loader(loader).resolve_type_names
|
13
15
|
|
14
|
-
Converter::Declarations::Declarations.new(env.declarations).to_ts
|
16
|
+
puts Converter::Declarations::Declarations.new(env.declarations).to_ts
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -73,6 +73,19 @@ module Rbs2ts
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
class Literal < ConverterBase
|
77
|
+
def to_ts
|
78
|
+
case type.literal
|
79
|
+
when ::String then
|
80
|
+
"\"#{type.literal}\""
|
81
|
+
when ::Integer, ::TrueClass, ::FalseClass then
|
82
|
+
"#{type.literal}"
|
83
|
+
else
|
84
|
+
'unknown'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
76
89
|
class Optional < ConverterBase
|
77
90
|
def to_ts
|
78
91
|
"#{Types::Resolver.to_ts(type.type)} | null | undefined"
|
@@ -169,6 +182,8 @@ module Rbs2ts
|
|
169
182
|
Types::BasesNil
|
170
183
|
when ::RBS::Types::ClassInstance then
|
171
184
|
Types::ClassInstance
|
185
|
+
when ::RBS::Types::Literal then
|
186
|
+
Types::Literal
|
172
187
|
when ::RBS::Types::Optional then
|
173
188
|
Types::Optional
|
174
189
|
when ::RBS::Types::Union then
|
data/lib/rbs2ts/version.rb
CHANGED
data/rbs2ts.gemspec
CHANGED
@@ -10,24 +10,9 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["mugi.uno@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = "Convert rbs to typescript"
|
13
|
-
spec.description = "Convert rbs to typescript"
|
14
13
|
spec.homepage = "https://github.com/mugi-uno/rbs2ts"
|
14
|
+
spec.license = "MIT"
|
15
15
|
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
|
21
|
-
# spec.metadata["homepage_uri"] = spec.homepage
|
22
|
-
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
23
|
-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
24
|
-
else
|
25
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
-
"public gem pushes."
|
27
|
-
end
|
28
|
-
|
29
|
-
# Specify which files should be added to the gem when it is released.
|
30
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
16
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
17
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
18
|
end
|
@@ -39,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
39
24
|
spec.add_dependency "thor"
|
40
25
|
spec.add_dependency "case_transform"
|
41
26
|
|
42
|
-
spec.add_development_dependency "bundler", "
|
27
|
+
spec.add_development_dependency "bundler", ">= 2.1.4"
|
43
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
44
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
45
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs2ts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.alpha.
|
4
|
+
version: 1.0.0.pre.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mugi-uno
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.1.4
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.1.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.0'
|
97
|
-
description:
|
97
|
+
description:
|
98
98
|
email:
|
99
99
|
- mugi.uno@gmail.com
|
100
100
|
executables:
|
@@ -102,6 +102,7 @@ executables:
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
+
- ".circleci/config.yml"
|
105
106
|
- ".gitignore"
|
106
107
|
- ".rspec"
|
107
108
|
- ".travis.yml"
|
@@ -120,7 +121,8 @@ files:
|
|
120
121
|
- lib/rbs2ts/version.rb
|
121
122
|
- rbs2ts.gemspec
|
122
123
|
homepage: https://github.com/mugi-uno/rbs2ts
|
123
|
-
licenses:
|
124
|
+
licenses:
|
125
|
+
- MIT
|
124
126
|
metadata: {}
|
125
127
|
post_install_message:
|
126
128
|
rdoc_options: []
|