Sha256: f3a495afc4b1d11d0e6554d46e3f61976d60fc2800b94aaba44cc6da2159ce0e

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

# -*- encoding : utf-8 -*-

require 'active_record'

# @!attribute path
#   @return [String]
# @!attribute polling_interval
#   @return [Double] defaults to 15.0
# @!attribute notification
#   @return [Boolean] default to true
# @!attribute remote_name
#   @return [String] default to 'origin'
# @!attribute remote_branch
#   @return [String] default to 'master'
# @attribute sync_type
#   @return ['full','fetch']
module Gitdocs
  class Configuration
    # @return [Boolean]
    def self.start_web_frontend
      Config.global.start_web_frontend
    end

    # @return [Integer]
    def self.web_frontend_port
      Config.global.web_frontend_port
    end

    # @param [Hash] new_config
    def self.update(new_config)
      Config.global.update_attributes(new_config)
    end

    # NOTE: This record has been kept as a subclass to avoid changing the
    # database table. There are other ways to achieve this, but this seemed most
    # clear for now. [2015-06-26 -- acant]
    #
    # @!attribute start_frontend_port
    #   @return [Boolean] defaults to true
    # @!attribute web_frontend_port
    #   @return [Integer] defaults to 8888
    class Config < ActiveRecord::Base
      # @return [Gitdocs::Configuration::Config]
      def self.global
        fail if all.size > 1
        create! if all.empty?
        all.first
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitdocs-0.6.2 lib/gitdocs/configuration.rb
gitdocs-0.6.1 lib/gitdocs/configuration.rb
gitdocs-0.6.0 lib/gitdocs/configuration.rb