Module: Dcc::Schema

Defined in:
lib/dcc/schema.rb,
lib/dcc/schema/version.rb

Defined Under Namespace

Modules: Version

Constant Summary collapse

RESOURCES_DIR =
File.expand_path("schema/resources", __dir__).freeze

Class Method Summary collapse

Class Method Details

.exists?(relative_path) ⇒ Boolean

Returns whether the bundled resource exists.

Returns:

  • (Boolean)

    whether the bundled resource exists.



24
25
26
# File 'lib/dcc/schema.rb', line 24

def exists?(relative_path)
  File.file?(path(relative_path))
end

.path(relative_path) ⇒ String

Returns absolute filesystem path.

Parameters:

  • relative_path (String, Array<String>)

    resource path relative to lib/dcc/schema/resources/, e.g. "dcc/v3.3.0/dcc.xsd".

Returns:

  • (String)

    absolute filesystem path.



19
20
21
# File 'lib/dcc/schema.rb', line 19

def path(relative_path)
  File.join(RESOURCES_DIR, *Array(relative_path))
end

.read(relative_path) ⇒ String

Read a bundled resource's contents.

Returns:

  • (String)


30
31
32
# File 'lib/dcc/schema.rb', line 30

def read(relative_path)
  File.read(path(relative_path))
end