Module: Ietf::Data::Importer

Defined in:
lib/ietf/data/importer.rb,
lib/ietf/data/importer/cli.rb,
lib/ietf/data/importer/group.rb,
lib/ietf/data/importer/version.rb,
lib/ietf/data/importer/scrapers.rb,
lib/ietf/data/importer/group_collection.rb,
lib/ietf/data/importer/scrapers/base_scraper.rb,
lib/ietf/data/importer/scrapers/ietf_scraper.rb,
lib/ietf/data/importer/scrapers/irtf_scraper.rb

Overview

Main module for IETF/IRTF group data importer

Defined Under Namespace

Modules: Scrapers Classes: Cli, Error, Group, GroupCollection

Constant Summary collapse

GROUPS_PATH =

Path to the groups data file

File.join(File.dirname(__FILE__), "importer", "groups.yaml")
VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.active_groupsObject

Get active groups



73
74
75
# File 'lib/ietf/data/importer.rb', line 73

def self.active_groups
  groups.select { |g| g.status == "active" }
end

.areasObject

Get all available areas



88
89
90
# File 'lib/ietf/data/importer.rb', line 88

def self.areas
  groups.map(&:area).compact.uniq.sort
end

.concluded_groupsObject

Get concluded groups



78
79
80
# File 'lib/ietf/data/importer.rb', line 78

def self.concluded_groups
  groups.select { |g| g.status == "concluded" }
end

.find_group(abbreviation) ⇒ Object

Find a group by its abbreviation (case insensitive)



38
39
40
# File 'lib/ietf/data/importer.rb', line 38

def self.find_group(abbreviation)
  groups.find { |g| g.abbreviation.downcase == abbreviation.to_s.downcase }
end

.group_exists?(abbreviation) ⇒ Boolean

Check if a group exists by abbreviation

Returns:

  • (Boolean)


33
34
35
# File 'lib/ietf/data/importer.rb', line 33

def self.group_exists?(abbreviation)
  !find_group(abbreviation).nil?
end

.group_typesObject

Get all available group types



83
84
85
# File 'lib/ietf/data/importer.rb', line 83

def self.group_types
  groups.map(&:type).uniq.sort
end

.groupsObject

All available groups



28
29
30
# File 'lib/ietf/data/importer.rb', line 28

def self.groups
  load_groups.groups
end

.groups_by_area(area) ⇒ Object

Get groups by area



68
69
70
# File 'lib/ietf/data/importer.rb', line 68

def self.groups_by_area(area)
  groups.select { |g| g.area&.downcase == area.to_s.downcase }
end

.groups_by_type(type) ⇒ Object

Get groups by type



63
64
65
# File 'lib/ietf/data/importer.rb', line 63

def self.groups_by_type(type)
  groups.select { |g| g.type.downcase == type.to_s.downcase }
end

.ietf_groupsObject

Get all IETF groups



43
44
45
# File 'lib/ietf/data/importer.rb', line 43

def self.ietf_groups
  groups.select { |g| g.organization == "ietf" }
end

.irtf_groupsObject

Get all IRTF groups



48
49
50
# File 'lib/ietf/data/importer.rb', line 48

def self.irtf_groups
  groups.select { |g| g.organization == "irtf" }
end

.load_groupsObject

Load the groups if the file exists, otherwise return empty collection



19
20
21
22
23
24
25
# File 'lib/ietf/data/importer.rb', line 19

def self.load_groups
  if File.exist?(GROUPS_PATH)
    GroupCollection.from_yaml(File.read(GROUPS_PATH))
  else
    GroupCollection.new(groups: [])
  end
end

.research_groupsObject

Get all research groups (IRTF)



58
59
60
# File 'lib/ietf/data/importer.rb', line 58

def self.research_groups
  groups.select { |g| g.type == "rg" }
end

.working_groupsObject

Get all working groups (IETF)



53
54
55
# File 'lib/ietf/data/importer.rb', line 53

def self.working_groups
  groups.select { |g| g.type == "wg" }
end