tdiary 4.0.2.20140201 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/ChangeLog +3 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +48 -29
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/index.rb +2 -2
- data/js/01conf.js +16 -0
- data/misc/convert2.rb +3 -3
- data/misc/filter/limitdays.rb +2 -2
- data/misc/filter/linkcheck.rb +2 -2
- data/misc/lib/fcgi_patch.rb +3 -3
- data/misc/paas/cloudfoundry/Gemfile.lock +51 -48
- data/misc/paas/heroku/Gemfile.lock +23 -21
- data/misc/paas/sqale/Gemfile.lock +23 -21
- data/misc/plugin/a.rb +4 -4
- data/misc/plugin/calendar2.rb +1 -1
- data/misc/plugin/category.rb +3 -3
- data/misc/plugin/comment_emoji_autocomplete.rb +1 -1
- data/misc/plugin/comment_mail-qmail.rb +1 -1
- data/misc/plugin/comment_mail-sendmail.rb +1 -1
- data/misc/plugin/comment_mail-smtp.rb +1 -1
- data/misc/plugin/counter.rb +27 -27
- data/misc/plugin/disp_referrer.rb +1 -1
- data/misc/plugin/en/amazon.rb +2 -2
- data/misc/plugin/en/category.rb +1 -1
- data/misc/plugin/en/counter.rb +1 -1
- data/misc/plugin/en/disp_referrer.rb +1 -1
- data/misc/plugin/en/kw.rb +1 -1
- data/misc/plugin/en/search_form.rb +1 -1
- data/misc/plugin/en/todo.rb +1 -1
- data/misc/plugin/en/weather.rb +5 -2
- data/misc/plugin/image.rb +2 -2
- data/misc/plugin/ja/disp_referrer.rb +7 -7
- data/misc/plugin/ja/my-sequel.rb +1 -1
- data/misc/plugin/ja/recent_comment3.rb +1 -1
- data/misc/plugin/ja/referer_scheme.rb +1 -1
- data/misc/plugin/ja/search_control.rb +1 -1
- data/misc/plugin/ja/search_form.rb +2 -2
- data/misc/plugin/ja/todo.rb +1 -1
- data/misc/plugin/ja/weather.rb +17 -12
- data/misc/plugin/makelirs.rb +4 -4
- data/misc/plugin/my-ex.rb +1 -1
- data/misc/plugin/my-sequel.rb +1 -1
- data/misc/plugin/pb-show.rb +1 -1
- data/misc/plugin/recent_comment.rb +5 -5
- data/misc/plugin/recent_comment3.rb +2 -2
- data/misc/plugin/recent_namazu.rb +4 -4
- data/misc/plugin/recent_rss.rb +7 -7
- data/misc/plugin/referer_scheme.rb +2 -2
- data/misc/plugin/search-default.rb +1 -1
- data/misc/plugin/sn.rb +3 -3
- data/misc/plugin/speed_comment.rb +1 -1
- data/misc/plugin/squeeze.rb +8 -8
- data/misc/plugin/tb-show.rb +1 -1
- data/misc/plugin/theme_online.rb +25 -0
- data/misc/plugin/tlink.rb +2 -2
- data/misc/plugin/todo.rb +2 -2
- data/misc/plugin/weather.rb +82 -26
- data/misc/plugin/whatsnew.rb +1 -1
- data/misc/plugin/xmlrpc/xmlrpc.rb +11 -11
- data/misc/theme_convert/theme_convert.rb +3 -3
- data/plugin/00default.rb +35 -28
- data/plugin/50sp.rb +1 -1
- data/plugin/60sf.rb +1 -1
- data/plugin/90migrate.rb +2 -2
- data/plugin/en/00default.rb +1 -1
- data/plugin/ja/00default.rb +1 -1
- data/spec/acceptance/append_comment_spec.rb +18 -18
- data/spec/acceptance/append_diary_spec.rb +22 -22
- data/spec/acceptance/bugfix/encoding_error_spec.rb +1 -1
- data/spec/acceptance/save_conf_comment_spec.rb +15 -15
- data/spec/acceptance/save_conf_default_spec.rb +26 -26
- data/spec/acceptance/save_conf_dnsbl_spec.rb +19 -19
- data/spec/acceptance/save_conf_filter_spec.rb +6 -6
- data/spec/acceptance/save_conf_plugin_spec.rb +11 -11
- data/spec/acceptance/save_conf_referer_spec.rb +4 -4
- data/spec/acceptance/save_conf_security_spec.rb +28 -28
- data/spec/acceptance/update_diary_spec.rb +16 -16
- data/spec/acceptance/view_category_spec.rb +1 -1
- data/spec/acceptance/view_comment_spec.rb +6 -6
- data/spec/acceptance/view_diary_spec.rb +25 -25
- data/spec/acceptance/view_referer_spec.rb +3 -3
- data/spec/core/compatible_spec.rb +5 -5
- data/spec/core/configuration_spec.rb +3 -3
- data/spec/core/core_ext_spec.rb +7 -7
- data/spec/core/io/default_spec.rb +1 -1
- data/spec/core/plugin_spec.rb +41 -41
- data/spec/core/rack/assets/precompile_spec.rb +3 -3
- data/spec/core/rack/html_anchor_spec.rb +15 -15
- data/spec/core/rack/static_spec.rb +3 -3
- data/spec/core/rack/valid_request_path_spec.rb +13 -13
- data/spec/core/style/tdiary_style_spec.rb +10 -10
- data/spec/core/style/wiki_style_spec.rb +16 -16
- data/spec/plugin/bq_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -1
- data/tdiary/configuration.rb +2 -2
- data/tdiary/environment.rb +1 -1
- data/tdiary/io/default.rb +1 -1
- data/tdiary/lang/ja.rb +2 -2
- data/tdiary/tasks/db.rake +5 -5
- data/tdiary/version.rb +1 -1
- data/test/disp_referrer_test.rb +4 -4
- data/test/my-sequel_test.rb +1 -1
- data/test/test_plugin_helper.rb +47 -0
- data/test/weather-ADDS-METARS-PHTO-140131.html +109 -0
- data/test/weather-ADDS-METARS-RJAA-130131.html +111 -0
- data/test/weather-ADDS-METARS-RJAA-130227.html +111 -0
- data/test/weather_test.rb +144 -18
- data/update.rb +2 -2
- metadata +10 -3
data/test/weather_test.rb
CHANGED
@@ -5,33 +5,159 @@ require File.expand_path('../test_helper', __FILE__)
|
|
5
5
|
require File.expand_path('../test_plugin_helper', __FILE__)
|
6
6
|
|
7
7
|
module EmptyRenderingTests
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def setup
|
9
|
+
@plugin_class = TDiary::StubPlugin::new_plugin('misc/plugin/weather.rb', language)
|
10
|
+
@weather = @plugin_class::Weather.new
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def test_empty_rendering_to_html
|
14
|
+
assert_equal('', @weather.to_html)
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def test_empty_rendering_to_i_html
|
18
|
+
assert_equal('', @weather.to_i_html)
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
class TestEmptyRenderingEn < Test::Unit::TestCase
|
23
|
-
|
23
|
+
include EmptyRenderingTests
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def language
|
26
|
+
"en"
|
27
|
+
end
|
28
28
|
end
|
29
29
|
|
30
30
|
class TestEmptyRenderingJa < Test::Unit::TestCase
|
31
|
-
|
31
|
+
include EmptyRenderingTests
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def language
|
34
|
+
"ja"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class TestUpdateWeatherUrl < Test::Unit::TestCase
|
39
|
+
def setup
|
40
|
+
@plugin = TDiary::StubPlugin::load_plugin('misc/plugin/weather.rb', 'en')
|
41
|
+
@old_url = 'http://weather.noaa.gov/weather/current/PHTO.html'
|
42
|
+
@new_url = 'http://www.aviationweather.gov/adds/metars/?station_ids=PHTO&std_trans=translated&chk_metars=on&hoursStr=most+recent+only'
|
43
|
+
@url_key = 'weather.url'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_update_weather_urL_from_old
|
47
|
+
hash = {@url_key => @old_url}
|
48
|
+
@plugin::update_weather_url( hash )
|
49
|
+
assert_equal(@new_url, hash[@url_key])
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_update_weather_urL_with_new
|
53
|
+
hash = {@url_key => @new_url}
|
54
|
+
@plugin::update_weather_url( hash )
|
55
|
+
assert_equal(@new_url, hash[@url_key])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class TestParseHtml < Test::Unit::TestCase
|
60
|
+
def setup
|
61
|
+
@plugin_class = TDiary::StubPlugin::new_plugin('misc/plugin/weather.rb', language)
|
62
|
+
@weather = @plugin_class::Weather.new
|
63
|
+
end
|
64
|
+
|
65
|
+
def language
|
66
|
+
"en"
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_parse_sample
|
70
|
+
html = open(File.join(File.dirname(__FILE__), 'weather-ADDS-METARS-RJAA-130131.html')).read.force_encoding('ISO-8859-1')
|
71
|
+
@weather.parse_html(html, @plugin_class::Weather_default_items)
|
72
|
+
assert_equal(Time.utc(2013, 1, 31, 12, 30, 0), Time.at(@weather.data['timestamp'].to_i))
|
73
|
+
assert_equal("-2.0", @weather.data['temperature(C)'])
|
74
|
+
assert_equal("-4.0", @weather.data['dewpoint(C)'])
|
75
|
+
assert_equal("1034.0", @weather.data['pressure(hPa)'])
|
76
|
+
assert_equal("1.0", @weather.data['wind(m/s)'])
|
77
|
+
assert_equal("240", @weather.data['wind(deg)'])
|
78
|
+
assert_equal("10+", @weather.data['visibility(km)'])
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_parse_sample_F
|
82
|
+
html = open(File.join(File.dirname(__FILE__), 'weather-ADDS-METARS-RJAA-130131.html')).read.force_encoding('ISO-8859-1')
|
83
|
+
@weather.parse_html(html, {'temperature(F)' => 'temperature(F)'})
|
84
|
+
assert_equal("28", @weather.data['temperature(F)'])
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_parse_sample_mile
|
88
|
+
html = open(File.join(File.dirname(__FILE__), 'weather-ADDS-METARS-RJAA-130131.html')).read.force_encoding('ISO-8859-1')
|
89
|
+
@weather.parse_html(html, {'visibility(mile)' => 'visibility(mile)'})
|
90
|
+
assert_equal("6 or more", @weather.data['visibility(mile)'])
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_parse_sample_no_significant_weather
|
94
|
+
html = open(File.join(File.dirname(__FILE__), 'weather-ADDS-METARS-RJAA-130131.html')).read.force_encoding('ISO-8859-1')
|
95
|
+
@weather.parse_html(html, {'weather' => 'weather'})
|
96
|
+
assert_equal("Few clouds", @weather.data['weather'])
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_parse_sample_FG_RA
|
100
|
+
html = open(File.join(File.dirname(__FILE__), 'weather-ADDS-METARS-RJAA-130227.html')).read.force_encoding('ISO-8859-1')
|
101
|
+
@weather.parse_html(html, {'weather' => 'weather'})
|
102
|
+
assert_equal("Fog/Light rain", @weather.data['weather'])
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_parse_sample_with_160
|
106
|
+
html = open(File.join(File.dirname(__FILE__), 'weather-ADDS-METARS-PHTO-140131.html')).read.force_encoding('ISO-8859-1')
|
107
|
+
@weather.parse_html(html, @plugin_class::Weather_default_items)
|
108
|
+
assert_equal(Time.utc(2014, 1, 31, 14, 53, 0), Time.at(@weather.data['timestamp'].to_i))
|
109
|
+
assert_equal("18.3", @weather.data['temperature(C)'])
|
110
|
+
assert_equal("16.7", @weather.data['dewpoint(C)'])
|
111
|
+
assert_equal("1012.3", @weather.data['pressure(hPa)'])
|
112
|
+
assert_equal("16+", @weather.data['visibility(km)'])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class TestStationRegexp < Test::Unit::TestCase
|
117
|
+
def setup
|
118
|
+
@plugin_class = TDiary::StubPlugin::new_plugin('misc/plugin/weather.rb', 'en')
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_extract_aviationweather_station_id
|
122
|
+
url = 'http://www.aviationweather.gov/adds/metars/?station_ids=PHTO&std_trans=translated&chk_metars=on&hoursStr=most+recent+only'
|
123
|
+
target = 'PHTO'
|
124
|
+
result = @plugin_class::Weather::extract_station_id(url)
|
125
|
+
assert_equal(target, result)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_extract_noaa_station_id
|
129
|
+
url = 'http://weather.noaa.gov/weather/current/RJTI.html'
|
130
|
+
target = 'RJTI'
|
131
|
+
result = @plugin_class::Weather::extract_station_id(url)
|
132
|
+
assert_equal(target, result)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_extract_raw_station_id
|
136
|
+
url = 'RJTI'
|
137
|
+
target = 'RJTI'
|
138
|
+
result = @plugin_class::Weather::extract_station_id(url)
|
139
|
+
assert_equal(target, result)
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_no_station_id
|
143
|
+
assert_nil(@plugin_class::Weather::extract_station_id('http://www.tdiary.org/'))
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# Stub for @conf
|
148
|
+
class WeatherStubConf
|
149
|
+
def to_native(str); str; end
|
150
|
+
def [](*args); nil; end
|
151
|
+
end
|
152
|
+
|
153
|
+
class FetchTest < Test::Unit::TestCase
|
154
|
+
def skip_fetch_from_aviationweather_gov
|
155
|
+
plugin_class = TDiary::StubPlugin::new_plugin('misc/plugin/weather.rb', 'en')
|
156
|
+
url = plugin_class::Weather::STATION_URL_TEMPLATE % 'PHTO'
|
157
|
+
|
158
|
+
weather = plugin_class::Weather.new(Time.now, nil, WeatherStubConf.new)
|
159
|
+
weather.get(url, {}, plugin_class::Weather_default_items)
|
160
|
+
assert_not_nil(weather.data['temperature(C)'])
|
161
|
+
end
|
36
162
|
end
|
37
163
|
|
data/update.rb
CHANGED
@@ -18,13 +18,13 @@ begin
|
|
18
18
|
require 'tdiary'
|
19
19
|
|
20
20
|
encoding_error = {}
|
21
|
-
cgi = CGI::new(:
|
21
|
+
cgi = CGI::new(accept_charset: "UTF-8") do |name, value|
|
22
22
|
encoding_error[name] = value
|
23
23
|
end
|
24
24
|
if encoding_error.empty?
|
25
25
|
@cgi = cgi
|
26
26
|
else
|
27
|
-
@cgi = CGI::new(:
|
27
|
+
@cgi = CGI::new(accept_charset: 'shift_jis')
|
28
28
|
@cgi.params = cgi.params.dup
|
29
29
|
end
|
30
30
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdiary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-02-
|
13
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- misc/plugin/squeeze.rb
|
232
232
|
- misc/plugin/src.rb
|
233
233
|
- misc/plugin/tb-show.rb
|
234
|
+
- misc/plugin/theme_online.rb
|
234
235
|
- misc/plugin/title_list.rb
|
235
236
|
- misc/plugin/title_tag.rb
|
236
237
|
- misc/plugin/tlink.rb
|
@@ -404,6 +405,9 @@ files:
|
|
404
405
|
- test/test_helper.rb
|
405
406
|
- test/test_plugin_helper.rb
|
406
407
|
- test/test_plugin_helper_test.rb
|
408
|
+
- test/weather-ADDS-METARS-PHTO-140131.html
|
409
|
+
- test/weather-ADDS-METARS-RJAA-130131.html
|
410
|
+
- test/weather-ADDS-METARS-RJAA-130227.html
|
407
411
|
- test/weather_test.rb
|
408
412
|
- theme/base.css
|
409
413
|
- theme/conf.block.png
|
@@ -441,7 +445,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
441
445
|
version: '0'
|
442
446
|
requirements: []
|
443
447
|
rubyforge_project:
|
444
|
-
rubygems_version: 2.2.
|
448
|
+
rubygems_version: 2.2.2
|
445
449
|
signing_key:
|
446
450
|
specification_version: 4
|
447
451
|
summary: a TSUKKOMI-able Web-log
|
@@ -498,4 +502,7 @@ test_files:
|
|
498
502
|
- test/test_helper.rb
|
499
503
|
- test/test_plugin_helper.rb
|
500
504
|
- test/test_plugin_helper_test.rb
|
505
|
+
- test/weather-ADDS-METARS-PHTO-140131.html
|
506
|
+
- test/weather-ADDS-METARS-RJAA-130131.html
|
507
|
+
- test/weather-ADDS-METARS-RJAA-130227.html
|
501
508
|
- test/weather_test.rb
|