laplus 0.2.0 → 0.3.0
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/Gemfile.lock +1 -1
- data/lib/laplus.rb +2 -1
- data/lib/laplus/inspect_strategy.rb +1 -0
- data/lib/laplus/inspect_strategy/method_strategy.rb +0 -5
- data/lib/laplus/inspect_strategy/proc_strategy.rb +30 -0
- data/lib/laplus/inspector.rb +1 -3
- data/lib/laplus/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6ad79a56f5facce27f63ce4737ad9cd877a56b8dc8a5c2f407dc5e1d0a8faa
|
4
|
+
data.tar.gz: 599548f568c96d3beea261ff4bdf7fa7ecdc8f6b3a42721c07af7d6402f22f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afbd34930cd53863913cfe57b5d35bd758ff2d1291ff5f996c475aeeb37ebf034b81f98e18e5c1d34d679b68856c1d58b880c515316c76c26b25311d46d7f6be
|
7
|
+
data.tar.gz: 12975a26a3b567264fc5a47ff949a27c1ff11591e5708bb2c5ce45a336fe6ee678f687a248b60373e388460ec97acbec209e2f71b0af25375e7754a6ca4fc40a
|
data/Gemfile.lock
CHANGED
data/lib/laplus.rb
CHANGED
@@ -13,6 +13,7 @@ module Laplus
|
|
13
13
|
|
14
14
|
autoload :Inspector, 'laplus/inspector'
|
15
15
|
autoload :Source, 'laplus/source'
|
16
|
+
autoload :InspectStrategy, 'laplus/inspect_strategy'
|
16
17
|
|
17
18
|
autoload :UI, 'laplus/ui'
|
18
19
|
autoload :Helper, 'laplus/helper'
|
@@ -20,7 +21,7 @@ module Laplus
|
|
20
21
|
autoload :IRBCommandExtension, 'laplus/repl_extensions/irb_command_extension'
|
21
22
|
end
|
22
23
|
|
23
|
-
[Method, UnboundMethod].each do |klass|
|
24
|
+
[Method, UnboundMethod, Proc].each do |klass|
|
24
25
|
klass.include Laplus::Extension
|
25
26
|
end
|
26
27
|
|
@@ -3,11 +3,6 @@
|
|
3
3
|
module Laplus
|
4
4
|
module InspectStrategy
|
5
5
|
class MethodStrategy < Base
|
6
|
-
# if with_super && method.respond_to?(:super_method) && method.super_method
|
7
|
-
# method.super_method.definition(with_super) + [MethodDefinition.definition(method)]
|
8
|
-
# else
|
9
|
-
# [MethodDefinition.definition(method)]
|
10
|
-
# end
|
11
6
|
def inspect
|
12
7
|
method = inspector.object
|
13
8
|
path, line = method.source_location
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Laplus
|
4
|
+
module InspectStrategy
|
5
|
+
class ProcStrategy < Base
|
6
|
+
def inspect
|
7
|
+
_proc = inspector.object
|
8
|
+
|
9
|
+
path, line = _proc.source_location
|
10
|
+
|
11
|
+
snippet = if _proc.source_location.nil?
|
12
|
+
'(defined in clang)'
|
13
|
+
elsif !File.exist?(path)
|
14
|
+
"defined at #{path}. but no such file."
|
15
|
+
else
|
16
|
+
Source.new(path).snip_code_at(line)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
desc_lines = []
|
21
|
+
desc_lines << ''
|
22
|
+
desc_lines << "#{path}:#{line}"
|
23
|
+
desc_lines << ''
|
24
|
+
desc_lines << UI::Indention.split(snippet).offset.indent(0).chomp
|
25
|
+
|
26
|
+
desc_lines.join("\n")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/laplus/inspector.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'laplus/inspect_strategy'
|
4
|
-
|
5
3
|
module Laplus
|
6
4
|
class Inspector
|
7
5
|
attr_reader :object
|
@@ -21,7 +19,7 @@ module Laplus
|
|
21
19
|
when Method, UnboundMethod
|
22
20
|
InspectStrategy::MethodStrategy.new(self)
|
23
21
|
when Proc
|
24
|
-
|
22
|
+
InspectStrategy::ProcStrategy.new(self)
|
25
23
|
else
|
26
24
|
raise NotImplementedError
|
27
25
|
end
|
data/lib/laplus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: laplus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nishisuke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/laplus/inspect_strategy.rb
|
80
80
|
- lib/laplus/inspect_strategy/base.rb
|
81
81
|
- lib/laplus/inspect_strategy/method_strategy.rb
|
82
|
+
- lib/laplus/inspect_strategy/proc_strategy.rb
|
82
83
|
- lib/laplus/inspector.rb
|
83
84
|
- lib/laplus/parser.rb
|
84
85
|
- lib/laplus/repl_extensions/irb_command_extension.rb
|