glossarist 1.0.8 → 1.0.9

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: 1b9c24fe8cac3a89767546bdf30adc9f927f4d1e0981e245d35bef08654d9c28
4
- data.tar.gz: 936351fa08da1ec9b0f6528e4c31ab4e3362e305fbaed9d9030b5a946e5777b3
3
+ metadata.gz: b8fa4ca87465329dfee265b0c813794fbb857d5bbd174c2f7f28f6b4e678f372
4
+ data.tar.gz: c83f9967b06603b4e756f47a8c9bd78ad89b0c1ac8201d6bfcd34c2efc0c5db4
5
5
  SHA512:
6
- metadata.gz: 16f57277fea7401f46dd1293b2a08715209b449d4eb0ed6f4971b9c94b75c16cd7af1528f665239c5d55bf79945ac250f626fde7a9075807883509b5ac1fba2e
7
- data.tar.gz: 183fb995759607328a8c881cd2f15f88390ad7f465d8b0ed0634fc8f6ad919bb25d4ee9c8ff0350343248a74b02a91bc7a10b9c0907ce591bd46e10a464f7c82
6
+ metadata.gz: 06207f39595d5ba32421f836268c71a081b028b32183062096c994fef1d794007f32093992716c97a39e91ccda07879405d934d7ea4e9746cf14470fd6e48993
7
+ data.tar.gz: 53b67a4ed78221ea53e2d4d498a39bf01b487d1ec7682a39da16a00ae17dfabc0f162a4b39ea25a6a8dc4259c30e3f0c38835743fbda821b4f53c4dd77ea8318
@@ -65,21 +65,25 @@ module Glossarist
65
65
  end
66
66
  end
67
67
 
68
- private def load_concept_from_file(filename)
69
- Concept.from_h(Psych.safe_load(File.read(filename)))
70
- end
71
-
72
68
  # Writes all concepts to files.
73
69
  def save_concepts
74
70
  @index.each_value &method(:save_concept_to_file)
75
71
  end
76
72
 
77
- private def save_concept_to_file(concept)
73
+ private
74
+
75
+ def load_concept_from_file(filename)
76
+ Concept.from_h(Psych.safe_load(File.read(filename)))
77
+ rescue Psych::SyntaxError => e
78
+ raise Glossarist::ParseError.new(filename: filename, line: e.line)
79
+ end
80
+
81
+ def save_concept_to_file(concept)
78
82
  filename = File.join(path, "concept-#{concept.id}.yaml")
79
83
  File.write(filename, Psych.dump(concept.to_h))
80
84
  end
81
85
 
82
- private def concepts_glob
86
+ def concepts_glob
83
87
  File.join(path, "concept-*.{yaml,yml}")
84
88
  end
85
89
  end
@@ -28,6 +28,8 @@ module Glossarist
28
28
 
29
29
  def load_concept_from_file(filename)
30
30
  ManagedConcept.new(Psych.safe_load(File.read(filename)))
31
+ rescue Psych::SyntaxError => e
32
+ raise Glossarist::ParseError.new(filename: filename, line: e.line)
31
33
  end
32
34
 
33
35
  def save_concept_to_file(concept)
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "1.0.8"
7
+ VERSION = "1.0.9"
8
8
  end
data/lib/glossarist.rb CHANGED
@@ -33,7 +33,23 @@ require_relative "glossarist/config"
33
33
 
34
34
  module Glossarist
35
35
  class Error < StandardError; end
36
+
36
37
  class InvalidTypeError < StandardError; end
38
+
39
+ class ParseError < StandardError
40
+ attr_accessor :line, :filename
41
+
42
+ def initialize(filename:, line: nil)
43
+ @filename = filename
44
+ @line = line
45
+
46
+ super()
47
+ end
48
+
49
+ def to_s
50
+ "Unable to parse file: #{filename}, error on line: #{line}"
51
+ end
52
+ end
37
53
  # Your code goes here...
38
54
 
39
55
  def self.configure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-03 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton