Module: GollumRails::Setup

Includes:
Options
Defined in:
lib/gollum_rails/setup.rb,
lib/gollum_rails/setup/error.rb,
lib/gollum_rails/setup/options.rb

Overview

Setup functionality for Rails initializer

will be generated by Rails generator: `rails g gollum_rails:install`

manually:

GollumRails::Setup.build do |config|
  config.repository = '<path_to_your_repository>'
  config.wiki = :default
  config.startup
end

Defined Under Namespace

Modules: Options Classes: GollumRailsSetupError

Class Method Summary collapse

Class Method Details

.build(new_attributes = nil, &block) ⇒ Object

defines block builder for Rails initializer. executes public methods inside own class


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gollum_rails/setup.rb', line 26

def build(new_attributes = nil, &block)
  if block_given?
    yield self
  else
    if !new_attributes.respond_to?(:stringify_keys)
      raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
    end
    attributes = new_attributes.stringify_keys
    attributes.each do |k, v|
      begin
        public_send("#{k}=", v)
      rescue NoMethodError
      end
    end

  end
  if self.repository == :application
    raise GollumRailsSetupError, "Rails configuration is not defined.
    Are you in a Rails app?" if Rails.application.nil?

    initialize_wiki Rails.application.config.wiki_repository
  else
    raise GollumRailsSetupError, "Git repository does not exist.
    Was the specified pathname correct?" unless Pathname.new(self.repository).exist?
    initialize_wiki self.repository
  end
end