Class: Boilerplate

Inherits:
Object
  • Object
show all
Defined in:
lib/boilerplate.rb

Class Method Summary collapse

Class Method Details

.attachObject



2
3
4
5
# File 'lib/boilerplate.rb', line 2

def self.attach
  self.create_refs()
  self.register_template()
end

.create_refsObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/boilerplate.rb', line 19

def self.create_refs
  huge_boilerplate_path = self.gem_installation_dir() + "/gems/huge-boilerplate-middleman-0.1/lib/huge-boilerplate-middleman"
  middleman_template_path = self.middleman_path() + "/lib/middleman/templates"
  
  sym_link = middleman_template_path + "/huge"
  register_template = huge_boilerplate_path + "/huge.rb"
  huge_boilerplate_templates_path = huge_boilerplate_path + "/boilerplate"
  
  system "ln -s #{huge_boilerplate_templates_path} #{sym_link}; cp #{register_template} #{middleman_template_path}"
end

.gem_installation_dirObject



7
8
9
10
# File 'lib/boilerplate.rb', line 7

def self.gem_installation_dir
  gem_env_installation_path = %x{gem environment | grep "INSTALLATION DIRECTORY: "}.strip.gsub('- INSTALLATION DIRECTORY: ', '')
  return gem_env_installation_path
end

.middleman_pathObject



12
13
14
15
16
17
# File 'lib/boilerplate.rb', line 12

def self.middleman_path
  middleman_version = %x{middleman version}.downcase.strip.gsub(' ', '-')
  path = self.gem_installation_dir() + '/gems/' + middleman_version
  
  return path
end

.register_templateObject



30
31
32
33
34
35
36
# File 'lib/boilerplate.rb', line 30

def self.register_template
  template = self.middleman_path() + "/lib/middleman/templates.rb"

  template_config = File.open(template, 'a') 
  template_config << "\nrequire \"middleman/templates/huge\""
  template_config.close()
end