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


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

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

#cgi_optionsObject (readonly)

Returns the value of attribute cgi_options


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

def cgi_options
  @cgi_options
end

#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


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

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


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

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

#read_existing_configurationObject


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

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


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

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


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

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