Class: Glossarist::GcrPackage

Inherits:
Object
  • Object
show all
Defined in:
lib/glossarist/gcr_package.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zip_path) ⇒ GcrPackage

Returns a new instance of GcrPackage.



10
11
12
13
14
# File 'lib/glossarist/gcr_package.rb', line 10

def initialize(zip_path)
  @zip_path = zip_path
  @metadata = nil
  @concepts = []
end

Instance Attribute Details

#conceptsObject (readonly)

Returns the value of attribute concepts.



8
9
10
# File 'lib/glossarist/gcr_package.rb', line 8

def concepts
  @concepts
end

#metadataObject (readonly)

Returns the value of attribute metadata.



8
9
10
# File 'lib/glossarist/gcr_package.rb', line 8

def 
  @metadata
end

#zip_pathObject (readonly)

Returns the value of attribute zip_path.



8
9
10
# File 'lib/glossarist/gcr_package.rb', line 8

def zip_path
  @zip_path
end

Class Method Details

.create(concepts:, metadata:, output_path:, register_data: nil) ⇒ Object



16
17
18
19
20
21
# File 'lib/glossarist/gcr_package.rb', line 16

def self.create(concepts:, metadata:, output_path:, register_data: nil)
  FileUtils.mkdir_p(File.dirname(output_path))
  package = new(output_path)
  package.send(:write, concepts, , register_data)
  package
end

.create_from_directory(dir, output:, shortname:, version:, title: nil, description: nil, owner: nil, tags: [], register_yaml: nil, uri_prefix: nil, concept_uri_template: nil, streaming: false) ⇒ Object

rubocop:disable Metrics/MethodLength, Metrics/ParameterLists



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/glossarist/gcr_package.rb', line 29

def self.create_from_directory(dir, output:, shortname:, version:, # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
                              title: nil, description: nil, owner: nil,
                              tags: [], register_yaml: nil,
                              uri_prefix: nil, concept_uri_template: nil,
                              streaming: false)
  dir = File.expand_path(dir)

  if streaming
    create_streaming(dir, output: output, shortname: shortname, version: version,
                          title: title, description: description, owner: owner,
                          tags: tags, register_yaml: register_yaml,
                          uri_prefix: uri_prefix,
                          concept_uri_template: concept_uri_template)
  else
    create_batch(dir, output: output, shortname: shortname, version: version,
                      title: title, description: description, owner: owner,
                      tags: tags, register_yaml: register_yaml,
                      uri_prefix: uri_prefix,
                      concept_uri_template: concept_uri_template)
  end
end

.load(zip_path) ⇒ Object



23
24
25
26
27
# File 'lib/glossarist/gcr_package.rb', line 23

def self.load(zip_path)
  package = new(zip_path)
  package.send(:read)
  package
end

Instance Method Details

#validateObject



51
52
53
# File 'lib/glossarist/gcr_package.rb', line 51

def validate
  GcrValidator.new.validate(@zip_path)
end