class Marv::Project::Project

Attributes

assets[RW]
config[RW]
context[RW]
root[RW]
task[RW]

Public Class Methods

new(task, dir, options) click to toggle source

Initialize project config

# File lib/marv/project/project.rb, line 13
def initialize(task, dir, options)
  @task = task
  @global = Marv::Global.new(task)
  @dir = ::File.expand_path(dir)
  @options = options
  @root = root_path
  @config_file = config_file
  @config = project_config
  @assets = project_assets
  @context = project_context
end

Public Instance Methods

assets_path() click to toggle source

Project assets path

# File lib/marv/project/project.rb, line 51
def assets_path
  ::File.join(source_path, 'assets')
end
build_path() click to toggle source

Project build path

# File lib/marv/project/project.rb, line 41
def build_path
  ::File.join(root_path, '.watch', 'build')
end
config_file() click to toggle source

Config file

# File lib/marv/project/project.rb, line 71
def config_file
  ::File.join(root_path, 'config.rb')
end
functions_file() click to toggle source

Theme functions file

# File lib/marv/project/project.rb, line 81
def functions_file
  ::File.join(functions_path, 'functions.php')
end
functions_path() click to toggle source

Project functions path

# File lib/marv/project/project.rb, line 56
def functions_path
  ::File.join(source_path, 'functions')
end
includes_path() click to toggle source

Project includes path

# File lib/marv/project/project.rb, line 66
def includes_path
  ::File.join(source_path, 'includes')
end
optional_config_file() click to toggle source

Check for config file in options

# File lib/marv/project/project.rb, line 117
def optional_config_file
  if ::File.exists?(@options.to_s)
    @options = @global.load_ruby_config(::File.expand_path(@options))
  end
end
package_path() click to toggle source

Project package path

# File lib/marv/project/project.rb, line 46
def package_path
  ::File.join(root_path, 'package')
end
plugin_file() click to toggle source

Plugin php file

# File lib/marv/project/project.rb, line 76
def plugin_file
  ::File.join(functions_path, "#{project_id.gsub('_', '-')}.php")
end
project_assets() click to toggle source

Get all project assets

# File lib/marv/project/project.rb, line 124
def project_assets
  assets = [
    ['style.css'],
    ['plugin.css'],
    ['admin.css'],
    ['javascripts', 'theme.js'],
    ['javascripts', 'plugin.js'],
    ['javascripts', 'admin.js']
  ]

  if project_config[:additional_assets]
    assets = assets | project_config[:additional_assets]
  end

  return assets
end
project_config() click to toggle source

Project config file

# File lib/marv/project/project.rb, line 86
def project_config
  config = {}

  # Merge global config
  config.merge!(@global.config)

  if @options.nil?
    config.merge!(project_config_file)
  else
    optional_config_file
    config.merge!(@options)
  end

  return config
end
project_config_file() click to toggle source

Check for config.rb in project folder

# File lib/marv/project/project.rb, line 103
def project_config_file
  config_file = {}

  if ::File.exists?(@config_file)
    config_file = @global.load_ruby_config(@config_file)
  else
    @task.say_error "Could not find the config file!", "Are you sure you're in a marv project directory?", false
    abort
  end

  return config_file
end
project_context() click to toggle source

Get project class context

# File lib/marv/project/project.rb, line 142
def project_context
  instance_eval('binding')
end
project_id() click to toggle source

Project id

# File lib/marv/project/project.rb, line 26
def project_id
  ::File.basename(@dir).gsub(/\W/, '_').downcase
end
root_path() click to toggle source

Project root path

# File lib/marv/project/project.rb, line 31
def root_path
  ::File.expand_path(@dir)
end
source_path() click to toggle source

Project source path

# File lib/marv/project/project.rb, line 36
def source_path
  ::File.join(root_path, 'source')
end
templates_path() click to toggle source

Project templates path

# File lib/marv/project/project.rb, line 61
def templates_path
  ::File.join(source_path, 'templates')
end