solargraph 0.32.1 → 0.32.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +6 -0
  5. data/.travis.yml +25 -0
  6. data/EXAMPLES.md +76 -0
  7. data/Gemfile +3 -0
  8. data/LANGUAGE_SERVER.md +51 -0
  9. data/LICENSE +21 -0
  10. data/OVERVIEW.md +37 -0
  11. data/README.md +106 -0
  12. data/Rakefile +14 -0
  13. data/SERVER.md +95 -0
  14. data/bin/solargraph +0 -0
  15. data/bin/solargraph-runtime +5 -5
  16. data/lib/solargraph.rb +54 -54
  17. data/lib/solargraph/api_map.rb +659 -659
  18. data/lib/solargraph/api_map/cache.rb +49 -49
  19. data/lib/solargraph/api_map/source_to_yard.rb +67 -67
  20. data/lib/solargraph/api_map/store.rb +201 -201
  21. data/lib/solargraph/bundle.rb +24 -24
  22. data/lib/solargraph/complex_type.rb +150 -150
  23. data/lib/solargraph/complex_type/type_methods.rb +124 -124
  24. data/lib/solargraph/complex_type/unique_type.rb +44 -44
  25. data/lib/solargraph/core_fills.rb +37 -37
  26. data/lib/solargraph/diagnostics.rb +52 -52
  27. data/lib/solargraph/diagnostics/base.rb +20 -20
  28. data/lib/solargraph/diagnostics/require_not_found.rb +28 -28
  29. data/lib/solargraph/diagnostics/rubocop.rb +98 -98
  30. data/lib/solargraph/diagnostics/rubocop_helpers.rb +46 -46
  31. data/lib/solargraph/diagnostics/type_not_defined.rb +108 -108
  32. data/lib/solargraph/diagnostics/update_errors.rb +38 -38
  33. data/lib/solargraph/language_server/completion_item_kinds.rb +33 -33
  34. data/lib/solargraph/language_server/error_codes.rb +18 -18
  35. data/lib/solargraph/language_server/host.rb +684 -681
  36. data/lib/solargraph/language_server/host/cataloger.rb +54 -79
  37. data/lib/solargraph/language_server/host/diagnoser.rb +80 -80
  38. data/lib/solargraph/language_server/host/dispatch.rb +112 -113
  39. data/lib/solargraph/language_server/host/sources.rb +138 -138
  40. data/lib/solargraph/language_server/message.rb +90 -90
  41. data/lib/solargraph/language_server/message/base.rb +83 -83
  42. data/lib/solargraph/language_server/message/completion_item/resolve.rb +40 -40
  43. data/lib/solargraph/language_server/message/exit_notification.rb +11 -11
  44. data/lib/solargraph/language_server/message/extended.rb +19 -19
  45. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +86 -86
  46. data/lib/solargraph/language_server/message/extended/document.rb +18 -18
  47. data/lib/solargraph/language_server/message/extended/document_gems.rb +30 -30
  48. data/lib/solargraph/language_server/message/extended/environment.rb +20 -20
  49. data/lib/solargraph/language_server/message/extended/search.rb +18 -18
  50. data/lib/solargraph/language_server/message/initialize.rb +141 -141
  51. data/lib/solargraph/language_server/message/initialized.rb +23 -23
  52. data/lib/solargraph/language_server/message/shutdown.rb +11 -11
  53. data/lib/solargraph/language_server/message/text_document.rb +25 -25
  54. data/lib/solargraph/language_server/message/text_document/completion.rb +51 -51
  55. data/lib/solargraph/language_server/message/text_document/definition.rb +18 -18
  56. data/lib/solargraph/language_server/message/text_document/did_change.rb +13 -13
  57. data/lib/solargraph/language_server/message/text_document/document_symbol.rb +21 -21
  58. data/lib/solargraph/language_server/message/text_document/folding_range.rb +24 -24
  59. data/lib/solargraph/language_server/message/text_document/formatting.rb +50 -50
  60. data/lib/solargraph/language_server/message/text_document/hover.rb +31 -31
  61. data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +32 -32
  62. data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +9 -9
  63. data/lib/solargraph/language_server/message/text_document/references.rb +14 -14
  64. data/lib/solargraph/language_server/message/text_document/rename.rb +17 -17
  65. data/lib/solargraph/language_server/message/text_document/signature_help.rb +19 -19
  66. data/lib/solargraph/language_server/message/workspace.rb +12 -12
  67. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +29 -29
  68. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +29 -27
  69. data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +24 -24
  70. data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +21 -21
  71. data/lib/solargraph/language_server/request.rb +22 -22
  72. data/lib/solargraph/language_server/symbol_kinds.rb +34 -34
  73. data/lib/solargraph/language_server/transport.rb +11 -11
  74. data/lib/solargraph/language_server/transport/adapter.rb +60 -60
  75. data/lib/solargraph/language_server/transport/data_reader.rb +66 -66
  76. data/lib/solargraph/language_server/uri_helpers.rb +25 -25
  77. data/lib/solargraph/library.rb +421 -419
  78. data/lib/solargraph/live_map.rb +126 -126
  79. data/lib/solargraph/live_map/cache.rb +38 -38
  80. data/lib/solargraph/location.rb +31 -31
  81. data/lib/solargraph/logging.rb +25 -25
  82. data/lib/solargraph/page.rb +68 -68
  83. data/lib/solargraph/pin.rb +50 -50
  84. data/lib/solargraph/pin/attribute.rb +41 -41
  85. data/lib/solargraph/pin/base.rb +280 -280
  86. data/lib/solargraph/pin/base_method.rb +76 -76
  87. data/lib/solargraph/pin/base_variable.rb +72 -72
  88. data/lib/solargraph/pin/block.rb +32 -32
  89. data/lib/solargraph/pin/block_parameter.rb +103 -103
  90. data/lib/solargraph/pin/class_variable.rb +9 -9
  91. data/lib/solargraph/pin/constant.rb +30 -30
  92. data/lib/solargraph/pin/conversions.rb +79 -79
  93. data/lib/solargraph/pin/documenting.rb +41 -41
  94. data/lib/solargraph/pin/duck_method.rb +14 -14
  95. data/lib/solargraph/pin/global_variable.rb +9 -9
  96. data/lib/solargraph/pin/instance_variable.rb +9 -9
  97. data/lib/solargraph/pin/keyword.rb +17 -17
  98. data/lib/solargraph/pin/local_variable.rb +23 -23
  99. data/lib/solargraph/pin/localized.rb +22 -22
  100. data/lib/solargraph/pin/method.rb +126 -126
  101. data/lib/solargraph/pin/method_alias.rb +30 -30
  102. data/lib/solargraph/pin/method_parameter.rb +40 -40
  103. data/lib/solargraph/pin/namespace.rb +54 -54
  104. data/lib/solargraph/pin/plugin/method.rb +25 -25
  105. data/lib/solargraph/pin/proxy_type.rb +35 -35
  106. data/lib/solargraph/pin/reference.rb +22 -22
  107. data/lib/solargraph/pin/reference/extend.rb +11 -11
  108. data/lib/solargraph/pin/reference/include.rb +11 -11
  109. data/lib/solargraph/pin/reference/require.rb +15 -15
  110. data/lib/solargraph/pin/reference/superclass.rb +11 -11
  111. data/lib/solargraph/pin/symbol.rb +44 -44
  112. data/lib/solargraph/pin/yard_pin.rb +10 -10
  113. data/lib/solargraph/pin/yard_pin/constant.rb +14 -14
  114. data/lib/solargraph/pin/yard_pin/method.rb +35 -35
  115. data/lib/solargraph/pin/yard_pin/namespace.rb +19 -19
  116. data/lib/solargraph/pin/yard_pin/yard_mixin.rb +14 -14
  117. data/lib/solargraph/plugin.rb +8 -8
  118. data/lib/solargraph/plugin/base.rb +41 -41
  119. data/lib/solargraph/plugin/canceler.rb +11 -11
  120. data/lib/solargraph/plugin/process.rb +172 -172
  121. data/lib/solargraph/plugin/runtime.rb +134 -134
  122. data/lib/solargraph/position.rb +110 -110
  123. data/lib/solargraph/range.rb +83 -83
  124. data/lib/solargraph/server_methods.rb +14 -14
  125. data/lib/solargraph/shell.rb +102 -102
  126. data/lib/solargraph/source.rb +521 -521
  127. data/lib/solargraph/source/chain.rb +120 -120
  128. data/lib/solargraph/source/chain/call.rb +107 -107
  129. data/lib/solargraph/source/chain/class_variable.rb +11 -11
  130. data/lib/solargraph/source/chain/constant.rb +30 -30
  131. data/lib/solargraph/source/chain/global_variable.rb +11 -11
  132. data/lib/solargraph/source/chain/head.rb +33 -33
  133. data/lib/solargraph/source/chain/instance_variable.rb +11 -11
  134. data/lib/solargraph/source/chain/link.rb +33 -33
  135. data/lib/solargraph/source/chain/literal.rb +21 -21
  136. data/lib/solargraph/source/chain/variable.rb +11 -11
  137. data/lib/solargraph/source/change.rb +77 -77
  138. data/lib/solargraph/source/cursor.rb +157 -157
  139. data/lib/solargraph/source/node_chainer.rb +96 -96
  140. data/lib/solargraph/source/node_methods.rb +225 -225
  141. data/lib/solargraph/source/source_chainer.rb +183 -183
  142. data/lib/solargraph/source_map.rb +169 -169
  143. data/lib/solargraph/source_map/clip.rb +145 -145
  144. data/lib/solargraph/source_map/completion.rb +21 -21
  145. data/lib/solargraph/source_map/mapper.rb +149 -149
  146. data/lib/solargraph/source_map/node_processor.rb +78 -78
  147. data/lib/solargraph/source_map/node_processor/alias_node.rb +19 -19
  148. data/lib/solargraph/source_map/node_processor/args_node.rb +28 -28
  149. data/lib/solargraph/source_map/node_processor/base.rb +68 -68
  150. data/lib/solargraph/source_map/node_processor/begin_node.rb +11 -11
  151. data/lib/solargraph/source_map/node_processor/block_node.rb +14 -14
  152. data/lib/solargraph/source_map/node_processor/casgn_node.rb +14 -14
  153. data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +14 -14
  154. data/lib/solargraph/source_map/node_processor/def_node.rb +54 -54
  155. data/lib/solargraph/source_map/node_processor/defs_node.rb +21 -21
  156. data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +12 -12
  157. data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +18 -18
  158. data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +16 -16
  159. data/lib/solargraph/source_map/node_processor/namespace_node.rb +26 -26
  160. data/lib/solargraph/source_map/node_processor/orasgn_node.rb +12 -12
  161. data/lib/solargraph/source_map/node_processor/sclass_node.rb +11 -11
  162. data/lib/solargraph/source_map/node_processor/send_node.rb +162 -162
  163. data/lib/solargraph/source_map/node_processor/sym_node.rb +11 -11
  164. data/lib/solargraph/source_map/region.rb +58 -58
  165. data/lib/solargraph/version.rb +3 -3
  166. data/lib/solargraph/views/environment.erb +53 -53
  167. data/lib/solargraph/workspace.rb +183 -183
  168. data/lib/solargraph/workspace/config.rb +170 -170
  169. data/lib/solargraph/yard_map.rb +298 -298
  170. data/lib/solargraph/yard_map/cache.rb +17 -17
  171. data/lib/solargraph/yard_map/core_docs.rb +163 -163
  172. data/lib/solargraph/yard_map/core_gen.rb +76 -76
  173. data/lib/yard-coregen.rb +16 -16
  174. data/lib/yard-solargraph.rb +18 -18
  175. data/solargraph.gemspec +37 -0
  176. data/travis-bundler.rb +10 -0
  177. metadata +19 -6
