sord 0.3.0 → 0.4.1

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: 48989b3587651b3576af45f8ba0664eb5e49696e6c8e9e18deb2bce33d78651e
4
- data.tar.gz: 2b0f10c99524c00ebe89d76eecab495bd38c55dc5a84a0e707b888030a07caf9
3
+ metadata.gz: cf3418f5f5f96e17c76ee48515382ac008d975ed200eae3f837f9e136077a7f3
4
+ data.tar.gz: 2592ad90c6b6c17ec9a9c550d348a3989b4511a51b2b115643dafa05b41e9191
5
5
  SHA512:
6
- metadata.gz: 6350ec6144be3d60d8056c0d25af71ad17c0960a1931e30cedb12fb1820461ed922fbad188b7ad6f8a3009a804311e6b2f63aae6bd938b7f036cfb00441db9ba
7
- data.tar.gz: 2fffdecb428ab937948eebefa56aac39da39d4b1972ddc98d8d7d2d4ef37ee3f1fedecaa95146286d53707d8b8ccc16fa30d2aec9dcbe4eeb39369f2b4f4280c
6
+ metadata.gz: 4db0db07817d59efdceb9455cbf3613d4d6031d635fc40ad6dd310ad0828a6b8a6be35c6cd7e9cfa11d3cb7ab23496c851686027a82f5e6f55c034420a9c98a2
7
+ data.tar.gz: b00f3f123af693111782b734ce72d00930613408f113197bcddd182c6b36308b8f6b9e7d3cc2e0bc7a7ed15bb666aec93a9da7d2e7f9595e601ff51b7e16866a
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in sord.gemspec
4
4
  gemspec
5
+
6
+ gem "commander", "~> 4.4"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sord (0.2.1)
4
+ sord (0.3.0)
5
5
  colorize
6
6
  sorbet-runtime
7
7
  yard
@@ -10,8 +10,11 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  colorize (0.8.1)
13
+ commander (4.4.7)
14
+ highline (~> 2.0.0)
13
15
  diff-lcs (1.3)
14
16
  docile (1.3.2)
17
+ highline (2.0.2)
15
18
  json (2.2.0)
16
19
  rake (10.5.0)
17
20
  rspec (3.8.0)
@@ -34,7 +37,7 @@ GEM
34
37
  simplecov-html (0.10.2)
35
38
  sorbet (0.4.4254)
36
39
  sorbet-static (= 0.4.4254)
37
- sorbet-runtime (0.4.4254)
40
+ sorbet-runtime (0.4.4293)
38
41
  sorbet-static (0.4.4254-x86_64-linux)
39
42
  yard (0.9.19)
40
43
 
@@ -43,6 +46,7 @@ PLATFORMS
43
46
 
44
47
  DEPENDENCIES
45
48
  bundler (~> 2.0)
49
+ commander (~> 4.4)
46
50
  rake (~> 10.0)
47
51
  rspec (~> 3.0)
48
52
  simplecov
data/exe/sord CHANGED
@@ -1,4 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'sord'
3
+ require 'commander/import'
3
4
 
4
- Sord::RbiGenerator.new.run($*[0])
5
+ program :name, 'sord'
6
+ program :version, Sord::VERSION
7
+ program :description, 'Generate Sorbet RBIs from YARD documentation'
8
+
9
+ default_command :gen
10
+ command :gen do |c|
11
+ c.syntax = 'sord gen <output-file> [options]'
12
+ c.description = 'Generates an RBI file from this directory\'s YARD docs'
13
+ c.option '--[no-]comments', 'Disables informational/warning comments in the RBI file'
14
+
15
+ c.action do |args, options|
16
+ options.default comments: true
17
+
18
+ if args.length != 1
19
+ Sord::Logging.error('Must specify filename')
20
+ exit 1
21
+ end
22
+
23
+ Sord::RbiGenerator.new(options).run(args.first)
24
+ end
25
+ end
@@ -15,15 +15,16 @@ module Sord
15
15
  attr_reader :object_count
16
16
 
17
17
  # Create a new RBI generator.
18
+ # @param [Hash] options
18
19
  # @return [RbiGenerator]
19
- def initialize
20
+ def initialize(options)
20
21
  @rbi_contents = ['# typed: strong']
21
22
  @object_count = 0
22
23
 
23
24
  # Hook the logger so that messages are added as comments to the RBI file
24
25
  Logging.add_hook do |type, msg, item|
25
26
  rbi_contents << " # sord #{type} - #{msg}"
26
- end
27
+ end if options.comments
27
28
  end
28
29
 
29
30
  # Increment the object counter.
@@ -84,6 +85,9 @@ module Sord
84
85
  elsif name.start_with? '*'
85
86
  # TODO: is there a YARD definition for this?
86
87
  "args: T::Array[T.any]"
88
+ elsif name.start_with? '&'
89
+ # Cut the ampersand from the block parameter name.
90
+ "#{name[1..-1]}: T.untyped"
87
91
  elsif meth.path.end_with? '='
88
92
  # Look for the matching getter method
89
93
  getter_path = meth.path[0...-1]
@@ -131,6 +135,8 @@ module Sord
131
135
  # @param [String] filename
132
136
  # @return [void]
133
137
  def run(filename)
138
+ raise "No filename specified" unless filename
139
+
134
140
  # Get YARD ready
135
141
  YARD::Registry.load!
136
142
 
@@ -158,7 +164,6 @@ module Sord
158
164
  end
159
165
 
160
166
  # Write the file
161
- raise "no filename specified" unless filename
162
167
  File.write(filename, rbi_contents.join(?\n))
163
168
 
164
169
  Logging.done("Processed #{object_count} objects")
data/lib/sord/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # typed: strong
2
2
  module Sord
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Christiansen