@@ -8,50 +8,50 @@ class Message < ApplicationRecord
88 # but I don't want to make this column.
99 # https://blade.ruby-lang.org/ruby-talk/1 is JST.
1010 # https://blade.ruby-lang.org/ruby-talk/410000 is not.
11- self . skip_time_zone_conversion_for_attributes = [ :published_at ]
11+ self . skip_time_zone_conversion_for_attributes = [ :published_at ]
1212
13- def self . from_s3 ( list_name , list_seq , s3_client = Aws ::S3 ::Client . new ( region : BLADE_BUCKET_REGION ) )
14- obj = s3_client . get_object ( bucket : BLADE_BUCKET_NAME , key : "#{ list_name } /#{ list_seq } " )
13+ def self . from_s3 ( list_name , list_seq , s3_client = Aws ::S3 ::Client . new ( region : BLADE_BUCKET_REGION ) )
14+ obj = s3_client . get_object ( bucket : BLADE_BUCKET_NAME , key : "#{ list_name } /#{ list_seq } " )
1515
16- m = self . from_string ( obj . body . read )
17- m . list_id = List . find_by_name ( list_name ) . id
18- m . list_seq = list_seq
19- m
20- end
16+ m = self . from_string ( obj . body . read )
17+ m . list_id = List . find_by_name ( list_name ) . id
18+ m . list_seq = list_seq
19+ m
20+ end
2121
22- def self . from_string ( str )
23- # There are a few hacks to import messages from blade.ruby-lang.org's
24- # S3 bucket.
22+ def self . from_string ( str )
23+ # There are a few hacks to import messages from blade.ruby-lang.org's
24+ # S3 bucket.
2525
26- # Need to call String#b. There are messages that have headers in non-UTF8,
27- # but the body is in UTF-8, such as ruby-list:2882.
28- headers_str , body = str . b . split ( /\n \n / , 2 )
26+ # Need to call String#b. There are messages that have headers in non-UTF8,
27+ # but the body is in UTF-8, such as ruby-list:2882.
28+ headers_str , body = str . b . split ( /\n \n / , 2 )
2929
30- # ruby-list:2840 doesn't have a proper From header.
31- headers_str = Kconv . toutf8 ( headers_str ) . gsub ( /\r \n / , '' )
30+ # ruby-list:2840 doesn't have a proper From header.
31+ headers_str = Kconv . toutf8 ( headers_str ) . gsub ( /\r \n / , '' )
3232
33- headers = headers_str . split ( /\n / ) . map { |line |
34- line . split ( /:\s +/ , 2 )
35- } . to_h
33+ headers = headers_str . split ( /\n / ) . map { |line |
34+ line . split ( /:\s +/ , 2 )
35+ } . to_h
3636
37- published_at = DateTime . strptime ( headers [ 'Date' ] , '%Y-%m-%dT%H:%M:%S%:z' )
37+ published_at = DateTime . strptime ( headers [ 'Date' ] , '%Y-%m-%dT%H:%M:%S%:z' )
3838
39- self . new (
40- body : Kconv . toutf8 ( body ) ,
41- subject : headers [ 'Subject' ] ,
42- from : headers [ 'From' ] ,
43- published_at : published_at ,
44- )
45- end
39+ self . new (
40+ body : Kconv . toutf8 ( body ) ,
41+ subject : headers [ 'Subject' ] ,
42+ from : headers [ 'From' ] ,
43+ published_at : published_at ,
44+ )
45+ end
4646
47- def reload_from_s3 ( s3_client = Aws ::S3 ::Client . new ( region : BLADE_BUCKET_REGION ) )
48- m = Message . from_s3 ( List . find_by_id ( self . list_id ) . name , self . list_seq , s3_client )
47+ def reload_from_s3 ( s3_client = Aws ::S3 ::Client . new ( region : BLADE_BUCKET_REGION ) )
48+ m = Message . from_s3 ( List . find_by_id ( self . list_id ) . name , self . list_seq , s3_client )
4949
50- self . body = m . body
51- self . subject = m . subject
52- self . from = from
53- self . published_at = m . published_at
50+ self . body = m . body
51+ self . subject = m . subject
52+ self . from = from
53+ self . published_at = m . published_at
5454
55- m
56- end
55+ m
56+ end
5757end
0 commit comments