Class: Steep::CLI::SignatureOptions
- Inherits:
-
Object
- Object
- Steep::CLI::SignatureOptions
show all
- Defined in:
- lib/steep/cli.rb
Defined Under Namespace
Classes: MissingGemError, NoTypeDefinitionFromGemError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SignatureOptions.
31
32
33
|
# File 'lib/steep/cli.rb', line 31
def initialize
@options = []
end
|
Instance Attribute Details
#no_builtin ⇒ Object
Returns the value of attribute no_builtin.
28
29
30
|
# File 'lib/steep/cli.rb', line 28
def no_builtin
@no_builtin
end
|
#no_bundler ⇒ Object
Returns the value of attribute no_bundler.
29
30
31
|
# File 'lib/steep/cli.rb', line 29
def no_bundler
@no_bundler
end
|
Instance Method Details
#<<(option) ⇒ Object
43
44
45
|
# File 'lib/steep/cli.rb', line 43
def <<(option)
@options << option
end
|
#add_bundler_gems(options) ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'lib/steep/cli.rb', line 81
def add_bundler_gems(options)
if defined?(Bundler)
Steep.logger.info "Bundler detected!"
Bundler.load.gems.each do |spec|
dirs = dirs_from_spec(spec)
options.unshift *dirs
end
end
end
|
#dirs_from_spec(spec) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/steep/cli.rb', line 63
def dirs_from_spec(spec)
type_dirs = spec.metadata["steep_types"].yield_self do |types|
case types
when nil
[]
when String
types.split(/:/).map do |type|
Pathname(type)
end
end
end
base_dir = Pathname(spec.gem_dir)
type_dirs.map do |dir|
base_dir + dir
end.select(&:directory?)
end
|
#find_gem_dir(gem) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/steep/cli.rb', line 47
def find_gem_dir(gem)
name, version = gem.split(/:/)
spec =
begin
Gem::Specification.find_by_name(name, version)
rescue Gem::MissingSpecError
raise MissingGemError.new(name: name, version: version)
end
dirs_from_spec(spec).tap do |dirs|
if dirs.empty?
raise NoTypeDefinitionFromGemError.new(gemspec: spec)
end
end
end
|
#no_builtin! ⇒ Object
35
36
37
|
# File 'lib/steep/cli.rb', line 35
def no_builtin!
@no_builtin = true
end
|
#no_bundler! ⇒ Object
39
40
41
|
# File 'lib/steep/cli.rb', line 39
def no_bundler!
@no_bundler = true
end
|
#paths ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/steep/cli.rb', line 91
def paths
options = if @options.none? {|option| option.is_a?(Pathname) } && Pathname("sig").directory?
@options + [Pathname("sig")]
else
@options
end
unless no_bundler
add_bundler_gems(options)
end
paths = options.flat_map do |option|
case option
when Pathname
[option]
when String
find_gem_dir(option)
end
end
unless no_builtin
paths.unshift BUILTIN_PATH
end
paths.reverse.uniq(&:realpath).reverse
end
|