Sha256: 5a8b335d8647801b5ecda0a0c21599be1dcfa716fb6f68500f9f842e0bb97be4

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require "pathname"
require "logger"

# Allows for pathnames to be easily added to
class Pathname
  def /(other)
    join(other.to_s)
  end
end

# <%= @options[:summary] %>
# This sets all the globals and creates our main namespace
module <%= @options[:lib_name] %>
  LIBROOT = Pathname(__FILE__).dirname.expand_path
  ROOT = LIBROOT/".."
  MIGRATION_ROOT = ROOT/:migrations
  MODEL_ROOT = ROOT/:model
  SPEC_HELPER_PATH = ROOT/:spec
  autoload :VERSION, (LIBROOT/"<%= @options[:lib_name_u] %>/version").to_s
  # Helper method to load models
  # @model String The model you wish to load
  def self.M(model)
    require <%= @options[:lib_name] %>::MODEL_ROOT.join(model).to_s
  end

  # Helper method to load files from ROOT
  # @file String The file you wish to load
  def self.R(file)
    require <%= @options[:lib_name] %>::ROOT.join(file).to_s
  end

  # Helper method to load files from lib/yrb
  # @file String The file you wish to load
  def self.L(file)
    require (<%= @options[:lib_name] %>::LIBROOT/:<%= @options[:lib_name_u] %>).join(file).to_s
  end

  def self.Run(*args)
    require "open3"
    Open3.popen3(*args) do |sin, sout, serr|
      o = Thread.new do
        sout.each_line { |l| puts l.chomp }
      end
      e = Thread.new do
        serr.each_line { |l| $stderr.puts l.chomp }
      end
      sin.close
      o.join
      e.join
    end
  end

end
<%= @options[:lib_name] %>::R "options"
<%= @options[:lib_name] %>::Log = Logger.new(<%= @options[:lib_name] %>.options.logfile, 10, 10240000) unless <%= @options[:lib_name] %>.const_defined?("Log")
<%= @options[:lib_name] %>::Log.level = <%= @options[:lib_name] %>.options.log_level

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seedling-0.0.6 lib/templates/core/lib/library.rb.seed