Sha256: 5cf00085f5a16e61ecd2702959743258a20ba1561b6f8a3e4ea6e642364d4fa4

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

require 'yaml'

class New
  VERSION = '0.0.1'
  DEFAULT_DIR = File.expand_path('../..', __FILE__)
  CUSTOM_DIR = File.expand_path('~/.new')
  TASKS_DIR_NAME = 'tasks'
  TEMPLATES_DIR_NAME = 'templates'
  CONFIG_FILE = '.new'

  # List all the available tasks
  #
  def self.tasks
    custom_tasks | default_tasks
  end

  # List all the available templates
  #
  def self.templates
    custom_templates | default_templates
  end

  def self.default_templates
    @default_templates ||= get_list TEMPLATES_DIR_NAME, :default
  end

  def self.custom_templates
    @custom_templates ||= get_list TEMPLATES_DIR_NAME, :custom
  end

  def self.default_tasks
    @default_tasks ||= get_list TASKS_DIR_NAME, :default
  end

  def self.custom_tasks
    @custom_tasks ||= get_list TASKS_DIR_NAME, :custom
  end

  def self.custom_config
    @custom_config ||= YAML.load(File.open(File.join(CUSTOM_DIR, CONFIG_FILE))).deep_symbolize_keys! rescue {}
  end

private

  def self.get_list dir, filter
    case filter
    when :default
      Dir[File.join(DEFAULT_DIR, dir, '**')]
    when :custom
      Dir[File.join(CUSTOM_DIR, dir, '**')]
    end.map{ |d| File.basename(d).to_sym }
  end
end

# core
require 'new/core'

# modules
require 'new/dsl'
require 'new/interpolate'
require 'new/version'

# classes
require 'new/cli'
require 'new/project'
require 'new/template'
require 'new/task'

class New
  extend New::Dsl
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
new-0.1.1 lib/new.rb
new-0.0.15 lib/new.rb
new-0.0.14 lib/new.rb
new-0.0.13 lib/new.rb
new-0.0.12 lib/new.rb
new-0.0.11 lib/new.rb
new-0.0.10 lib/new.rb
new-0.0.9 lib/new.rb
new-0.0.8 lib/new.rb
new-0.0.7 lib/new.rb
new-0.0.6 lib/new.rb
new-0.0.5 lib/new.rb