memorack 0.2.0 → 0.2.1

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: 86c45efe555619b9ccb0baf170a9ec452f0fa52e
4
- data.tar.gz: b012723ff47cef6d9887501fd28c88d3d6a5fcfc
3
+ metadata.gz: 827dc521c8e16aa7f5f7689e32d91a0fc1918d57
4
+ data.tar.gz: b1cdbfa7c2a0674fe02b0279d62dcf6d9fa8d2f0
5
5
  SHA512:
6
- metadata.gz: 5ca5bf21735546d0371a71efebad1c902b869283495a26b4c276442e0cb949169ddafd894479590c3d77bebf5c82479a9548346607f1f9321301a9e6f6390c21
7
- data.tar.gz: dbfa869e5a135c9d5244d7b92cb65aab7634786b8a0361c643e2b9039de285074ab65f88834f60a3396d8a58013da548bf82c00517bb07c0d3d5ac0fad560f5b
6
+ metadata.gz: 032bb4527d6c6f494b47a6eb0476660721e1d7d1e8f1421414d43afb37d07e5b0b3101cbc0f56e7f38057173ae1ec50eb03002b469e6fe9919d3186c77eb87bb
7
+ data.tar.gz: bd75dbffa43ac28389a3243c6c1403bb746519a8e4f6112edd81b005bf3ce2f2995847a34eef9f8850549d5b17bac871431594a2fb97e4bf49679a63ba33a475
data/.gitignore CHANGED
@@ -16,6 +16,7 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ vendor
19
20
 
20
21
  # editor noise
21
22
  *~
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -51,6 +51,7 @@ module MemoRack
51
51
  def i18n_init
52
52
  I18n.load_path = Dir[File.expand_path('../locales/*.yml', __FILE__)]
53
53
  I18n.backend.load_translations
54
+ I18n.enforce_available_locales = false
54
55
 
55
56
  locale = ENV['LANG'][0, 2].to_sym if ENV['LANG']
56
57
  I18n.locale = locale if I18n.available_locales.include?(locale)
@@ -65,7 +66,7 @@ module MemoRack
65
66
  # ディレクトリを繰返す
66
67
  def dir_earch(dir, match = '**/*', flag = File::FNM_DOTMATCH)
67
68
  Dir.chdir(dir) { |d|
68
- Dir.glob(match, flag).each { |file|
69
+ Dir.glob(match, flag).sort.each { |file|
69
70
  next if File.basename(file) =~ /^[.]{1,2}$/
70
71
  file = File.join(file, '') if File.directory?(file)
71
72
  yield(file)
@@ -79,9 +80,11 @@ module MemoRack
79
80
 
80
81
  puts "#{domain}:"
81
82
 
82
- Dir.foreach(themes) { |file|
83
- next if /^\./ =~ file
84
- puts " #{file}"
83
+ Dir.open(themes) { |dir|
84
+ dir.sort.each { |file|
85
+ next if /^\./ =~ file
86
+ puts " #{file}"
87
+ }
85
88
  }
86
89
  end
87
90
 
@@ -5,6 +5,7 @@ require 'pathname'
5
5
  require 'rubygems'
6
6
  require 'i18n'
7
7
 
8
+ require 'mustache'
8
9
  require 'memorack/tilt-mustache'
9
10
  require 'memorack/mdmenu'
10
11
  require 'memorack/locals'
@@ -74,6 +75,7 @@ module MemoRack
74
75
  # ロケールの読込み
75
76
  I18n.load_path = @locale_paths
76
77
  I18n.backend.load_translations
78
+ I18n.enforce_available_locales = false
77
79
 
78
80
  @requires.each { |lib| require lib }
79
81
  @locals = default_locals(@options)
@@ -599,7 +601,18 @@ module MemoRack
599
601
  # Tilt に登録されている拡張子を集める
600
602
  def extnames(extname)
601
603
  klass = Tilt[extname]
602
- Tilt.mappings.select { |key, value| value.member?(klass) }.collect { |key, value| key }
604
+ r = []
605
+
606
+ if Tilt.respond_to?(:mappings)
607
+ r |= Tilt.mappings.select { |key, value| value.member?(klass) }.collect { |key, value| key }
608
+ end
609
+
610
+ if Tilt.respond_to?(:default_mapping)
611
+ r |= Tilt.default_mapping.template_map.select { |key, value| value == klass }.collect { |key, value| key }
612
+ r |= Tilt.default_mapping.lazy_map.select { |key, value| value.assoc(klass.to_s) }.collect { |key, value| key }
613
+ end
614
+
615
+ r
603
616
  end
604
617
 
605
618
  # 対応フォーマットを取得する
@@ -25,16 +25,16 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency('tilt')
26
26
  gem.add_dependency('mustache')
27
27
  gem.add_dependency('redcarpet', '>= 2.0.0')
28
- gem.add_dependency('json')
29
28
  gem.add_dependency('sass')
30
29
  gem.add_dependency('i18n')
31
30
 
32
31
  # for development
33
32
  gem.add_development_dependency('bundler', '~> 1.3')
34
33
  gem.add_development_dependency('rake')
35
- gem.add_development_dependency('minitest')
34
+ gem.add_development_dependency('minitest', '~> 4.7') if Gem.ruby_version < Gem::Version.create('2.0')
36
35
  gem.add_development_dependency('turn')
37
36
  gem.add_development_dependency('rack-test')
37
+ gem.add_development_dependency('org-ruby')
38
38
 
39
39
  gem.post_install_message = %Q{
40
40
  ==================
@@ -3,7 +3,9 @@
3
3
  require File.expand_path('../spec_helper', __FILE__)
4
4
  require 'memorack'
5
5
  require 'memorack/cli'
6
+ require 'time'
6
7
  require 'cgi'
8
+ require 'set'
7
9
 
8
10
 
9
11
  describe MemoRack do
@@ -60,16 +62,20 @@ describe MemoRack do
60
62
  end
61
63
 
62
64
  # git でパッチをあてる
63
- def git_am(name)
65
+ def git_am(name, init = false)
66
+ FileUtils.remove_entry_secure('.git') if init && File.exists?('.git')
67
+
64
68
  unless File.exists?('.git')
65
69
  `git init`
70
+ `git config --local user.email "you@example.com"`
71
+ `git config --local user.name "Your Name"`
66
72
  `git add .`
67
73
  `git commit -m "first commit"`
68
74
  end
69
75
 
70
76
  path = File.expand_path("../patches/#{name}", __FILE__)
71
77
  if File.directory?(path)
72
- Dir[File.join(path, '*.patch')].each { |path|
78
+ Dir[File.join(path, '*.patch')].sort.each { |path|
73
79
  `git am -3 "#{path}"`
74
80
  }
75
81
  else
@@ -78,6 +84,18 @@ describe MemoRack do
78
84
  end
79
85
  end
80
86
 
87
+ # ファイル構成が同じかチェックする
88
+ def must_files(path, files)
89
+ files = files.split("\n") if files.kind_of?(String)
90
+
91
+ Dir.chdir(path || '.') { |dir|
92
+ list = Dir.glob('**/*', File::FNM_DOTMATCH)
93
+ list.reject! { |item| item =~ %r[(^|/)\.{1,2}$] }
94
+ Set.new(list).must_equal Set.new(files)
95
+ }
96
+ end
97
+
98
+
81
99
  before do
82
100
  require 'tmpdir'
83
101
  @tmpdir = Dir.mktmpdir
@@ -208,25 +226,24 @@ describe MemoRack do
208
226
 
209
227
  Dir.chdir(@tmpdir) {
210
228
  proc { memorack 'create', name }.must_output "Created '#{name}'\n"
211
- `cd #{name}; find . -print`.must_equal <<-EOD.cut_indent
212
- .
213
- ./.gitignore
214
- ./.powenv
215
- ./config.ru
216
- ./content
217
- ./content/README.md
218
- ./Gemfile
219
- ./plugins
220
- ./plugins/.gitkeep
221
- ./themes
222
- ./themes/custom
223
- ./themes/custom/config.json
224
- ./themes/custom/index.md
225
- ./themes/custom/locales
226
- ./themes/custom/locales/.gitkeep
227
- ./themes/custom/macro.yml
228
- ./themes/custom/pages
229
- ./themes/custom/pages/.gitkeep
229
+ must_files name, <<-EOD.cut_indent
230
+ .gitignore
231
+ .powenv
232
+ config.ru
233
+ content
234
+ content/README.md
235
+ Gemfile
236
+ plugins
237
+ plugins/.gitkeep
238
+ themes
239
+ themes/custom
240
+ themes/custom/config.json
241
+ themes/custom/index.md
242
+ themes/custom/locales
243
+ themes/custom/locales/.gitkeep
244
+ themes/custom/macro.yml
245
+ themes/custom/pages
246
+ themes/custom/pages/.gitkeep
230
247
  EOD
231
248
  }
232
249
  end
@@ -283,16 +300,15 @@ describe MemoRack do
283
300
  chmemo { |name|
284
301
  proc { memorack 'theme', '-c', theme }.must_output "Created 'themes/#{theme}'\n"
285
302
 
286
- `cd themes/#{theme}; find . -print`.must_equal <<-EOD.cut_indent
287
- .
288
- ./404.md
289
- ./config.json
290
- ./css
291
- ./css/2-column.scss
292
- ./css/basic-styles.scss
293
- ./css/styles.scss
294
- ./error.html
295
- ./index.html
303
+ must_files File.join('themes', theme), <<-EOD.cut_indent
304
+ 404.md
305
+ config.json
306
+ css
307
+ css/2-column.scss
308
+ css/basic-styles.scss
309
+ css/styles.scss
310
+ error.html
311
+ index.html
296
312
  EOD
297
313
  }
298
314
  end
@@ -316,13 +332,12 @@ describe MemoRack do
316
332
  @theme = 'oreilly'
317
333
 
318
334
  @file_lists = <<-EOD.cut_indent
319
- .
320
- ./css
321
- ./css/2-column.css
322
- ./css/basic-styles.css
323
- ./css/styles.css
324
- ./index.html
325
- ./README.html
335
+ css
336
+ css/2-column.css
337
+ css/basic-styles.css
338
+ css/styles.css
339
+ index.html
340
+ README.html
326
341
  EOD
327
342
  end
328
343
 
@@ -334,7 +349,7 @@ describe MemoRack do
334
349
  proc { memorack 'build' }.must_output "Build 'content/' -> '#{output}'\n"
335
350
 
336
351
  Dir.chdir(output) { |output|
337
- `find . -print`.must_equal @file_lists
352
+ must_files nil, @file_lists
338
353
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
339
354
  }
340
355
  }
@@ -354,7 +369,7 @@ describe MemoRack do
354
369
  proc { memorack 'build', path }.must_output "Build '#{path}' -> '#{output}'\n"
355
370
 
356
371
  Dir.chdir(output) { |output|
357
- `find . -print`.must_equal @file_lists
372
+ must_files nil, @file_lists
358
373
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
359
374
  }
360
375
  }
@@ -368,7 +383,7 @@ describe MemoRack do
368
383
  proc { memorack 'build', '--output', output }.must_output "Build 'content/' -> '#{output}'\n"
369
384
 
370
385
  Dir.chdir(output) { |output|
371
- `find . -print`.must_equal @file_lists
386
+ must_files nil, @file_lists
372
387
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
373
388
  }
374
389
  }
@@ -382,7 +397,7 @@ describe MemoRack do
382
397
  proc { memorack 'build', '--theme', theme }.must_output "Build 'content/' -> '#{output}'\n"
383
398
 
384
399
  Dir.chdir(output) { |output|
385
- `find . -print`.must_equal @file_lists
400
+ must_files nil, @file_lists
386
401
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
387
402
  }
388
403
  }
@@ -397,7 +412,7 @@ describe MemoRack do
397
412
  proc { memorack 'build', '--url', url }.must_output "Build 'content/' -> '#{output}'\n"
398
413
 
399
414
  Dir.chdir(output) { |output|
400
- `find . -print`.must_equal @file_lists
415
+ must_files nil, @file_lists
401
416
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
402
417
  File.read('index.html').must_match %r[<a href="#{url}/README.html">MemoRack について</a>]
403
418
  }
@@ -414,7 +429,7 @@ describe MemoRack do
414
429
  proc { memorack 'build', '--local' }.must_output "Build 'content/' -> '#{output}'\n"
415
430
 
416
431
  Dir.chdir(output) { |output|
417
- `find . -print`.must_equal @file_lists
432
+ must_files nil, @file_lists
418
433
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
419
434
  File.read('index.html').must_match %r[<a href="#{url}/README.html">MemoRack について</a>]
420
435
  }
@@ -430,15 +445,14 @@ describe MemoRack do
430
445
  proc { memorack 'build', '--prettify' }.must_output "Build 'content/' -> '#{output}'\n"
431
446
 
432
447
  Dir.chdir(output) { |output|
433
- `find . -print`.must_equal <<-EOD.cut_indent
434
- .
435
- ./css
436
- ./css/2-column.css
437
- ./css/basic-styles.css
438
- ./css/styles.css
439
- ./index.html
440
- ./README
441
- ./README/index.html
448
+ must_files nil, <<-EOD.cut_indent
449
+ css
450
+ css/2-column.css
451
+ css/basic-styles.css
452
+ css/styles.css
453
+ index.html
454
+ README
455
+ README/index.html
442
456
  EOD
443
457
 
444
458
  `git hash-object css/styles.css`.must_equal @hash[theme]+"\n"
@@ -482,16 +496,16 @@ describe MemoRack do
482
496
  output = '_site'
483
497
 
484
498
  chmemo { |name|
485
- git_am 'git'
499
+ git_am 'git', true
486
500
  proc { memorack 'build' }.must_output "Build 'content/' -> '#{output}'\n"
487
501
 
488
502
  Dir.chdir(output) { |output|
489
- ctime = '<div>作成時間:2013-05-11 18:47:31 +0900</div>'
490
- mtime = '<div>更新時間:2013-05-11 18:49:46 +0900</div>'
503
+ ctime = Time.parse '2013-05-11 18:47:31 +0900'
504
+ mtime = Time.parse '2013-05-11 18:49:46 +0900'
491
505
 
492
506
  history = File.read('HISTORY.html')
493
- history.must_match /#{Regexp.escape ctime}/
494
- history.must_match /#{Regexp.escape mtime}/
507
+ history.must_match /#{Regexp.escape "<div>作成時間:#{ctime}</div>"}/
508
+ history.must_match /#{Regexp.escape "<div>更新時間:#{mtime}</div>"}/
495
509
  }
496
510
  }
497
511
  end
@@ -1,5 +1,5 @@
1
- require 'minitest/spec'
2
1
  require 'minitest/autorun'
2
+ require 'minitest/spec'
3
3
  require 'rack/test'
4
4
 
5
5
  begin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memorack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gnue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-11 00:00:00.000000000 Z
11
+ date: 2013-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.0.0
69
- - !ruby/object:Gem::Dependency
70
- name: json
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: sass
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +123,7 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: minitest
126
+ name: turn
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - '>='
@@ -151,7 +137,7 @@ dependencies:
151
137
  - !ruby/object:Gem::Version
152
138
  version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
- name: turn
140
+ name: rack-test
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - '>='
@@ -165,7 +151,7 @@ dependencies:
165
151
  - !ruby/object:Gem::Version
166
152
  version: '0'
167
153
  - !ruby/object:Gem::Dependency
168
- name: rack-test
154
+ name: org-ruby
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
157
  - - '>='
@@ -187,6 +173,7 @@ extensions: []
187
173
  extra_rdoc_files: []
188
174
  files:
189
175
  - .gitignore
176
+ - .travis.yml
190
177
  - Gemfile
191
178
  - HISTORY.md
192
179
  - LICENSE.txt
@@ -267,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
254
  version: '0'
268
255
  requirements: []
269
256
  rubyforge_project:
270
- rubygems_version: 2.0.0
257
+ rubygems_version: 2.0.14
271
258
  signing_key:
272
259
  specification_version: 4
273
260
  summary: Rack Application for markdown memo