glossarist-new 1.0.3 → 1.0.4

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: f0b88c582178e67916b7058bba75f92a14b5862926188092fa6e539c0eb05ad5
4
- data.tar.gz: c7d3c4e294f2f77279e712d865239a824ea84ee8fb2a884e23f935c9ca5b871e
3
+ metadata.gz: 33417ab36e59957a55a83d33feb67f9657d1a790c72200a113a8da5d5da30dbb
4
+ data.tar.gz: 394244acd5674b48b66316576472f23bab6d9ffb9c8d9cac6febe592827d75a7
5
5
  SHA512:
6
- metadata.gz: 2ed31f71ae7f554ed6e4f32f27f2203d78c66ce95e6f1e33502cc610142d9cef534ba21fe6a01aee37bf75f6d889b61f99780448e12aa591e4454cf73986d891
7
- data.tar.gz: aa4f3b7c9882afde4d1bbf541ccf509150e434a63fa0f68314d6f72e48d344a22d73524eed91524b5b81c83105cc9917c5c469a24560c181619fe0c10c827f01
6
+ metadata.gz: d855e52b2d3d48a1b2a7c46190a229af9e0597f2b971e18a3d73ad3194387fba2f9a8d270abe8840f59bd9940d4802ec6b2dcaf8b9422f425dcb7fd172a66a8a
7
+ data.tar.gz: 75414f5177abe52d0fa160d5cb5769ea27ba175f89cfa6e7aa2c6fdb8c3d26e03e00181b310d85e3e0e6dba93cfbbeab0c61dca9e3f74260bc77706cdd6b94ac
data/README.adoc CHANGED
@@ -1,5 +1,28 @@
1
1
  = Glossarist
2
2
 
3
+ == Commands
4
+
5
+ generate_latex: Convert Concepts to Latex format
6
+
7
+ === Usage:
8
+ glossarist generate_latex p, --concepts-path=CONCEPTS_PATH
9
+
10
+ === Options:
11
+ [cols="1,1"]
12
+ |===
13
+ |p, --concepts-path
14
+ |Path to yaml concepts directory
15
+
16
+ |l, --latex-concepts
17
+ |File path having list of concepts that should be converted to LATEX format. If not provided all the concepts will be converted to the latex format
18
+
19
+ |o, --output-file
20
+ |Output file path. By default the output will pe printed to the console
21
+
22
+ |e, --extra-attributes
23
+ |List of extra attributes that are not in standard Glossarist Concept model. eg -e one two three
24
+ |===
25
+
3
26
  == Credits
4
27
 
5
28
  This gem is developed, maintained and funded by
data/exe/glossarist ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/glossarist"
4
+
5
+ class GlossaristCommand < Thor
6
+ desc "generate_latex", "Convert Concepts to Latex format"
7
+
8
+ option :concepts_path, aliases: :p, required: true, desc: "Path to yaml concepts directory"
9
+ option :latex_concepts, aliases: :l, desc: "File path having list of concepts that should be converted to LATEX format. If not provided all the concepts will be converted to the latex format"
10
+ option :output_file, aliases: :o, desc: "Output file path. By default the output will pe printed to the console"
11
+ option :extra_attributes, aliases: :e, type: :array, desc: "List of extra attributes that are not in standard Glossarist Concept model"
12
+ def generate_latex
13
+ assets = []
14
+ latex_concepts_file = options[:latex_concepts]
15
+
16
+ if options[:extra_attributes]
17
+ Glossarist.configure do |config|
18
+ config.register_extension_attributes(options[:extra_attributes])
19
+ end
20
+ end
21
+
22
+ concept_set = Glossarist::ConceptSet.new(options[:concepts_path], assets)
23
+ latex_str = concept_set.to_latex(latex_concepts_file)
24
+
25
+ output_file_path = options[:output_file]
26
+ if output_file_path
27
+ File.open(output_file_path, "w") do |file|
28
+ file.puts latex_str
29
+ end
30
+ else
31
+ puts latex_str
32
+ end
33
+ end
34
+
35
+ def method_missing(*args)
36
+ warn "No method found named: #{args[0]}"
37
+ warn "Run with `--help` or `-h` to see available options"
38
+ exit 1
39
+ end
40
+
41
+ def respond_to_missing?
42
+ true
43
+ end
44
+
45
+ def self.exit_on_failure?
46
+ true
47
+ end
48
+ end
49
+
50
+ GlossaristCommand.start(ARGV)
data/glossarist.gemspec CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "relaton", "~>1.13.0"
34
+ spec.add_dependency "thor"
34
35
 
