octopress 3.0.0.alpha8 → 3.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +5 -0
  4. data/README.md +130 -27
  5. data/lib/octopress.rb +8 -2
  6. data/lib/octopress/command.rb +3 -0
  7. data/lib/octopress/commands/build.rb +1 -4
  8. data/lib/octopress/commands/doctor.rb +3 -7
  9. data/lib/octopress/commands/helpers.rb +8 -3
  10. data/lib/octopress/commands/init.rb +15 -0
  11. data/lib/octopress/commands/new.rb +25 -22
  12. data/lib/octopress/commands/publish.rb +3 -1
  13. data/lib/octopress/commands/serve.rb +4 -7
  14. data/lib/octopress/configuration.rb +20 -12
  15. data/lib/octopress/draft.rb +39 -8
  16. data/lib/octopress/{core_ext.rb → ext/hash.rb} +0 -0
  17. data/lib/octopress/ext/titlecase.rb +37 -0
  18. data/lib/octopress/page.rb +49 -33
  19. data/lib/octopress/post.rb +17 -16
  20. data/lib/octopress/scaffold.rb +26 -0
  21. data/lib/octopress/version.rb +1 -1
  22. data/octopress.gemspec +1 -1
  23. data/scaffold/_octopress.yml +11 -0
  24. data/scaffold/_templates/page +6 -0
  25. data/scaffold/_templates/post +6 -0
  26. data/test/expected/_drafts/stupid-idea.markdown +6 -0
  27. data/test/expected/_layouts/page.html +1 -0
  28. data/test/expected/_layouts/post.html +1 -0
  29. data/test/expected/_octopress.yml +11 -0
  30. data/test/expected/_posts/2014-03-11-idea.markdown +6 -0
  31. data/test/expected/_posts/2014-03-12-awesome-stuff.markdown +6 -0
  32. data/test/expected/_posts/2014-03-13-awesome.markdown +6 -0
  33. data/test/expected/_site/2014/03/11/idea.html +1 -0
  34. data/test/expected/_site/2014/03/12/awesome-stuff.html +1 -0
  35. data/test/expected/_site/2014/03/13/awesome.html +1 -0
  36. data/test/expected/_site/awesome-page.html +1 -0
  37. data/test/expected/_site/cool-page.html +1 -0
  38. data/test/expected/_site/index.html +0 -0
  39. data/test/expected/_site/okay-page/index.html +1 -0
  40. data/test/expected/_templates/page +6 -0
  41. data/test/expected/_templates/post +6 -0
  42. data/test/expected/awesome-page.html +5 -0
  43. data/test/expected/cool-page.html +5 -0
  44. data/test/expected/index.html +0 -0
  45. data/test/expected/okay-page/index.html +5 -0
  46. data/test/test.rb +100 -0
  47. data/test/test_suite.rb +107 -0
  48. metadata +57 -10
  49. data/docs/_octopress.yml +0 -1
  50. data/docs/index.html +0 -1
  51. data/lib/octopress/commands/docs.rb +0 -74