@@ -1,17 +1,17 @@
1
- module Solargraph
2
- class YardMap
3
- class Cache
4
- def initialize
5
- @path_pins = {}
6
- end
7
-
8
- def set_path_pins path, pins
9
- @path_pins[path] = pins
10
- end
11
-
12
- def get_path_pins path
13
- @path_pins[path]
14
- end
15
- end
16
- end
17
- end
1
+ module Solargraph
2
+ class YardMap
3
+ class Cache
4
+ def initialize
5
+ @path_pins = {}
6
+ end
7
+
8
+ def set_path_pins path, pins
9
+ @path_pins[path] = pins
10
+ end
11
+
12
+ def get_path_pins path
13
+ @path_pins[path]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,163 +1,163 @@
1
- require 'net/http'
2
- require 'uri'
3
- require 'json'
4
- require 'fileutils'
5
-
6
- module Solargraph
7
- class YardMap
8
- # Tools for managing core documentation.
9
- #
10
- module CoreDocs
11
- # The URL for downloading core documentation
12
- SOURCE = 'https://solargraph.org/download'
13
-
14
- # The default core documentation version
15
- DEFAULT = '2.2.2'
16
-
17
- class << self
18
- # The directory where core documentation is installed.
19
- #
20
- # @return [String]
21
- def cache_dir
22
- # The directory is not stored in a variable so it can be overridden
23
- # in specs.
24
- ENV['SOLARGRAPH_CACHE'] || File.join(Dir.home, '.solargraph', 'cache')
25
- end
26
-
27
- # Ensure installation of minimum documentation.
28
- #
29
- # @return [void]
30
- def require_minimum
31
- return unless best_match.nil?
32
- FileUtils.mkdir_p cache_dir
33
- FileUtils.cp File.join(Solargraph::YARDOC_PATH, "#{DEFAULT}.tar.gz"), cache_dir
34
- install_archive File.join(cache_dir, "#{DEFAULT}.tar.gz")
35
- end
36
-
37
- # True if core documentation is installed for the specified version
38
- # number.
39
- #
40
- # @param ver [String] The version number to check
41
- # @return [Boolean]
42
- def valid?(ver)
43
- dir = File.join(cache_dir, ver)
44
- return false unless File.directory?(dir)
45
- return false unless File.directory?(File.join(dir, 'yardoc'))
46
- return false unless File.directory?(File.join(dir, 'yardoc-stdlib'))
47
- true
48
- end
49
-
50
- # Get a list of version numbers for currently installed core
51
- # documentation.
52
- #
53
- # @return [Array<String>] The installed version numbers
54
- def versions
55
- dirs = Dir[File.join(cache_dir, '*')].map{|d| File.basename(d)}
56
- dirs.keep_if{|d| valid?(d)}
57
- dirs.sort!{|a, b| Gem::Version.new(b) <=> Gem::Version.new(a)}
58
- dirs
59
- end
60
-
61
- # Get the version number of the installed core documentation that is
62
- # the closest match for the current Ruby version.
63
- #
64
- # @return [String] The closest match
65
- def best_match
66
- avail = versions
67
- cur = Gem::Version.new(RUBY_VERSION)
68
- avail.each do |v|
69
- return v if Gem::Version.new(v) <= cur
70
- end
71
- avail.last
72
- end
73
-
74
- # Get a list of core documentation versions that are available for
75
- # download.
76
- #
77
- # @return [Array<String>] The version numbers
78
- def available
79
- uri = URI.parse("#{SOURCE}/versions.json")
80
- response = Net::HTTP.get_response(uri)
81
- obj = JSON.parse(response.body)
82
- raise SourceNotAvailableError, "Error connecting to #{SOURCE}" unless obj['status'] == 'ok'
83
- obj['cores']
84
- end
85
-
86
- # Get the version number of core documentation available for download
87
- # that is the closest match for the current Ruby version.
88
- #
89
- # @param current [String] The version to compare
90
- # @return [String] The version number of the best match
91
- def best_download current = RUBY_VERSION
92
- rv = Gem::Version.new(current)
93
- found = available
94
- found.each do |ver|
95
- return ver if Gem::Version.new(ver) <= rv
96
- end
97
- found.last
98
- end
99
-
100
- # Get the path to a yardoc file for Ruby core documentation.
101
- #
102
- # @param ver [String] The version number (best match is default)
103
- # @return [String] The path to the yardoc
104
- def yardoc_file(ver = best_match)
105
- raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
106
- File.join(cache_dir, ver, 'yardoc')
107
- end
108
-
109
- # Get the path to a yardoc file for Ruby stdlib documentation.
110
- #
111
- # @param ver [String] The version number (best match is default)
112
- # @return [String] The path to the yardoc
113
- def yardoc_stdlib_file(ver = best_match)
114
- raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
115
- File.join(cache_dir, ver, 'yardoc-stdlib')
116
- end
117
-
118
- # Download the specified version of core documentation.
119
- #
120
- # @param version [String]
121
- # @return [void]
122
- def download version
123
- FileUtils.mkdir_p cache_dir
124
- uri = URI.parse("#{SOURCE}/#{version}.tar.gz")
125
- response = Net::HTTP.get_response(uri)
126
- zipfile = File.join(cache_dir, "#{version}.tar.gz")
127
- File.binwrite zipfile, response.body
128
- install_archive zipfile
129
- end
130
-
131
- # Reset the core documentation cache to the minimum requirement.
132
- #
133
- # @return [void]
134
- def clear
135
- FileUtils.rm_rf cache_dir, secure: true
136
- require_minimum
137
- end
138
-
139
- private
140
-
141
- # Extract the specified archive to the core cache directory.
142
- #
143
- # @param filename [String]
144
- # @return [void]
145
- def install_archive filename
146
- tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
147
- tar_extract.rewind
148
- tar_extract.each do |entry|
149
- if entry.directory?
150
- FileUtils.mkdir_p File.join(cache_dir, entry.full_name)
151
- else
152
- FileUtils.mkdir_p File.join(cache_dir, File.dirname(entry.full_name))
153
- File.open(File.join(cache_dir, entry.full_name), 'wb') do |f|
154
- f << entry.read
155
- end
156
- end
157
- end
158
- tar_extract.close
159
- end
160
- end
161
- end
162
- end
163
- end
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+ require 'fileutils'
5
+
6
+ module Solargraph
7
+ class YardMap
8
+ # Tools for managing core documentation.
9
+ #
10
+ module CoreDocs
11
+ # The URL for downloading core documentation
12
+ SOURCE = 'https://solargraph.org/download'
13
+
14
+ # The default core documentation version
15
+ DEFAULT = '2.2.2'
16
+
17
+ class << self
18
+ # The directory where core documentation is installed.
19
+ #
20
+ # @return [String]
21
+ def cache_dir
22
+ # The directory is not stored in a variable so it can be overridden
23
+ # in specs.
24
+ ENV['SOLARGRAPH_CACHE'] || File.join(Dir.home, '.solargraph', 'cache')
25
+ end
26
+
27
+ # Ensure installation of minimum documentation.
28
+ #
29
+ # @return [void]
30
+ def require_minimum
31
+ return unless best_match.nil?
32
+ FileUtils.mkdir_p cache_dir
33
+ FileUtils.cp File.join(Solargraph::YARDOC_PATH, "#{DEFAULT}.tar.gz"), cache_dir
34
+ install_archive File.join(cache_dir, "#{DEFAULT}.tar.gz")
35
+ end
36
+
37
+ # True if core documentation is installed for the specified version
38
+ # number.
39
+ #
40
+ # @param ver [String] The version number to check
41
+ # @return [Boolean]
42
+ def valid?(ver)
43
+ dir = File.join(cache_dir, ver)
44
+ return false unless File.directory?(dir)
45
+ return false unless File.directory?(File.join(dir, 'yardoc'))
46
+ return false unless File.directory?(File.join(dir, 'yardoc-stdlib'))
47
+ true
48
+ end
49
+
50
+ # Get a list of version numbers for currently installed core
51
+ # documentation.
52
+ #
53
+ # @return [Array<String>] The installed version numbers
54
+ def versions
55
+ dirs = Dir[File.join(cache_dir, '*')].map{|d| File.basename(d)}
56
+ dirs.keep_if{|d| valid?(d)}
57
+ dirs.sort!{|a, b| Gem::Version.new(b) <=> Gem::Version.new(a)}
58
+ dirs
59
+ end
60
+
61
+ # Get the version number of the installed core documentation that is
62
+ # the closest match for the current Ruby version.
63
+ #
64
+ # @return [String] The closest match
65
+ def best_match
66
+ avail = versions
67
+ cur = Gem::Version.new(RUBY_VERSION)
68
+ avail.each do |v|
69
+ return v if Gem::Version.new(v) <= cur
70
+ end
71
+ avail.last
72
+ end
73
+
74
+ # Get a list of core documentation versions that are available for
75
+ # download.
76
+ #
77
+ # @return [Array<String>] The version numbers
78
+ def available
79
+ uri = URI.parse("#{SOURCE}/versions.json")
80
+ response = Net::HTTP.get_response(uri)
81
+ obj = JSON.parse(response.body)
82
+ raise SourceNotAvailableError, "Error connecting to #{SOURCE}" unless obj['status'] == 'ok'
83
+ obj['cores']
84
+ end
85
+
86
+ # Get the version number of core documentation available for download
87
+ # that is the closest match for the current Ruby version.
88
+ #
89
+ # @param current [String] The version to compare
90
+ # @return [String] The version number of the best match
91
+ def best_download current = RUBY_VERSION
92
+ rv = Gem::Version.new(current)
93
+ found = available
94
+ found.each do |ver|
95
+ return ver if Gem::Version.new(ver) <= rv
96
+ end
97
+ found.last
98
+ end
99
+
100
+ # Get the path to a yardoc file for Ruby core documentation.
101
+ #
102
+ # @param ver [String] The version number (best match is default)
103
+ # @return [String] The path to the yardoc
104
+ def yardoc_file(ver = best_match)
105
+ raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
106
+ File.join(cache_dir, ver, 'yardoc')
107
+ end
108
+
109
+ # Get the path to a yardoc file for Ruby stdlib documentation.
110
+ #
111
+ # @param ver [String] The version number (best match is default)
112
+ # @return [String] The path to the yardoc
113
+ def yardoc_stdlib_file(ver = best_match)
114
+ raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
115
+ File.join(cache_dir, ver, 'yardoc-stdlib')
116
+ end
117
+
118
+ # Download the specified version of core documentation.
119
+ #
120
+ # @param version [String]
121
+ # @return [void]
122
+ def download version
123
+ FileUtils.mkdir_p cache_dir
124
+ uri = URI.parse("#{SOURCE}/#{version}.tar.gz")
125
+ response = Net::HTTP.get_response(uri)
126
+ zipfile = File.join(cache_dir, "#{version}.tar.gz")
127
+ File.binwrite zipfile, response.body
128
+ install_archive zipfile
129
+ end
130
+
131
+ # Reset the core documentation cache to the minimum requirement.
132
+ #
133
+ # @return [void]
134
+ def clear
135
+ FileUtils.rm_rf cache_dir, secure: true
136
+ require_minimum
137
+ end
138
+
139
+ private
140
+
141
+ # Extract the specified archive to the core cache directory.
142
+ #
143
+ # @param filename [String]
144
+ # @return [void]
145
+ def install_archive filename
146
+ tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
147
+ tar_extract.rewind
148
+ tar_extract.each do |entry|
149
+ if entry.directory?
150
+ FileUtils.mkdir_p File.join(cache_dir, entry.full_name)
151
+ else
152
+ FileUtils.mkdir_p File.join(cache_dir, File.dirname(entry.full_name))
153
+ File.open(File.join(cache_dir, entry.full_name), 'wb') do |f|
154
+ f << entry.read
155
+ end
156
+ end
157
+ end
158
+ tar_extract.close
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
@@ -1,76 +1,76 @@
1
- require 'fileutils'
2
- require 'tmpdir'
3
- require 'pathname'
4
- require 'rubygems/package'
5
- require 'shellwords'
6
-
7
- module Solargraph
8
- class YardMap
9
- # Tools for generating core documentation.
10
- #
11
- module CoreGen
12
- class << self
13
- # Generate documentation from the specified Ruby source directory.
14
- #
15
- # @param ruby_dir [String] The Ruby source directory
16
- # @param dest_dir [String] The destination directory for the yardocs
17
- # @return [void]
18
- def generate_docs ruby_dir, dest_dir
19
- path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
20
- FileUtils.mkdir_p path_name
21
- Dir.chdir(ruby_dir) do
22
- `yardoc --plugin coregen -b "#{File.join(path_name, 'yardoc')}" -n *.c`
23
- raise 'An error occurred generating the core yardoc.' unless $?.success?
24
- # YARD::CLI::Yardoc.run('--plugin', 'coregen', '-b', "#{File.join(path_name, 'yardoc')}", '-n', File.join(ruby_dir, '*.c'))
25
- `yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
26
- raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
27
- # YARD::CLI::Yardoc.run('-b', "#{File.join(path_name, 'yardoc-stdlib')}", '-n', File.join(ruby_dir, 'lib', '**', '*.rb'), File.join(ruby_dir, 'ext', '**', '*.c'), File.join(ruby_dir, 'ext', '**', '*.rb'))
28
- end
29
- end
30
-
31
- # Generate a gzip of documentation from the specified Ruby source
32
- # directory.
33
- #
34
- # This method is designed to generate the directory architecture that
35
- # YardMap core docs expect.
36
- #
37
- # @param ruby_dir [String] The Ruby source directory
38
- # @param ver_name [String, nil] The version name
39
- # @param dest_dir [String] The destination directory
40
- # @return [void]
41
- def generate_gzip ruby_dir, ver_name = nil, dest_dir = Dir.pwd
42
- Dir.mktmpdir do |tmp|
43
- base_name = ver_name || begin
44
- match = ruby_dir.match(/\d+\.\d+\.\d+$/)
45
- raise "Unable to determine version name from #{ruby_dir}" if match.nil?
46
- match[0]
47
- end
48
- path_name = Pathname.new(tmp).join(base_name).to_s
49
- generate_docs ruby_dir, path_name
50
- gzip path_name, Pathname.new(dest_dir).join("#{base_name}.tar.gz").to_s
51
- end
52
- end
53
-
54
- private
55
-
56
- # @param dir [String] The directory to compress
57
- # @param dst [String] The destination file
58
- def gzip dir, dst
59
- File.open(dst, 'wb') do |file|
60
- Zlib::GzipWriter.wrap(file) do |gzip|
61
- Gem::Package::TarWriter.new(gzip) do |tar|
62
- Dir["#{dir}/**/*"].each do |filename|
63
- next if File.directory?(filename)
64
- relname = File.join(File.basename(dir), filename[dir.length+1..-1])
65
- tar.add_file_simple(relname, 0o644, File.size(filename)) do |io|
66
- io.write File.read_binary(filename)
67
- end
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+ require 'pathname'
4
+ require 'rubygems/package'
5
+ require 'shellwords'
6
+
7
+ module Solargraph
8
+ class YardMap
9
+ # Tools for generating core documentation.
10
+ #
11
+ module CoreGen
12
+ class << self
13
+ # Generate documentation from the specified Ruby source directory.
14
+ #
15
+ # @param ruby_dir [String] The Ruby source directory
16
+ # @param dest_dir [String] The destination directory for the yardocs
17
+ # @return [void]
18
+ def generate_docs ruby_dir, dest_dir
19
+ path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
20
+ FileUtils.mkdir_p path_name
21
+ Dir.chdir(ruby_dir) do
22
+ `yardoc --plugin coregen -b "#{File.join(path_name, 'yardoc')}" -n *.c`
23
+ raise 'An error occurred generating the core yardoc.' unless $?.success?
24
+ # YARD::CLI::Yardoc.run('--plugin', 'coregen', '-b', "#{File.join(path_name, 'yardoc')}", '-n', File.join(ruby_dir, '*.c'))
25
+ `yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
26
+ raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
27
+ # YARD::CLI::Yardoc.run('-b', "#{File.join(path_name, 'yardoc-stdlib')}", '-n', File.join(ruby_dir, 'lib', '**', '*.rb'), File.join(ruby_dir, 'ext', '**', '*.c'), File.join(ruby_dir, 'ext', '**', '*.rb'))
28
+ end
29
+ end
30
+
31
+ # Generate a gzip of documentation from the specified Ruby source
32
+ # directory.
33
+ #
34
+ # This method is designed to generate the directory architecture that
35
+ # YardMap core docs expect.
36
+ #
37
+ # @param ruby_dir [String] The Ruby source directory
38
+ # @param ver_name [String, nil] The version name
39
+ # @param dest_dir [String] The destination directory
40
+ # @return [void]
41
+ def generate_gzip ruby_dir, ver_name = nil, dest_dir = Dir.pwd
42
+ Dir.mktmpdir do |tmp|
43
+ base_name = ver_name || begin
44
+ match = ruby_dir.match(/\d+\.\d+\.\d+$/)
45
+ raise "Unable to determine version name from #{ruby_dir}" if match.nil?
46
+ match[0]
47
+ end
48
+ path_name = Pathname.new(tmp).join(base_name).to_s
49
+ generate_docs ruby_dir, path_name
50
+ gzip path_name, Pathname.new(dest_dir).join("#{base_name}.tar.gz").to_s
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # @param dir [String] The directory to compress
57
+ # @param dst [String] The destination file
58
+ def gzip dir, dst
59
+ File.open(dst, 'wb') do |file|
60
+ Zlib::GzipWriter.wrap(file) do |gzip|
61
+ Gem::Package::TarWriter.new(gzip) do |tar|
62
+ Dir["#{dir}/**/*"].each do |filename|
63
+ next if File.directory?(filename)
64
+ relname = File.join(File.basename(dir), filename[dir.length+1..-1])
65
+ tar.add_file_simple(relname, 0o644, File.size(filename)) do |io|
66
+ io.write File.read_binary(filename)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end