laplus 0.2.0 → 0.3.0

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: 8d9a7313969eddd93b1d3cd04dcfe984903118ca5a59f569ceae4d192631df2b
4
- data.tar.gz: 836c649f816ce8c5420cfd0780e2739c53348e77a845c252e3a9a6619bffbe09
3
+ metadata.gz: de6ad79a56f5facce27f63ce4737ad9cd877a56b8dc8a5c2f407dc5e1d0a8faa
4
+ data.tar.gz: 599548f568c96d3beea261ff4bdf7fa7ecdc8f6b3a42721c07af7d6402f22f71
5
5
  SHA512:
6
- metadata.gz: 83e991aa35c6a7cd394ea56128b726b91555ecda9f9acdd27e60ef2539a3c2890552660f0ba318476b545d51436acb8b2185759bf4995f85a3f696885200b85e
7
- data.tar.gz: 5855b09beef4e874107dff83f46aea02c0ea2ca866ab5cae5146cbced41d46ef0289eb6068f892e694963bf23864d76de980884ea916f0bff76fb3fad88e59da
6
+ metadata.gz: afbd34930cd53863913cfe57b5d35bd758ff2d1291ff5f996c475aeeb37ebf034b81f98e18e5c1d34d679b68856c1d58b880c515316c76c26b25311d46d7f6be
7
+ data.tar.gz: 12975a26a3b567264fc5a47ff949a27c1ff11591e5708bb2c5ce45a336fe6ee678f687a248b60373e388460ec97acbec209e2f71b0af25375e7754a6ca4fc40a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- laplus (0.2.0)
4
+ laplus (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
 
@@ -4,5 +4,6 @@ module Laplus
4
4
  module InspectStrategy
5
5
  autoload :Base, 'laplus/inspect_strategy/base'
6
6
  autoload :MethodStrategy, 'laplus/inspect_strategy/method_strategy'
7
+ autoload :ProcStrategy, 'laplus/inspect_strategy/proc_strategy'
7
8
  end
8
9
  end
@@ -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
@@ -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
- raise NotImplementedError
22
+ InspectStrategy::ProcStrategy.new(self)
25
23
  else
26
24
  raise NotImplementedError
27
25
  end
@@ -1,3 +1,3 @@
1
1
  module Laplus
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-17 00:00:00.000000000 Z
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