octopress 3.0.0.rc.11 → 3.0.0.rc.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f890b49b0468bf8cea9498b00ab637505eb9bf62
4
- data.tar.gz: 8e9b290d772534b231f13eef5cedf218aa4f46e3
3
+ metadata.gz: af8aa291d4f97bb0fe20c1fc5965758ee4701999
4
+ data.tar.gz: 4f995072d9b4192bc48a12449f21ff35eaacc8a3
5
5
  SHA512:
6
- metadata.gz: 0bad3975b63a5d5c4d35451f62b1fd6609824df851ce780d3534c12ad88fb85e67832a0c7a6ccfa8856e5b83dd04d02fa83bad193308ef52c4beaeb5ae77fd6f
7
- data.tar.gz: 49f2e67e03d06fba6f38c11eba0f98436cb0f0c7f711907974493658fbd1042beb7924eeef79db1f4e8a51b0708aeda99a58d6dbe4f5805454b30fa217ff9826
6
+ metadata.gz: 58c2b53290232258b67eb395d03297b8ebe9bb01b21c5be8e1c4acd87e33bc95aef431e8d1f65a3612a2d14b41b9270502a0447d7146f30fcd6d3d7e586f698d
7
+ data.tar.gz: 5edb343188cb88856c57fc0cb8f20ca4d7037611ff4e1edaf715f6840d5be92732fd2c292a73fa339e59b6063e93326ad43cd7e06c6443c833e08a1482b973de
data/CHANGELOG.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # Octopress Changelog
2
2
 
3
3
  ## Current released version
4
+ ### 3.0.0 RC11 - 2014-05-23
4
5
 
5
- ### 3.0.0 RC11 - 2014-19-07
6
-
7
- - Replaced Hash extensions with Jekyll utility methods
8
- - Replaced String extension "titlecase" with Octopress utility method
6
+ - Change: Default page template no longer includes a date.
7
+ - Improved date management when publishing a draft.
9
8
 
10
9
  ## Past versions
11
10
 
11
+ ### 3.0.0 RC11 - 2014-05-07
12
+
13
+ - Replaced Hash extensions with Jekyll utility methods.
14
+ - Replaced String extension "titlecase" with Octopress utility method.
15
+
12
16
  ### 3.0.0 RC10 - 2014-05-07
13
17
 
14
18
  - Now using SafeYAML.load instead of YAML.safe_load [#38](https://github.com/octopress/octopress/issues/38)
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Octopress
2
2
 
3
-
4
3
  Octopress is an obsessively designed toolkit for writing and deploying Jekyll blogs. Pretty sweet, huh?
5
4
 
6
5
  <!--[![Gem Version](https://badge.fury.io/rb/octopress.png)](http://badge.fury.io/rb/octopress)-->
@@ -10,7 +9,7 @@ Octopress is an obsessively designed toolkit for writing and deploying Jekyll bl
10
9
 
11
10
  Add this line to your application's Gemfile:
12
11
 
13
- gem 'octopress', '~> 3.0.0.rc.11'
12
+ gem 'octopress', '~> 3.0.0.rc.12'
14
13
 
15
14
  And then execute:
16
15
 
@@ -96,7 +95,7 @@ title: "My Title"
96
95
  date: YYYY-MM-DDTHH:MM:SS-00:00
97
96
  ```
98
97
 
99
- "Ok, great? What else can I do?" Great question! Check out these other options:
98
+ "OK, great? What else can I do?" Great question! Check out these other options:
100
99
 
101
100
  | Option | Description |
102
101
  |:---------------------|:----------------------------------------|
@@ -104,7 +103,7 @@ date: YYYY-MM-DDTHH:MM:SS-00:00
104
103
  | `--date DATE` | The date for the post. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
105
104
  | `--slug SLUG` | Slug for the new post. |
106
105
  | `--dir DIR` | Create post at _posts/DIR/. |
107
- | `--force` | Overwrite exsiting file. |
106
+ | `--force` | Overwrite existing file. |
108
107
 
109
108
  ### New Page
110
109
 
@@ -119,7 +118,11 @@ $ octopress new page about.html # ./about.html
119
118
  | `--template PATH` | Use a template from <path> |
120
119
  | `--title TITLE` | The title of the new page |
121
120
  | `--date DATE` | The date for the page. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
122
- | `--force` | Overwrite exsiting file. |
121
+ | `--force` | Overwrite existing file. |
122
+
123
+ Note: The default page template doesn't expect a date. If you want to add dates
124
+ to your posts, consider adding `date: {{ date }}` to the default template
125
+ `_templates/page`, or create a new template to use for dated pages.
123
126
 
124
127
  ### New Draft
125
128
 
@@ -149,7 +152,7 @@ This will move your draft to the `_posts` directory and rename the file with the
149
152
  | `--date DATE` | The date for the post. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
150
153
  | `--slug SLUG` | Change the slug for the new post. |
151
154
  | `--dir DIR` | Create post at _posts/DIR/. |
152
- | `--force` | Overwrite exsiting file. |
155
+ | `--force` | Overwrite existing file. |
153
156
 
154
157
  When publishing a draft, the new post will use the draft's date. Pass the option `--date now` to the publish command to set the new post date from your system clock. As usual, you can pass any compatible date string as well.
155
158
 
@@ -161,7 +164,6 @@ Octopress post and page templates look like this.
161
164
  ---
162
165
  layout: {{ layout }}
163
166
  title: {{ title }}
164
- date: {{ date }}
165
167
  ---
166
168
 
167
169
  ```
@@ -4,14 +4,18 @@ permalink: /changelog/
4
4
  ---
5
5
 
6
6
  ## Current released version
7
+ ### 3.0.0 RC11 - 2014-05-23
7
8
 
8
- ### 3.0.0 RC11 - 2014-19-07
9
-
10
- - Replaced Hash extensions with Jekyll utility methods
11
- - Replaced String extension "titlecase" with Octopress utility method
9
+ - Change: Default page template no longer includes a date.
10
+ - Improved date management when publishing a draft.
12
11
 
13
12
  ## Past versions
14
13
 
14
+ ### 3.0.0 RC11 - 2014-05-07
15
+
16
+ - Replaced Hash extensions with Jekyll utility methods.
17
+ - Replaced String extension "titlecase" with Octopress utility method.
18
+
15
19
  ### 3.0.0 RC10 - 2014-05-07
16
20
 
17
21
  - Now using SafeYAML.load instead of YAML.safe_load [#38](https://github.com/octopress/octopress/issues/38)
@@ -2,7 +2,6 @@
2
2
  title: "Octopress"
3
3
  ---
4
4
 
5
-
6
5
  Octopress is an obsessively designed toolkit for writing and deploying Jekyll blogs. Pretty sweet, huh?
7
6
 
8
7
  <!--[![Gem Version](https://badge.fury.io/rb/octopress.png)](http://badge.fury.io/rb/octopress)-->
@@ -12,7 +11,7 @@ Octopress is an obsessively designed toolkit for writing and deploying Jekyll bl
12
11
 
13
12
  Add this line to your application's Gemfile:
14
13
 
15
- gem 'octopress', '~> 3.0.0.rc.11'
14
+ gem 'octopress', '~> 3.0.0.rc.12'
16
15
 
17
16
  And then execute:
18
17
 
@@ -98,7 +97,7 @@ title: "My Title"
98
97
  date: YYYY-MM-DDTHH:MM:SS-00:00
99
98
  ```
100
99
 
101
- "Ok, great? What else can I do?" Great question! Check out these other options:
100
+ "OK, great? What else can I do?" Great question! Check out these other options:
102
101
 
103
102
  | Option | Description |
104
103
  |:---------------------|:----------------------------------------|
@@ -106,7 +105,7 @@ date: YYYY-MM-DDTHH:MM:SS-00:00
106
105
  | `--date DATE` | The date for the post. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
107
106
  | `--slug SLUG` | Slug for the new post. |
108
107
  | `--dir DIR` | Create post at _posts/DIR/. |
109
- | `--force` | Overwrite exsiting file. |
108
+ | `--force` | Overwrite existing file. |
110
109
 
111
110
  ### New Page
112
111
 
@@ -121,7 +120,11 @@ $ octopress new page about.html # ./about.html
121
120
  | `--template PATH` | Use a template from <path> |
122
121
  | `--title TITLE` | The title of the new page |
123
122
  | `--date DATE` | The date for the page. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
124
- | `--force` | Overwrite exsiting file. |
123
+ | `--force` | Overwrite existing file. |
124
+
125
+ Note: The default page template doesn't expect a date. If you want to add dates
126
+ to your posts, consider adding `date: {{ date }}` to the default template
127
+ `_templates/page`, or create a new template to use for dated pages.
125
128
 
126
129
  ### New Draft
127
130
 
@@ -151,7 +154,7 @@ This will move your draft to the `_posts` directory and rename the file with the
151
154
  | `--date DATE` | The date for the post. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
152
155
  | `--slug SLUG` | Change the slug for the new post. |
153
156
  | `--dir DIR` | Create post at _posts/DIR/. |
154
- | `--force` | Overwrite exsiting file. |
157
+ | `--force` | Overwrite existing file. |
155
158
 
156
159
  When publishing a draft, the new post will use the draft's date. Pass the option `--date now` to the publish command to set the new post date from your system clock. As usual, you can pass any compatible date string as well.
157
160
 
@@ -163,7 +166,6 @@ Octopress post and page templates look like this.
163
166
  ---
164
167
  layout: {{ layout }}
165
168
  title: {{ title }}
166
- date: {{ date }}
167
169
  ---
168
170
 
169
171
  ```
@@ -77,7 +77,7 @@ module Octopress
77
77
  # read_draft_date
78
78
  #
79
79
  def read_draft_date
80
- match = read.match(/date:\s+(.+)?$/)
80
+ match = read.match(/date:\s+(\d.+)$/)
81
81
  match[1] if match
82
82
  end
83
83
 
@@ -87,7 +87,7 @@ module Octopress
87
87
  def read_draft_content
88
88
  if @options['date']
89
89
  # remove date if it exists
90
- content = read.sub(/date:\s+.+?\n/, "")
90
+ content = read.sub(/date:.*$\n/, "")
91
91
 
92
92
  # Insert date after title
93
93
  content.sub(/(title:.+$)/i, '\1'+"\ndate: #{@options['date']}")
@@ -82,13 +82,13 @@ module Octopress
82
82
  end
83
83
  end
84
84
 
85
- # Load the user provide or default template for a new post or page.
85
+ # Load the user provided or default template for a new post or page.
86
86
  #
87
87
  def content
88
88
 
89
89
  # Handle case where user passes the full path
90
90
  #
91
- file = @options['template']
91
+ file = @options['template'] || default_template
92
92
 
93
93
  if file
94
94
  file.sub(/^_templates\//, '')
@@ -103,6 +103,10 @@ module Octopress
103
103
  end
104
104
  end
105
105
 
106
+ def default_template
107
+ 'page'
108
+ end
109
+
106
110
  # Render Liquid vars in YAML front-matter.
107
111
  def parse_template(input)
108
112
 
@@ -111,12 +115,13 @@ module Octopress
111
115
  # If YAML front-matter dashes aren't present parse the whole
112
116
  # template and add dashes.
113
117
  #
114
- parsed = if input =~ /\A-{3}\s+(.+?)\s+-{3}\s+(.+)/m
118
+
119
+ parsed = if input =~ /\A-{3}\s+(.+?)\s+-{3}(.+)?/m
115
120
  template = Liquid::Template.parse($1)
116
- "---\n#{template.render(@options).strip}\n---\n\n#{$2}"
121
+ "---\n#{template.render(@options).strip}\n---\n#{$2}"
117
122
  else
118
123
  template = Liquid::Template.parse(input)
119
- "---\n#{template.render(@options).strip}\n---\n\n"
124
+ "---\n#{template.render(@options).strip}\n---\n"
120
125
  end
121
126
  end
122
127
 
@@ -135,7 +140,11 @@ module Octopress
135
140
  # Page template defaults
136
141
  #
137
142
  def default_content
138
- front_matter %w{layout title date}
143
+ if @options['date']
144
+ front_matter %w{layout title date}
145
+ else
146
+ front_matter %w{layout title}
147
+ end
139
148
  end
140
149
 
141
150
  end
@@ -17,6 +17,16 @@ module Octopress
17
17
  File.join(dir, name)
18
18
  end
19
19
 
20
+ def default_template
21
+ 'post'
22
+ end
23
+
24
+ # Post template defaults
25
+ #
26
+ def default_content
27
+ front_matter %w{layout title date}
28
+ end
29
+
20
30
  # Returns a string which is url compatible.
21
31
  #
22
32
  def title_slug
@@ -1,3 +1,3 @@
1
1
  module Octopress
2
- VERSION = "3.0.0.rc.11"
2
+ VERSION = "3.0.0.rc.12"
3
3
  end
@@ -1,6 +1,4 @@
1
1
  ---
2
2
  layout: {{ layout }}
3
3
  title: {{ title }}
4
- date: {{ date }}
5
4
  ---
6
-
@@ -3,4 +3,3 @@ layout: {{ layout }}
3
3
  title: {{ title }}
4
4
  date: {{ date }}
5
5
  ---
6
-
@@ -0,0 +1 @@
1
+ <div class='page'>Some Date Page</div>
@@ -0,0 +1 @@
1
+ <div class='page'>Some Date Page</div>
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ date: {{ date }}
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ kittens: true
5
+ ---
@@ -1,6 +1,4 @@
1
1
  ---
2
2
  layout: {{ layout }}
3
3
  title: {{ title }}
4
- date: {{ date }}
5
4
  ---
6
-
@@ -3,4 +3,3 @@ layout: {{ layout }}
3
3
  title: {{ title }}
4
4
  date: {{ date }}
5
5
  ---
6
-
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: page
3
+ title: "Some Date Page"
4
+ kittens: true
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: page
3
+ title: "Some Date Page"
4
+ date: 2011-11-11T11:11:00Z
5
+ ---
6
+
data/test/test.rb CHANGED
@@ -8,7 +8,7 @@ FileUtils.cd('test-site') do |dir|
8
8
 
9
9
  # Create a blank site
10
10
  #
11
- test({
11
+ test_cmd({
12
12
  desc: 'Create a blank site',
13
13
  cmd: [
14
14
  'octopress new . --blank',
@@ -21,7 +21,7 @@ FileUtils.cd('test-site') do |dir|
21
21
 
22
22
  # Init Octopress scaffolding
23
23
  #
24
- test({
24
+ test_cmd({
25
25
  desc: 'Init Octopress scaffolding',
26
26
  cmd: 'octopress init .',
27
27
  expect: "Octopress scaffold added to ."
@@ -29,7 +29,7 @@ FileUtils.cd('test-site') do |dir|
29
29
 
30
30
  # Add a new post
31
31
  #
32
- test({
32
+ test_cmd({
33
33
  desc: 'Add a new post',
34
34
  cmd: 'octopress new post "Awesome stuff" --date "2014-03-12 05:10 -0000"',
35
35
  expect: '_posts/2014-03-12-awesome-stuff.markdown',
@@ -37,7 +37,7 @@ FileUtils.cd('test-site') do |dir|
37
37
 
38
38
  # Add another new post with a slug
39
39
  #
40
- test({
40
+ test_cmd({
41
41
  desc: 'Add another new post with a slug',
42
42
  cmd: 'octopress new post "Super Awesome stuff" --slug awesome --date "2014-03-13 15:20 -0000"',
43
43
  expect: '_posts/2014-03-13-awesome.markdown',
@@ -45,7 +45,7 @@ FileUtils.cd('test-site') do |dir|
45
45
 
46
46
  # Add a new post in a subdirectory
47
47
  #
48
- test({
48
+ test_cmd({
49
49
  desc: 'Add a new post',
50
50
  cmd: 'octopress new post "Some stuff" --dir stuff --date "2014-02-11 05:10 -0000"',
51
51
  expect: '_posts/stuff/2014-02-11-some-stuff.markdown',
@@ -53,7 +53,7 @@ FileUtils.cd('test-site') do |dir|
53
53
 
54
54
  # Add a draft
55
55
  #
56
- test({
56
+ test_cmd({
57
57
  desc: 'Add a draft',
58
58
  cmd: 'octopress new draft "Stupid idea" --date "2014-03-10 15:20 -0000"',
59
59
  expect: '_drafts/stupid-idea.markdown',
@@ -61,7 +61,7 @@ FileUtils.cd('test-site') do |dir|
61
61
 
62
62
  # Add another draft
63
63
  #
64
- test({
64
+ test_cmd({
65
65
  desc: 'Add another draft',
66
66
  cmd: 'octopress new draft "Another idea" --date "2014-02-10 15:20 -0000"',
67
67
  expect: '_drafts/another-idea.markdown',
@@ -69,7 +69,7 @@ FileUtils.cd('test-site') do |dir|
69
69
 
70
70
  # Add a draft with a slug
71
71
  #
72
- test({
72
+ test_cmd({
73
73
  desc: 'Add a draft with a slug',
74
74
  cmd: 'octopress new draft "Some great idea for a post" --slug idea',
75
75
  expect: '_drafts/idea.markdown',
@@ -77,7 +77,7 @@ FileUtils.cd('test-site') do |dir|
77
77
 
78
78
  # Add yet another draft
79
79
  #
80
- test({
80
+ test_cmd({
81
81
  desc: 'Add yet another draft',
82
82
  cmd: 'octopress new draft "yet another idea" --date "2014-02-13 15:20 -0000"',
83
83
  expect: '_drafts/yet-another-idea.markdown',
@@ -85,7 +85,7 @@ FileUtils.cd('test-site') do |dir|
85
85
 
86
86
  # Publish a draft
87
87
  #
88
- test({
88
+ test_cmd({
89
89
  desc: 'Publish a draft',
90
90
  cmd: 'octopress publish _drafts/another-idea.markdown',
91
91
  expect: '_posts/2014-02-10-another-idea.markdown',
@@ -93,7 +93,7 @@ FileUtils.cd('test-site') do |dir|
93
93
 
94
94
  # Publish a draft with a date
95
95
  #
96
- test({
96
+ test_cmd({
97
97
  desc: 'Publish a draft with a date',
98
98
  cmd: 'octopress publish _drafts/idea.markdown --date "2014-03-11 20:20 -0000"',
99
99
  expect: '_posts/2014-03-11-idea.markdown',
@@ -101,7 +101,7 @@ FileUtils.cd('test-site') do |dir|
101
101
 
102
102
  # Publish a draft in a dir
103
103
  #
104
- test({
104
+ test_cmd({
105
105
  desc: 'Publish a draft in a dir',
106
106
  cmd: 'octopress publish _drafts/yet-another-idea.markdown --dir ideas',
107
107
  expect: '_posts/ideas/2014-02-13-yet-another-idea.markdown',
@@ -109,7 +109,7 @@ FileUtils.cd('test-site') do |dir|
109
109
 
110
110
  # Add a page
111
111
  #
112
- test({
112
+ test_cmd({
113
113
  desc: 'Add a page',
114
114
  cmd: 'octopress new page awesome-page --title "Awesome Page"',
115
115
  expect: 'awesome-page.html',
@@ -117,7 +117,7 @@ FileUtils.cd('test-site') do |dir|
117
117
 
118
118
  # Add a page with an extension
119
119
  #
120
- test({
120
+ test_cmd({
121
121
  desc: 'Add a page with an extension',
122
122
  cmd: 'octopress new page cool-page.html --title "some cool page"',
123
123
  expect: 'cool-page.html',
@@ -125,17 +125,38 @@ FileUtils.cd('test-site') do |dir|
125
125
 
126
126
  # Add a page with a directory
127
127
  #
128
- test({
128
+ test_cmd({
129
129
  desc: 'Add a page with a directory',
130
130
  cmd: 'octopress new page okay-page/ --title "This page is meh"',
131
131
  expect: 'okay-page/index.html',
132
132
  })
133
133
 
134
+ # Add a page with a date
135
+ #
136
+ test_cmd({
137
+ desc: 'Add a page with a custom template',
138
+ cmd: [
139
+ 'echo "---\nlayout: {{ layout }}\ntitle: {{ title }}\nkittens: true\n---" > _templates/other_page',
140
+ 'octopress new page custom-template-page.html --title "some date page" --template other_page'
141
+ ],
142
+ expect: 'custom-template-page.html',
143
+ })
144
+
145
+ # Add a page with a date
146
+ #
147
+ test_cmd({
148
+ desc: 'Add a page with a date',
149
+ cmd: [
150
+ 'echo "---\nlayout: {{ layout }}\ntitle: {{ title }}\ndate: {{ date }}\n---" > _templates/date_page',
151
+ 'octopress new page date-page.html --title "some date page" --date "2011-11-11 11:11 -0000" --template date_page'
152
+ ],
153
+ expect: 'date-page.html',
154
+ })
134
155
  end
135
156
 
136
157
  # Build the site
137
158
  #
138
159
  system "cd test-site; octopress build; cd -"
139
- compare_directories('test-site', 'expected')
160
+ test_dirs('Compare directories', 'test-site', 'expected')
140
161
 
141
162
  print_results
data/test/test_suite.rb CHANGED
@@ -4,6 +4,22 @@ require 'find'
4
4
  # This is a makeshift integration test-suite.
5
5
  # It is unapologetically pragmatic.
6
6
 
7
+
8
+ # Build Jekyll
9
+ #
10
+ def build(options={})
11
+ if options[:octopress_config]
12
+ FileUtils.cp options[:octopress_config], '_octopress.yml'
13
+ end
14
+
15
+ config = ['_config.yml'] << options[:config]
16
+ cmd = "rm -rf site && bundle exec jekyll build --config #{config.join(',')}"
17
+
18
+ `#{cmd}`
19
+ `rm _octopress.yml` if options[:octopress_config]
20
+ end
21
+
22
+
7
23
  # Find all files in a given directory
8
24
  #
9
25
  def dir_files(dir)
@@ -14,31 +30,62 @@ end
14
30
  #
15
31
  # This will walk through dir1 and diff matching paths in dir2
16
32
  #
17
- def compare_directories(dir1, dir2)
33
+ def test_dirs(desc, dir1, dir2)
34
+
35
+ test_missing_files(desc, dir1, dir2)
36
+
18
37
  dir_files(dir1).each do |file|
19
38
  file2 = file.sub(dir1, dir2)
20
39
  if File.exist?(file2)
21
- diff = diff_file(file, file2)
22
- if diff =~ /(<.+?\n)?(---\n)?(>.+)/
40
+ if diff = diff_file(file, file2)
23
41
  @failures << {
24
- desc: "Diff of file: #{file} in #{dir2}",
25
- expected: $1,
26
- result: $3
42
+ desc: "#{desc}\nDiff of file: #{file.sub(dir1+'/', '')}\n",
43
+ result: format_diff(diff)
27
44
  }
28
45
  pout 'F'.red
29
46
  else
30
47
  pout '.'.green
31
48
  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
49
  end
39
50
  end
40
51
  end
41
52
 
53
+ def format_diff(diff)
54
+ "#{diff.gsub(/\A.+?\n/,'').gsub(/^[^><].+/,'---').gsub(/^>.+/){|m|
55
+ m.green
56
+ }.gsub(/^(<.+?)$/){ |m|
57
+ m.red
58
+ }}"
59
+ end
60
+
61
+ # List differences between files in two directories
62
+ #
63
+ def test_missing_files(desc, dir1, dir2)
64
+ files1 = dir_files(dir1).map {|f| f.sub(dir1,'') }
65
+ files2 = dir_files(dir2).map {|f| f.sub(dir2,'') }
66
+
67
+ missing = []
68
+
69
+ (files2 - files1).each do |file|
70
+ missing << File.join(dir1, file)
71
+ end
72
+
73
+ (files1 - files2).each do |file|
74
+ missing << File.join(dir2, file)
75
+ end
76
+
77
+ if !missing.empty?
78
+ @failures << {
79
+ desc: "#{desc}\nMissing files:\n",
80
+ result: " - " + missing.join("\n - ")
81
+ }
82
+
83
+ pout 'F'.red
84
+ else
85
+ pout '.'.green
86
+ end
87
+ end
88
+
42
89
  # Diff two files
43
90
  #
44
91
  def diff_file(file1, file2)
@@ -50,7 +97,7 @@ def diff_file(file1, file2)
50
97
  end
51
98
  end
52
99
 
53
- # Run test cases
100
+ # Test command output
54
101
  #
55
102
  # Input: options hash, format:
56
103
  # {
@@ -59,22 +106,30 @@ end
59
106
  # expect: expected output from command
60
107
  # }
61
108
  #
62
- def test(options)
109
+ def test_cmd(options)
63
110
  if cmd = options[:cmd]
64
111
  cmd = [cmd] unless cmd.is_a? Array
112
+
113
+ # In debug mode command output is printed
114
+ #
65
115
  if options[:debug]
66
116
  system cmd.join('; ')
67
117
  else
68
118
  output = `#{cmd.join('; ')}`.gsub(/#{Dir.pwd}\/*/,'').strip
119
+
120
+ # Remove character color codes
121
+ output = output.gsub("\e",'').gsub(/\[\d+m/,'').gsub("\[0m",'')
69
122
  end
70
- if options[:expect].strip == output
123
+ if options[:expect] && options[:expect].strip == output
71
124
  pout '.'.green
72
125
  else
73
126
  pout 'F'.red
74
127
  @failures << {
75
- desc: options[:desc],
76
- expected: options[:expect],
77
- result: output,
128
+ desc: options[:desc]+"\n",
129
+ result: <<-HERE
130
+ expected: #{(options[:expect] || '').strip.green}
131
+ result: #{(output || '').strip.red}
132
+ HERE
78
133
  }
79
134
  end
80
135
  end
@@ -93,14 +148,9 @@ end
93
148
  def print_results
94
149
  if !@failures.empty?
95
150
  @failures.each do |test|
96
- puts "\nFailed: #{test[:desc]}"
97
- if test[:message]
98
- puts test[:message].yellow
99
- else
100
- puts (test[:expected] || '').green
101
- puts test[:result].red
102
- end
103
- # print a newline for easier reading
151
+ pout "\nFailed: #{test[:desc]}"
152
+ puts test[:result]
153
+ # print a newline for easier reading
104
154
  puts ""
105
155
  end
106
156
  abort
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.rc.11
4
+ version: 3.0.0.rc.12
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-05-19 00:00:00.000000000 Z
12
+ date: 2014-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mercenary
@@ -155,12 +155,18 @@ files:
155
155
  - test/expected/_site/2014/03/13/awesome.html
156
156
  - test/expected/_site/awesome-page.html
157
157
  - test/expected/_site/cool-page.html
158
+ - test/expected/_site/custom-template-page.html
159
+ - test/expected/_site/date-page.html
158
160
  - test/expected/_site/index.html
159
161
  - test/expected/_site/okay-page/index.html
162
+ - test/expected/_templates/date_page
163
+ - test/expected/_templates/other_page
160
164
  - test/expected/_templates/page
161
165
  - test/expected/_templates/post
162
166
  - test/expected/awesome-page.html
163
167
  - test/expected/cool-page.html
168
+ - test/expected/custom-template-page.html
169
+ - test/expected/date-page.html
164
170
  - test/expected/index.html
165
171
  - test/expected/okay-page/index.html
166
172
  - test/test.rb
@@ -210,12 +216,18 @@ test_files:
210
216
  - test/expected/_site/2014/03/13/awesome.html
211
217
  - test/expected/_site/awesome-page.html
212
218
  - test/expected/_site/cool-page.html
219
+ - test/expected/_site/custom-template-page.html
220
+ - test/expected/_site/date-page.html
213
221
  - test/expected/_site/index.html
214
222
  - test/expected/_site/okay-page/index.html
223
+ - test/expected/_templates/date_page
224
+ - test/expected/_templates/other_page
215
225
  - test/expected/_templates/page
216
226
  - test/expected/_templates/post
217
227
  - test/expected/awesome-page.html
218
228
  - test/expected/cool-page.html
229
+ - test/expected/custom-template-page.html
230
+ - test/expected/date-page.html
219
231
  - test/expected/index.html
220
232
  - test/expected/okay-page/index.html
221
233
  - test/test.rb