@@ -0,0 +1,11 @@
1
+ # Default extension for new posts and pages
2
+ post_ext: markdown
3
+ page_ext: html
4
+
5
+ # Default templates for posts and pages
6
+ # Found in _templates/
7
+ post_layout: post
8
+ page_layout: page
9
+
10
+ # Format titles with titlecase?
11
+ titlecase: true
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Some Great Idea for a Post"
4
+ date: 2014-03-11T20:20:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Awesome Stuff"
4
+ date: 2014-03-12T05:10:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Super Awesome Stuff"
4
+ date: 2014-03-13T15:20:00Z
5
+ ---
6
+
@@ -0,0 +1 @@
1
+ <div class='post'>Some Great Idea for a Post</div>
@@ -0,0 +1 @@
1
+ <div class='post'>Awesome Stuff</div>
@@ -0,0 +1 @@
1
+ <div class='post'>Super Awesome Stuff</div>
@@ -0,0 +1 @@
1
+ <div class='page'>Awesome Page</div>
@@ -0,0 +1 @@
1
+ <div class='page'>Some Cool Page</div>
File without changes
@@ -0,0 +1 @@
1
+ <div class='page'>This Page Is Meh</div>
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ date: {{ date }}
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ date: {{ date }}
5
+ ---
6
+
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: page
3
+ title: "Awesome Page"
4
+ ---
5
+
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: page
3
+ title: "Some Cool Page"
4
+ ---
5
+
File without changes
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: page
3
+ title: "This Page Is Meh"
4
+ ---
5
+
@@ -0,0 +1,100 @@
1
+ require './test_suite'
2
+
3
+ @failures = []
4
+
5
+ `rm -rf test-site; mkdir test-site`
6
+
7
+ FileUtils.cd('test-site') do |dir|
8
+
9
+ # Create a blank site
10
+ #
11
+ test({
12
+ desc: 'Create a blank site',
13
+ cmd: [
14
+ 'octopress new . --blank',
15
+ 'echo "<div class=\'post\'>{{ page.title }}{{ content }}</div>" > _layouts/post.html',
16
+ 'echo "<div class=\'page\'>{{ page.title }}{{ content }}</div>" > _layouts/page.html'
17
+ ],
18
+ expect: "New jekyll site installed in ."
19
+ })
20
+
21
+ # Init Octopress scaffolding
22
+ #
23
+ test({
24
+ desc: 'Init Octopress scaffolding',
25
+ cmd: 'octopress init .',
26
+ expect: "Octopress scaffold added to ."
27
+ })
28
+
29
+ # Add a new post
30
+ #
31
+ test({
32
+ desc: 'Add a new post',
33
+ cmd: 'octopress new post "Awesome stuff" --date "2014-03-12 05:10 -0000"',
34
+ expect: '_posts/2014-03-12-awesome-stuff.markdown',
35
+ })
36
+
37
+ # Add another new post with a slug
38
+ #
39
+ test({
40
+ desc: 'Add another new post with a slug',
41
+ cmd: 'octopress new post "Super Awesome stuff" --slug awesome --date "2014-03-13 15:20 -0000"',
42
+ expect: '_posts/2014-03-13-awesome.markdown',
43
+ })
44
+
45
+ # Add a draft
46
+ #
47
+ test({
48
+ desc: 'Add a draft',
49
+ cmd: 'octopress new draft "Stupid idea" --date "2014-03-10 15:20 -0000"',
50
+ expect: '_drafts/stupid-idea.markdown',
51
+ })
52
+
53
+ # Add a draft with a slug
54
+ #
55
+ test({
56
+ desc: 'Add a draft with a slug',
57
+ cmd: 'octopress new draft "Some great idea for a post" --slug idea',
58
+ expect: '_drafts/idea.markdown',
59
+ })
60
+
61
+ # Publish a draft with a date
62
+ #
63
+ test({
64
+ desc: 'Publish a draft with a date',
65
+ cmd: 'octopress publish _drafts/idea.markdown --date "2014-03-11 20:20 -0000"',
66
+ expect: '_posts/2014-03-11-idea.markdown',
67
+ })
68
+
69
+ # Add a page
70
+ #
71
+ test({
72
+ desc: 'Add a page',
73
+ cmd: 'octopress new page awesome-page --title "Awesome Page"',
74
+ expect: 'awesome-page.html',
75
+ })
76
+
77
+ # Add a page with an extension
78
+ #
79
+ test({
80
+ desc: 'Add a page with an extension',
81
+ cmd: 'octopress new page cool-page.html --title "some cool page"',
82
+ expect: 'cool-page.html',
83
+ })
84
+
85
+ # Add a page with a directory
86
+ #
87
+ test({
88
+ desc: 'Add a page with a directory',
89
+ cmd: 'octopress new page okay-page/ --title "This page is meh"',
90
+ expect: 'okay-page/index.html',
91
+ })
92
+
93
+ end
94
+
95
+ # Build the site
96
+ #
97
+ system "cd test-site; octopress build; cd -"
98
+ compare_directories('test-site', 'expected')
99
+
100
+ print_results
@@ -0,0 +1,107 @@
1
+ require 'colorator'
2
+ require 'find'
3
+
4
+ # This is a makeshift integration test-suite.
5
+ # It is unapologetically pragmatic.
6
+
7
+ # Find all files in a given directory
8
+ #
9
+ def dir_files(dir)
10
+ Find.find(dir).to_a.reject!{|f| File.directory?(f) }
11
+ end
12
+
13
+ # Recursively diff two directories
14
+ #
15
+ # This will walk through dir1 and diff matching paths in dir2
16
+ #
17
+ def compare_directories(dir1, dir2)
18
+ dir_files(dir1).each do |file|
19
+ file2 = file.sub(dir1, dir2)
20
+ if File.exist?(file2)
21
+ diff = diff_file(file, file2)
22
+ if diff =~ /(<.+?\n)?(---\n)?(>.+)/
23
+ @failures << {
24
+ desc: "Diff of file: #{file} in #{dir2}",
25
+ expected: $1,
26
+ result: $3
27
+ }
28
+ pout 'F'.red
29
+ else
30
+ pout '.'.green
31
+ end
32
+ else
33
+ @failures << {
34
+ desc: "Diff of file: #{file} in #{dir2}",
35
+ message: "No such file or directory: #{file2}"
36
+ }
37
+ pout 'F'.red
38
+ end
39
+ end
40
+ end
41
+
42
+ # Diff two files
43
+ #
44
+ def diff_file(file1, file2)
45
+ diff = `diff #{file1} #{file2}`
46
+ if diff.size > 0
47
+ diff
48
+ else
49
+ false
50
+ end
51
+ end
52
+
53
+ # Run test cases
54
+ #
55
+ # Input: options hash, format:
56
+ # {
57
+ # desc: description of task
58
+ # cmd: system command to be run, (String or Array)
59
+ # expect: expected output from command
60
+ # }
61
+ #
62
+ def test(options)
63
+ if cmd = options[:cmd]
64
+ cmd = [cmd] unless cmd.is_a? Array
65
+ output = `#{cmd.join('; ')}`.gsub(/#{Dir.pwd}\/*/,'').strip
66
+ if options[:expect].strip == output
67
+ pout '.'.green
68
+ else
69
+ pout 'F'.red
70
+ @failures << {
71
+ desc: options[:desc],
72
+ expected: options[:expect],
73
+ result: output,
74
+ }
75
+ end
76
+ end
77
+ end
78
+
79
+
80
+ # Print a single character without a newline
81
+ #
82
+ def pout(str)
83
+ print str
84
+ $stdout.flush
85
+ end
86
+
87
+ # Ouptut nicely formatted failure messages
88
+ #
89
+ def print_results
90
+ if !@failures.empty?
91
+ @failures.each do |test|
92
+ puts "\nFailed: #{test[:desc]}"
93
+ if test[:message]
94
+ puts test[:message].yellow
95
+ else
96
+ puts test[:expected].green
97
+ puts test[:result].red
98
+ end
99
+ # print a newline for easier reading
100
+ puts ""
101
+ end
102
+ abort
103
+ else
104
+ puts "All passed!".green
105
+ end
106
+ end
107
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha8
4
+ version: 3.0.0.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-03 00:00:00.000000000 Z
12
+ date: 2014-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mercenary
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 1.4.2
34
+ version: 1.4.3
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ~>
40
40
  - !ruby/object:Gem::Version
41
- version: 1.4.2
41
+ version: 1.4.3
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -92,30 +92,55 @@ extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
94
  - .gitignore
95
+ - .travis.yml
95
96
  - Gemfile
96
97
  - LICENSE
97
98
  - README.md
98
99
  - Rakefile
99
100
  - bin/octopress
100
- - docs/_octopress.yml
101
- - docs/_site/index.html
102
- - docs/index.html
103
101
  - lib/octopress.rb
104
102
  - lib/octopress/command.rb
105
103
  - lib/octopress/commands/build.rb
106
- - lib/octopress/commands/docs.rb
107
104
  - lib/octopress/commands/doctor.rb
108
105
  - lib/octopress/commands/helpers.rb
106
+ - lib/octopress/commands/init.rb
109
107
  - lib/octopress/commands/new.rb
110
108
  - lib/octopress/commands/publish.rb
111
109
  - lib/octopress/commands/serve.rb
112
110
  - lib/octopress/configuration.rb
113
- - lib/octopress/core_ext.rb
114
111
  - lib/octopress/draft.rb
112
+ - lib/octopress/ext/hash.rb
113
+ - lib/octopress/ext/titlecase.rb
115
114
  - lib/octopress/page.rb
116
115
  - lib/octopress/post.rb
116
+ - lib/octopress/scaffold.rb
117
117
  - lib/octopress/version.rb
118
118
  - octopress.gemspec
119
+ - scaffold/_octopress.yml
120
+ - scaffold/_templates/page
121
+ - scaffold/_templates/post
122
+ - test/expected/_drafts/stupid-idea.markdown
123
+ - test/expected/_layouts/page.html
124
+ - test/expected/_layouts/post.html
125
+ - test/expected/_octopress.yml
126
+ - test/expected/_posts/2014-03-11-idea.markdown
127
+ - test/expected/_posts/2014-03-12-awesome-stuff.markdown
128
+ - test/expected/_posts/2014-03-13-awesome.markdown
129
+ - test/expected/_site/2014/03/11/idea.html
130
+ - test/expected/_site/2014/03/12/awesome-stuff.html
131
+ - test/expected/_site/2014/03/13/awesome.html
132
+ - test/expected/_site/awesome-page.html
133
+ - test/expected/_site/cool-page.html
134
+ - test/expected/_site/index.html
135
+ - test/expected/_site/okay-page/index.html
136
+ - test/expected/_templates/page
137
+ - test/expected/_templates/post
138
+ - test/expected/awesome-page.html
139
+ - test/expected/cool-page.html
140
+ - test/expected/index.html
141
+ - test/expected/okay-page/index.html
142
+ - test/test.rb
143
+ - test/test_suite.rb
119
144
  homepage: http://octopress.org
120
145
  licenses:
121
146
  - MIT
@@ -141,4 +166,26 @@ signing_key:
141
166
  specification_version: 4
142
167
  summary: Octopress is an obsessively designed framework for Jekyll blogging. It’s
143
168
  easy to configure and easy to deploy. Sweet huh?
144
- test_files: []
169
+ test_files:
170
+ - test/expected/_drafts/stupid-idea.markdown
171
+ - test/expected/_layouts/page.html
172
+ - test/expected/_layouts/post.html
173
+ - test/expected/_octopress.yml
174
+ - test/expected/_posts/2014-03-11-idea.markdown
175
+ - test/expected/_posts/2014-03-12-awesome-stuff.markdown
176
+ - test/expected/_posts/2014-03-13-awesome.markdown
177
+ - test/expected/_site/2014/03/11/idea.html
178
+ - test/expected/_site/2014/03/12/awesome-stuff.html
179
+ - test/expected/_site/2014/03/13/awesome.html
180
+ - test/expected/_site/awesome-page.html
181
+ - test/expected/_site/cool-page.html
182
+ - test/expected/_site/index.html
183
+ - test/expected/_site/okay-page/index.html
184
+ - test/expected/_templates/page
185
+ - test/expected/_templates/post
186
+ - test/expected/awesome-page.html
187
+ - test/expected/cool-page.html
188
+ - test/expected/index.html
189
+ - test/expected/okay-page/index.html
190
+ - test/test.rb
191
+ - test/test_suite.rb
@@ -1 +0,0 @@
1
- docs_mode: true
@@ -1 +0,0 @@
1
- OMG DOCS
@@ -1,74 +0,0 @@
1
- require 'jekyll'
2
- require 'yaml'
3
- require File.expand_path('helpers', File.dirname(__FILE__))
4
-
5
- module Octopress
6
- class Docs < Command
7
- def self.init_with_program(p)
8
- p.command(:docs) do |c|
9
- c.syntax 'octopress docs'
10
- c.description "Launch local server with docs for Octopress v#{Octopress::VERSION} and Octopress Ink plugins."
11
-
12
- c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
13
- c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
14
- if ENV['OCTODEV']
15
- c.option 'watch', '--watch', 'Watch docs site for changes and rebuild. (For docs development)'
16
- end
17
- c.option 'jekyll', '--jekyll', "Launch local server with docs for Jekyll v#{Jekyll::VERSION}"
18
-
19
- c.action do |args, options|
20
- serve_docs(options)
21
- end
22
- end
23
- end
24
-
25
- def self.serve_docs(options)
26
- if options['jekyll']
27
- options = init_jekyll_docs(options)
28
- else
29
- options = init_octopress_docs(options)
30
- end
31
- options["serving"] = true
32
- options = CommandHelpers.normalize_options(options)
33
- options = ::Jekyll.configuration(options.to_symbol_keys)
34
- ::Jekyll::Commands::Build.process(options)
35
- ::Jekyll::Commands::Serve.process(options)
36
- end
37
-
38
- def self.init_octopress_docs(options)
39
- Octopress.config({'octopress-config'=>File.join(site_dir, '_octopress.yml')})
40
- require_gems
41
- options['source'] = site_dir
42
- options['destination'] = File.join(site_dir, '_site')
43
- options
44
- end
45
-
46
- def self.init_jekyll_docs(options)
47
- options.delete('jekyll')
48
-
49
- # Find local Jekyll gem path
50
- #
51
- spec = Gem::Specification.find_by_name("jekyll")
52
- gem_path = spec.gem_dir
53
-
54
- options['source'] = "#{gem_path}/site",
55
- options['destination'] = "#{gem_path}/site/_site"
56
- options
57
- end
58
-
59
- def self.site_dir
60
- File.expand_path('docs', File.join(File.dirname(__FILE__), '../../../', ))
61
- end
62
-
63
- def self.require_gems
64
- file = File.join(Dir.pwd, '_config.yml')
65
- if File.exist? file
66
- config = YAML.safe_load(File.open(file))
67
- gems = config['gems']
68
- if gems && gems.is_a?(Array)
69
- gems.each {|g| require g }
70
- end
71
- end
72
- end
73
- end
74
- end