Class: UniProp::MetaData

Inherits:
Object
  • Object
show all
Defined in:
lib/uniprop/inspects.rb,
lib/uniprop/metadata_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prop_data, metadata_path) ⇒ MetaData

Returns a new instance of MetaData.

Parameters:

  • prop_data (PropData)
  • metadata_path (Pathname)


7
8
9
10
11
12
13
14
15
16
# File 'lib/uniprop/metadata_processor.rb', line 7

def initialize(prop_data, )
  @prop_data = prop_data
   = 

  if .exist?
     = JSON.parse(File.read())
  else
    raise FileNotFoundError, "#{@metadata_path} is not found."
  end
end

Instance Attribute Details

#metadata_pathObject (readonly)

Returns the value of attribute metadata_path.



3
4
5
# File 'lib/uniprop/metadata_processor.rb', line 3

def 
  
end

#prop_dataObject (readonly)

Returns the value of attribute prop_data.



3
4
5
# File 'lib/uniprop/metadata_processor.rb', line 3

def prop_data
  @prop_data
end

#raw_metadataObject (readonly)

Returns the value of attribute raw_metadata.



3
4
5
# File 'lib/uniprop/metadata_processor.rb', line 3

def 
  
end

Instance Method Details

#find_raw_version_metadata(version_name) ⇒ Hash<String,Object>

メタデータから、version_nameと同じweightのバージョンに関する記述を取得

Parameters:

  • version_name (String)

Returns:

  • (Hash<String,Object>)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/uniprop/metadata_processor.rb', line 45

def (version_name)
  weight = Version.name_to_weight(version_name)

  result = raw_version_metadatas.find { Version.name_to_weight(_1["version_name"])==weight }

  if result
    return result
  else
    raise MetaDataNotFoundError, "metadata for #{version_name} is not found."
  end
end

#has_raw_version_metadata?(version_name) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
61
# File 'lib/uniprop/metadata_processor.rb', line 57

def has_raw_version_metadata?(version_name)
  !!(version_name)
rescue
  false
end

#inspectObject



49
50
51
# File 'lib/uniprop/inspects.rb', line 49

def inspect
  "#<#{self.class.name}>"
end

#metadata_validatorMetaDataValidator

Returns:



64
65
66
67
# File 'lib/uniprop/metadata_processor.rb', line 64

def 
   ||= MetaDataValidator.new(self)
  
end

#raw_version_metadatasArray<Hash<String,Object>>

Returns:

  • (Array<Hash<String,Object>>)


38
39
40
# File 'lib/uniprop/metadata_processor.rb', line 38

def raw_version_metadatas
  @raw_version_metadatas ||= ["version_metadatas"].sort { Version.name_to_weight(_1["version_name"]) }
end

#version_names(update_metadata: false, confirm: false) ⇒ Array<String>

メタデータのversion_names項目の値を取得。メタデータにこの項目が記述されていない場合、Unicode.orgからバージョン一覧を取得

Parameters:

  • update_metadata (Boolean) (defaults to: false)

    trueの場合、取得した情報がメタデータと異なる際に、メタデータを更新

  • confirm (Boolean) (defaults to: false)

    trueの場合、Unicode.orgからバージョン名一覧を取得する。メタデータにバージョン一覧が記述されている場合にも、Unicord.orgから取得した情報を優先して返す。メタデータにversion_names項目が無い場合、confirm==falseでもUnicode.orgから情報を取得する

Returns:

  • (Array<String>)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/uniprop/metadata_processor.rb', line 22

def version_names(update_metadata: false, confirm: false)
  if confirm || ["version_names"].nil? || ["version_names"].empty?
    actual_version_names = UniPropUtils::DownloaderWrapper.get_version_names

    if 
      ["version_names"] = actual_version_names
      prop_data.()
    end
    
    return actual_version_names
  else
    return ["version_names"]
  end
end