Class: Schemas::LocalSource
- Inherits:
-
Source
- Object
- Source
- Schemas::LocalSource
- Defined in:
- app/models/schemas/local_source.rb
Overview
Reads schemas from files, in a folder for each subject, with one file for
each version:
The next version can be worked on as a work in progress (WIP), as record
loaders' .wip.yml files are:
Defined Under Namespace
Classes: DuplicateVersion, MixedTypes
Constant Summary collapse
- TYPE_EXTENSIONS =
The file extension for each schema type
{ json_schema: '.json', avro: '.avsc' }.freeze
- VERSION_NAME =
A file name that is a version number, such as 1 or 12
/\A[1-9]\d*\z/- WIP_NAME =
A WIP file name: a version number, then .wip, such as 2.wip; the number is captured
/\A([1-9]\d*)\.wip\z/
Instance Attribute Summary collapse
-
#root ⇒ Pathname
readonly
The directory that holds the subject folders.
Instance Method Summary collapse
-
#fetch(subject, version) ⇒ Schemas::Schema
Fetches one version of a schema.
-
#initialize(root = Rails.root.join('config/schemas'), wip: false) ⇒ LocalSource
constructor
A new instance of LocalSource.
Constructor Details
#initialize(root = Rails.root.join('config/schemas'), wip: false) ⇒ LocalSource
Returns a new instance of LocalSource.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/schemas/local_source.rb', line 39 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
Instance Attribute Details
#root ⇒ Pathname (readonly)
Returns the directory that holds the subject folders.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/models/schemas/local_source.rb', line 34 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
Instance Method Details
#fetch(subject, version) ⇒ Schemas::Schema
Fetches one version of a schema.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/models/schemas/local_source.rb', line 48 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |