tdiary 4.0.2 → 4.0.2.20140201

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/Gemfile +8 -7
  4. data/Gemfile.lock +17 -15
  5. data/config.ru +0 -2
  6. data/doc/INSTALL-paas.md +17 -5
  7. data/misc/plugin/amazon/amazonimg.rb +1 -1
  8. data/misc/plugin/category.rb +7 -7
  9. data/misc/plugin/image.rb +4 -1
  10. data/misc/plugin/search-default.rb +269 -0
  11. data/misc/theme_convert/theme_convert.rb +3 -3
  12. data/plugin/50sp.rb +3 -2
  13. data/spec/acceptance/append_comment_spec.rb +8 -8
  14. data/spec/acceptance/append_diary_spec.rb +9 -9
  15. data/spec/acceptance/save_conf_comment_spec.rb +7 -7
  16. data/spec/acceptance/save_conf_default_spec.rb +31 -31
  17. data/spec/acceptance/save_conf_dnsbl_spec.rb +28 -28
  18. data/spec/acceptance/save_conf_referer_spec.rb +6 -6
  19. data/spec/acceptance/save_conf_security_spec.rb +37 -37
  20. data/spec/acceptance/support/helpers.rb +8 -8
  21. data/spec/acceptance/update_diary_spec.rb +21 -21
  22. data/spec/acceptance/view_category_spec.rb +5 -5
  23. data/spec/acceptance/view_comment_spec.rb +6 -6
  24. data/spec/acceptance/view_diary_spec.rb +12 -12
  25. data/spec/acceptance/view_referer_spec.rb +3 -3
  26. data/spec/acceptance_helper.rb +2 -2
  27. data/spec/core/configuration_spec.rb +1 -1
  28. data/spec/core/io/default_spec.rb +30 -2
  29. data/spec/core/plugin_spec.rb +1 -1
  30. data/tdiary/application/configuration.rb +0 -1
  31. data/tdiary/application/extensions/omniauth.rb +1 -1
  32. data/tdiary/application.rb +6 -9
  33. data/tdiary/cli.rb +6 -6
  34. data/tdiary/configuration.rb +2 -2
  35. data/tdiary/extensions/core.rb +18 -0
  36. data/tdiary/extensions.rb +6 -0
  37. data/tdiary/io/base.rb +11 -7
  38. data/tdiary/lang/ja.rb +2 -2
  39. data/tdiary/server.rb +1 -1
  40. data/tdiary/version.rb +1 -1
  41. data/tdiary.rb +2 -1
  42. data/test/test_plugin_helper.rb +54 -10
  43. data/test/test_plugin_helper_test.rb +27 -5
  44. data/test/weather_test.rb +26 -22
  45. data/tmp/.gitkeep +0 -0
  46. metadata +7 -3
@@ -4,11 +4,11 @@ require 'acceptance_helper'
4
4
  feature '日記の更新' do
5
5
  scenario '特定の日記の内容を更新する' do
6
6
  visit '/update.rb'
7
- fill_in "year", :with => '2001'
8
- fill_in "month", :with => '4'
9
- fill_in "day", :with => '23'
10
- fill_in "title", :with => "tDiaryのテスト"
11
- fill_in "body", :with => <<-BODY
7
+ fill_in "year", with: '2001'
8
+ fill_in "month", with: '4'
9
+ fill_in "day", with: '23'
10
+ fill_in "title", with: "tDiaryのテスト"
11
+ fill_in "body", with: <<-BODY
12
12
  !さて、テストである。
13
13
  とりあえず自前の環境ではちゃんと動いているが、きっと穴がいっぱいあるに違いない:-P
14
14
 
@@ -19,7 +19,7 @@ BODY
19
19
  click_button "追記"
20
20
 
21
21
  visit '/'
22
- page.find('h2', :text => '2001年04月23日').click_link '2001年04月23日'
22
+ page.find('h2', text: '2001年04月23日').click_link '2001年04月23日'
23
23
  within('div.day span.title'){ page.should have_content "tDiaryのテスト" }
24
24
  within('div.body'){
25
25
  page.should have_content "さて、テストである。"
@@ -30,12 +30,12 @@ BODY
30
30
  }
31
31
 
32
32
  visit '/update.rb'
33
- fill_in "year", :with => '2001'
34
- fill_in "month", :with => '4'
35
- fill_in "day", :with => '23'
33
+ fill_in "year", with: '2001'
34
+ fill_in "month", with: '4'
35
+ fill_in "day", with: '23'
36
36
  click_button 'この日付の日記を編集'
37
37
 
38
- fill_in "body", :with => <<-BODY
38
+ fill_in "body", with: <<-BODY
39
39
  !もう一度テストである。
40
40
  本当に動くかな?
41
41
  BODY
@@ -43,7 +43,7 @@ BODY
43
43
  click_button "登録"
44
44
 
45
45
  visit '/'
46
- page.find('h2', :text => '2001年04月23日').click_link '2001年04月23日'
46
+ page.find('h2', text: '2001年04月23日').click_link '2001年04月23日'
47
47
  within('div.day span.title'){ page.should have_content "tDiaryのテスト" }
48
48
  within('div.body'){
49
49
  page.should have_no_content "さて、テストである。"
@@ -58,12 +58,12 @@ BODY
58
58
  append_default_diary
59
59
 
60
60
  visit '/update.rb'
61
- fill_in "year", :with => Date.today.year
62
- fill_in "month", :with => Date.today.month
63
- fill_in "day", :with => Date.today.day
61
+ fill_in "year", with: Date.today.year
62
+ fill_in "month", with: Date.today.month
63
+ fill_in "day", with: Date.today.day
64
64
  click_button 'この日付の日記を編集'
65
65
 
66
- within('div.textarea') { fill_in "body", :with => '' }
66
+ within('div.textarea') { fill_in "body", with: '' }
67
67
 
68
68
  click_button "登録"
69
69
  page.should have_content "Click here!"
@@ -76,9 +76,9 @@ BODY
76
76
  append_default_diary
77
77
 
78
78
  visit '/update.rb'
79
- fill_in "year", :with => Date.today.year
80
- fill_in "month", :with => Date.today.month
81
- fill_in "day", :with => Date.today.day
79
+ fill_in "year", with: Date.today.year
80
+ fill_in "month", with: Date.today.month
81
+ fill_in "day", with: Date.today.day
82
82
  click_button 'この日付の日記を編集'
83
83
  check 'hide'
84
84
 
@@ -95,9 +95,9 @@ BODY
95
95
  append_default_diary('20010504')
96
96
 
97
97
  visit '/update.rb'
98
- fill_in "year", :with => '2001'
99
- fill_in "month", :with => '5'
100
- fill_in "day", :with => '3'
98
+ fill_in "year", with: '2001'
99
+ fill_in "month", with: '5'
100
+ fill_in "day", with: '3'
101
101
  click_button 'この日付の日記を編集'
102
102
 
103
103
  page.should have_content('«前の日記(2001年05月02日)')
@@ -8,11 +8,11 @@ feature 'カテゴリ機能の動作' do
8
8
  visit '/'
9
9
  click_link '追記'
10
10
 
11
- within('span.year') { fill_in "year", :with => '2001' }
12
- within('span.month') { fill_in "month", :with => '4' }
13
- within('span.day') { fill_in "day", :with => '23' }
11
+ within('span.year') { fill_in "year", with: '2001' }
12
+ within('span.month') { fill_in "month", with: '4' }
13
+ within('span.day') { fill_in "day", with: '23' }
14
14
  within('div.textarea') {
15
- fill_in "body", :with => <<-BODY
15
+ fill_in "body", with: <<-BODY
16
16
  ![category] さて、テストである。
17
17
  とりあえず自前の環境ではちゃんと動いているが、きっと穴がいっぱいあるに違いない:-P
18
18
 
@@ -24,7 +24,7 @@ BODY
24
24
  click_button "追記"
25
25
 
26
26
  visit '/'
27
- page.find('a', :text => "category").click
27
+ page.find('a', text: "category").click
28
28
  page.should have_content 'Categories'
29
29
  end
30
30
  end
@@ -16,7 +16,7 @@ feature 'ツッコミの表示' do
16
16
  page.should have_no_content "こんにちは!こんにちは!"
17
17
 
18
18
  today = Date.today.strftime("%Y年%m月%d日")
19
- page.find('h2', :text => today).click_link today
19
+ page.find('h2', text: today).click_link today
20
20
  page.should have_no_content "alpha"
21
21
  page.should have_no_content "こんにちは!こんにちは!"
22
22
  end
@@ -26,15 +26,15 @@ feature 'ツッコミの表示' do
26
26
 
27
27
  visit "/"
28
28
  click_link 'ツッコミを入れる'
29
- fill_in "name", :with => "寿司"
30
- fill_in "body", :with => <<-BODY
29
+ fill_in "name", with: "寿司"
30
+ fill_in "body", with: <<-BODY
31
31
  :sushi: は美味しい
32
32
  BODY
33
33
  click_button '投稿'
34
34
 
35
35
  visit "/"
36
36
  today = Date.today.strftime("%Y年%m月%d日")
37
- page.find('h2', :text => today).click_link today
37
+ page.find('h2', text: today).click_link today
38
38
  within('div.day div.comment div.commentbody') {
39
39
  page.body.should be_include "<img src='http://www.emoji-cheat-sheet.com/graphics/emojis/sushi.png' width='20' height='20' title='sushi' alt='sushi' class='emoji' /> は美味しい"
40
40
  }
@@ -45,8 +45,8 @@ BODY
45
45
 
46
46
  visit "/"
47
47
  click_link 'ツッコミを入れる'
48
- fill_in "name", :with => "寿司"
49
- fill_in "body", :with => <<-BODY
48
+ fill_in "name", with: "寿司"
49
+ fill_in "body", with: <<-BODY
50
50
  :sushi: は美味しい
51
51
  BODY
52
52
  click_button '投稿'
@@ -19,7 +19,7 @@ feature '日記を読む' do
19
19
  after_day = '2010年05月01日'
20
20
 
21
21
  visit '/'
22
- page.find('h2', :text => before_day).click_link "#{before_day}"
22
+ page.find('h2', text: before_day).click_link "#{before_day}"
23
23
  within('div.adminmenu'){ page.should have_content "次の日記(#{after_day})"}
24
24
 
25
25
  click_link "次の日記(#{after_day})"
@@ -54,7 +54,7 @@ feature '日記を読む' do
54
54
  append_default_diary('20030423')
55
55
 
56
56
  visit '/'
57
- page.find('h2', :text => "2001年04月23日").click_link '2001年04月23日'
57
+ page.find('h2', text: "2001年04月23日").click_link '2001年04月23日'
58
58
  click_link '長年日記'
59
59
 
60
60
  titles = page.all('h2 span.date a').map{|t| t.text }
@@ -79,12 +79,12 @@ feature '日記を読む' do
79
79
 
80
80
  visit '/'
81
81
  click_link '追記'
82
- within('span.year') { fill_in "year", :with => 2001 }
83
- within('span.month') { fill_in "month", :with => 01 }
84
- within('span.day') { fill_in "day", :with => 31 }
85
- within('div.title') { fill_in "title", :with => "tDiaryのテスト" }
82
+ within('span.year') { fill_in "year", with: 2001 }
83
+ within('span.month') { fill_in "month", with: 01 }
84
+ within('span.day') { fill_in "day", with: 31 }
85
+ within('div.title') { fill_in "title", with: "tDiaryのテスト" }
86
86
  within('div.textarea') {
87
- fill_in "body", :with => <<-BODY
87
+ fill_in "body", with: <<-BODY
88
88
  !さて、月末である。
89
89
  今月も終わる
90
90
  BODY
@@ -93,12 +93,12 @@ BODY
93
93
 
94
94
  visit '/'
95
95
  click_link '追記'
96
- within('span.year') { fill_in "year", :with => 2001 }
97
- within('span.month') { fill_in "month", :with => 02 }
98
- within('span.day') { fill_in "day", :with => 01 }
99
- within('div.title') { fill_in "title", :with => "tDiaryのテスト" }
96
+ within('span.year') { fill_in "year", with: 2001 }
97
+ within('span.month') { fill_in "month", with: 02 }
98
+ within('span.day') { fill_in "day", with: 01 }
99
+ within('div.title') { fill_in "title", with: "tDiaryのテスト" }
100
100
  within('div.textarea') {
101
- fill_in "body", :with => <<-BODY
101
+ fill_in "body", with: <<-BODY
102
102
  !さて、月始めである。
103
103
  今月も始まる
104
104
  BODY
@@ -1,12 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'acceptance_helper'
3
3
 
4
- feature 'リンク元の表示', :exclude_selenium => true do
4
+ feature 'リンク元の表示', exclude_selenium: true do
5
5
  scenario '日表示にリンク元が表示されている' do
6
6
  append_default_diary
7
7
  visit '/'
8
8
  today = Date.today.strftime("%Y年%m月%d日")
9
- page.find('h2', :text => today).click_link today
9
+ page.find('h2', text: today).click_link today
10
10
  within('div.day') {
11
11
  page.should have_css('div[class="refererlist"]')
12
12
  within('div.refererlist') { page.should have_content "http://www.example.com" }
@@ -17,7 +17,7 @@ feature 'リンク元の表示', :exclude_selenium => true do
17
17
  append_default_diary
18
18
  visit "/"
19
19
  today = Date.today.strftime("%Y年%m月%d日")
20
- page.find('h2', :text => today).click_link today
20
+ page.find('h2', text: today).click_link today
21
21
  within('div.day div.refererlist') { page.should have_link "http://www.example.com" }
22
22
  end
23
23
  end
@@ -30,7 +30,7 @@ RSpec.configure do |config|
30
30
  work_conf = File.expand_path('../../tdiary.conf', __FILE__)
31
31
 
32
32
  config.before(:all) do
33
- FileUtils.cp_r tdiary_conf, work_conf, :verbose => false
33
+ FileUtils.cp_r tdiary_conf, work_conf, verbose: false
34
34
  end
35
35
 
36
36
  config.after(:all) do
@@ -39,7 +39,7 @@ RSpec.configure do |config|
39
39
 
40
40
  config.before(:each) do
41
41
  FileUtils.mkdir_p work_data_dir
42
- FileUtils.cp_r(fixture_conf, File.join(work_data_dir, "tdiary.conf"), :verbose => false) unless fixture_conf.empty?
42
+ FileUtils.cp_r(fixture_conf, File.join(work_data_dir, "tdiary.conf"), verbose: false) unless fixture_conf.empty?
43
43
  end
44
44
 
45
45
  config.after(:each) do
@@ -8,7 +8,7 @@ describe TDiary::Configuration do
8
8
  let(:work_conf) { File.expand_path('../../../tdiary.conf', __FILE__) }
9
9
 
10
10
  before do
11
- FileUtils.cp_r tdiary_conf, work_conf, :verbose => false
11
+ FileUtils.cp_r tdiary_conf, work_conf, verbose: false
12
12
  end
13
13
 
14
14
  after do
@@ -46,7 +46,7 @@ describe TDiary::IO::Default do
46
46
  end
47
47
  end
48
48
 
49
- subject { File.open(TDiary.root + "/tmp/#{Time.now.year}/#{Time.now.year}#{Time.now.month}.td2").read }
49
+ subject { File.open(TDiary.root + "/tmp/#{Time.now.year}/#{Time.now.strftime('%Y%m')}.td2").read }
50
50
  it { expect(subject).to be_include "foo" }
51
51
  it { expect(subject).to be_include "bar" }
52
52
 
@@ -68,7 +68,7 @@ describe TDiary::IO::Default do
68
68
  end
69
69
  end
70
70
 
71
- subject { File.open(TDiary.root + "/tmp/#{Time.now.year}/#{Time.now.year}#{Time.now.month}.td2").read }
71
+ subject { File.open(TDiary.root + "/tmp/#{Time.now.year}/#{Time.now.strftime('%Y%m')}.td2").read }
72
72
 
73
73
  it "update contents of diary" do
74
74
  expect(subject).to_not be_nil
@@ -81,6 +81,34 @@ describe TDiary::IO::Default do
81
81
 
82
82
  end
83
83
 
84
+ describe "#style" do
85
+ context "given Foo style" do
86
+ let(:io) { TDiary::IO::Default.new(DummyTDiary.new) }
87
+
88
+ before do
89
+ TDiary::Style.const_set(:FooSection, Class.new)
90
+ TDiary::Style.const_set(:FooDiary, Class.new)
91
+ end
92
+
93
+ it "activates a style automatically" do
94
+ style = io.style("Foo")
95
+ expect(style).to eq TDiary::Style::FooDiary
96
+ expect(style).to be < TDiary::Style::BaseDiary
97
+ expect(style).to be < TDiary::Style::CategorizableDiary
98
+ expect(TDiary::Style::FooSection).to be < TDiary::Style::BaseSection
99
+ end
100
+
101
+ it "raises a BadStyleError when style is unknown" do
102
+ expect { io.style("Bar") }.to raise_error(TDiary::BadStyleError)
103
+ end
104
+
105
+ after do
106
+ TDiary::Style.send(:remove_const, :FooSection)
107
+ TDiary::Style.send(:remove_const, :FooDiary)
108
+ end
109
+ end
110
+ end
111
+
84
112
  before(:all) do
85
113
  ["/tmp/tdiary.conf", "/tmp/#{Time.now.year}"].each do |file|
86
114
  FileUtils.rm_rf TDiary.root + file
@@ -8,7 +8,7 @@ describe TDiary::Plugin do
8
8
  before do
9
9
  config = PluginFake::Config.new
10
10
  config.plugin_path = 'spec/fixtures/plugin'
11
- @plugin = TDiary::Plugin.new({ :conf => config, :debug => true })
11
+ @plugin = TDiary::Plugin.new({ conf: config, debug: true })
12
12
  end
13
13
 
14
14
  describe '#load_plugin' do
@@ -4,7 +4,6 @@ module TDiary
4
4
  attr_accessor :assets_paths, :assets_precompile, :plugin_paths, :path, :builder_procs, :authenticate_proc
5
5
 
6
6
  def initialize
7
- @assets_paths = []
8
7
  # if you need to auto compilation for CoffeeScript
9
8
  @assets_precompile = false;
10
9
  @plugin_paths = []
@@ -4,7 +4,7 @@ require 'tdiary/rack/auth/omniauth'
4
4
 
5
5
  TDiary::Application.configure do
6
6
  config.builder do
7
- use ::Rack::Session::Pool, :expire_after => 2592000
7
+ use ::Rack::Session::Pool, expire_after: 2592000
8
8
  use OmniAuth::Builder do
9
9
  configure {|conf| conf.path_prefix = "/auth" }
10
10
  provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ require 'tdiary'
2
3
  require 'rack/builder'
3
4
  require 'tdiary/application/configuration'
4
5
  require 'tdiary/rack'
@@ -41,12 +42,6 @@ module TDiary
41
42
  end
42
43
 
43
44
  Application.configure do
44
- config.assets_paths.concat %w(js theme).map {|path|
45
- [TDiary.root, TDiary.server_root].map {|base_dir|
46
- File.join(base_dir, path)
47
- }
48
- }.flatten.uniq
49
-
50
45
  config.builder do
51
46
  map Application.config.path[:index] do
52
47
  use TDiary::Rack::HtmlAnchor
@@ -62,9 +57,11 @@ module TDiary
62
57
 
63
58
  map Application.config.path[:assets] do
64
59
  environment = Sprockets::Environment.new
65
- Application.config.assets_paths.each do |path|
66
- environment.append_path path
67
- end
60
+ TDiary::Extensions::constants.map {|extension|
61
+ TDiary::Extensions::const_get( extension ).assets_path
62
+ }.flatten.uniq.each {|assets_path|
63
+ environment.append_path assets_path
64
+ }
68
65
 
69
66
  if Application.config.assets_precompile
70
67
  require 'tdiary/rack/assets/precompile'
data/tdiary/cli.rb CHANGED
@@ -12,7 +12,7 @@ module TDiary
12
12
  end
13
13
 
14
14
  desc "new DIR_NAME", "Create a new tDiary directory"
15
- method_option "skip-bundle", :type => :boolean, :banner =>
15
+ method_option "skip-bundle", type: :boolean, banner:
16
16
  "don't run bundle and .htpasswd generation"
17
17
  def new(name)
18
18
  target = File.join(Dir.pwd, name)
@@ -35,7 +35,7 @@ module TDiary
35
35
  end
36
36
 
37
37
  desc "update", "update tDiary"
38
- method_option "skip-bundle", :type => :boolean, :banner =>
38
+ method_option "skip-bundle", type: :boolean, banner:
39
39
  "don't run bundle"
40
40
  def update
41
41
  target = Dir.pwd
@@ -88,13 +88,13 @@ module TDiary
88
88
  end
89
89
 
90
90
  desc "server", "Start tDiary server"
91
- method_option "rack", :type => :string, :banner =>
91
+ method_option "rack", type: :string, banner:
92
92
  "start server with rack interface (default)"
93
- method_option "cgi", :type => :string, :banner =>
93
+ method_option "cgi", type: :string, banner:
94
94
  "start server with cgi interface"
95
- method_option "bind", :aliases => "b", :type => :string, :default => "0.0.0.0", :banner =>
95
+ method_option "bind", aliases: "b", type: :string, default: "0.0.0.0", banner:
96
96
  "bind to the IP"
97
- method_option "port", :aliases => "p", :type => :numeric, :default => 19292, :banner =>
97
+ method_option "port", aliases: "p", type: :numeric, default: 19292, banner:
98
98
  "use PORT"
99
99
  def server
100
100
  require 'tdiary/environment'
@@ -71,10 +71,10 @@ module TDiary
71
71
  str.force_encoding(charset || 'utf-8')
72
72
  end
73
73
  unless str.valid_encoding?
74
- str.encode!('utf-16be', {:invalid => :replace, :undef => :replace})
74
+ str.encode!('utf-16be', {:invalid => :replace, undef: :replace})
75
75
  end
76
76
  unless str.encoding == Encoding::UTF_8
77
- str.encode!('utf-8', {:invalid => :replace, :undef => :replace})
77
+ str.encode!('utf-8', {:invalid => :replace, undef: :replace})
78
78
  end
79
79
  str
80
80
  end
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module TDiary
4
+ module Extensions
5
+ class Core
6
+ def self.sp_path
7
+ end
8
+
9
+ def self.assets_path
10
+ %w(js theme).map {|path|
11
+ [TDiary.root, TDiary.server_root].map {|base_dir|
12
+ File.join(base_dir, path)
13
+ }
14
+ }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ require 'tdiary/extensions/core'
2
+
3
+ module TDiary
4
+ module Extensions
5
+ end
6
+ end
data/tdiary/io/base.rb CHANGED
@@ -45,14 +45,18 @@ module TDiary
45
45
  path = path.sub(/\/+$/, '').untaint
46
46
  Dir.glob("#{path}/*.rb") {|style_file| require style_file.untaint }
47
47
  end
48
- (["tdiary", "wiki"] + [@tdiary.conf.style].map(&:downcase)).flatten.uniq.each do |style|
49
- klass = TDiary::Style.const_get("#{style.capitalize}Diary")
50
- klass.send(:include, TDiary::Style::BaseDiary)
51
- klass.send(:include, TDiary::Style::CategorizableDiary)
52
- if TDiary::Style.const_defined? ("#{style.capitalize}Section")
53
- TDiary::Style.const_get("#{style.capitalize}Section").send(:include, TDiary::Style::BaseSection)
48
+ TDiary::Style.constants(false).each do |name|
49
+ prefix = name.slice(/\A(.*)Diary\z/, 1)
50
+ if prefix && /\A(Base|Categorizable)\z/ !~ prefix
51
+ klass = TDiary::Style.const_get(name)
52
+ klass.send(:include, TDiary::Style::BaseDiary)
53
+ klass.send(:include, TDiary::Style::CategorizableDiary)
54
+ section_class_name = "#{prefix}Section"
55
+ if TDiary::Style.const_defined?(section_class_name)
56
+ TDiary::Style.const_get(section_class_name).send(:include, TDiary::Style::BaseSection)
57
+ end
58
+ @styles[prefix.downcase] = klass
54
59
  end
55
- @styles[style] = klass
56
60
  end
57
61
  end
58
62
 
data/tdiary/lang/ja.rb CHANGED
@@ -23,11 +23,11 @@ def mobile_encoding
23
23
  end
24
24
 
25
25
  def to_mobile( str )
26
- str.encode(mobile_encoding, {:invalid => :replace, :undef => :replace})
26
+ str.encode(mobile_encoding, {:invalid => :replace, undef: :replace})
27
27
  end
28
28
 
29
29
  def to_mail( str )
30
- str.encode('iso-2022-jp', {:invalid => :replace, :undef => :replace})
30
+ str.encode('iso-2022-jp', {:invalid => :replace, undef: :replace})
31
31
  end
32
32
 
33
33
  def migrate_to_utf8( str )
data/tdiary/server.rb CHANGED
@@ -30,7 +30,7 @@ module TDiary
30
30
 
31
31
  def initialize( opts )
32
32
  @server = WEBrick::HTTPServer.new(
33
- :Port => opts[:port], :BindAddress => opts[:bind],
33
+ :Port => opts[:port], BindAddress: opts[:bind],
34
34
  :DocumentRoot => TDiary.root,
35
35
  :MimeTypes => tdiary_mime_types,
36
36
  :Logger => webrick_logger_to( opts[:logger] ),
data/tdiary/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TDiary
2
- VERSION = '4.0.2'
2
+ VERSION = '4.0.2.20140201'
3
3
  end
data/tdiary.rb CHANGED
@@ -45,6 +45,7 @@ module TDiary
45
45
  autoload :Server, 'tdiary/server'
46
46
  # Rack Application, TODO: integrate Server and Application
47
47
  autoload :Application, 'tdiary/application'
48
+ autoload :Extensions, 'tdiary/extensions'
48
49
 
49
50
  # Diary model class
50
51
  autoload :Style, 'tdiary/style'
@@ -124,7 +125,7 @@ module TDiary
124
125
 
125
126
  # directory where the server was started
126
127
  def server_root
127
- Dir.pwd
128
+ Dir.pwd.untaint
128
129
  end
129
130
 
130
131
  def configuration
@@ -42,23 +42,67 @@ module TDiary
42
42
 
43
43
  class ConfStub
44
44
  def style; 'tDiary'; end
45
+
46
+ def initialize
47
+ @conf = Hash.new
48
+ end
49
+
50
+ def []=(k,v)
51
+ @conf[k] = v
52
+ end
53
+
54
+ def [](k)
55
+ return @conf[k]
56
+ end
45
57
  end
46
58
 
47
- class PluginTestCase < Test::Unit::TestCase
59
+ class StubPlugin
60
+ def self.inherited(child)
61
+ super
62
+ child.module_eval(<<-EOS)
63
+ def context
64
+ binding
65
+ end
66
+ EOS
67
+ end
68
+
48
69
  include TDiary::PluginTestStub
49
70
 
50
- def add_stub_ivars
51
- @options = {}
52
- @conf_genre_label = {}
53
- @conf = TDiary::ConfStub.new
71
+ def StubPlugin::_load_plugin(plugin_relative_path, lang = 'en')
72
+ plugin_class = Class.new(StubPlugin)
73
+ plugin = plugin_class.new(lang)
74
+ plugin.load(plugin_relative_path)
75
+ return plugin_class, plugin
54
76
  end
55
77
 
56
- def load_plugin(plugin_relative_path, lang = 'en', context = binding)
57
- add_stub_ivars
58
- ppath = PluginTestHelper.absolute_path_of(plugin_relative_path)
59
- pl10n = PluginTestHelper.resource_absolute_path_of(plugin_relative_path, lang)
60
- File.open(pl10n){|f| eval(f.read, context, PluginTestHelper.resource_relative_path_of(plugin_relative_path, lang))}
78
+ def StubPlugin::load_plugin(plugin_relative_path, lang = 'en')
79
+ return StubPlugin::_load_plugin(plugin_relative_path, lang = 'en')[1]
80
+ end
81
+
82
+ def StubPlugin::new_plugin(plugin_relative_path, lang = 'en')
83
+ return StubPlugin::_load_plugin(plugin_relative_path, lang = 'en')[0]
84
+ end
85
+
86
+ attr_accessor :conf
87
+ attr_accessor :options
88
+
89
+ def initialize(lang = 'en')
90
+ @lang = lang
91
+ reset
92
+ end
93
+
94
+ def load(plugin_relative_path)
95
+ reset
96
+ ppath = TDiary::PluginTestHelper.absolute_path_of(plugin_relative_path)
97
+ pl10n = TDiary::PluginTestHelper.resource_absolute_path_of(plugin_relative_path, @lang)
98
+ File.open(pl10n){|f| eval(f.read, context, TDiary::PluginTestHelper.resource_relative_path_of(plugin_relative_path, @lang))}
61
99
  File.open(ppath){|f| eval(f.read, context, plugin_relative_path)}
62
100
  end
101
+
102
+ def reset
103
+ @options = {}
104
+ @conf_genre_label = {}
105
+ @conf = TDiary::ConfStub.new
106
+ end
63
107
  end
64
108
  end