ontology_version.rb revision 81da36894af70bbb8d8e24b004026ad4c5c1bc99
1516N/Aclass OntologyVersion < ActiveRecord::Base
581N/A include CodeReferencable
581N/A include Numbering
581N/A
581N/A include OntologyVersion::Files
581N/A include OntologyVersion::States
581N/A include OntologyVersion::Parsing
581N/A include OntologyVersion::Proving
581N/A include OntologyVersion::OopsRequests
581N/A include IRIUrlBuilder::Includeable
581N/A include ::AccessScopesForRepositoryAssociations
581N/A
581N/A include Rails.application.routes.url_helpers
581N/A include ActionDispatch::Routing::UrlFor
581N/A
581N/A numbering_parent_column 'ontology_id'
581N/A
581N/A belongs_to :ontology, :counter_cache => :versions_count
581N/A has_one :repository, through: :ontology
581N/A has_many :theorems, through: :ontology
581N/A has_one :repository, through: :ontology
581N/A has_many :theorems, through: :ontology
926N/A
1895N/A belongs_to :commit
926N/A has_one :author, through: :commit
581N/A has_one :committer, through: :commit
581N/A has_one :pusher, through: :commit
581N/A
581N/A # Provers that can be used for proving goals in this ontology.
1715N/A has_and_belongs_to_many :provers
581N/A
1895N/A# before_validation :set_checksum
581N/A# validate :raw_file_size_maximum
1895N/A
581N/A# validates_presence_of :basepath
1715N/A
581N/A scope :latest, order('id DESC')
1715N/A scope :done, state('done')
581N/A scope :failed, state('failed')
581N/A
792N/A acts_as_tree
581N/A
1895N/A # updated_at of the latest version
581N/A def self.last_updated_at
581N/A latest.first.try(:updated_at)
581N/A end
581N/A
581N/A def to_param
581N/A self.number
581N/A end
581N/A
611N/A def to_s
611N/A "#{ontology.name} (version #{number})"
611N/A end
611N/A
581N/A # Public URL to this version
581N/A #
581N/A # TODO: This returns a path without the commit id and filename for now,
581N/A # because the FilesController or the routes were not supporting it.
581N/A def url(params={})
581N/A #Rails.application.routes.url_helpers.repository_ref_path(repository, commit_oid, ontology.path, params.reverse_merge(host: Ontohub::Application.config.fqdn, port: Ontohub::Application.config.port, only_path: false))
581N/A url_for [repository, ontology, self]
581N/A end
2026N/A
2026N/A def default_url_options
2026N/A {host: Ontohub::Application.config.fqdn,
2026N/A port: Ontohub::Application.config.port}
2026N/A end
2026N/A
2026N/A def path
2026N/A "#{basepath}#{file_extension}"
2026N/A end
2026N/A
2026N/A def file_in_repository
2026N/A ontology.repository.get_file(path, commit_oid)
2026N/A end
2026N/A
2026N/A def locid
2026N/A "/ref/#{number}#{ontology.locid}"
2026N/A end
2026N/A
2026N/A alias_method :versioned_locid, :locid
2026N/A
2026N/A def latest_version?
2026N/A ontology.versions.last == self
709N/A end
709N/A
1895N/A protected
1895N/A
709N/A def raw_file_size_maximum
709N/A if raw_file.size > 10.megabytes.to_i
1895N/A errors.add :raw_file, 'The maximum file size is 10M.'
1895N/A end
709N/A end
1895N/A
1895N/A def refresh_checksum!
709N/A self.checksum = Digest::SHA1.file(raw_path!).hexdigest
709N/A save! if checksum_changed?
792N/A end
926N/A
792N/Aend
1895N/A