cafe_buy_duo 0.1.52 → 0.1.55

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_buy_duo.rb +65 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb6262162997d15877bbefc16791064e678caa15cba1fe4502669f9e1a4b58c2
4
- data.tar.gz: ae6f20b8fa94e6704f2e596749019afa47297e4757105ee55f07586c4f441609
3
+ metadata.gz: 3e3fa15289ffaa9e4d4a8e63f5265686f3140e018031382cf339e18aca728701
4
+ data.tar.gz: 71c0e1f53c2ad1ea7dd7dbf6d303065b820bfa2200d702a6e4e229974f5403d9
5
5
  SHA512:
6
- metadata.gz: 4a07c7159f00755c9721322c8a4a0315717e4b4dce78d1ef5bf2960a5055c940fd33322b9a1bf04acc6e46f7e29500c8bfd485aa2439982ca8647db2bb95c4c7
7
- data.tar.gz: e73ef5468ac924cdeae86cc0263c1e2b99b15925dddcbeab5ca60ebaf3f684c003bb50fa67a575385c777ee1d11658b4f123e561aa405a79a235adcd89ab5b6c
6
+ metadata.gz: 3a2485806831d6e4b6c22a4bd4afd8875c88d33a386854adbf509c46b4c03e9817fb5f55cd8b819f75e9aad41bce307c5d37930bc19c226edc3258caae38375b
7
+ data.tar.gz: dea6ecf9bbd2dff434404cb0716ac613e681c6cfd020d909775a7a41bec335e91b1b86708f162d288f3d428403feee33b176bb1ef3377f29fdc2c46c27f1ccb0
data/lib/cafe_buy_duo.rb CHANGED
@@ -2435,24 +2435,28 @@ class Wordpress
2435
2435
 
2436
2436
 
2437
2437
  def crop_image_height_under_width(path, min_crop_ratio = 0.625)
2438
- img = Magick::Image.read(path).first
2439
- width = img.columns
2440
- height = img.rows
2441
-
2442
-
2438
+ img = Magick::Image.read(path).first
2439
+ width = img.columns
2440
+ height = img.rows
2443
2441
 
2444
- if height > width
2445
- min_height = (width * min_crop_ratio).to_i
2446
- new_height = rand(min_height..width)
2447
- crop_top = ((height - new_height) / 2.0).round
2442
+ if height > width
2443
+ min_height = (width * min_crop_ratio).to_i
2444
+ new_height = rand(min_height..width)
2445
+ crop_top = ((height - new_height) / 2.0).round
2448
2446
 
2449
- cropped = img.crop(0, crop_top, width, new_height, true)
2450
- cropped.write(path)
2447
+ cropped = img.crop(0, crop_top, width, new_height, true)
2451
2448
 
2452
-
2453
- else
2454
-
2455
- end
2449
+ retries = 0
2450
+ begin
2451
+ cropped.write(path)
2452
+ rescue => e
2453
+ retries += 1
2454
+ puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
2455
+ sleep(1)
2456
+ retry if retries < 5
2457
+ raise "이미지 저장 실패: #{e.message}"
2458
+ end
2459
+ end
2456
2460
  end
2457
2461
 
2458
2462
  def auto_image(keyword = nil)
@@ -4002,15 +4006,34 @@ class Wordpress
4002
4006
  # title = content.split("\n")[0]
4003
4007
  #end
4004
4008
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
4005
- # 콘텐츠를 줄 단위로 분리
4006
4009
  content_lines = content.split("\n")
4007
-
4008
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
4009
- title = content_lines.find { |line| !line.start_with?('<img src=') }
4010
-
4011
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
4012
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
4013
-
4010
+
4011
+ title = content_lines.find do |line|
4012
+ line = line.strip
4013
+ !line.empty? && !line.start_with?('<img src=')
4014
+ end
4015
+
4016
+ title ||= content_lines[1]
4017
+
4018
+ if title
4019
+ # 마침표(.) 포함 첫 문장 추출
4020
+ first_part = title[/.*?\./]
4021
+ first_part = first_part ? first_part.strip : title.strip
4022
+
4023
+ # 200bytes 제한 (한글 100자 내외)
4024
+ bytes_limit = 200
4025
+ truncated = ""
4026
+ current_bytes = 0
4027
+
4028
+ first_part.each_char do |char|
4029
+ char_bytes = char.bytesize
4030
+ break if current_bytes + char_bytes > bytes_limit
4031
+ truncated << char
4032
+ current_bytes += char_bytes
4033
+ end
4034
+
4035
+ title = truncated
4036
+ end
4014
4037
  end
4015
4038
 
4016
4039
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -4034,6 +4057,25 @@ class Wordpress
4034
4057
  @data['table'] << []
4035
4058
  @data['table'].pop
4036
4059
 
4060
+ # content를 줄 단위로 쪼갬
4061
+ lines = content.lines
4062
+
4063
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
4064
+ empty_line_count = 0
4065
+ lines.each do |line|
4066
+ if line.strip.empty?
4067
+ empty_line_count += 1
4068
+ else
4069
+ break
4070
+ end
4071
+ end
4072
+
4073
+ # 앞 빈 줄 제거
4074
+ lines = lines.drop(empty_line_count)
4075
+
4076
+ # 다시 content로 합침
4077
+ content = lines.join
4078
+
4037
4079
  p option
4038
4080
 
4039
4081
  dd_time = @data['table'][index][9].to_s.force_encoding('utf-8').to_i
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.52
4
+ version: 0.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-26 00:00:00.000000000 Z
10
+ date: 2025-07-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com