Sha256: 26f23917ed29f4915822437983e5b450f4599b0435c9cacfeac257faf187716c

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

require 'non_config'
require 'redmine_rest'

module RedmineCLI
  #
  # Class that stores configuration and manipulates with it
  #
  class Config < NonConfig::Base
    @path_to_config = File.expand_path('.redmine_cli', Dir.home)

    def self.configure_rest
      RedmineRest::Models.configure_models user: user,
                                           password: password,
                                           site: site
    end

    def self.create_config
      defaults = { 'just_created' => true,
                   'user' => 'login',
                   'password' => 'password',
                   'site' => 'URL to Redmine' }
      File.open(@path_to_config, 'w') { |f| f.write defaults.to_yaml }
    end

    def self.new?
      self['just_created']
    end

    create_config unless File.exist? @path_to_config

    source :default, File.expand_path('../../assets/default_config.yml', __FILE__)
    source :user, @path_to_config

    configure_rest
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
redmine_cli-0.3.1 lib/redmine_cli/config.rb
redmine_cli-0.3.0 lib/redmine_cli/config.rb
redmine_cli-0.2.2 lib/redmine_cli/config.rb
redmine_cli-0.2.1 lib/redmine_cli/config.rb
redmine_cli-0.2.0 lib/redmine_cli/config.rb
redmine_cli-0.1.0 lib/redmine_cli/config.rb