Module: Filezor::Server::ClassMethods

Included in:
Filezor::Server
Defined in:
lib/filezor/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rootObject

Returns the value of attribute root.



148
149
150
# File 'lib/filezor/server.rb', line 148

def root
  @root
end

Instance Method Details

#authenticate(user, pwd) ⇒ Object



162
163
164
165
# File 'lib/filezor/server.rb', line 162

def authenticate(user, pwd)
  # puts "#{pwd} == #{password}"
  pwd == password
end

#cachingObject



150
151
152
# File 'lib/filezor/server.rb', line 150

def caching
  !!@caching
end

#caching=(caching) ⇒ Object



158
159
160
# File 'lib/filezor/server.rb', line 158

def caching=(caching)
  @caching = caching
end

#passwordObject



167
168
169
170
171
172
173
174
# File 'lib/filezor/server.rb', line 167

def password
  @password ||= begin
                  tmp = File.exists?(password_file) ?
                    File.read(password_file) :
                    "default"
                    tmp
                end
end

#password=(pwd) ⇒ Object



176
177
178
179
# File 'lib/filezor/server.rb', line 176

def password=(pwd)
  File.open(password_file, "w") {|f| f.print(pwd) }
  @password = pwd
end

#password_fileObject



181
182
183
# File 'lib/filezor/server.rb', line 181

def password_file
  File.join(root, ".password")
end

#start_embedded!(root, password) ⇒ Object

Helpful for testing clients



186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/filezor/server.rb', line 186

def start_embedded!(root, password)
  ppid = Process.pid
  Filezor::Server.root = root
  Filezor::Server.password = password
  fork do
    harikari(ppid)
    STDOUT.reopen("/dev/null")
    Filezor::Server.run!
  end

  sleep 1
end