sus 0.18.1 → 0.19.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e39bdf28a3135bf28cf66714d3ac2998c1c863e979c172573a3e5e509de2246e
4
- data.tar.gz: 88273ca646abe719cb562693f233d6210d8e505456ae8dd663d74971086d33b7
3
+ metadata.gz: cfeea4d70fa47d75bd19bf498b1172dc61124f1d3cc517800c70ae087342c14c
4
+ data.tar.gz: e1b2279e1168e680fd068af67f6d44f376cfe1c7c74728b7506f661dafdb1db9
5
5
  SHA512:
6
- metadata.gz: eca3ca7daddbc30591698658f6d87cc11a56c9dee2456b1060339fe1442aa5d8479a11ccdf7d9f4e7d617478ff033b0c24482db8d8145b7046e69a106a75409c
7
- data.tar.gz: 2df536e6206a37f475bde130d8a6f8f4f8c8eab49a3ea2f7d29f48b4a64b53d6145cc77c27f2105043385756cc8d44d34983334a6de633c5c8d78275777b1ee7
6
+ metadata.gz: b09f509fccb65717ae48c657ecb0a2e530761276614d3dc1f9f49fb131caeaf074cbd4bfef1458e029b38347b3aa95a3eb93f7cf6fd7ceeb6e0a23914bbaca66
7
+ data.tar.gz: ac457785b0c6753fd85107c08a37ae735ba1b4e9716aa3b167e51a2de0e5d27dea4a93062c730af5fb36a4a5279472cef71c20431d5602778d04040c6c420d83
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.19.0"
8
8
  end
data/lib/sus/with.rb CHANGED
@@ -44,7 +44,9 @@ module Sus
44
44
  end
45
45
 
46
46
  module Context
47
- def with(subject, **variables, &block)
47
+ def with(subject = nil, **variables, &block)
48
+ subject ||= variables.inspect
49
+
48
50
  add With.build(self, subject, variables, &block)
49
51
  end
50
52
  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.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file