sord 0.5.0 → 0.6.0
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/README.md +0 -13
- data/lib/sord/logging.rb +2 -2
- data/lib/sord/rbi_generator.rb +24 -20
- data/lib/sord/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de7160886a2e2fd6df02d245102315d772029a951075d885a88ac253ed1ea0a
|
4
|
+
data.tar.gz: a14f5c19796cfd9033111c76ef144541a3dd9304d1421341fcb3fb9e9f1e65f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec7636f302c059c5a1fe826cfa077c786410b1d3378783feac63ce77a7600df516fc1f1794f869996d0aa64f13de2a42eceda806d7378efece157c0254a58a6
|
7
|
+
data.tar.gz: 208a0d864121ca13eeeb2c5713cd98768e4710dc9cf2bdacb9fd13471e97e2dc580f9b31530dee847b4de8e9d62072f1a1cef640c4f768f4537754058ad253c3
|
data/README.md
CHANGED
@@ -111,19 +111,6 @@ The general rule of thumb for type conversions is:
|
|
111
111
|
You should search through your resulting RBI to find and fix and
|
112
112
|
`SORD_ERROR`s.
|
113
113
|
|
114
|
-
## Things to work on
|
115
|
-
|
116
|
-
- No support whatsoever for blocks (they appear to cause syntax errors in RBI
|
117
|
-
currently)
|
118
|
-
- I'm not 100% sure how this handles undocumented methods and classes.
|
119
|
-
- More inference systems would be nice.
|
120
|
-
- This won't generate type parameter definitions for things which mix-in
|
121
|
-
`Enumerable`.
|
122
|
-
- Module scoping is an issue - if `Example::Person` is replaced with `Person`
|
123
|
-
in the YARD comments in the above example, Sorbet won't be able to resolve
|
124
|
-
it. _This can be solved by making definitions syntactically heirarchical._
|
125
|
-
- Tests!!
|
126
|
-
|
127
114
|
## Contributing
|
128
115
|
|
129
116
|
Bug reports and pull requests are welcome on GitHub at https://github.com/AaronC81/sord. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/sord/logging.rb
CHANGED
@@ -61,7 +61,7 @@ module Sord
|
|
61
61
|
# is associated with, if any. This is shown before the log message if it is
|
62
62
|
# specified.
|
63
63
|
def self.duck(msg, item=nil)
|
64
|
-
generic(:
|
64
|
+
generic(:duck, '[DUCK ]'.cyan, msg, item)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Print an error message. This should be used for things which require the
|
@@ -128,4 +128,4 @@ module Sord
|
|
128
128
|
@@hooks << blk
|
129
129
|
end
|
130
130
|
end
|
131
|
-
end
|
131
|
+
end
|
data/lib/sord/rbi_generator.rb
CHANGED
@@ -132,6 +132,26 @@ module Sord
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
# Given a YARD NamespaceObject, add lines defining its mixins, methods
|
136
|
+
# and children to the RBI file.
|
137
|
+
# @param [YARD::CodeObjects::NamespaceObject] item
|
138
|
+
def add_namespace(item)
|
139
|
+
count_object
|
140
|
+
|
141
|
+
if item.type == :class && item.superclass.to_s != "Object"
|
142
|
+
rbi_contents << "class #{item.name} < #{item.superclass.path}"
|
143
|
+
else
|
144
|
+
rbi_contents << "#{item.type} #{item.name}"
|
145
|
+
end
|
146
|
+
add_mixins(item)
|
147
|
+
add_methods(item)
|
148
|
+
|
149
|
+
item.children.select { |x| [:class, :module].include?(x.type) }
|
150
|
+
.each { |child| add_namespace(child) }
|
151
|
+
|
152
|
+
rbi_contents << "end"
|
153
|
+
end
|
154
|
+
|
135
155
|
# Generates the RBI file and writes it to the given file path.
|
136
156
|
# @param [String] filename
|
137
157
|
# @return [void]
|
@@ -143,26 +163,10 @@ module Sord
|
|
143
163
|
|
144
164
|
# TODO: constants?
|
145
165
|
|
146
|
-
#
|
147
|
-
YARD::Registry.
|
148
|
-
|
149
|
-
|
150
|
-
rbi_contents << "module #{item.path}"
|
151
|
-
add_mixins(item)
|
152
|
-
add_methods(item)
|
153
|
-
rbi_contents << "end"
|
154
|
-
end
|
155
|
-
|
156
|
-
# Now populate with classes
|
157
|
-
YARD::Registry.all(:class).each do |item|
|
158
|
-
count_object
|
159
|
-
|
160
|
-
superclass = (item.superclass if item.superclass.to_s != "Object")
|
161
|
-
rbi_contents << "class #{item.path} #{"< #{superclass}" if superclass}"
|
162
|
-
add_mixins(item)
|
163
|
-
add_methods(item)
|
164
|
-
rbi_contents << "end"
|
165
|
-
end
|
166
|
+
# Generate top-level modules, which recurses to all modules
|
167
|
+
YARD::Registry.root.children
|
168
|
+
.select { |x| [:class, :module].include?(x.type) }
|
169
|
+
.each { |child| add_namespace(child) }
|
166
170
|
|
167
171
|
# Write the file
|
168
172
|
File.write(filename, rbi_contents.join(?\n))
|
data/lib/sord/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Christiansen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|