Module: Yop
- Defined in:
- lib/yop.rb,
lib/yop/home.rb,
lib/yop/config.rb,
lib/yop/version.rb,
lib/yop/bootstrap.rb,
lib/yop/templates.rb
Overview
Base module for Yop
Defined Under Namespace
Classes: Template
Class Method Summary collapse
-
.bootstrap(template, directory) ⇒ Object
Bootstrap a project (which will be) located in ‘directory` with the template `template`.
-
.config(key = nil) ⇒ Any
Get the local Yop config.
-
.config!(opts = {}) ⇒ Object
Set variables in the local Yop config.
-
.get_template(name) ⇒ Yop::Template
Retrieve a template from its name, or raise a ‘NonExistentTemplate` exception if it doesn’t exist.
-
.home(subcomponent = "") ⇒ String
Return the local Yop directory location.
-
.init ⇒ Object
Initialize Yop’s local directory.
-
.templates ⇒ Array
All the available templates.
-
.version ⇒ String
The current gem’s version.
Class Method Details
.bootstrap(template, directory) ⇒ Object
Bootstrap a project (which will be) located in ‘directory` with the template `template`
12 13 14 |
# File 'lib/yop/bootstrap.rb', line 12 def bootstrap(template, directory) get_template(template).apply directory end |
.config(key = nil) ⇒ Any
Get the local Yop config. If no argument is given the whole config is returned. If one is given, the corresponding value is returned.
13 14 15 16 17 18 19 20 21 |
# File 'lib/yop/config.rb', line 13 def config(key = nil) read_config unless @conf if !key.nil? @conf[key] else @conf end end |
.config!(opts = {}) ⇒ Object
Set variables in the local Yop config.
26 27 28 29 |
# File 'lib/yop/config.rb', line 26 def config!(opts = {}) @conf.update(opts) save_config end |
.get_template(name) ⇒ Yop::Template
Retrieve a template from its name, or raise a ‘NonExistentTemplate` exception if it doesn’t exist
20 21 22 23 24 |
# File 'lib/yop/templates.rb', line 20 def get_template(name) dirs = Dir["#{Yop.home("templates")}/#{name}"] fail NonExistentTemplate, name if dirs.empty? Template.new(dirs.first, config(:vars) || {}) end |
.home(subcomponent = "") ⇒ String
Return the local Yop directory location. If an argument is given, it assumes it’s a Yop subcomponent and returns its location.
11 12 13 |
# File 'lib/yop/home.rb', line 11 def home(subcomponent = "") File.("~/.yop/#{subcomponent}") end |
.init ⇒ Object
Initialize Yop’s local directory
17 18 19 20 21 |
# File 'lib/yop/home.rb', line 17 def init FileUtils.mkdir_p home FileUtils.mkdir_p home("templates") FileUtils.touch home("config.yml") end |
.templates ⇒ Array
Returns all the available templates.
12 13 14 |
# File 'lib/yop/templates.rb', line 12 def templates Dir["#{Yop.home("templates")}/*"] end |
.version ⇒ String
Returns the current gem’s version.
5 6 7 |
# File 'lib/yop/version.rb', line 5 def self.version "0.0.1" end |