pry-doc 0.13.2pre6 → 0.13.2pre7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad15e20d11d68e36a2bf2fa5187d1b7551b94c75ac3d1201a2dcd14883247322
4
- data.tar.gz: 8c650e9e6250e86806f33e0d4af8214ea9ff8b3fa461d50c708440f6b2723a3b
3
+ metadata.gz: 1a92e58a3ca468b0210dcebc21c7a7a466ab8167c0fff8b6ef78f634c0d938db
4
+ data.tar.gz: 416ea1f86b706da35c66bcb2e4e4b20969d0533abca761ecc9d71e6829124a46
5
5
  SHA512:
6
- metadata.gz: a3c06161e8a146295adad2bcf8c666e81d063450abc2ded4d07db73eb801d454f4044bf47dcdf58c6f5c772174ce3a57d847acdf77754f40fc3c6df3b9e85478
7
- data.tar.gz: f2dc5aaf3918fe5f4f4bbb3fc1c7bd35b921e0ab7bae05e8f2443416cee8034081bdb70437148127d62455415a26fda1ed58207249b7498495e3b0e7b7f2c531
6
+ metadata.gz: 68ccf8ee9fd41abda6ed98013335f71cc4bb2e7dad1909fc5c31301e462e2fef2d62b5e8589cf5efa287f05b21e02038bdc186218f738a16f78781fe287d3028
7
+ data.tar.gz: a958ebf650666981c40ab95626c6316ef70290193c2d07bd482abafa903b87df0452a246f7561b2fbf43d5d90e40dfae6970fc89d570a171a7507accb304dc2c
data/lib/pry-doc.rb CHANGED
@@ -1,8 +1,3 @@
1
- require 'yard'
2
-
3
- require 'pry-doc/version'
4
- require 'pry-doc/pry_ext/method_info'
5
-
6
1
  module PryDoc
7
2
  def self.load_yardoc(version)
8
3
  path = "#{File.dirname(__FILE__)}/pry-doc/docs/#{version}"
@@ -23,4 +18,8 @@ module PryDoc
23
18
  root
24
19
  end
25
20
 
21
+ require 'yard'
22
+ require 'pry-doc/version'
23
+ require 'pry-doc/pry_ext/method_info'
24
+
26
25
  PryDoc.load_yardoc(RUBY_VERSION[0...3].sub!('.', ''))
@@ -41,7 +41,7 @@ module Pry::CInternals
41
41
  end
42
42
 
43
43
  def full_path_for(file_name)
44
- if RbConfig::CONFIG['host'] =~ /mswin|mingw/
44
+ if Pry::Platform.windows?
45
45
  # windows etags already has the path expanded, wtf
46
46
  file_name
47
47
  else
@@ -9,6 +9,7 @@ module Pry::CInternals
9
9
 
10
10
  class << self
11
11
  attr_accessor :ruby_source_folder
12
+ attr_accessor :ruby_source_installer
12
13
  end
13
14
 
14
15
  # The Ruby version that corresponds to a downloadable release
@@ -22,6 +23,7 @@ module Pry::CInternals
22
23
  end
23
24
 
24
25
  self.ruby_source_folder = File.join(File.expand_path("~/.pry.d"), "ruby-#{ruby_version}")
26
+ self.ruby_source_installer = RubySourceInstaller.new(ruby_version, ruby_source_folder)
25
27
 
26
28
  attr_reader :line_number_style
27
29
  attr_reader :symbol_extractor
@@ -72,10 +74,11 @@ module Pry::CInternals
72
74
  end
73
75
 
74
76
  def self.symbol_map
75
- parse_tagfile
76
- @symbol_map ||= @c_files.each_with_object({}) do |v, h|
77
- h.merge!(v.symbols) { |k, old_val, new_val| old_val + new_val }
78
- end
77
+ @symbol_map ||= (
78
+ parse_tagfile
79
+ @c_files.each_with_object({}) do |v, h|
80
+ h.merge!(v.symbols) { |k, old_val, new_val| old_val + new_val }
81
+ end)
79
82
  end
80
83
 
81
84
  def self.parse_tagfile
