stepmod-utils 0.3.13 → 0.3.14

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: bb7bf9af17dc5e00cbaa48dbadcca9866867c666f27454fdcedd05cc10424e77
4
- data.tar.gz: e082809ce1ba11806170e75ab9e35e4fb32dbf5062b0cc991c52a320adef12d0
3
+ metadata.gz: 2dbfad6cebbd4552c2b91cfd5aac3dc5a032bde8a44269b83303d8472bf86310
4
+ data.tar.gz: 185a292f76f2e5b792383b8f2ca17438cb939a557f3df763ed5c9321c28b7438
5
5
  SHA512:
6
- metadata.gz: 8f181ca96460491b225d3f589092af504c18dc684d1d561556ab0504f148e01413566a05a17ccfe7f4de8fd8f6d0b154949d2e7fea3b21d9cd3bbdcf162285df
7
- data.tar.gz: 6cfe79605d3aa7da7387caf85b1374dec3601eec9880f1740364976feb12b218908635dffc1bc446fc519458856e4a5e55e9fffaca677e3cdbf1c7d0c6b86b4e
6
+ metadata.gz: a6f855167c151253c8b2278dfafe460198fe2c7789ce3cb2eba4dca20dc216546d88b68f199f48a6508574b1c28eaf476604799c99b3762662269eec743e0d5e
7
+ data.tar.gz: a85e8f5a2d4607f5c001c5889c4549d2698279bb5163b3e87c79e5e28c3f0bbea7a38dd56d3440af3b43467ac2d93d7b16407d63f27c7abc61ca3fe1f5aa6551
data/README.adoc CHANGED
@@ -10,7 +10,8 @@ image:https://img.shields.io/github/commits-since/metanorma/stepmod-utils/latest
10
10
 
11
11
  == Purpose
12
12
 
13
- The `stepmod-utils` Ruby gem provides a number of tools to work with the STEPmod repository.
13
+ The `stepmod-utils` Ruby gem provides a number of tools to work with the STEPmod
14
+ repository.
14
15
 
15
16
 
16
17
  == CVS to Git migration procedures
@@ -31,11 +32,8 @@ Or include it in your gemspec.
31
32
 
32
33
  [source,sh]
33
34
  ----
34
- # Extracts from current directory
35
- $ stepmod-extract-terms
36
-
37
- # Extracts from specified stepmod/ or stepmod/data/ directory
38
- $ stepmod-extract-terms {stepmod-data-directory}
35
+ # Extracts from specified stepmod/data/ directory
36
+ $ stepmod-extract-terms -p {stepmod-data-directory} -i {path-to-repository_index.xml}
39
37
  ----
40
38
 
41
39
  Then these files will be created:
@@ -21,14 +21,48 @@ end
21
21
  require "bundler/setup"
22
22
  require "stepmod/utils/terms_extractor"
23
23
 
24
- stepmod_dir = ARGV.first || Dir.pwd
24
+ require 'optparse'
25
+
26
+ options = {}
27
+ OptionParser.new do |opts|
28
+ opts.banner = "Usage: #{$0} [options]"
29
+
30
+ opts.on("-p", "--path STEPMOD_DATA_PATH", String, "Path to STEPmod CVS data directory") do |path|
31
+ options[:stepmod_dir] = path
32
+ end
33
+
34
+ opts.on("-i", "--index INDEX_PATH", String, "Path to repository_index.xml") do |path|
35
+ unless path.nil?
36
+ options[:index_path] = Pathname.new(path).to_s
37
+ end
38
+ end
39
+
40
+ opts.on_tail("-h", "--help", "Show this message") do
41
+ puts opts
42
+ exit
43
+ end
44
+ end.parse!
45
+
46
+ stepmod_dir = options[:stepmod_dir]
47
+ if stepmod_dir.nil?
48
+ raise StandardError.new("STEPmod data path not set, set with the `-p` option.")
49
+ else
50
+ log "STEPmod data path: `#{stepmod_dir}`"
51
+ end
52
+
53
+ index_path = options[:index_path] || File.join(stepmod_dir, "repository_index.xml")
54
+ unless File.exists?(index_path)
55
+ raise StandardError.new("Index file not present at #{index_path}, set with the `-i` option.")
56
+ else
57
+ log "Repository index path: `#{index_path}`"
58
+ end
25
59
 
26
60
  general_concepts,
27
61
  resource_concepts,
28
62
  parsed_bibliography,
29
63
  part_concepts,
30
64
  part_resources,
31
- part_modules = Stepmod::Utils::TermsExtractor.call(stepmod_dir)
65
+ part_modules = Stepmod::Utils::TermsExtractor.call(stepmod_dir, index_path)
32
66
 
33
67
  def part_to_title(bibdata)
34
68
  case bibdata.part.to_i
@@ -15,6 +15,7 @@ module Stepmod
15
15
 
16
16
  attr_reader :stepmod_path,
17
17
  :stepmod_dir,
18
+ :index_path,
18
19
  :general_concepts,
19
20
  :resource_concepts,
20
21
  :parsed_bibliography,
@@ -25,14 +26,15 @@ module Stepmod
25
26
  :part_modules,
26
27
  :stdout
27
28
 
28
- def self.call(stepmod_dir, stdout = $stdout)
29
- new(stepmod_dir, stdout).call
29
+ def self.call(stepmod_dir, index_path, stdout = $stdout)
30
+ new(stepmod_dir, index_path, stdout).call
30
31
  end
31
32
 
32
- def initialize(stepmod_dir, stdout)
33
+ def initialize(stepmod_dir, index_path, stdout)
33
34
  @stdout = stdout
34
35
  @stepmod_dir = stepmod_dir
35
36
  @stepmod_path = Pathname.new(stepmod_dir).realpath
37
+ @index_path = Pathname.new(index_path).to_s
36
38
  @general_concepts = Glossarist::Collection.new
37
39
  @resource_concepts = Glossarist::Collection.new
38
40
  @parsed_bibliography = []
@@ -79,7 +81,7 @@ module Stepmod
79
81
 
80
82
  log "INFO: Detecting paths..."
81
83
 
82
- repo_index = Nokogiri::XML(File.read(stepmod_path.join("repository_index.xml"))).root
84
+ repo_index = Nokogiri::XML(File.read(@index_path)).root
83
85
 
84
86
  files = []
85
87
 
@@ -1,5 +1,5 @@
1
1
  module Stepmod
2
2
  module Utils
3
- VERSION = "0.3.13".freeze
3
+ VERSION = "0.3.14".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stepmod-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-11 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby