cafe_buy 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.rb +65 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f94b7d1bcfb6264a812baed1a521a2f8f4ddf2724b49520f03db280675989019
4
- data.tar.gz: a85ba553efe2bdc42104ca639ecc5d67035b4e74a1a87db6873ba082d1d7c4a7
3
+ metadata.gz: 1b14e8e371491f2be06f04ae67f13dd328dd42a46cc83e79d8690fca5e64009e
4
+ data.tar.gz: 5308a6bd4f2834e52cec5ed8c49cc441b6f7907f34e3a157ebbf09bd3e0d44e6
5
5
  SHA512:
6
- metadata.gz: bc56b9eff065ad14f45f3ad5711e8cf1a6a5b0c8305e587454c3ed0c4ac749e9cedb668329ff84c66596f49cffa1e50bce12d2b0af7889c939e1bc49f87c6b52
7
- data.tar.gz: 61bccdfb975cd969708c6729066408476b70ccd79f7df844c87fbb32ac67374725e3aff811d8e7fbc8ef002f913de8184434df30b73f7d036502ae1901ddeb2e
6
+ metadata.gz: 9231706e9259d4d1c333cc6458ac55add55aaa90b03d85e7c736e32cc785544fbe8ffb00e22085bdf64b4e69dd900ae6382fb1559da82df608acb5910aa3ccfa
7
+ data.tar.gz: 30a6be435830890e10b4d59f8789bb5792ae5b42b161575af231ca1f4899b4fc127db69ae5f27756360948bc1383c1743a03ad0daecd159d5ae751f1717b3938
data/lib/cafe_buy.rb CHANGED
@@ -2367,24 +2367,28 @@ class Wordpress
2367
2367
 
2368
2368
 
2369
2369
  def crop_image_height_under_width(path, min_crop_ratio = 0.625)
2370
- img = Magick::Image.read(path).first
2371
- width = img.columns
2372
- height = img.rows
2373
-
2374
-
2370
+ img = Magick::Image.read(path).first
2371
+ width = img.columns
2372
+ height = img.rows
2375
2373
 
2376
- if height > width
2377
- min_height = (width * min_crop_ratio).to_i
2378
- new_height = rand(min_height..width)
2379
- crop_top = ((height - new_height) / 2.0).round
2374
+ if height > width
2375
+ min_height = (width * min_crop_ratio).to_i
2376
+ new_height = rand(min_height..width)
2377
+ crop_top = ((height - new_height) / 2.0).round
2380
2378
 
2381
- cropped = img.crop(0, crop_top, width, new_height, true)
2382
- cropped.write(path)
2379
+ cropped = img.crop(0, crop_top, width, new_height, true)
2383
2380
 
2384
-
2385
- else
2386
-
2387
- end
2381
+ retries = 0
2382
+ begin
2383
+ cropped.write(path)
2384
+ rescue => e
2385
+ retries += 1
2386
+ puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
2387
+ sleep(1)
2388
+ retry if retries < 5
2389
+ raise "이미지 저장 실패: #{e.message}"
2390
+ end
2391
+ end
2388
2392
  end
2389
2393
 
2390
2394
  def auto_image(keyword = nil)
@@ -3934,15 +3938,34 @@ class Wordpress
3934
3938
  # title = content.split("\n")[0]
3935
3939
  #end
3936
3940
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3937
- # 콘텐츠를 줄 단위로 분리
3938
3941
  content_lines = content.split("\n")
3939
-
3940
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3941
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3942
-
3943
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3944
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3945
-
3942
+
3943
+ title = content_lines.find do |line|
3944
+ line = line.strip
3945
+ !line.empty? && !line.start_with?('<img src=')
3946
+ end
3947
+
3948
+ title ||= content_lines[1]
3949
+
3950
+ if title
3951
+ # 마침표(.) 포함 첫 문장 추출
3952
+ first_part = title[/.*?\./]
3953
+ first_part = first_part ? first_part.strip : title.strip
3954
+
3955
+ # 200bytes 제한 (한글 100자 내외)
3956
+ bytes_limit = 200
3957
+ truncated = ""
3958
+ current_bytes = 0
3959
+
3960
+ first_part.each_char do |char|
3961
+ char_bytes = char.bytesize
3962
+ break if current_bytes + char_bytes > bytes_limit
3963
+ truncated << char
3964
+ current_bytes += char_bytes
3965
+ end
3966
+
3967
+ title = truncated
3968
+ end
3946
3969
  end
3947
3970
 
3948
3971
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3966,6 +3989,25 @@ class Wordpress
3966
3989
  @data['table'] << []
3967
3990
  @data['table'].pop
3968
3991
 
3992
+ # content를 줄 단위로 쪼갬
3993
+ lines = content.lines
3994
+
3995
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
3996
+ empty_line_count = 0
3997
+ lines.each do |line|
3998
+ if line.strip.empty?
3999
+ empty_line_count += 1
4000
+ else
4001
+ break
4002
+ end
4003
+ end
4004
+
4005
+ # 앞 빈 줄 제거
4006
+ lines = lines.drop(empty_line_count)
4007
+
4008
+ # 다시 content로 합침
4009
+ content = lines.join
4010
+
3969
4011
  p option
3970
4012
 
3971
4013
  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
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