guard_boilerplate 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +15 -5
- data/bin/gbp +16 -16
- data/lib/version.rb +1 -1
- data/templates/Guardfile +6 -6
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,11 +8,13 @@ Impatient? Have Ruby installed and understand what a gem is? Use the Boilerplate
|
|
8
8
|
|
9
9
|
1. Install the [LiveReload](https://github.com/mockko/livereload#readme) extension in your browser
|
10
10
|
2. Install guard_boilerplate and start a new project:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
gem install guard_boilerplate
|
12
|
+
if [ `uname -s` == "Darwin" ] ; then gem install rb-fsevent ; fi
|
13
|
+
if [ `uname -s` == "Linux" ] ; then gem install rb-inotify ; fi
|
14
|
+
mkdir my_site && cd my_site
|
15
|
+
curl -L 'https://github.com/paulirish/html5-boilerplate/tarball/master' | tar -xzf - --strip-components 1
|
16
|
+
gbp hamlize && gbp sassify
|
17
|
+
gbp start
|
16
18
|
3. Hit the LiveReload **LR** button in your browser
|
17
19
|
4. Edit!
|
18
20
|
|
@@ -50,6 +52,14 @@ Are you ready?
|
|
50
52
|
|
51
53
|
gem install guard_boilerplate
|
52
54
|
|
55
|
+
On the Mac?
|
56
|
+
|
57
|
+
gem install rb-fsevent
|
58
|
+
|
59
|
+
On Linux?
|
60
|
+
|
61
|
+
gem install rb-inotify
|
62
|
+
|
53
63
|
Now give yourself a slap on the back.
|
54
64
|
|
55
65
|
# Use!
|
data/bin/gbp
CHANGED
@@ -27,13 +27,13 @@ class GuardBoilerPlate < Thor
|
|
27
27
|
|
28
28
|
desc "sassify", "Migrates CSS files to SCSS files"
|
29
29
|
def sassify
|
30
|
-
if File.directory? "
|
30
|
+
if File.directory? "assets/stylesheets"
|
31
31
|
say "\nA sass/ directory already exists, so skipping\n", :red
|
32
32
|
else
|
33
33
|
say "Copying CSS files to SCSS...", :green
|
34
|
-
FileUtils.mkdir_p "
|
34
|
+
FileUtils.mkdir_p "assets/stylesheets", :verbose => true
|
35
35
|
Dir["css/**/*.css"].each do |css_file|
|
36
|
-
scss_file = css_file.sub(/^css/, '
|
36
|
+
scss_file = css_file.sub(/^css/, 'assets/stylesheets').sub(/\.css$/, '.scss')
|
37
37
|
FileUtils.mkdir_p(File.dirname(scss_file))
|
38
38
|
FileUtils.cp css_file, scss_file, :verbose => true
|
39
39
|
say "Generated #{scss_file} from #{css_file} (straight copy)", :green
|
@@ -43,26 +43,26 @@ class GuardBoilerPlate < Thor
|
|
43
43
|
|
44
44
|
desc "hamlize", "Migrates your HTML files to Haml files"
|
45
45
|
def hamlize
|
46
|
-
if File.directory? "
|
46
|
+
if File.directory? "assets/views"
|
47
47
|
say "\nA haml/ directory already exists, so skipping\n", :red
|
48
48
|
else
|
49
49
|
say "Converting HTML files to Haml...", :green
|
50
|
-
FileUtils.mkdir_p "
|
50
|
+
FileUtils.mkdir_p "assets/views", :verbose => true
|
51
51
|
Dir["**/*.html"].each { |html_file| html_to_haml(html_file) }
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
desc "minify", "Compresses your HTML files from Haml and CSS files from SCSS"
|
56
56
|
def minify
|
57
|
-
if File.directory? "
|
57
|
+
if File.directory? "assets/views"
|
58
58
|
say "\nMinifying HTML from Haml...", :green
|
59
|
-
Dir["
|
59
|
+
Dir["assets/views/**/*.haml"].each do |haml_file|
|
60
60
|
haml_to_html(haml_file, :ugly => true)
|
61
61
|
end
|
62
62
|
end
|
63
|
-
if File.directory? "
|
63
|
+
if File.directory? "assets/stylesheets"
|
64
64
|
say "\nMinifying CSS from SCSS...", :green
|
65
|
-
Dir["
|
65
|
+
Dir["assets/stylesheets/**/*.scss"].each do |scss_file|
|
66
66
|
scss_to_css(scss_file, :style => :compressed)
|
67
67
|
end
|
68
68
|
end
|
@@ -70,15 +70,15 @@ class GuardBoilerPlate < Thor
|
|
70
70
|
|
71
71
|
desc "prettify", "Pretties your HTML files from Haml and CSS files from SCSS"
|
72
72
|
def prettify
|
73
|
-
if File.directory? "
|
73
|
+
if File.directory? "assets/views"
|
74
74
|
say "\nPrettifying HTML from Haml...", :green
|
75
|
-
Dir["
|
75
|
+
Dir["assets/views/**/*.haml"].each do |haml_file|
|
76
76
|
haml_to_html(haml_file)
|
77
77
|
end
|
78
78
|
end
|
79
|
-
if File.directory? "
|
79
|
+
if File.directory? "assets/stylesheets"
|
80
80
|
say "\nPrettifying CSS from SCSS...", :green
|
81
|
-
Dir["
|
81
|
+
Dir["assets/stylesheets/**/*.scss"].each do |scss_file|
|
82
82
|
scss_to_css(scss_file)
|
83
83
|
end
|
84
84
|
end
|
@@ -91,7 +91,7 @@ class GuardBoilerPlate < Thor
|
|
91
91
|
private
|
92
92
|
|
93
93
|
def html_to_haml(html_file)
|
94
|
-
haml_file = File.join('
|
94
|
+
haml_file = File.join('assets/views', html_file.sub(/\.html?$/, '.haml'))
|
95
95
|
|
96
96
|
template = File.open(html_file, 'rb') { |f| f.read }
|
97
97
|
output = Haml::HTML.new(template).render
|
@@ -102,7 +102,7 @@ class GuardBoilerPlate < Thor
|
|
102
102
|
|
103
103
|
def haml_to_html(haml_file, options = {})
|
104
104
|
options = { :format => :html5 }.update(options)
|
105
|
-
html_file = haml_file.sub(/^
|
105
|
+
html_file = haml_file.sub(/^assets\/views\//, '').sub(/\.haml$/, '.html')
|
106
106
|
|
107
107
|
template = File.open(haml_file, 'rb') { |f| f.read }
|
108
108
|
output = Haml::Engine.new(template, options).render
|
@@ -112,7 +112,7 @@ class GuardBoilerPlate < Thor
|
|
112
112
|
|
113
113
|
def scss_to_css(scss_file, options = {})
|
114
114
|
options = { :syntax => :scss, :style => :expanded }.update(options)
|
115
|
-
css_file = scss_file.sub(/^
|
115
|
+
css_file = scss_file.sub(/^assets\/stylesheets/, 'css').sub(/\.scss$/, '.css')
|
116
116
|
|
117
117
|
template = File.open(scss_file, 'rb') { |f| f.read }
|
118
118
|
output = Sass::Engine.new(template, options).render
|
data/lib/version.rb
CHANGED
data/templates/Guardfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# More info at https://github.com/guard/guard#readme
|
2
2
|
|
3
|
-
guard 'sass' do
|
4
|
-
watch(%r{
|
3
|
+
guard 'sass', :output => '../css' do
|
4
|
+
watch(%r{assets/stylesheets/.+\.(scss|sass)})
|
5
5
|
end
|
6
6
|
|
7
7
|
guard 'shell' do
|
8
|
-
watch(%r{
|
9
|
-
`haml -f html5 #{File.join("
|
8
|
+
watch(%r{assets/views/(.+)\.haml}) do |m|
|
9
|
+
`haml -f html5 #{File.join("assets/views", m[1])}.haml #{m[1]}.html`
|
10
10
|
puts "Rebuilt #{m[1]}.html"
|
11
11
|
end
|
12
12
|
end
|
@@ -16,9 +16,9 @@ end
|
|
16
16
|
|
17
17
|
guard 'livereload' do
|
18
18
|
watch(%r{.+\.(html|htm)})
|
19
|
-
watch(%r{haml/.+\.(haml)})
|
20
19
|
watch(%r{css/.+\.(css)})
|
21
|
-
watch(%r{sass/.+\.(scss|sass)})
|
22
20
|
watch(%r{img/.+\.(png|jpeg|jpg)})
|
23
21
|
watch(%r{js/.+\.(js)})
|
22
|
+
watch(%r{assets/views/.+\.(haml)})
|
23
|
+
watch(%r{assets/stylesheets/.+\.(scss|sass)})
|
24
24
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard_boilerplate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Fletcher Nichol
|