A bit more thinking. We are going to need to understand themes a lot sooner than I thought.

This commit is contained in:
Adam Williams 2011-12-22 23:23:36 -05:00
parent 94456bec3f
commit a11c07bd5f
9 changed files with 93 additions and 12 deletions

View File

@ -3,10 +3,13 @@ PATH
specs:
octopress (0.0.1)
gli (~> 1.4.0)
jekyll (~> 0.11.0)
GEM
remote: http://rubygems.org/
specs:
albino (1.3.3)
posix-spawn (>= 0.3.6)
aruba (0.4.9)
childprocess (>= 0.2.3)
cucumber (>= 1.1.1)
@ -15,6 +18,8 @@ GEM
builder (3.0.0)
childprocess (0.2.3)
ffi (~> 1.0.6)
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
cucumber (1.1.4)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
@ -22,11 +27,25 @@ GEM
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
diff-lcs (1.1.3)
directory_watcher (1.4.1)
fast-stemmer (1.0.0)
ffi (1.0.11)
gherkin (2.7.1)
json (>= 1.4.6)
gli (1.4.0)
jekyll (0.11.0)
albino (>= 1.3.2)
classifier (>= 1.3.1)
directory_watcher (>= 1.1.1)
kramdown (>= 0.13.2)
liquid (>= 1.9.0)
maruku (>= 0.5.9)
json (1.6.3)
kramdown (0.13.4)
liquid (2.3.0)
maruku (0.6.0)
syntax (>= 1.0.0)
posix-spawn (0.3.6)
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
@ -38,6 +57,7 @@ GEM
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.7.0)
syntax (1.0.0)
term-ansicolor (1.0.7)
PLATFORMS

View File

@ -2,16 +2,16 @@ Feature: create subcommand
In order to make blogs for hackers
As a hacker using the octopress executable
I want to generate a blog from a template
I want to create a blog from a template
Scenario: No flags, switches or arguments
When I successfully run `octopress create`
Then the octopress blog files should exist
Then an empty project structure 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
Then an empty project structure should exist
Scenario: directory exists

View File

@ -1,7 +1,13 @@
Then /the octopress blog files should exist/ do
Then /an empty project structure should exist/ do
check_directory_presence(%w(
_plugins
), true)
check_file_presence(%w(
.rvmrc
.rbenv-version
_config.yml
Gemfile
_plugins/octopress.rb
), true)
end

View File

@ -4,16 +4,10 @@ class Octopress::Commands::Create
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
cp_r File.join(@template_root, '.'), @project_root
end
end

View File

@ -0,0 +1,36 @@
class String
def titlecase
small_words = %w(a an and as at but by en for if in of on or the to v v. via vs vs.)
x = split(" ").map do |word|
# note: word could contain non-word characters!
# downcase all small_words, capitalize the rest
small_words.include?(word.gsub(/\W/, "").downcase) ? word.downcase! : word.smart_capitalize!
word
end
# capitalize first and last words
x.first.to_s.smart_capitalize!
x.last.to_s.smart_capitalize!
# small words are capitalized after colon, period, exclamation mark, question mark
x.join(" ").gsub(/(:|\.|!|\?)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " }
end
def titlecase!
replace(titlecase)
end
def smart_capitalize
# ignore any leading crazy characters and capitalize the first real character
if self =~ /^['"\(\[']*([a-z])/
i = index($1)
x = self[i,self.length]
# word with capitals and periods mid-word are left alone
self[i,1] = self[i,1].upcase unless x =~ /[A-Z]/ or x =~ /\.\w+/
end
self
end
def smart_capitalize!
replace(smart_capitalize)
end
end

View File

@ -1,2 +1,17 @@
source 'http://rubygems.org'
gem 'compass'
# The gems you'll need for generating your site on your development machine.
# The deployment strategy you use determines what you need in production, if
# anything.
#
group :development do
gem 'jekyll', '~> 0.11.0'
gem 'compass', '~> 0.11.0'
end
# If your deployment target has you running Ruby, you might have some gems
# listed here. This will be the case if you deploy to Heroku.
#
group :production do
end

View File

@ -0,0 +1,9 @@
# Files in this directory are loaded by Jekyll. Learn more at
# https://github.com/mojombo/jekyll/wiki/Plugins.
# The Title Case plugin adds some handy String methods:
#
# "my string".titlecase -> "My String"
# "my string".smart_capitalize -> "???"
#
# require 'octopress/plugins/titlecase'

View File

@ -18,6 +18,7 @@ bin/octopress
s.bindir = 'bin'
s.executables << 'octopress'
s.add_dependency('gli', '~> 1.4.0')
s.add_dependency('jekyll', '~> 0.11.0')
s.add_development_dependency('rake')
s.add_development_dependency('rdoc')
s.add_development_dependency('aruba', '~> 0.4.9')