pry-doc 0.13.0pre6 → 0.13.0pre7
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 +4 -4
- data/Rakefile +5 -0
- data/lib/pry-doc/pry_ext/show_source_with_c_internals/symbol_extractor.rb +2 -2
- data/lib/pry-doc/version.rb +1 -1
- data/spec/fixtures/c_source/hello.c +11 -0
- data/spec/fixtures/c_source/tags +7 -1
- data/spec/pry-doc_spec.rb +66 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecf2ae29bffe6f81c0a6ec6dce2e15c2ce364d09
|
4
|
+
data.tar.gz: 20fd2f5ae0a4f1cb9eab9c736e199991d40834ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de7b2c32043e9917fce673b8bf10b2070ce17e091cd08bc9708ec4d51441f22e9a6ba5c16af886cab9684f8aa29a34c62d817d6dc65c54c8eb912833e15ff122
|
7
|
+
data.tar.gz: 0273e48b4b2c3bfcdc0480204b065c85e3465827c13049c065edcd890a265b90005c6866c2adaa189d1e22a598fe1615aae073af1aae7b89e215d0e6486f97f0
|
data/Rakefile
CHANGED
@@ -12,6 +12,11 @@ require 'latest_ruby'
|
|
12
12
|
require 'rake/clean'
|
13
13
|
require "#{direc}/lib/#{PROJECT_NAME}/version"
|
14
14
|
|
15
|
+
desc "start pry with fixture c file"
|
16
|
+
task :pry_fixture do
|
17
|
+
sh %{pry -I./lib -r pry-doc -e "Pry::CInternals::CodeFetcher.ruby_source_folder = './spec/fixtures/c_source'"}
|
18
|
+
end
|
19
|
+
|
15
20
|
desc "generate fixture etags"
|
16
21
|
task :etags do
|
17
22
|
sh 'etags --no-members spec/fixtures/c_source/*.c -o spec/fixtures/c_source/tags'
|
@@ -12,7 +12,7 @@ module Pry::CInternals
|
|
12
12
|
def extract(info)
|
13
13
|
if info.original_symbol.start_with?("#define")
|
14
14
|
extract_macro(info)
|
15
|
-
elsif info.original_symbol =~ /\s
|
15
|
+
elsif info.original_symbol =~ /\s+(struct|enum)\s+/
|
16
16
|
extract_struct(info)
|
17
17
|
elsif info.original_symbol.start_with?("}")
|
18
18
|
extract_typedef_struct(info)
|
@@ -38,7 +38,7 @@ module Pry::CInternals
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def extract_typedef_struct(info)
|
41
|
-
extract_code(info
|
41
|
+
extract_code(info, direction: :reverse) do |code|
|
42
42
|
return code if balanced?(code)
|
43
43
|
end
|
44
44
|
end
|
data/lib/pry-doc/version.rb
CHANGED
data/spec/fixtures/c_source/tags
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
goodbye.c,9
|
3
3
|
foo(2,5
|
4
4
|
|
5
|
-
hello.c,
|
5
|
+
hello.c,256
|
6
6
|
foo(2,4
|
7
7
|
#define baby 5,19
|
8
8
|
typedef int wassup;9,73
|
@@ -11,3 +11,9 @@ enum bar 11,94
|
|
11
11
|
beta,13,114
|
12
12
|
gamma14,122
|
13
13
|
struct baz 17,134
|
14
|
+
typedef enum cute_enum_e 22,169
|
15
|
+
lillybing,23,196
|
16
|
+
tote,24,209
|
17
|
+
lilt25,217
|
18
|
+
} baby_enum;26,224
|
19
|
+
} cutie_pie;31,283
|
data/spec/pry-doc_spec.rb
CHANGED
@@ -17,10 +17,22 @@ RSpec.describe PryDoc do
|
|
17
17
|
Pry::Helpers::Text.strip_color(str)
|
18
18
|
end
|
19
19
|
|
20
|
-
before
|
20
|
+
before do
|
21
21
|
described_class.ruby_source_folder = File.join(File.dirname(__FILE__), "fixtures/c_source")
|
22
22
|
end
|
23
23
|
|
24
|
+
context "no tags file exists" do
|
25
|
+
it "attempts to install and setup ruby" do
|
26
|
+
described_class.ruby_source_folder = File.join(File.dirname(__FILE__), "fishface")
|
27
|
+
expect(described_class).to receive(:install_and_setup_ruby_source)
|
28
|
+
|
29
|
+
# will try to read from the 'created' tags file, this will error, so rescue
|
30
|
+
# (since we're stubbing out `install_and_setup_ruby_source` no tags file
|
31
|
+
# ever gets created)
|
32
|
+
described_class.tagfile rescue nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
24
36
|
describe ".symbol_map" do
|
25
37
|
it "generates the map with the correct symbols" do
|
26
38
|
expect(described_class.symbol_map).to have_key("foo")
|
@@ -28,34 +40,9 @@ RSpec.describe PryDoc do
|
|
28
40
|
expect(described_class.symbol_map).to have_key("wassup")
|
29
41
|
expect(described_class.symbol_map).to have_key("bar")
|
30
42
|
expect(described_class.symbol_map).to have_key("baz")
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
context "with line numbers" do
|
35
|
-
context "normal style (actual line numbers)" do
|
36
|
-
it "displays actual line numbers" do
|
37
|
-
code, = described_class.new(line_number_style: :'line-numbers').fetch_first_definition("bar")
|
38
|
-
expect(decolor code).to include <<EOF
|
39
|
-
11: enum bar {
|
40
|
-
12: alpha,
|
41
|
-
13: beta,
|
42
|
-
14: gamma
|
43
|
-
15: };
|
44
|
-
EOF
|
45
|
-
end
|
46
|
-
|
47
|
-
context "base one style (line numbers start with 1)" do
|
48
|
-
it "displays actual line numbers" do
|
49
|
-
code, = described_class.new(line_number_style: :'base-one').fetch_first_definition("bar")
|
50
|
-
expect(decolor code).to include <<EOF
|
51
|
-
1: enum bar {
|
52
|
-
2: alpha,
|
53
|
-
3: beta,
|
54
|
-
4: gamma
|
55
|
-
5: };
|
56
|
-
EOF
|
57
|
-
end
|
58
|
-
end
|
43
|
+
expect(described_class.symbol_map).to have_key("cute_enum_e")
|
44
|
+
expect(described_class.symbol_map).to have_key("baby_enum")
|
45
|
+
expect(described_class.symbol_map).to have_key("cutie_pie")
|
59
46
|
end
|
60
47
|
end
|
61
48
|
|
@@ -78,6 +65,34 @@ EOF
|
|
78
65
|
end
|
79
66
|
|
80
67
|
describe "#fetch_first_definition" do
|
68
|
+
context "with line numbers" do
|
69
|
+
context "normal style (actual line numbers)" do
|
70
|
+
it "displays actual line numbers" do
|
71
|
+
code, = described_class.new(line_number_style: :'line-numbers').fetch_first_definition("bar")
|
72
|
+
expect(decolor code).to include <<EOF
|
73
|
+
11: enum bar {
|
74
|
+
12: alpha,
|
75
|
+
13: beta,
|
76
|
+
14: gamma
|
77
|
+
15: };
|
78
|
+
EOF
|
79
|
+
end
|
80
|
+
|
81
|
+
context "base one style (line numbers start with 1)" do
|
82
|
+
it "displays actual line numbers" do
|
83
|
+
code, = described_class.new(line_number_style: :'base-one').fetch_first_definition("bar")
|
84
|
+
expect(decolor code).to include <<EOF
|
85
|
+
1: enum bar {
|
86
|
+
2: alpha,
|
87
|
+
3: beta,
|
88
|
+
4: gamma
|
89
|
+
5: };
|
90
|
+
EOF
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
81
96
|
it "returns the code for a function" do
|
82
97
|
code, = described_class.new(line_number_style: nil).fetch_first_definition("foo")
|
83
98
|
expect(decolor code).to include(<<EOF
|
@@ -125,6 +140,28 @@ struct baz {
|
|
125
140
|
};
|
126
141
|
EOF
|
127
142
|
end
|
143
|
+
|
144
|
+
it "returns the code for a typedef'd struct" do
|
145
|
+
code, = described_class.new(line_number_style: nil).fetch_first_definition("cutie_pie")
|
146
|
+
expect(decolor code).to include <<EOF
|
147
|
+
typedef struct {
|
148
|
+
int lovely;
|
149
|
+
char horse;
|
150
|
+
} cutie_pie;
|
151
|
+
EOF
|
152
|
+
end
|
153
|
+
|
154
|
+
it "returns the code for a typedef'd enum" do
|
155
|
+
code, = described_class.new(line_number_style: nil).fetch_first_definition("baby_enum")
|
156
|
+
expect(decolor code).to include <<EOF
|
157
|
+
typedef enum cute_enum_e {
|
158
|
+
lillybing,
|
159
|
+
tote,
|
160
|
+
lilt
|
161
|
+
} baby_enum;
|
162
|
+
EOF
|
163
|
+
end
|
164
|
+
|
128
165
|
end
|
129
166
|
end
|
130
167
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.0pre7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mair (banisterfiend)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|