Class: DmSvn::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-svn/config.rb

Constant Summary collapse

OPTS =
[:uri, :username, :password,
:body_property, :property_prefix, :extension]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dm-svn/config.rb', line 9

def initialize
  # Set defaults
  @body_property = 'body'
  @property_prefix = 'ws:'
  @extension = 'txt'

  # Try to set variables from database.yml.
  # The location of database.yml should, I suppose, be configurable.
  # Oh, well.
  if Object.const_defined?("RAILS_ROOT")
    f = "#{RAILS_ROOT}/config/database.yml"
    env = Kernel.const_defined?("RAILS_ENV") ? RAILS_ENV : "development"
  elsif Object.const_defined?("Merb")
    f = "#{Merb.root}/config/database.yml"
    env = Merb.env.to_sym || :development
  end
  
  if f
    config = YAML.load(IO.read(f))[env]
    OPTS.each do |field|
      config_field = config["svn_#{field}"] || config["svn_#{field}".to_sym]
      if config_field
        instance_variable_set("@#{field}", config_field)
      end
    end
  end
  
end

Instance Attribute Details

#path_from_rootObject

Used by Sync.



7
8
9
# File 'lib/dm-svn/config.rb', line 7

def path_from_root
  @path_from_root
end