class Roger::Project

Loader for rogerfile and project dependencies

Attributes

html_path[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
layouts_path[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
mode[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
options[RW]
partial_path[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
partials_path[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
path[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
rogerfile[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
rogerfile_path[RW]

@attr :path [Pathname] The project path @attr :html_path [Pathname] The path of the HTML of this project @attr :partial_path [Pathname] The path for the partials for this project @attr :rogerfile [Rogerfile] The Rogerfile for this project @attr :rogerfile_path [Pathname] The path to the Rogerfile @attr :mode [nil, :test, :server, :release] The mode we're currently in.

If nil, we aren't doing anything.
shell[RW]

Public Class Methods

new(path, options = {}) click to toggle source
# File lib/roger/project.rb, line 24
def initialize(path, options = {})
  @path = Pathname.new(path)

  @options = {
    html_path: @path + "html",
    partial_path: @path + "partials",
    layouts_path: @path + "layouts",
    rogerfile_path: @path + "Rogerfile",
    renderer: {},
    server: {},
    release: {},
    test: {}
  }

  # Clumsy string to symbol key conversion
  options.each { |k, v| @options[k.is_a?(String) ? k.to_sym : k] = v }

  initialize_accessors
  initialize_rogerfile_path
  initialize_roger
end

Public Instance Methods

html_path=(p) click to toggle source
# File lib/roger/project.rb, line 62
def html_path=(p)
  @html_path = realpath_or_path(p)
end
layouts_path=(p) click to toggle source
# File lib/roger/project.rb, line 72
def layouts_path=(p)
  @layouts_path = single_or_multiple_paths(p)
end
partial_path=(p) click to toggle source
# File lib/roger/project.rb, line 66
def partial_path=(p)
  @partial_path = single_or_multiple_paths(p)
end
Also aliased as: partials_path=
partials_path=(p)
Alias for: partial_path=
release(options = {}) click to toggle source
# File lib/roger/project.rb, line 54
def release(options = {})
  @release ||= Release.new(self, merge_options(options, :release))
end
server(options = {}) click to toggle source
# File lib/roger/project.rb, line 50
def server(options = {})
  @server ||= Server.new(self, merge_options(options, :server))
end
test(options = {}) click to toggle source
# File lib/roger/project.rb, line 58
def test(options = {})
  @test ||= Test.new(self, merge_options(options, :test))
end

Protected Instance Methods

initialize_accessors() click to toggle source
# File lib/roger/project.rb, line 106
def initialize_accessors
  self.html_path = @options[:html_path]
  self.partial_path =
    @options[:partials_path] || @options[:partial_path] || html_path + "../partials/"
  self.layouts_path = @options[:layouts_path]
  self.shell = @options[:shell]
end
initialize_roger() click to toggle source
# File lib/roger/project.rb, line 114
def initialize_roger
  if rogerfile_path
    @rogerfile = Rogerfile.new(self, rogerfile_path)
    @rogerfile.load
  else
    @rogerfile = Rogerfile.new(self)
  end
end
initialize_rogerfile_path() click to toggle source
# File lib/roger/project.rb, line 86
def initialize_rogerfile_path
  # We stop immediately if rogerfile is not a Pathname
  unless @options[:rogerfile_path].is_a? Pathname
    self.rogerfile_path = @options[:rogerfile_path]
    return
  end

  # If roger file exist we're good to go
  if @options[:rogerfile_path].exist?
    self.rogerfile_path = @options[:rogerfile_path]
  else
    # If the rogerfile does not exist we check for deprecated Mockupfile
    mockupfile_path = path + "Mockupfile"
    if mockupfile_path.exist?
      warn("Mockupfile has been deprecated! Please rename Mockupfile to Rogerfile")
      self.rogerfile_path = mockupfile_path
    end
  end
end
merge_options(options, key) click to toggle source

Creates new options and merges:

# File lib/roger/project.rb, line 82
def merge_options(options, key)
  {}.update(@options[key]).update(options)
end
realpath_or_path(path) click to toggle source
# File lib/roger/project.rb, line 131
def realpath_or_path(path)
  path = Pathname.new(path)
  if path.exist?
    path.realpath
  else
    path
  end
end
single_or_multiple_paths(p) click to toggle source
# File lib/roger/project.rb, line 123
def single_or_multiple_paths(p)
  if p.is_a?(Array)
    p.map { |tp| realpath_or_path(tp) }
  else
    realpath_or_path(p)
  end
end