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.
- checksums.yaml +4 -4
- data/lib/cafe_buy_duo.rb +65 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3fa15289ffaa9e4d4a8e63f5265686f3140e018031382cf339e18aca728701
|
4
|
+
data.tar.gz: 71c0e1f53c2ad1ea7dd7dbf6d303065b820bfa2200d702a6e4e229974f5403d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2438
|
+
img = Magick::Image.read(path).first
|
2439
|
+
width = img.columns
|
2440
|
+
height = img.rows
|
2443
2441
|
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
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
|
-
|
2450
|
-
cropped.write(path)
|
2447
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2451
2448
|
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
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
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
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.
|
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-
|
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
|