class Pave::Theme

Attributes

name[R]

Public Class Methods

create(name) click to toggle source
# File lib/pave/theme.rb, line 7
def self.create(name)
  new(name).setup
end
new(name) click to toggle source
# File lib/pave/theme.rb, line 28
def initialize(name)
  @name = name
end

Public Instance Methods

coffee_folder() click to toggle source
# File lib/pave/theme.rb, line 32
def coffee_folder
  coffee_path = `find ./themes -name 'app.js'`
  coffee_path.gsub("/app.js", "/").strip
end
copy_theme() click to toggle source
# File lib/pave/theme.rb, line 60
def copy_theme
  sh "cp -a #{Pave.template_folder}/themes/blank #{Dir.pwd}/themes/#{self.name}"
end
create_project_css_folders() click to toggle source
# File lib/pave/theme.rb, line 64
def create_project_css_folders
  sh "cd themes/#{self.name}/css/ && mkdir -p #{self.name}/{components,layouts}"
  sh "cd themes/#{self.name}/css/#{self.name} && touch ./components/_components.scss && touch ./layouts/_layouts.scss"
  sh "cd themes/#{self.name}/css/ && echo \"@import '#{self.name}/components/components';\" >> ./styles.scss && echo \"@import '#{self.name}/layouts/layouts';\" >> ./styles.scss"
end
install_bitters() click to toggle source
# File lib/pave/theme.rb, line 54
def install_bitters
  say "Installing Bitters..."
  sh "gem install bitters"
  sh "cd themes/#{self.name}/css/ && bitters install && cd -"
end
install_bourbon() click to toggle source
# File lib/pave/theme.rb, line 42
def install_bourbon
  say "Installing Bourbon..."
  sh "gem install bourbon"
  sh "cd themes/#{self.name}/css/ && bourbon install && cd -"
end
install_neat() click to toggle source
# File lib/pave/theme.rb, line 48
def install_neat
  say "Installing Neat..."
  sh "gem install neat"
  sh "cd themes/#{self.name}/css/ && neat install && cd -"
end
install_sass() click to toggle source
# File lib/pave/theme.rb, line 37
def install_sass
  say "Installing SASS..."
  sh "gem install sass"
end
setup() click to toggle source
# File lib/pave/theme.rb, line 70
def setup
  say "Creating theme..."
  copy_theme
  install_sass
  install_bourbon
  install_neat
  install_bitters
  create_project_css_folders
  say "Docs for Bourbon: http://bourbon.io/docs/"
  say "Docs for Neat: http://neat.bourbon.io/"
  say "Docs for Bitters: http://bitters.bourbon.io/"
  say ""
  say "Theme installed. Run `pave watch` to generate css from your sass files."
end
watch(browser) click to toggle source
# File lib/pave/theme.rb, line 11
def watch(browser)
  processes = []
  processes << Process.spawn("pave livereload #{browser}", out: $stdout, err: $stderr)
  processes << Process.spawn("sass --watch ./themes/ --style compressed", out: $stdout, err: $stderr)
  processes << Process.spawn("coffee -wcj #{coffee_folder}app.js #{coffee_folder}", out: $stdout, err: $stderr)

  Signal.trap("INT") do
    processes.map do |pid|
      Process.kill("INT", pid)
    end

    exit!
  end

  Process.wait processes.sample # Just wait on a random process
end