Sha256: 53b1a1f82986ee99969ff857f0f2fe3984a81ec92e53819944b8de2a1ee4d9ae

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

require "parseconfig"

class Primo

  CONFIG_FILE = File.expand_path('~/.primo').freeze

  def self.create name
    system "rails new #{name} -m #{current_template_path}"
  end

  def self.default value
    ensure_config
    File.write CONFIG_FILE, File.read(CONFIG_FILE)
      .gsub(/^default *= *\S*/m, "default = '#{value}'")
  end

  def self.current_template
    ensure_config
    ParseConfig.new(CONFIG_FILE)["default"]
  end

  def self.current_template_path
    default = current_template
    default = File.expand_path("templates/#{default}.rb") unless default =~ /\.rb$/i
    default
  end

  def self.ensure_config
    FileUtils.cp("data/.primo", CONFIG_FILE) unless File.exists?(CONFIG_FILE)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
primo-0.0.5 lib/primo.rb