Learned a lot, with create structured nicely.

This commit is contained in:
Adam Williams 2011-12-21 12:38:38 -05:00
parent dc99730a8b
commit 94456bec3f
12 changed files with 107 additions and 10 deletions

View File

@ -1,3 +1,50 @@
octopress create
-------------------------------
*********************************************************************
Congratulations! Your compass project has been created.
You may now add and edit sass stylesheets in the sass subdirectory of your project.
Sass files beginning with an underscore are called partials and won't be
compiled to CSS, but they can be imported into other sass stylesheets.
You can configure your project by editing the config.rb configuration file.
You must compile your sass stylesheets into CSS when they change.
This can be done in one of the following ways:
1. To compile on demand:
compass compile [path/to/project]
2. To monitor your project for changes and automatically recompile:
compass watch [path/to/project]
More Resources:
* Website: http://compass-style.org/
* Sass: http://sass-lang.com
* Community: http://groups.google.com/group/compass-users/
To import your new stylesheets add the following lines of HTML (or equivalent) to your webpage:
<head>
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
<link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]>
<link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
octopress --global-option command -d myblog octopress --global-option command -d myblog
octopress --path /my/blog post --option new "Hello" octopress --path /my/blog post --option new "Hello"

View File

@ -3,7 +3,7 @@
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib') $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
require 'rubygems' require 'rubygems'
require 'gli' require 'gli'
require 'octopress_version' require 'octopress'
include GLI include GLI
@ -29,11 +29,7 @@ command :create do |c|
c.default_value 'default' c.default_value 'default'
c.flag :f c.flag :f
c.action do |global_options,options,args| c.action do |global_options,options,args|
puts "Hello!" Octopress::Commands::Create.new(args[0] || '.').execute
# Your command logic here
# If you have any errors, just raise them
# raise "that command made no sense"
end end
end end

View File

@ -1,5 +1,17 @@
Feature: Create a new Octopress Blog Feature: create subcommand
Scenario: create with no flags, switches or arguments In order to make blogs for hackers
As a hacker using the octopress executable
I want to generate a blog from a template
Scenario: No flags, switches or arguments
When I successfully run `octopress create` When I successfully run `octopress create`
Then the stdout should contain "Hello!" Then the octopress blog files should exist
Scenario: Path argument provided
When I successfully run `octopress create pathto/myblog`
Then a directory named "pathto/myblog" should exist
When I cd to "pathto/myblog"
Then the octopress blog files should exist
Scenario: directory exists

View File

@ -0,0 +1,7 @@
Then /the octopress blog files should exist/ do
check_file_presence(%w(
.rvmrc
.rbenv-version
Gemfile
), true)
end

View File

@ -0,0 +1,8 @@
module Octopress
def Octopress.template_root
File.join File.expand_path(File.dirname(__FILE__)), 'octopress', 'template'
end
end
require 'octopress/version'
require 'octopress/commands'

View File

@ -0,0 +1,4 @@
module Octopress::Commands
end
require 'octopress/commands/create'

View File

@ -0,0 +1,19 @@
class Octopress::Commands::Create
include FileUtils
def initialize(project_path)
@project_root = File.expand_path project_path
@template_root = Octopress.template_root
puts @template_root
end
def execute
mkdir_p @project_root
Dir.glob(File.join(@template_root, '*'), File::FNM_DOTMATCH).each do |template_path|
basename = File.basename template_path
next if %w(. ..).include?(basename)
puts "File: #{basename}"
cp template_path, @project_root
end
end
end

View File

@ -0,0 +1 @@
1.9.2-p290

View File

@ -0,0 +1 @@
rvm use 1.9.2

View File

@ -0,0 +1,2 @@
source 'http://rubygems.org'
gem 'compass'

View File

@ -1,5 +1,5 @@
# Ensure we require the local version and not one we might have installed already # Ensure we require the local version and not one we might have installed already
require File.join([File.dirname(__FILE__),'lib','octopress_version.rb']) require File.join([File.dirname(__FILE__),'lib','octopress','version.rb'])
spec = Gem::Specification.new do |s| spec = Gem::Specification.new do |s|
s.name = 'octopress' s.name = 'octopress'
s.version = Octopress::VERSION s.version = Octopress::VERSION