Class: Wiki2Go::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/Wiki2Go/Install/make_site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



44
45
46
47
48
49
50
51
52
53
# File 'lib/Wiki2Go/Install/make_site.rb', line 44

def initialize
  @user         = WebUser.new(nil,nil)
  @server       = 'localhost'
  @port         = '80'
  @default_wiki = ''
  @directory    = Dir.getwd
  @type         = nil
  @source_dir   = File.expand_path(File.dirname(__FILE__))
  @subsite      = ''
end

Instance Attribute Details

#default_wikiObject

Returns the value of attribute default_wiki.



38
39
40
# File 'lib/Wiki2Go/Install/make_site.rb', line 38

def default_wiki
  @default_wiki
end

#directoryObject

Returns the value of attribute directory.



39
40
41
# File 'lib/Wiki2Go/Install/make_site.rb', line 39

def directory
  @directory
end

#portObject

Returns the value of attribute port.



37
38
39
# File 'lib/Wiki2Go/Install/make_site.rb', line 37

def port
  @port
end

#serverObject

Returns the value of attribute server.



36
37
38
# File 'lib/Wiki2Go/Install/make_site.rb', line 36

def server
  @server
end

#source_dirObject (readonly)

Returns the value of attribute source_dir.



41
42
43
# File 'lib/Wiki2Go/Install/make_site.rb', line 41

def source_dir
  @source_dir
end

#subsiteObject

Returns the value of attribute subsite.



42
43
44
# File 'lib/Wiki2Go/Install/make_site.rb', line 42

def subsite
  @subsite
end

#typeObject

Returns the value of attribute type.



40
41
42
# File 'lib/Wiki2Go/Install/make_site.rb', line 40

def type
  @type
end

#userObject

Returns the value of attribute user.



35
36
37
# File 'lib/Wiki2Go/Install/make_site.rb', line 35

def user
  @user
end

Instance Method Details

#dotted_portObject



84
85
86
87
88
89
90
# File 'lib/Wiki2Go/Install/make_site.rb', line 84

def dotted_port
  if @port.nil? || @port.empty? then
    ':80'
  else
    ':' + @port
  end
end

#existing_configurationObject

Return a Wiki2GoConfig object, if there is a CgiOptions.rb file Returns nil if no configuration could be read



57
58
59
60
61
62
63
64
# File 'lib/Wiki2Go/Install/make_site.rb', line 57

def existing_configuration
  configfile = File.join(@directory,'site','scripts','CgiOptions.rb')
  if File.exists?(configfile) then
    load configfile
    return CgiOptions.new
  end
  return nil
end

#read_existing_configurationObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/Wiki2Go/Install/make_site.rb', line 66

def read_existing_configuration
  config = existing_configuration
  unless config.nil? then
    if @type.nil? then
      @type = Configuration.type_of(config)
    end

    if @user.user.nil? then
      @user.user = config.user if config.respond_to?(:user) 
    end

    if @user.group.nil? || @user.group.empty? then
      @user.group = (config.respond_to?(:group) ? config.group : nil)
    end

  end
end

#server_at(url) ⇒ Object



100
101
102
103
104
105
106
107
108
109
# File 'lib/Wiki2Go/Install/make_site.rb', line 100

def server_at(url)
  uri = URI::parse(url)
  if uri.scheme.nil? then
    @server = url
  else
    @server  = uri.host
    @subsite = uri.path
    @port    = uri.port.to_s
  end
end

#server_urlObject



92
93
94
95
96
97
98
# File 'lib/Wiki2Go/Install/make_site.rb', line 92

def server_url
  if @port.nil? || @port.empty? || @port == '80' then
    server
  else
    server + dotted_port
  end
end