pry-doc 0.13.2pre5 → 0.13.2pre6

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: 3e03a24e1b0b08449718fdd990b4aee51dcb95784c07223078105ed5510de5c8
4
- data.tar.gz: 67a81b1d1447663bd4f722b64f8698dde4dfd9d583d8ea02557a709ece691f1d
3
+ metadata.gz: ad15e20d11d68e36a2bf2fa5187d1b7551b94c75ac3d1201a2dcd14883247322
4
+ data.tar.gz: 8c650e9e6250e86806f33e0d4af8214ea9ff8b3fa461d50c708440f6b2723a3b
5
5
  SHA512:
6
- metadata.gz: 19d64ec89537c727aff83347773983e4a8503db5478899a4c42865b017977729d1994e6930234fa61ac4525a1cd81e64392e750ddd09a5c60bd3d1993d04fd69
7
- data.tar.gz: 2d30085ec8d034f7be0beb65c0ad1828ecbc702351b58411e3e408a7bf3b111f7751a830d3887dab156192d204a3b719b524d92fd6adfb02db83d8f9a315b4c8
6
+ metadata.gz: a3c06161e8a146295adad2bcf8c666e81d063450abc2ded4d07db73eb801d454f4044bf47dcdf58c6f5c772174ce3a57d847acdf77754f40fc3c6df3b9e85478
7
+ data.tar.gz: f2dc5aaf3918fe5f4f4bbb3fc1c7bd35b921e0ab7bae05e8f2443416cee8034081bdb70437148127d62455415a26fda1ed58207249b7498495e3b0e7b7f2c531
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require_relative 'c_file'
3
3
  require_relative 'symbol_extractor'
4
+ require_relative 'ruby_source_installer'
4
5
 
5
6
  module Pry::CInternals
6
7
  class CodeFetcher
@@ -85,8 +86,9 @@ module Pry::CInternals
85
86
 
86
87
  def self.tagfile
87
88
  tags = File.join(ruby_source_folder, "TAGS")
88
- install_and_setup_ruby_source unless File.exists?(tags)
89
-
89
+ if !File.exists?(tags)
90
+ RubySourceInstaller.new(ruby_version, ruby_source_folder).install
91
+ end
90
92
  @tagfile ||= File.read(tags)
91
93
  end
92
94
 
@@ -95,73 +97,5 @@ module Pry::CInternals
95
97
  def self.check_for_error(message, &block)
96
98
  raise Pry::CommandError, message if $?.to_i != 0 || block && !block.call
97
99
  end
