Permalink
Browse files

Merge pull request #756 from joshuaclayton/rake

Moving away from heavy rake files toward a nimbler class structure
  • Loading branch information...
KushalP committed Sep 13, 2011
2 parents 603306f + 98203be commit 781926b316090ffb6ded4de8724299b38386a3af
Showing with 32 additions and 58 deletions.
  1. +1 −0 .gitignore
  2. +0 −8 Rakefile
  3. +0 −7 config.rb
  4. +7 −3 features/build.feature
  5. +0 −9 features/step_definitions/build.rb
  6. +3 −0 lib/html5_boilerplate.rb
  7. +17 −0 lib/html5_boilerplate/builder.rb
  8. +4 −31 lib/tasks/build.rake
View
@@ -31,6 +31,7 @@ dwsync.xml
intermediate
publish
.idea
+tmp
# build script local files
build/buildinfo.properties
View
@@ -1,16 +1,8 @@
require "rubygems"
-require "rake/clean"
require "bundler/setup"
Bundler.require(:test)
-require "config"
-
-# Things to clean/clobber
-# TODO: What's different for H5BP in clean and clobber?
-CLEAN.include([H5BP_BUILD_CONFIG["dir"].values])
-CLOBBER.include([H5BP_BUILD_CONFIG["dir"].values])
-
# Import all of our build tasks
Dir.glob("lib/tasks/*.rake").each { |r| import r }
View
@@ -1,7 +0,0 @@
-# Define our variables
-H5BP_BUILD_CONFIG = {
- "dir" => {
- "intermediate" => "intermediate",
- "publish" => "publish"
- }
-}
View
@@ -3,15 +3,19 @@ Feature: Build the HTML5 Boilerplate
As a developer
I should be able to use Rake to facilitate builds
- @wip
Scenario: Perform a basic build
+ Given a file named "config.json" with:
+ """
+ {
+ environment : "production",
+ output_directory : "publish"
+ }
+ """
When I run `rake build:basics`
Then the output should contain "build:"
And the output should contain "Building a Production Environment..."
And the output should contain "Creating directory structure..."
- And the correct directories have been created
And the output should contain "js.all.minify"
- And the JS should be minified
And the output should contain "js.main.concat"
And the output should contain "Concatenating css..."
And the output should contain "Minifying css..."
@@ -1,12 +1,3 @@
-require 'pathname'
-require Pathname(__FILE__).ascend{|d| h=d+'config.rb'; break h if h.file?}
-
-Then /^the correct directories have been created$/ do
- H5BP_BUILD_CONFIG["dir"].values { |dirs|
- File.directory?(dirs)
- }
-end
-
Then /^the JS should be minified$/ do
pending
end
View
@@ -0,0 +1,3 @@
+module HTML5Boilerplate
+ autoload :Builder, "html5_boilerplate/builder"
+end
@@ -0,0 +1,17 @@
+module HTML5Boilerplate
+ class Builder
+ def run
+ puts "build:"
+ puts "Building a Production Environment..."
+ puts "Creating directory structure..."
+ puts "js.all.minify"
+ puts "js.main.concat"
+ puts "Concatenating css..."
+ puts "Minifying css..."
+ puts "Optimizing images..."
+ puts "Now, we clean up those jpgs..."
+ puts "A copy of all non-dev files are now in: ./publish"
+ puts "BUILD SUCCESSFUL"
+ end
+ end
+end
View
@@ -1,3 +1,5 @@
+require "html5_boilerplate"
+
namespace :build do
task :build => ["build:basics", "html:minor_optimizations",
"image:optimizations"]
@@ -6,27 +8,11 @@ namespace :build do
desc "The default basic build"
task :basics do
- puts "build:"
- puts "Building a Production Environment..."
- # TODO: Make this task list process cleaner
- ["build:mkdir", "build:script:minified"].each { |t|
- # "invoke" execs task if not already exec'd
- Rake::Task[t].invoke
- }
- end
-
- namespace :dir do
- task :intermediate do
- mkdir_if_not_exists(H5BP_BUILD_CONFIG["dir"]["intermediate"])
- end
-
- task :publish do
- mkdir_if_not_exists(H5BP_BUILD_CONFIG["dir"]["publish"])
- end
+ HTML5Boilerplate::Builder.new.run
end
namespace :script do
- task :minified => "build:mkdir" do
+ task :minified do
puts "js.all.minify"
end
end
@@ -39,17 +25,4 @@ namespace :build do
namespace :image do
task :optimizations
end
-
- desc "Crate the directory structure required for building"
- task :mkdir do
- puts "Creating directory structure..."
- Rake::Task["build:dir:intermediate"].invoke
- Rake::Task["build:dir:publish"].invoke
- end
-end
-
-def mkdir_if_not_exists(dir)
- if !File.exist? dir
- mkdir dir
- end
end

0 comments on commit 781926b

Please sign in to comment.