Class: Smeagol::Wiki

Inherits:
Gollum::Wiki
  • Object
show all
Defined in:
lib/smeagol/wiki.rb

Instance Method Summary collapse

Instance Method Details

#settingsObject

The Smeagol wiki settings. These can be found in the smeagol.yaml file at the root of the repository.

Returns an OpenStruct of settings.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/smeagol/wiki.rb', line 42

def settings
  # Cache settings if already read
  if @settings.nil?
    file = "#{path}/settings.yml"
    if File.readable?(file)
      @settings = YAML::load(IO.read(file)).to_ostruct
    else
      @settings = OpenStruct.new
    end
  end
  return @settings
end

#update(git) ⇒ Object

Public: Updates the wiki repository.

git - The path to the git binary.

Returns true if successful. Otherwise returns false.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smeagol/wiki.rb', line 12

def update(git)
  # TODO: Change this method to raise errors if something goes wrong instead
  #       of returning a status.
  
  # If the git executable is available, pull from master and check status.
  if !git.nil?
    output = `cd #{path} && #{git} pull origin master 2>/dev/null`
    
    # Write update to log if something happened
    if output.index('Already up-to-date').nil?
      $stderr.puts "==Repository updated at #{Time.new()} : #{path}=="
    end

    return $? == 0
  # Otherwise return false.
  else
    return false
  end
end