35
36
  spec.add_development_dependency "pry", "~> 0.14.0"
36
37
  spec.add_development_dependency "rake", "~> 13.0"
@@ -40,12 +40,16 @@ module Glossarist
40
40
  # @return [Array<DetailedDefinition>]
41
41
  attr_reader :examples
42
42
 
43
+ # Contains list of extended attributes
44
+ attr_accessor :extension_attributes
45
+
43
46
  def initialize(*)
44
47
  @localizations = {}
45
48
  @sources = []
46
49
  @related = []
47
50
  @notes = []
48
51
  @designations = []
52
+ @extension_attributes = {}
49
53
 
50
54
  super
51
55
  end
@@ -14,6 +14,7 @@ module Glossarist
14
14
 
15
15
  def initialize
16
16
  @registered_classes = DEFAULT_CLASSES.dup
17
+ @extension_attributes = []
17
18
  end
18
19
 
19
20
  def class_for(name)
@@ -24,14 +25,30 @@ module Glossarist
24
25
  @registered_classes[class_name] = klass
25
26
  end
26
27
 
28
+ def extension_attributes
29
+ @extension_attributes
30
+ end
31
+
32
+ def register_extension_attributes(attributes)
33
+ @extension_attributes = attributes
34
+ end
35
+
27
36
  class << self
28
37
  def class_for(name)
29
38
  self.instance.class_for(name)
30
39
  end
31
40
 
41
+ def extension_attributes
42
+ self.instance.extension_attributes
43
+ end
44
+
32
45
  def register_class(class_name, klass)
33
46
  self.instance.register_class(class_name, klass)
34
47
  end
48
+
49
+ def register_extension_attributes(attributes)
50
+ self.register_extension_attributes(attributes)
51
+ end
35
52
  end
36
53
  end
37
54
  end
@@ -44,7 +44,7 @@ module Glossarist
44
44
  "review_date" => review_date,
45
45
  "review_decision_date" => review_decision_date,
46
46
  "review_decision_event" => review_decision_event,
47
- }.compact)
47
+ }.compact).merge(@extension_attributes)
48
48
  end
49
49
 
50
50
  def self.from_h(hash)
@@ -18,8 +18,12 @@ module Glossarist
18
18
  def set_attribute(name, value)
19
19
  public_send("#{name}=", value)
20
20
  rescue NoMethodError
21
- raise ArgumentError, "#{self.class.name} does not have " +
22
- "attribute #{name} defined or the attribute is read only."
21
+ if Config.extension_attributes.include?(name)
22
+ extension_attributes[name] = value
23
+ else
24
+ raise ArgumentError, "#{self.class.name} does not have " +
25
+ "attribute #{name} defined or the attribute is read only."
26
+ end
23
27
  end
24
28
 
25
29
  def self.from_h(hash)
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "1.0.3"
7
+ VERSION = "1.0.4"
8
8
  end
data/lib/glossarist.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  #
5
5
 
6
6
  require "psych"
7
+ require "thor"
7
8
 
8
9
  require_relative "glossarist/utilities"
9
10
  require_relative "glossarist/version"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist-new
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-10 00:00:00.000000000 Z
11
+ date: 2023-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pry
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +83,8 @@ dependencies:
69
83
  description:
70
84
  email:
71
85
  - open.source@ribose.com
72
- executables: []
86
+ executables:
87
+ - glossarist
73
88
  extensions: []
74
89
  extra_rdoc_files: []
75
90
  files:
@@ -84,6 +99,7 @@ files:
84
99
  - README.adoc
85
100
  - Rakefile
86
101
  - config.yml
102
+ - exe/glossarist
87
103
  - glossarist.gemspec
88
104
  - lib/glossarist.rb
89
105
  - lib/glossarist/asset.rb