read_source 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/read_source/read_source.rb +13 -1
- data/lib/read_source/version.rb +1 -1
- 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: 1fe5690b5654faa5d41644a0e2f86a573ab8f8ca
|
4
|
+
data.tar.gz: 4cacdd3df7e3fb516a501fe7b2897bb3700d520c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89131c96ad04b06847fd7e55ca2f3180ec5b8530552d170071206e6d6ea5353b4c5a7273f5f06dcba1e7f2d819fec3243bb0d07c021cbfeab703a6885cb56df8
|
7
|
+
data.tar.gz: 5ccbccb6a4f88f3cf4d267625617256958137942dd7b4b980912c2319d97ff5eab4473f6470b64ba0ada4d235a2c993fa6e970657eb38b0e7da06aee79bce570
|
@@ -3,6 +3,11 @@ module ReadSource
|
|
3
3
|
def read_source
|
4
4
|
(file, line_num = send :source_location) || return
|
5
5
|
|
6
|
+
if file == "(irb)"
|
7
|
+
warn "This feature doesn't work for code written in IRB!"
|
8
|
+
return
|
9
|
+
end
|
10
|
+
|
6
11
|
is_inline_method = ->str{
|
7
12
|
defs = str.scan(/def(?:\b|ine_method.*do)/).count
|
8
13
|
ends = str.scan(/end/).count
|
@@ -16,7 +21,8 @@ module ReadSource
|
|
16
21
|
source = source[indent..-1]
|
17
22
|
return source if source.=~(/\A[[:space:]]*attr[\w]*/) || is_inline_method.(source)
|
18
23
|
readlines[line_num..-1].each do |line|
|
19
|
-
|
24
|
+
add_line = line =~ /\A[[:space:]]*\n\z/ ? "\n" : line[indent..-1]
|
25
|
+
source += add_line
|
20
26
|
if indent == /\A[[:space:]]*/.match(line).to_s.length
|
21
27
|
break source
|
22
28
|
end
|
@@ -25,6 +31,12 @@ module ReadSource
|
|
25
31
|
|
26
32
|
def attr?
|
27
33
|
(file, line_num = send :source_location) || return
|
34
|
+
|
35
|
+
if file == "(irb)"
|
36
|
+
warn "This feature doesn't work for code written in IRB!"
|
37
|
+
return
|
38
|
+
end
|
39
|
+
|
28
40
|
def_header = IO.readlines(file)[line_num-1]
|
29
41
|
return unless def_header =~ /\A[[:space:]]*attr[\w]*/
|
30
42
|
def_header[/attr[\w]*/].to_sym rescue nil
|
data/lib/read_source/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: read_source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|