sus 0.18.1 → 0.18.2

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: e39bdf28a3135bf28cf66714d3ac2998c1c863e979c172573a3e5e509de2246e
4
- data.tar.gz: 88273ca646abe719cb562693f233d6210d8e505456ae8dd663d74971086d33b7
3
+ metadata.gz: 7368b0ed0e288959f59f0fe6c2c5dd93ff90ba52f423b1365406e8de260536c1
4
+ data.tar.gz: 10fe5fec8209ce9cea739f580a3f4bd1b36be3b6e384f6ff85ad813fad32d0f2
5
5
  SHA512:
6
- metadata.gz: eca3ca7daddbc30591698658f6d87cc11a56c9dee2456b1060339fe1442aa5d8479a11ccdf7d9f4e7d617478ff033b0c24482db8d8145b7046e69a106a75409c
7
- data.tar.gz: 2df536e6206a37f475bde130d8a6f8f4f8c8eab49a3ea2f7d29f48b4a64b53d6145cc77c27f2105043385756cc8d44d34983334a6de633c5c8d78275777b1ee7
6
+ metadata.gz: 1456e34138bea3c5952ababab2950ac946ddce0a3f55879ed1bedb9828c536ffb5c4ced7b9a35f4e80ad1879e230dd26b0fc120b7258e218710530165d9233e5
7
+ data.tar.gz: b1ea6d027ec46f0aa72e74fd6cb169a71b5209a57791b52b7f41c1a1f2fc7d70353e08e73ebfef2d7262e67a7be10702500d07ee99f18499d898de5b0ad917ed
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sus/file.rb CHANGED
@@ -9,6 +9,17 @@ require_relative 'context'
9
9
  # This has to be done at the top level. It allows us to define constants within the given class while still retaining top-level constant resolution.
10
10
  Sus::TOPLEVEL_CLASS_EVAL = ->(__klass__, __path__){__klass__.class_eval(::File.read(__path__), __path__)}
11
11
 
12
+ # This is a hack to allow us to get the line number of a syntax error.
13
+ unless SyntaxError.method_defined?(:lineno)
14
+ class SyntaxError
15
+ def lineno
16
+ if message =~ /:(\d+):/
17
+ $1.to_i
18
+ end
19
+ end
20
+ end
21
+ end
22
+
12
23
  module Sus
13
24
  module File
14
25
  extend Context
@@ -41,7 +52,15 @@ module Sus
41
52
 
42
53
  class FileLoadError
43
54
  def self.build(parent, path, error)
44
- identity = Identity.file(parent.identity, path).scoped(error.backtrace_locations)
55
+ identity = Identity.file(parent.identity, path)
56
+
57
+ # This is a mess.
58
+ if error.is_a?(SyntaxError) and error.path == path
59
+ identity = identity.with_line(error.lineno)
60
+ else
61
+ identity = identity.scoped(error.backtrace_locations)
62
+ end
63
+
45
64
  self.new(identity, path, error)
46
65
  end
47
66
 
@@ -52,6 +71,7 @@ module Sus
52
71
  end
53
72
 
54
73
  attr :identity
74
+ attr :error
55
75
 
56
76
  def leaf?
57
77
  true
data/lib/sus/identity.rb CHANGED
@@ -26,6 +26,10 @@ module Sus
26
26
  @key = nil
27
27
  end
28
28
 
29
+ def with_line(line)
30
+ self.class.new(@path, @name, line, @parent, unique: @unique)
31
+ end
32
+
29
33
  attr :path
30
34
  attr :name
31
35
  attr :line
@@ -103,10 +107,6 @@ module Sus
103
107
 
104
108
  protected
105
109
 
106
- def with_line(line)
107
- Identity.new(@path, @name, line, @parent, unique: @unique)
108
- end
109
-
110
110
  def append_unique_key(key, unique = @unique)
111
111
  if @parent
112
112
  @parent.append_unique_key(key)
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.18.1"
7
+ VERSION = "0.18.2"
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file