Class: Pave::Theme
- Inherits:
-
Object
show all
- Includes:
- Shell
- Defined in:
- lib/pave/theme.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Shell
#file_insert, included, #sh, #shell
Constructor Details
#initialize(name) ⇒ Theme
Returns a new instance of Theme.
28
29
30
|
# File 'lib/pave/theme.rb', line 28
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/pave/theme.rb', line 5
def name
@name
end
|
Class Method Details
.create(name) ⇒ Object
7
8
9
|
# File 'lib/pave/theme.rb', line 7
def self.create(name)
new(name).setup
end
|
Instance Method Details
#coffee_folder ⇒ Object
32
33
34
35
|
# 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 ⇒ Object
60
61
62
|
# 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 ⇒ Object
64
65
66
67
68
|
# 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 ⇒ Object
54
55
56
57
58
|
# 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 ⇒ Object
42
43
44
45
46
|
# 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 ⇒ Object
48
49
50
51
52
|
# 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 ⇒ Object
37
38
39
40
|
# File 'lib/pave/theme.rb', line 37
def install_sass
say "Installing SASS..."
sh "gem install sass"
end
|
#setup ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# 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) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# 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 end
|