Module: Bipm::Data::Outcomes
- Includes:
- Enumerable
- Defined in:
- lib/bipm/data/outcomes.rb,
lib/bipm/data/outcomes/body.rb,
lib/bipm/data/outcomes/action.rb,
lib/bipm/data/outcomes/meeting.rb,
lib/bipm/data/outcomes/approval.rb,
lib/bipm/data/outcomes/resolution.rb,
lib/bipm/data/outcomes/consideration.rb,
lib/bipm/data/outcomes/localized_body.rb
Defined Under Namespace
Classes: Action, Approval, Body, Consideration, LocalizedBody, Meeting, Resolution
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Attribute Details
#file_path=(value) ⇒ Object
Sets the attribute file_path
11
12
13
|
# File 'lib/bipm/data/outcomes.rb', line 11
def file_path=(value)
@file_path = value
end
|
Class Method Details
.bodies ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/bipm/data/outcomes.rb', line 19
def self.bodies
%i[
ccauv ccem ccl ccm ccpr ccqm ccri cct cctf ccu
cgpm cipm jcgm jcrb
].to_h do |name|
[name, body(name)]
end
end
|
.body(name) ⇒ Object
13
14
15
16
|
# File 'lib/bipm/data/outcomes.rb', line 13
def self.body(name)
ensure_downloaded
Body.new(name)
end
|
.each(&block) ⇒ Object
28
29
30
|
# File 'lib/bipm/data/outcomes.rb', line 28
def self.each(&block)
bodies.values.each(&block)
end
|
.ensure_downloaded ⇒ Object
It may be possible, that we don’t have the BIPM data loaded.
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/bipm/data/outcomes.rb', line 43
def self.ensure_downloaded
if File.exist?(file_path)
return
elsif !File.writable?(File.dirname(file_path))
require "fileutils"
self.file_path = "#{ENV["HOME"]}/.local/share/metanorma/bipm-data-importer/data/"
FileUtils.mkdir_p(File.dirname(self.file_path))
end
git_path = "https://github.com/metanorma/bipm-data-outcomes"
system "git", "clone", git_path, file_path or
raise "Downloading bipm-data-outcomes failed: possibly git not available"
end
|
.file_path ⇒ Object
8
9
10
|
# File 'lib/bipm/data/outcomes.rb', line 8
def self.file_path
@file_path ||= "#{__dir__}/../../../data/"
end
|