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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e5fae70c3b672c0a57efee7e021fa86c6ef1586
4
- data.tar.gz: 302b6c3613a02d57db30d5afdfceda1a92c1e1a1
3
+ metadata.gz: 1fe5690b5654faa5d41644a0e2f86a573ab8f8ca
4
+ data.tar.gz: 4cacdd3df7e3fb516a501fe7b2897bb3700d520c
5
5
  SHA512:
6
- metadata.gz: 9dd33d3fabc2fc0500cd5131d8561000318d4475ac8f6d41fee1a283b19a4e434350db09fd38bbc4f7071a4fe62efda389da593dedcf5d4a33d883e851b3bf60
7
- data.tar.gz: 6591d7b75244cd9df7761f5e456144d128da03a260ff901ce0c1c7f676e01752a247810fbb4bedba96946c1d020120544471343818bb0ca5438ce3731f6e0b03
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
- source += line[indent..-1]
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
@@ -1,3 +1,3 @@
1
1
  module ReadSource
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
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
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-23 00:00:00.000000000 Z
11
+ date: 2017-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler