jekyll-import 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,104 @@
1
+ require 'helper'
2
+ require 'date'
3
+
4
+ class TestMTMigrator < Test::Unit::TestCase
5
+ def stub_entry_row(overrides = {})
6
+ now = DateTime.now
7
+ # These properties corespond to the column names for the mt_entry table
8
+ {
9
+ :entry_id => 1,
10
+ :entry_blog_id => 1,
11
+ :entry_status => JekyllImport::MT::STATUS_PUBLISHED,
12
+ :entry_author_id => 1,
13
+ :entry_allow_comments => 0,
14
+ :entry_allow_pings => 0,
15
+ :entry_convert_breaks => "__default__",
16
+ :entry_category_id => nil,
17
+ :entry_title => "Lorem Ipsum",
18
+ :entry_excerpt => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
19
+ :entry_text => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat.",
20
+ :entry_text_more => "Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna.",
21
+ :entry_to_ping_urls => "",
22
+ :entry_pinged_urls => nil,
23
+ :entry_keywords => "",
24
+ :entry_tangent_cache => nil,
25
+ :entry_created_on => now,
26
+ :entry_modified_on => now,
27
+ :entry_created_by => nil,
28
+ :entry_modified_by => 1,
29
+ :entry_basename => "lorem_ipsum",
30
+ :entry_atom_id => "tag:www.example.com,#{now.year}:/blog/1.4",
31
+ :entry_week_number => "#{now.year}#{now.cweek}".to_i,
32
+ :entry_ping_count => 0,
33
+ :entry_comment_count => 0,
34
+ :entry_authored_on => now,
35
+ :entry_template_id => nil,
36
+ :entry_class => "entry"
37
+ }.merge(overrides)
38
+ end
39
+
40
+ should "set layout to post" do
41
+ assert_equal("post", JekyllImport::MT.post_metadata(stub_entry_row)["layout"])
42
+ end
43
+
44
+ should "extract authored_on as date, formatted as 'YYYY-MM-DD HH:MM:SS Z'" do
45
+ post = stub_entry_row
46
+ expected_date = post[:entry_authored_on].strftime('%Y-%m-%d %H:%M:%S %z')
47
+ assert_equal(expected_date, JekyllImport::MT.post_metadata(post)["date"])
48
+ end
49
+
50
+ should "extract entry_excerpt as excerpt" do
51
+ post = stub_entry_row
52
+ assert_equal(post[:entry_excerpt], JekyllImport::MT.post_metadata(post)["excerpt"])
53
+ end
54
+
55
+ should "extract entry_id as mt_id" do
56
+ post = stub_entry_row(:entry_id => 123)
57
+ assert_equal(123, JekyllImport::MT.post_metadata(post)["mt_id"])
58
+ end
59
+
60
+ should "extract entry_title as title" do
61
+ post = stub_entry_row
62
+ assert_equal(post[:entry_title], JekyllImport::MT.post_metadata(post)["title"])
63
+ end
64
+
65
+ should "set published to false if entry_status is not published" do
66
+ post = stub_entry_row(:entry_status => JekyllImport::MT::STATUS_DRAFT)
67
+ assert_equal(false, JekyllImport::MT.post_metadata(post)["published"])
68
+ end
69
+
70
+ should "not set published if entry_status is published" do
71
+ post = stub_entry_row(:entry_status => JekyllImport::MT::STATUS_PUBLISHED)
72
+ assert_equal(nil, JekyllImport::MT.post_metadata(post)["published"])
73
+ end
74
+
75
+ should "include entry_text" do
76
+ post = stub_entry_row
77
+ assert JekyllImport::MT.post_content(post).include?(post[:entry_text])
78
+ end
79
+
80
+ should "include entry_text_more" do
81
+ post = stub_entry_row
82
+ assert JekyllImport::MT.post_content(post).include?(post[:entry_text_more])
83
+ end
84
+
85
+ should "include a <!--MORE--> separator when there is entry_text_more" do
86
+ post = stub_entry_row(:entry_text_more => "Some more entry")
87
+ assert JekyllImport::MT.post_content(post).include?(JekyllImport::MT::MORE_CONTENT_SEPARATOR)
88
+ end
89
+
90
+ should "not include a <!--MORE--> separator when there is no entry_text_more" do
91
+ post = stub_entry_row(:entry_text_more => "")
92
+ refute JekyllImport::MT.post_content(post).include?(JekyllImport::MT::MORE_CONTENT_SEPARATOR)
93
+ end
94
+
95
+ should "include the entry_authored_on date in the file name" do
96
+ post = stub_entry_row(:entry_authored_on => Time.parse("2013-01-02 00:00:00").utc)
97
+ assert JekyllImport::MT.post_file_name(post).include?("2013-01-02")
98
+ end
99
+
100
+ should "include entry_basename in the file name" do
101
+ post = stub_entry_row(:entry_basename => "my_blog-entry")
102
+ assert JekyllImport::MT.post_file_name(post).include?("my_blog-entry")
103
+ end
104
+ end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+ require 'htmlentities'
3
+
4
+ class TestWordpressMigrator < Test::Unit::TestCase
5
+ should "clean slashes from slugs" do
6
+ test_title = "blogs part 1/2"
7
+ assert_equal("blogs-part-1-2", JekyllImport::WordPress.sluggify(test_title))
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require 'helper'
2
+
3
+ class TestWordpressDotComMigrator < Test::Unit::TestCase
4
+ should "clean slashes from slugs" do
5
+ test_title = "blogs part 1/2"
6
+ assert_equal("blogs-part-1-2", JekyllImport::WordpressDotCom.sluggify(test_title))
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,334 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-import
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.beta1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Tom Preston-Werner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jekyll
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: fastercsv
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: nokogiri
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: safe_yaml
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.7'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.7'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 10.0.3
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 10.0.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 4.0.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 4.0.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: redgreen
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: shoulda
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 3.3.2
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 3.3.2
142
+ - !ruby/object:Gem::Dependency
143
+ name: rr
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '1.0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: simplecov
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: '0.7'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '0.7'
174
+ - !ruby/object:Gem::Dependency
175
+ name: simplecov-gem-adapter
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: 1.0.1
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: 1.0.1
190
+ - !ruby/object:Gem::Dependency
191
+ name: sequel
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: '3.42'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '3.42'
206
+ - !ruby/object:Gem::Dependency
207
+ name: htmlentities
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: '4.3'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: '4.3'
222
+ - !ruby/object:Gem::Dependency
223
+ name: hpricot
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ~>
228
+ - !ruby/object:Gem::Version
229
+ version: '0.8'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: '0.8'
238
+ - !ruby/object:Gem::Dependency
239
+ name: mysql
240
+ requirement: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ~>
244
+ - !ruby/object:Gem::Version
245
+ version: '2.8'
246
+ type: :development
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ~>
252
+ - !ruby/object:Gem::Version
253
+ version: '2.8'
254
+ - !ruby/object:Gem::Dependency
255
+ name: pg
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ~>
260
+ - !ruby/object:Gem::Version
261
+ version: '0.12'
262
+ type: :development
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ~>
268
+ - !ruby/object:Gem::Version
269
+ version: '0.12'
270
+ description: Provides the Import command for Jekyll.
271
+ email: tom@mojombo.com
272
+ executables: []
273
+ extensions: []
274
+ extra_rdoc_files:
275
+ - README.md
276
+ - LICENSE
277
+ files:
278
+ - Gemfile
279
+ - History.txt
280
+ - LICENSE
281
+ - README.md
282
+ - Rakefile
283
+ - jekyll-import.gemspec
284
+ - lib/jekyll-import.rb
285
+ - lib/jekyll/commands/import.rb
286
+ - lib/jekyll/jekyll-import/csv.rb
287
+ - lib/jekyll/jekyll-import/drupal6.rb
288
+ - lib/jekyll/jekyll-import/drupal7.rb
289
+ - lib/jekyll/jekyll-import/enki.rb
290
+ - lib/jekyll/jekyll-import/joomla.rb
291
+ - lib/jekyll/jekyll-import/marley.rb
292
+ - lib/jekyll/jekyll-import/mephisto.rb
293
+ - lib/jekyll/jekyll-import/mt.rb
294
+ - lib/jekyll/jekyll-import/posterous.rb
295
+ - lib/jekyll/jekyll-import/rss.rb
296
+ - lib/jekyll/jekyll-import/s9y.rb
297
+ - lib/jekyll/jekyll-import/textpattern.rb
298
+ - lib/jekyll/jekyll-import/tumblr.rb
299
+ - lib/jekyll/jekyll-import/typo.rb
300
+ - lib/jekyll/jekyll-import/wordpress.rb
301
+ - lib/jekyll/jekyll-import/wordpressdotcom.rb
302
+ - test/helper.rb
303
+ - test/test_mt_importer.rb
304
+ - test/test_wordpress_importer.rb
305
+ - test/test_wordpressdotcom_importer.rb
306
+ homepage: http://github.com/mojombo/jekyll-import
307
+ licenses: []
308
+ post_install_message:
309
+ rdoc_options:
310
+ - --charset=UTF-8
311
+ require_paths:
312
+ - lib
313
+ required_ruby_version: !ruby/object:Gem::Requirement
314
+ none: false
315
+ requirements:
316
+ - - ! '>='
317
+ - !ruby/object:Gem::Version
318
+ version: '0'
319
+ required_rubygems_version: !ruby/object:Gem::Requirement
320
+ none: false
321
+ requirements:
322
+ - - ! '>'
323
+ - !ruby/object:Gem::Version
324
+ version: 1.3.1
325
+ requirements: []
326
+ rubyforge_project: jekyll-import
327
+ rubygems_version: 1.8.23
328
+ signing_key:
329
+ specification_version: 2
330
+ summary: Import command for Jekyll (static site generator).
331
+ test_files:
332
+ - test/test_mt_importer.rb
333
+ - test/test_wordpress_importer.rb
334
+ - test/test_wordpressdotcom_importer.rb