jekyll_generator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +33 -0
  3. data/PostInstall.txt +7 -0
  4. data/README.rdoc +58 -0
  5. data/Rakefile +28 -0
  6. data/app_generators/jekyll_generator/USAGE +5 -0
  7. data/app_generators/jekyll_generator/jekyll_generator_generator.rb +87 -0
  8. data/app_generators/jekyll_generator/templates/atom.xml +27 -0
  9. data/app_generators/jekyll_generator/templates/config.yml +1 -0
  10. data/app_generators/jekyll_generator/templates/index.markdown +6 -0
  11. data/bin/jekyll_generator +19 -0
  12. data/features/development.feature +13 -0
  13. data/features/jekyll.feature +71 -0
  14. data/features/steps/common.rb +212 -0
  15. data/features/steps/env.rb +6 -0
  16. data/features/steps/jekyll.rb +24 -0
  17. data/jekyll_generators/plain_theme/plain_theme_generator.rb +3 -0
  18. data/jekyll_generators/plain_theme/templates/_layouts/default.html +61 -0
  19. data/jekyll_generators/plain_theme/templates/_layouts/post.html +86 -0
  20. data/jekyll_generators/plain_theme/templates/css/stylesheet.css +166 -0
  21. data/jekyll_generators/textmate_theme/templates/_layouts/default.html +72 -0
  22. data/jekyll_generators/textmate_theme/templates/_layouts/post.html +91 -0
  23. data/jekyll_generators/textmate_theme/templates/css/macromates.css +380 -0
  24. data/jekyll_generators/textmate_theme/textmate_theme_generator.rb +13 -0
  25. data/lib/jekyll_generator/theme_generator_base.rb +28 -0
  26. data/lib/jekyll_generator.rb +14 -0
  27. data/script/console +10 -0
  28. data/script/destroy +14 -0
  29. data/script/generate +14 -0
  30. data/spec/jekyll_generator_spec.rb +11 -0
  31. data/spec/spec.opts +1 -0
  32. data/spec/spec_helper.rb +10 -0
  33. data/tasks/rspec.rake +21 -0
  34. metadata +119 -0
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.0.0 2008-12-21
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,33 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ app_generators/jekyll_generator/USAGE
7
+ app_generators/jekyll_generator/jekyll_generator_generator.rb
8
+ app_generators/jekyll_generator/templates/atom.xml
9
+ app_generators/jekyll_generator/templates/config.yml
10
+ app_generators/jekyll_generator/templates/index.markdown
11
+ bin/jekyll_generator
12
+ features/development.feature
13
+ features/jekyll.feature
14
+ features/steps/common.rb
15
+ features/steps/env.rb
16
+ features/steps/jekyll.rb
17
+ jekyll_generators/plain_theme/plain_theme_generator.rb
18
+ jekyll_generators/plain_theme/templates/_layouts/default.html
19
+ jekyll_generators/plain_theme/templates/_layouts/post.html
20
+ jekyll_generators/plain_theme/templates/css/stylesheet.css
21
+ jekyll_generators/textmate_theme/templates/_layouts/default.html
22
+ jekyll_generators/textmate_theme/templates/_layouts/post.html
23
+ jekyll_generators/textmate_theme/templates/css/macromates.css
24
+ jekyll_generators/textmate_theme/textmate_theme_generator.rb
25
+ lib/jekyll_generator.rb
26
+ lib/jekyll_generator/theme_generator_base.rb
27
+ script/console
28
+ script/destroy
29
+ script/generate
30
+ spec/jekyll_generator_spec.rb
31
+ spec/spec.opts
32
+ spec/spec_helper.rb
33
+ tasks/rspec.rake
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on jekyll_generator, see http://jekyll_generator.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = jekyll_generator
2
+
3
+ * http://drnic.github.com/jekyll_generator
4
+
5
+ == DESCRIPTION:
6
+
7
+ A nice generator for a Jekyll website including Disqus comments integration. Probably tightly integrated to github and Github Pages. Will be relaxed later.
8
+
9
+ == EXAMPLES:
10
+
11
+ * http://drnic.github.com/macruby-tmbundle
12
+
13
+ == SYNOPSIS:
14
+
15
+ cd to/your/project
16
+ jekyll_generator website --title "Name of Project"
17
+ cd website
18
+ jekyll
19
+ open _site/index.html
20
+
21
+ It is assumed that your project is already a git repository stored on github. The generators
22
+ all use this assumption to derive information about the project.
23
+
24
+ == REQUIREMENTS:
25
+
26
+ * jekyll - this is not installed with jekyll_generator itself
27
+
28
+ sudo gem source http://gems.github.com/
29
+ sudo gem install mojombo-jekyll
30
+
31
+ == INSTALL:
32
+
33
+ sudo gem install jekyll_generator
34
+
35
+ == LICENSE:
36
+
37
+ (The MIT License)
38
+
39
+ Copyright (c) 2008 Dr Nic Williams, http://drnicwilliams, http://mocra.com
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining
42
+ a copy of this software and associated documentation files (the
43
+ 'Software'), to deal in the Software without restriction, including
44
+ without limitation the rights to use, copy, modify, merge, publish,
45
+ distribute, sublicense, and/or sell copies of the Software, and to
46
+ permit persons to whom the Software is furnished to do so, subject to
47
+ the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be
50
+ included in all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
53
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
55
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
56
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
57
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
58
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/jekyll_generator'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('jekyll_generator', JekyllGenerator::VERSION) do |p|
7
+ p.developer('Dr Nic Williams', 'drnicwilliams@gmail.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
+ p.rubyforge_name = 'drnicutilities'
11
+ p.extra_deps = [
12
+ ['rubigen', ">= #{::RubiGen::VERSION}"]
13
+ ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+ Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ # TODO - want other tests/tasks run by default? Add them to the list
28
+ # task :default => [:spec, :features]
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,87 @@
1
+ class JekyllGeneratorGenerator < RubiGen::Base
2
+
3
+ default_options :theme => 'plain'
4
+
5
+ attr_reader :title, :name, :theme, :github_user, :header_color
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @destination_root = File.expand_path(args.shift)
11
+ @name = base_name
12
+ extract_options
13
+ @title ||= base_name.humanize
14
+ @header_color ||= random_color
15
+
16
+ remote_origin_url = `git config remote.origin.url`
17
+ if remote_origin_url.size > 0 && matches = remote_origin_url.match(/git@github.com:(.*)\/(.*).git/)
18
+ @github_user, @name = matches[1..2]
19
+ options[:github_user] ||= @github_user
20
+ end
21
+ options[:name] ||= @name
22
+ options[:header_color] ||= @header_color
23
+ end
24
+
25
+ def manifest
26
+ record do |m|
27
+ # Ensure appropriate folder(s) exists
28
+ m.directory ''
29
+ BASEDIRS.each { |path| m.directory path }
30
+
31
+ m.template_copy_each ["index.markdown", "atom.xml", "config.yml"]
32
+ m.template "_posts/first_post.markdown", "_posts/#{Date.today.to_s}-first-post.markdown"
33
+
34
+ m.dependency "#{theme}_theme", [], :destination => destination_root, :collision => :force
35
+ end
36
+ end
37
+
38
+ protected
39
+ def banner
40
+ <<-EOS
41
+ Creates a Jekyell static website including Disqus comment system.
42
+
43
+ USAGE: #{spec.name} path/to/website
44
+ EOS
45
+ end
46
+
47
+ def add_options!(opts)
48
+ opts.separator ''
49
+ opts.separator 'Options:'
50
+ # For each option below, place the default
51
+ # at the top of the file next to "default_options"
52
+ opts.on("--header-color=rrggbb", String,
53
+ "Color for your theme's header (if theme permits header color selection)",
54
+ "Default: random") { |v| options[:header_color] = v }
55
+ opts.on("--title=\"Your Project\"", String,
56
+ "Your project's human title",
57
+ "Default: current folder name") { |v| options[:title] = v }
58
+ opts.on("-t", "--theme=THEME", String,
59
+ "Initial layouts, css, images from a theme.",
60
+ "Available: plain, textmate",
61
+ "Default: plain") { |v| options[:theme] = v }
62
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
63
+ end
64
+
65
+ def extract_options
66
+ @theme = options[:theme]
67
+ @header_color = options[:header_color]
68
+ @title = options[:title]
69
+ end
70
+
71
+ def random_color
72
+ colors = ['aaa', # light grey
73
+ '8DBD82', # background from http://newgem.rubyforge.org/
74
+ 'E9C000', # background from http://drnicjavascript.rubyforge.org/github_badge/
75
+ '4D606C', # header background from http://disqus.com/people/drnic/
76
+ 'FF6633', # orangy color
77
+ 'FF6633', # dark blue color
78
+ ]
79
+ colors[rand(colors.length)]
80
+ end
81
+
82
+ # Installation skeleton. Intermediate directories are automatically
83
+ # created so don't sweat their absence here.
84
+ BASEDIRS = %w(
85
+ _posts
86
+ )
87
+ end
@@ -0,0 +1,27 @@
1
+ ---
2
+ layout: nil
3
+ ---
4
+ <?xml version="1.0" encoding="utf-8"?>
5
+ <feed xmlns="http://www.w3.org/2005/Atom">
6
+
7
+ <title><%= title %></title>
8
+ <link href="http://<%= github_user %>.github.com/<%= name %>/atom.xml" rel="self"/>
9
+ <link href="http://<%= github_user %>.github.com/<%= name %>/"/>
10
+ <updated>{{ site.time | date_to_xmlschema }}</updated>
11
+ <id>http://<%= github_user %>.github.com/<%= name %>/</id>
12
+ <author>
13
+ <name>Dr Nic Williams</name>
14
+ <email><%= github_user %>williams@gmail.com</email>
15
+ </author>
16
+
17
+ {% for post in site.posts %}
18
+ <entry>
19
+ <title>{{ post.title }}</title>
20
+ <link href="http://<%= github_user %>.github.com/<%= name %>{{ post.url }}"/>
21
+ <updated>{{ post.date | date_to_xmlschema }}</updated>
22
+ <id>http://<%= github_user %>.github.com/<%= name %>{{ post.id }}</id>
23
+ <content type="html">{{ post.content | xml_escape }}</content>
24
+ </entry>
25
+ {% endfor %}
26
+
27
+ </feed>
@@ -0,0 +1 @@
1
+ <%= options.reject {|name, value| [:stdout, :command, :quiet, :collision, :generator].include? name}.to_yaml %>
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title: <%= title %>
4
+ ---
5
+
6
+ This project <a href="http://github.com/<%= github_user %>/<%= name %>"><%= title %></a> is awesome.
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'jekyll_generator/version'
8
+ puts "#{File.basename($0)} #{JekyllGenerator::VERSION}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ RubiGen::Base.use_application_sources! :rubygems
14
+ RubiGen::Base.prepend_sources(*[
15
+ RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "app_generators")),
16
+ RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "jekyll_generators"))
17
+ ])
18
+
19
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'jekyll_generator')
@@ -0,0 +1,13 @@
1
+ Feature: Development processes of newgem itself (rake tasks)
2
+
3
+ As a Newgem maintainer or contributor
4
+ I want rake tasks to maintain and release the gem
5
+ So that I can spend time on the tests and code, and not excessive time on maintenance processes
6
+
7
+ Scenario: Generate RubyGem
8
+ Given this project is active project folder
9
+ And 'pkg' folder is deleted
10
+ When task 'rake gem' is invoked
11
+ Then folder 'pkg' is created
12
+ And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
13
+ And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
@@ -0,0 +1,71 @@
1
+ Feature: Generate a working Jekyll-based website
2
+ In order to reduce cost of creating a new website for a project
3
+ As a project developer/marketer
4
+ I want a Jekyll-based website generated
5
+
6
+ Scenario: Generate a site with default theme
7
+ Given a project folder 'myproject'
8
+ And I make it a git repository with origin remote 'git@github.com:myname/myproject.git'
9
+ When I run local executable 'jekyll_generator' with arguments 'website --title "My Project"'
10
+ Then folder 'website' is created
11
+ And folder 'website/_posts' is created
12
+ And file 'website/index.markdown' is created
13
+ And contents of file 'website/index.markdown' does match /http:\/\/github.com\/myname\/myproject/
14
+ And file 'website/atom.xml' is created
15
+ And contents of file 'website/atom.xml' does match /http:\/\/myname.github.com\/myproject/
16
+ And file 'website/_layouts/default.html' is created
17
+ And contents of file 'website/_layouts/default.html' does match /My Project/
18
+ And contents of file 'website/_layouts/default.html' does match /http:\/\/github.com\/myname\/myproject/
19
+ And file 'website/_layouts/post.html' is created
20
+ And contents of file 'website/_layouts/default.html' does match /My Project/
21
+ And contents of file 'website/_layouts/post.html' does match /http:\/\/github.com\/myname\/myproject/
22
+ And file 'website/css/stylesheet.css' is created
23
+ And contents of file 'website/css/stylesheet.css' does not match /background:\s#;/
24
+ And folder 'website/_site' is not created
25
+ And does invoke generator 'plain_theme'
26
+ And output does not match /General Options:/
27
+ When I run executable 'jekyll' with arguments 'website website/_site'
28
+ Then folder 'website/_site' is created
29
+ And file 'website/_site/index.html' is created
30
+
31
+ Scenario: Site with default theme has posts
32
+ Given a project folder 'myproject'
33
+ And I make it a git repository with origin remote 'git@github.com:myname/myproject.git'
34
+ When I run local executable 'jekyll_generator' with arguments 'website --title "My Project"'
35
+ And I create a blog post
36
+ And I run executable 'jekyll' with arguments 'website website/_site'
37
+ Then blog post HTML file is created
38
+
39
+ Scenario: Site with underscored name should have hyphenated disqus name
40
+ Given a project folder 'my_project'
41
+ And I make it a git repository with origin remote 'git@github.com:myname/my_project.git'
42
+ When I run local executable 'jekyll_generator' with arguments 'website --title "My Project"'
43
+ Then contents of file 'website/_layouts/default.html' does match /disqus.com\/forums\/my-project/
44
+ And contents of file 'website/_layouts/post.html' does match /disqus.com\/forums\/my-project/
45
+
46
+ Scenario: Generate a site with textmate theme
47
+ Given a project folder 'myproject'
48
+ And I make it a git repository with origin remote 'git@github.com:myname/myproject.git'
49
+ When I run local executable 'jekyll_generator' with arguments 'website --theme textmate --title "My Project"'
50
+ Then folder 'website' is created
51
+ And file 'website/_layouts/default.html' is created
52
+ And contents of file 'website/_layouts/default.html' does match /My Project/
53
+ And contents of file 'website/_layouts/default.html' does match /http:\/\/github.com\/myname\/myproject/
54
+ And file 'website/_layouts/post.html' is created
55
+ And contents of file 'website/_layouts/default.html' does match /My Project/
56
+ And contents of file 'website/_layouts/post.html' does match /http:\/\/github.com\/myname\/myproject/
57
+ And file 'website/css/macromates.css' is created
58
+ And folder 'website/_site' is not created
59
+ And does invoke generator 'textmate_theme'
60
+ And output does not match /General Options:/
61
+ When I run executable 'jekyll' with arguments 'website website/_site'
62
+ Then folder 'website/_site' is created
63
+ And file 'website/_site/index.html' is created
64
+
65
+ Scenario: Site with default theme has posts
66
+ Given a project folder 'myproject'
67
+ And I make it a git repository with origin remote 'git@github.com:myname/myproject.git'
68
+ When I run local executable 'jekyll_generator' with arguments 'website --theme textmate --title "My Project"'
69
+ When I create a blog post
70
+ When I run executable 'jekyll' with arguments 'website website/_site'
71
+ Then blog post HTML file is created
@@ -0,0 +1,212 @@
1
+ def in_project_folder(&block)
2
+ project_folder = @active_project_folder || @tmp_root
3
+ FileUtils.chdir(project_folder, &block)
4
+ end
5
+
6
+ def in_home_folder(&block)
7
+ FileUtils.chdir(@home_path, &block)
8
+ end
9
+
10
+ Given %r{^a safe folder} do
11
+ FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
12
+ FileUtils.mkdir_p @tmp_root
13
+ FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
14
+ @lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
15
+ Given "env variable $HOME set to '#{@home_path}'"
16
+ end
17
+
18
+ Given /a project folder '(.*)'/ do |project_folder|
19
+ Given "a safe folder"
20
+ @active_project_folder = File.expand_path(File.join(@tmp_root, project_folder))
21
+ FileUtils.mkdir_p @active_project_folder
22
+ end
23
+
24
+ Given %r{^this project is active project folder} do
25
+ Given "a safe folder"
26
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
27
+ end
28
+
29
+ Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
30
+ ENV[env_var] = value
31
+ end
32
+
33
+ def force_local_lib_override(project_name = @project_name)
34
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
35
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
36
+ f << "$:.unshift('#{@lib_path}')\n"
37
+ f << rakefile
38
+ end
39
+ end
40
+
41
+ def setup_active_project_folder project_name
42
+ @active_project_folder = File.join(@tmp_root, project_name)
43
+ @project_name = project_name
44
+ end
45
+
46
+ Given %r{'(.*)' folder is deleted} do |folder|
47
+ in_project_folder do
48
+ FileUtils.rm_rf folder
49
+ end
50
+ end
51
+
52
+ When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
53
+ @stdout = StringIO.new
54
+ FileUtils.chdir(@active_project_folder) do
55
+ if Object.const_defined?("APP_ROOT")
56
+ APP_ROOT.replace(FileUtils.pwd)
57
+ else
58
+ APP_ROOT = FileUtils.pwd
59
+ end
60
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
61
+ end
62
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
63
+ @stdout.rewind
64
+ f << @stdout.read
65
+ end
66
+ end
67
+
68
+ When %r{run executable '(.*)' with arguments '(.*)'} do |executable, arguments|
69
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
70
+ in_project_folder do
71
+ system "#{executable} #{arguments} > #{@stdout} 2>&1"
72
+ end
73
+ end
74
+
75
+ When %r{run project executable '(.*)' with arguments '(.*)'} do |executable, arguments|
76
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
77
+ in_project_folder do
78
+ system "#{executable} #{arguments} > #{@stdout} 2>&1"
79
+ end
80
+ end
81
+
82
+ When %r{run local executable '(.*)' with arguments '(.*)'} do |executable, arguments|
83
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
84
+ @stderr = File.expand_path(File.join(@tmp_root, "executable.err"))
85
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
86
+ in_project_folder do
87
+ system "#{executable} #{arguments} > #{@stdout} 2> #{@stderr}"
88
+ end
89
+ end
90
+
91
+ When %r{^task 'rake (.*)' is invoked$} do |task|
92
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
93
+ FileUtils.chdir(@active_project_folder) do
94
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
95
+ end
96
+ end
97
+
98
+ Then %r{^folder '(.*)' (is|is not) created} do |folder, is|
99
+ in_project_folder do
100
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
101
+ end
102
+ end
103
+
104
+ Then %r{^file '(.*)' (is|is not) created} do |file, is|
105
+ in_project_folder do
106
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
107
+ end
108
+ end
109
+
110
+ Then %r{^file with name matching '(.*)' is created} do |pattern|
111
+ in_project_folder do
112
+ Dir[pattern].should_not be_empty
113
+ end
114
+ end
115
+
116
+ Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
117
+ File.exists?(gem_file).should be_true
118
+ File.exists?(project_file).should be_true
119
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
120
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
121
+ project_file_contents.should == gem_file_contents
122
+ end
123
+
124
+ Then %r{^output same as contents of '(.*)'$} do |file|
125
+ expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
126
+ actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
127
+ actual_output.should == expected_output
128
+ end
129
+
130
+ Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
131
+ actual_output = File.read(@stdout)
132
+ does_invoke == "does" ?
133
+ actual_output.should(match(/dependency\s+#{generator}/)) :
134
+ actual_output.should_not(match(/dependency\s+#{generator}/))
135
+ end
136
+
137
+ Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
138
+ actual_output = File.read(@stdout)
139
+ actual_output.should match(/#{opt1}/)
140
+ actual_output.should match(/#{opt2}/)
141
+ end
142
+
143
+ Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
144
+ actual_output = File.read(@stdout)
145
+ (does == 'does') ?
146
+ actual_output.should(match(/#{regex}/)) :
147
+ actual_output.should_not(match(/#{regex}/))
148
+ end
149
+
150
+ Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
151
+ in_project_folder do
152
+ actual_output = File.read(file)
153
+ (does == 'does') ?
154
+ actual_output.should(match(/#{regex}/)) :
155
+ actual_output.should_not(match(/#{regex}/))
156
+ end
157
+ end
158
+
159
+ Then %r{^all (\d+) tests pass} do |expected_test_count|
160
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
161
+ actual_output = File.read(@stdout)
162
+ actual_output.should match(expected)
163
+ end
164
+
165
+ Then %r{^all (\d+) examples pass} do |expected_test_count|
166
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
167
+ actual_output = File.read(@stdout)
168
+ actual_output.should match(expected)
169
+ end
170
+
171
+ Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
172
+ in_project_folder do
173
+ yaml = eval yaml
174
+ YAML.load(File.read(file)).should == yaml
175
+ end
176
+ end
177
+
178
+ Then %r{^Rakefile can display tasks successfully} do
179
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
180
+ FileUtils.chdir(@active_project_folder) do
181
+ system "rake -T > #{@stdout} 2> #{@stdout}"
182
+ end
183
+ actual_output = File.read(@stdout)
184
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
185
+ end
186
+
187
+ Then %r{^task 'rake (.*)' is executed successfully} do |task|
188
+ @stdout.should_not be_nil
189
+ actual_output = File.read(@stdout)
190
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
191
+ actual_output.should_not match(/Error/i)
192
+ end
193
+
194
+ Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
195
+ in_project_folder do
196
+ gem_file = Dir["pkg/*.gem"].first
197
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
198
+ spec_value = gem_spec.send(key.to_sym)
199
+ spec_value.to_s.should match(/#{regex}/)
200
+ end
201
+ end
202
+
203
+ When /^I make it a git repository with origin remote '(.*)'$/ do |remote|
204
+ @stdout = File.expand_path(File.join(@tmp_root, "git.out"))
205
+ @stderr = File.expand_path(File.join(@tmp_root, "git.err"))
206
+ in_project_folder do
207
+ system "git init > #{@stdout} 2> #{@stderr}"
208
+ system "git add . > #{@stdout} 2> #{@stderr}"
209
+ system "git commit -m 'initial import' > #{@stdout} 2> #{@stderr}"
210
+ system "git remote add origin #{remote} > #{@stdout} 2> #{@stderr}"
211
+ end
212
+ end
@@ -0,0 +1,6 @@
1
+ require File.dirname(__FILE__) + "/../../lib/jekyll_generator"
2
+
3
+ gem 'cucumber'
4
+ require 'cucumber'
5
+ gem 'rspec'
6
+ require 'spec'
@@ -0,0 +1,24 @@
1
+ When /^I create a blog post$/ do
2
+ in_project_folder do
3
+ File.open("website/_posts/2008-12-21-my-first-post.markdown", "w") do |f|
4
+ f << <<-EOS.gsub(/^ /, '')
5
+ ---
6
+ layout: post
7
+ title: My first post
8
+ ---
9
+
10
+ This is my post
11
+ EOS
12
+ end
13
+ end
14
+ end
15
+
16
+ Then /^blog post HTML file is created$/ do
17
+ file = "website/_site/2008/12/21/my-first-post.html"
18
+ in_project_folder do
19
+ File.should be_exist(file)
20
+ end
21
+ Given "contents of file '#{file}' does match /<head>/"
22
+ Given "contents of file '#{file}' does match /<title>My first post</title>/"
23
+ Given "contents of file '#{file}' does match /This is my post/"
24
+ end
@@ -0,0 +1,3 @@
1
+ require File.dirname(__FILE__) + '/../../lib/jekyll_generator'
2
+ class PlainThemeGenerator < JekyllGenerator::ThemeGeneratorBase
3
+ end