98
-
99
- def self.ask_for_install
100
- print "Identifier not found - do you want to install CRuby sources to attempt to resolve the identifier there?\nThis allows the lookup of C internals Y/N "
101
-
102
- if $stdin.gets !~ /^y/i
103
- puts "CRuby sources not installed. To prevent being asked again, add `Pry.config.skip_cruby_source = true` to your ~/.pryrc"
104
- raise Pry::CommandError, "No definition found."
105
- end
106
- end
107
-
108
- def self.install_and_setup_ruby_source
109
- ask_for_install
110
- puts "Downloading and setting up Ruby #{ruby_version} source..."
111
- download_ruby
112
- generate_tagfile
113
- puts "...Finished!"
114
- end
115
-
116
- # for windows support need to:
117
- # (1) curl -k --fail -L https://github.com/ruby/ruby/archive/v2_4_1.zip
118
- # need -k as insecure as don't have root certs
119
- # (2) 7z x v2_4_1.zip to extract it (via 7zip, choco install 7zip)
120
- # (3) generate etags with: dir /b /s *.c *.h *.y | etags - --no-members
121
- # (4) Done!
122
- def self.download_ruby
123
- FileUtils.mkdir_p(ruby_source_folder)
124
- FileUtils.cd(File.dirname(ruby_source_folder)) do
125
- %x{ #{curl_cmd} }
126
- check_for_error(curl_cmd) { Dir.entries(ruby_source_folder).count > 5 }
127
- end
128
- end
129
-
130
- def self.curl_cmd
131
- if Pry::Platform.windows?
132
- %{
133
- curl -k --fail -L -O https://github.com/ruby/ruby/archive/v#{ruby_version}.zip & 7z -y x v#{ruby_version}.zip
134
- }
135
- else
136
- "curl --fail -L https://github.com/ruby/ruby/archive/v#{ruby_version}.tar.gz | tar xzvf - 2> /dev/null"
137
- end
138
- end
139
-
140
- def self.etag_binary
141
- @etag_binary ||= if Pry::Platform.linux?
142
- arch = RbConfig::CONFIG['arch'] =~ /i(3|6)86/ ? 32 : 64
143
- File.join(PryDoc.root, "libexec/linux/etags-#{arch}")
144
- elsif Pry::Platform.windows?
145
- File.join(PryDoc.root, "libexec/windows/etags")
146
- else
147
- "etags"
148
- end
149
- end
150
-
151
- def self.etag_cmd
152
- if Pry::Platform.windows?
153
- %{dir /b /s *.c *.h *.y | "#{etag_binary}" - --no-members}
154
- else
155
- "find . -type f -name '*.[chy]' | #{etag_binary} - --no-members"
156
- end
157
- end
158
-
159
- def self.generate_tagfile
160
- FileUtils.cd(ruby_source_folder) do
161
- puts "Generating tagfile!"
162
- %x{ #{etag_cmd} }
163
- check_for_error(etag_cmd) { File.size(File.join(ruby_source_folder, "TAGS")) > 500 }
164
- end
165
- end
166
100
  end
167
101
  end
@@ -0,0 +1,79 @@
1
+ module Pry::CInternals
2
+ class RubySourceInstaller
3
+ attr_reader :ruby_version
4
+ attr_reader :ruby_source_folder
5
+
6
+ def initialize(ruby_version, ruby_source_folder)
7
+ @ruby_version = ruby_version
8
+ @ruby_source_folder = ruby_source_folder
9
+ end
10
+
11
+ def install
12
+ ask_for_install
13
+ puts "Downloading and setting up Ruby #{ruby_version} source..."
14
+ download_ruby
15
+ generate_tagfile
16
+ puts "...Finished!"
17
+ end
18
+
19
+ def ask_for_install
20
+ print "Identifier not found - do you want to install CRuby sources to attempt to resolve the identifier there?\nThis allows the lookup of C internals Y/N "
21
+
22
+ if $stdin.gets !~ /^y/i
23
+ puts "CRuby sources not installed. To prevent being asked again, add `Pry.config.skip_cruby_source = true` to your ~/.pryrc"
24
+ raise Pry::CommandError, "No definition found."
25
+ end
26
+ end
27
+
28
+ def download_ruby
29
+ FileUtils.mkdir_p(ruby_source_folder)
30
+ FileUtils.cd(File.dirname(ruby_source_folder)) do
31
+ %x{ #{curl_cmd} }
32
+ check_for_error(curl_cmd) { Dir.entries(ruby_source_folder).count > 5 }
33
+ end
34
+ end
35
+
36
+ # @param [String] message Message to display on error
37
+ # @param [&Block] block Optional assertion
38
+ def check_for_error(message, &block)
39
+ raise Pry::CommandError, message if $?.to_i != 0 || block && !block.call
40
+ end
41
+
42
+ def curl_cmd
43
+ if Pry::Platform.windows?
44
+ %{
45
+ curl -k --fail -L -O https://github.com/ruby/ruby/archive/v#{ruby_version}.zip & 7z -y x v#{ruby_version}.zip
46
+ }
47
+ else
48
+ "curl --fail -L https://github.com/ruby/ruby/archive/v#{ruby_version}.tar.gz | tar xzvf - 2> /dev/null"
49
+ end
50
+ end
51
+
52
+ def etag_binary
53
+ @etag_binary ||= if Pry::Platform.linux?
54
+ arch = RbConfig::CONFIG['arch'] =~ /i(3|6)86/ ? 32 : 64
55
+ File.join(PryDoc.root, "libexec/linux/etags-#{arch}")
56
+ elsif Pry::Platform.windows?
57
+ File.join(PryDoc.root, "libexec/windows/etags")
58
+ else
59
+ "etags"
60
+ end
61
+ end
62
+
63
+ def etag_cmd
64
+ if Pry::Platform.windows?
65
+ %{dir /b /s *.c *.h *.y | "#{etag_binary}" - --no-members}
66
+ else
67
+ "find . -type f -name '*.[chy]' | #{etag_binary} - --no-members"
68
+ end
69
+ end
70
+
71
+ def generate_tagfile
72
+ FileUtils.cd(ruby_source_folder) do
73
+ puts "Generating tagfile!"
74
+ %x{ #{etag_cmd} }
75
+ check_for_error(etag_cmd) { File.size(File.join(ruby_source_folder, "TAGS")) > 500 }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,3 +1,3 @@
1
1
  module PryDoc
2
- VERSION = '0.13.2pre5'
2
+ VERSION = '0.13.2pre6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2pre5
4
+ version: 0.13.2pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)
@@ -131,6 +131,7 @@ files:
131
131
  - lib/pry-doc/pry_ext/show_source_with_c_internals.rb
132
132
  - lib/pry-doc/pry_ext/show_source_with_c_internals/c_file.rb
133
133
  - lib/pry-doc/pry_ext/show_source_with_c_internals/code_fetcher.rb
134
+ - lib/pry-doc/pry_ext/show_source_with_c_internals/ruby_source_installer.rb
134
135
  - lib/pry-doc/pry_ext/show_source_with_c_internals/symbol_extractor.rb
135
136
  - lib/pry-doc/version.rb
136
137
  - libexec/linux/etags-32