@@ -87,15 +90,9 @@ module Pry::CInternals
87
90
  def self.tagfile
88
91
  tags = File.join(ruby_source_folder, "TAGS")
89
92
  if !File.exists?(tags)
90
- RubySourceInstaller.new(ruby_version, ruby_source_folder).install
93
+ ruby_source_installer.install
91
94
  end
92
95
  @tagfile ||= File.read(tags)
93
96
  end
94
-
95
- # @param [String] message Message to display on error
96
- # @param [&Block] block Optional assertion
97
- def self.check_for_error(message, &block)
98
- raise Pry::CommandError, message if $?.to_i != 0 || block && !block.call
99
- end
100
97
  end
101
98
  end
@@ -3,9 +3,15 @@ module Pry::CInternals
3
3
  attr_reader :ruby_version
4
4
  attr_reader :ruby_source_folder
5
5
 
6
+ attr_accessor :curl_cmd
7
+ attr_accessor :etag_binary
8
+ attr_accessor :etag_cmd
9
+
6
10
  def initialize(ruby_version, ruby_source_folder)
7
11
  @ruby_version = ruby_version
8
12
  @ruby_source_folder = ruby_source_folder
13
+
14
+ set_platform_specific_commands
9
15
  end
10
16
 
11
17
  def install
@@ -16,8 +22,24 @@ module Pry::CInternals
16
22
  puts "...Finished!"
17
23
  end
18
24
 
25
+ private
26
+
27
+ def set_platform_specific_commands
28
+ if Pry::Platform.windows?
29
+ self.curl_cmd = "curl -k --fail -L -O https://github.com/ruby/ruby/archive/v#{ruby_version}.zip " +
30
+ "& 7z -y x v#{ruby_version}.zip"
31
+ self.etag_binary = File.join(PryDoc.root, "libexec/windows/etags")
32
+ self.etag_cmd = %{dir /b /s *.c *.h *.y | "#{etag_binary}" - --no-members}
33
+ else
34
+ self.curl_cmd = "curl --fail -L https://github.com/ruby/ruby/archive/v#{ruby_version}.tar.gz | tar xzvf - 2> /dev/null"
35
+ self.etag_binary = Pry::Platform.linux? ? File.join(PryDoc.root, "libexec/linux/etags-#{arch}") : "etags"
36
+ self.etag_cmd = "find . -type f -name '*.[chy]' | #{etag_binary} - --no-members"
37
+ end
38
+ end
39
+
19
40
  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 "
41
+ print "Identifier not found - do you want to install CRuby sources to attempt to resolve the identifier there?" +
42
+ "\nThis allows the lookup of C internals Y/N "
21
43
 
22
44
  if $stdin.gets !~ /^y/i
23
45
  puts "CRuby sources not installed. To prevent being asked again, add `Pry.config.skip_cruby_source = true` to your ~/.pryrc"
@@ -39,33 +61,8 @@ module Pry::CInternals
39
61
  raise Pry::CommandError, message if $?.to_i != 0 || block && !block.call
40
62
  end
41
63
 
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
64
+ def arch
65
+ RbConfig::CONFIG['arch'] =~ /i(3|6)86/ ? 32 : 64
69
66
  end
70
67
 
71
68
  def generate_tagfile
@@ -1,3 +1,3 @@
1
1
  module PryDoc
2
- VERSION = '0.13.2pre6'
2
+ VERSION = '0.13.2pre7'
3
3
  end
data/spec/pry-doc_spec.rb CHANGED
@@ -24,7 +24,7 @@ RSpec.describe PryDoc do
24
24
  context "no tags file exists" do
25
25
  it "attempts to install and setup ruby" do
26
26
  described_class.ruby_source_folder = File.join(File.dirname(__FILE__), "fishface")
27
- expect(described_class).to receive(:install_and_setup_ruby_source)
27
+ expect(described_class.ruby_source_installer).to receive(:install)
28
28
 
29
29
  # will try to read from the 'created' tags file, this will error, so rescue
30
30
  # (since we're stubbing out `install_and_setup_ruby_source` no tags file
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.2pre6
4
+ version: 0.13.2pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)