cafe_basics_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_basics_duo.rb +65 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60647955187b2b942307988080314021176bf5359a4899611fd88293402edc38
4
- data.tar.gz: 3d16d1ee3a8c39c168b031f4fcea42cf995981843523851f832b82f616d8e1ff
3
+ metadata.gz: 254da32d83fd097f8d5ae9e26d4c3c306c4afbfbbe37f6e57a8529a577cf202f
4
+ data.tar.gz: c6d2b84d4404ed78ab26a0e5e892d5b45422c94876223d85e2fdfde8dd9749cb
5
5
  SHA512:
6
- metadata.gz: fb237f7fb35781a4e4f04d83b224ff6b22fece83cee9dec8c39fa3e01178b6a8db18e3e9dc9e4e14fd33d444740b1173fbdff9031228948b093de450cf1032d3
7
- data.tar.gz: c06a8c8484d36289cab1c0efa7a5d1b1c557331c86a78e4539a92a1d89193c8034bfc6560753936109f364c6d5e82e654caf52cb7b523c2dd531f34c32fbcfcb
6
+ metadata.gz: 22a2b190f6907f9030b9ba07d68297b2c56725b9f42c65273479ba47765e96adc4ce8789306f5bc493c4b90fe51dc4cabe84524a573df4aad294f5b01a26e0cc
7
+ data.tar.gz: df99d99bcf10e80010526e0e0a0fb3abe361930114f17af054c30cf7dbdbdd04d971952d0eb4204d38a28de77e4ac1023e5d3cda4a316dbbf6342f13d8867b59
@@ -2097,24 +2097,28 @@ class Wordpress
2097
2097
 
2098
2098
 
2099
2099
  def crop_image_height_under_width(path, min_crop_ratio = 0.625)
2100
- img = Magick::Image.read(path).first
2101
- width = img.columns
2102
- height = img.rows
2103
-
2104
-
2100
+ img = Magick::Image.read(path).first
2101
+ width = img.columns
2102
+ height = img.rows
2105
2103
 
2106
- if height > width
2107
- min_height = (width * min_crop_ratio).to_i
2108
- new_height = rand(min_height..width)
2109
- crop_top = ((height - new_height) / 2.0).round
2104
+ if height > width
2105
+ min_height = (width * min_crop_ratio).to_i
2106
+ new_height = rand(min_height..width)
2107
+ crop_top = ((height - new_height) / 2.0).round
2110
2108
 
2111
- cropped = img.crop(0, crop_top, width, new_height, true)
2112
- cropped.write(path)
2109
+ cropped = img.crop(0, crop_top, width, new_height, true)
2113
2110
 
2114
-
2115
- else
2116
-
2117
- end
2111
+ retries = 0
2112
+ begin
2113
+ cropped.write(path)
2114
+ rescue => e
2115
+ retries += 1
2116
+ puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
2117
+ sleep(1)
2118
+ retry if retries < 5
2119
+ raise "이미지 저장 실패: #{e.message}"
2120
+ end
2121
+ end
2118
2122
  end
2119
2123
 
2120
2124
  def auto_image(keyword = nil)
@@ -3617,15 +3621,34 @@ class Wordpress
3617
3621
  # title = content.split("\n")[0]
3618
3622
  #end
3619
3623
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3620
- # 콘텐츠를 줄 단위로 분리
3621
3624
  content_lines = content.split("\n")
3622
-
3623
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3624
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3625
-
3626
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3627
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3628
-
3625
+
3626
+ title = content_lines.find do |line|
3627
+ line = line.strip
3628
+ !line.empty? && !line.start_with?('<img src=')
3629
+ end
3630
+
3631
+ title ||= content_lines[1]
3632
+
3633
+ if title
3634
+ # 마침표(.) 포함 첫 문장 추출
3635
+ first_part = title[/.*?\./]
3636
+ first_part = first_part ? first_part.strip : title.strip
3637
+
3638
+ # 200bytes 제한 (한글 100자 내외)
3639
+ bytes_limit = 200
3640
+ truncated = ""
3641
+ current_bytes = 0
3642
+
3643
+ first_part.each_char do |char|
3644
+ char_bytes = char.bytesize
3645
+ break if current_bytes + char_bytes > bytes_limit
3646
+ truncated << char
3647
+ current_bytes += char_bytes
3648
+ end
3649
+
3650
+ title = truncated
3651
+ end
3629
3652
  end
3630
3653
 
3631
3654
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3649,6 +3672,25 @@ class Wordpress
3649
3672
  @data['table'] << []
3650
3673
  @data['table'].pop
3651
3674
 
3675
+ # content를 줄 단위로 쪼갬
3676
+ lines = content.lines
3677
+
3678
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
3679
+ empty_line_count = 0
3680
+ lines.each do |line|
3681
+ if line.strip.empty?
3682
+ empty_line_count += 1
3683
+ else
3684
+ break
3685
+ end
3686
+ end
3687
+
3688
+ # 앞 빈 줄 제거
3689
+ lines = lines.drop(empty_line_count)
3690
+
3691
+ # 다시 content로 합침
3692
+ content = lines.join
3693
+
3652
3694
  p option
3653
3695
 
3654
3696
  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_basics_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