Skip to content
Browse files

Let's wrap this up

  • Loading branch information...
1 parent c5708e1 commit 9887e07b61358d6902af4947a243dde327bbe987 @ddemaree committed
Showing with 80 additions and 48 deletions.
  1. +10 −0 Rakefile
  2. +1 −1 bin/soundwave
  3. +0 −45 lib/soundwave.rb
  4. +67 −0 lib/soundwave/cli.rb
  5. +2 −1 lib/soundwave/rake.rb
  6. +0 −1 soundwave.gemspec
View
10 Rakefile
@@ -0,0 +1,10 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
+# require 'rspec/core/rake_task'
+# RSpec::Core::RakeTask.new(:spec)
+
+require 'annotations/rake_task'
+Annotations::RakeTask.new(:notes)
+
+task :default => [:notes]
+
View
2 bin/soundwave
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-require 'soundwave'
+require 'soundwave/cli'
Soundwave::CLI.run
View
45 lib/soundwave.rb
@@ -3,50 +3,6 @@
require 'multi_json'
module Soundwave
- module CLI
- extend self
-
- def run
- require 'optparse'
-
- options = {}
- opts = OptionParser.new do |opts|
- opts.summary_width = 24
- opts.banner = "Help banner needed"
-
- opts.on("--version", "Display current version") do
- puts "Soundwave " + Soundwave::VERSION
- exit 0
- end
-
- opts.on("-i DIRECTORY", "--includes-dir=DIRECTORY", "Adds DIRECTORY to includes path") do |directory|
- options[:include_dirs] ||= []
- options[:include_dirs] << directory
- end
- end
-
- opts.parse!
-
- source = ARGV.shift || "./"
-
- if File.directory?(source)
- puts "Generating website in #{source}"
- site = Site.new(source)
- destination = ARGV.shift || site.source.join("_site")
- site.generate(destination)
- else
- site = Site.new("./")
- page = Page.new(site, source)
- if destination = ARGV.shift
- destination = site.source.join(destination)
- page.write(destination)
- else
- puts page.render
- end
- end
- end
- end
-
class Mustache < ::Mustache
attr_reader :page
@@ -153,5 +109,4 @@ def read_data
end
end
end
-
end
View
67 lib/soundwave/cli.rb
@@ -0,0 +1,67 @@
+module Soundwave
+ module CLI
+ extend self
+
+ def run
+ require 'optparse'
+
+ help = <<HELP
+Soundwave processes Mustache templates and YAML/JSON data into static web pages.
+
+Usage:
+- soundwave [options]
+ Processes all .mustache files in the current directory.
+
+- soundwave [options] SOURCE [DESTINATION ...]
+ Processes all .mustache files in SOURCE, and outputs them to DESTINATION.
+ If DESTINATION is empty, defaults to SOURCE/_site.
+
+- soundwave [options] FILENAME [DESTINATION ...]
+ Renders the Mustache template at FILENAME and writes it to DESTINATION
+ if given, or to STDOUT.
+
+Options:
+HELP
+
+ options = {}
+ opts = OptionParser.new do |opts|
+ opts.banner = help
+
+ opts.on("--version", "Display current version") do
+ puts "Soundwave " + Soundwave::VERSION
+ exit 0
+ end
+
+ opts.on("-i DIRECTORY", "--includes-dir=DIRECTORY", "Adds DIRECTORY to includes path") do |directory|
+ options[:include_dirs] ||= []
+ options[:include_dirs] << directory
+ end
+
+ opts.on("-d DIRECTORY", "--data-dir=DIRECTORY", "Adds DIRECTORY to data path") do |directory|
+ options[:data_dirs] ||= []
+ options[:data_dirs] << directory
+ end
+ end
+
+ opts.parse!
+
+ source = ARGV.shift || "./"
+
+ if File.directory?(source)
+ puts "Generating website in #{source}"
+ site = Site.new(source)
+ destination = ARGV.shift || site.source.join("_site")
+ site.generate(destination)
+ else
+ site = Site.new("./")
+ page = Page.new(site, source)
+ if destination = ARGV.shift
+ destination = site.source.join(destination)
+ page.write(destination)
+ else
+ puts page.render
+ end
+ end
+ end
+ end
+end
View
3 lib/soundwave/rake.rb
@@ -1,5 +1,6 @@
require 'rake'
require 'rake/tasklib'
+require 'soundwave'
module Soundwave
class RakeTask < ::Rake::TaskLib
@@ -8,7 +9,7 @@ class RakeTask < ::Rake::TaskLib
def initialize(name=:pages, source="./", destination="./_site")
@name = name
@site = Site.new(source)
- @destination = destination
+ @destination = Pathname(destination).expand_path
define
end
View
1 soundwave.gemspec
@@ -20,7 +20,6 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency "activesupport", ">= 3.1.0"
gem.add_runtime_dependency "mustache"
gem.add_runtime_dependency "hike"
- # gem.add_runtime_dependency "tilt"
gem.add_development_dependency "annotations"
gem.add_development_dependency "bundler"

0 comments on commit 9887e07

Please sign in to comment.
Something went wrong with that request. Please try again.